@Override public synchronized void close() throws IOException { if (out != null) { // Close the output stream and decode the key for the output stream // before returning to the caller. // out.close(); try { restoreKey(); } finally { out = null; } } }
public NativeAzureFsOutputStream(OutputStream out, String aKey, String anEncodedKey) throws IOException { // Check input arguments. The output stream should be non-null and the // keys // should be valid strings. if (null == out) { throw new IllegalArgumentException( "Illegal argument: the output stream is null."); } if (null == aKey || 0 == aKey.length()) { throw new IllegalArgumentException( "Illegal argument the key string is null or empty"); } if (null == anEncodedKey || 0 == anEncodedKey.length()) { throw new IllegalArgumentException( "Illegal argument the encoded key string is null or empty"); } // Initialize the member variables with the incoming parameters. this.out = out; setKey(aKey); setEncodedKey(anEncodedKey); }
bufOutStream = new NativeAzureFsOutputStream(store.storefile( keyEncoded, permissionStatus), key, keyEncoded);
bufOutStream = new NativeAzureFsOutputStream(store.storefile( keyEncoded, permissionStatus, key), key, keyEncoded);
@Test public void testCompactionDisabled() throws Throwable { try (FSDataOutputStream appendStream = fs.create(TEST_PATH_NORMAL)) { // testing new file SyncableDataOutputStream dataOutputStream = null; OutputStream wrappedStream = appendStream.getWrappedStream(); if (wrappedStream instanceof NativeAzureFileSystem.NativeAzureFsOutputStream) { NativeAzureFileSystem.NativeAzureFsOutputStream fsOutputStream = (NativeAzureFileSystem.NativeAzureFsOutputStream) wrappedStream; dataOutputStream = (SyncableDataOutputStream) fsOutputStream.getOutStream(); } else if (wrappedStream instanceof SyncableDataOutputStream) { dataOutputStream = (SyncableDataOutputStream) wrappedStream; } else { Assert.fail("Unable to determine type of " + wrappedStream + " class of " + wrappedStream.getClass()); } Assert.assertFalse("Data output stream is a BlockBlobAppendStream: " + dataOutputStream, dataOutputStream.getOutStream() instanceof BlockBlobAppendStream); } }
public NativeAzureFsOutputStream(OutputStream out, String aKey, String anEncodedKey) throws IOException { // Check input arguments. The output stream should be non-null and the // keys // should be valid strings. if (null == out) { throw new IllegalArgumentException( "Illegal argument: the output stream is null."); } if (null == aKey || 0 == aKey.length()) { throw new IllegalArgumentException( "Illegal argument the key string is null or empty"); } if (null == anEncodedKey || 0 == anEncodedKey.length()) { throw new IllegalArgumentException( "Illegal argument the encoded key string is null or empty"); } // Initialize the member variables with the incoming parameters. this.out = out; setKey(aKey); setEncodedKey(anEncodedKey); }
private BlockBlobAppendStream getBlockBlobAppendStream(FSDataOutputStream appendStream) { SyncableDataOutputStream dataOutputStream = null; if (appendStream.getWrappedStream() instanceof NativeAzureFileSystem.NativeAzureFsOutputStream) { NativeAzureFileSystem.NativeAzureFsOutputStream fsOutputStream = (NativeAzureFileSystem.NativeAzureFsOutputStream) appendStream.getWrappedStream(); dataOutputStream = (SyncableDataOutputStream) fsOutputStream.getOutStream(); } if (appendStream.getWrappedStream() instanceof SyncableDataOutputStream) { dataOutputStream = (SyncableDataOutputStream) appendStream.getWrappedStream(); } Assert.assertNotNull("Did not recognize " + dataOutputStream, dataOutputStream); return (BlockBlobAppendStream) dataOutputStream.getOutStream(); }
@Override public synchronized void close() throws IOException { if (out != null) { // Close the output stream and decode the key for the output stream // before returning to the caller. // out.close(); restoreKey(); out = null; } }
@Override // Syncable public void hsync() throws IOException { if (out instanceof Syncable) { ((Syncable) out).hsync(); } else { flush(); } }
/** * Restore the original key name from the m_key member variable. Note: The * output file stream is created with an encoded blob store key to guarantee * load balancing on the front end of the Azure storage partition servers. * The create also includes the name of the original key value which is * stored in the m_key member variable. This method should only be called * when the stream is closed. */ private void restoreKey() throws IOException { store.rename(getEncodedKey(), getKey()); } }
@Override // Syncable public void hflush() throws IOException { if (out instanceof Syncable) { ((Syncable) out).hflush(); } else { flush(); } }
private boolean isBlockBlobAppendStreamWrapper(FSDataOutputStream stream) { return ((SyncableDataOutputStream) ((NativeAzureFileSystem.NativeAzureFsOutputStream) stream.getWrappedStream()) .getOutStream()) .getOutStream() instanceof BlockBlobAppendStream; }
/** * Restore the original key name from the m_key member variable. Note: The * output file stream is created with an encoded blob store key to guarantee * load balancing on the front end of the Azure storage partition servers. * The create also includes the name of the original key value which is * stored in the m_key member variable. This method should only be called * when the stream is closed. */ private void restoreKey() throws IOException { store.rename(getEncodedKey(), getKey()); } }