private PermissionStatus getPermissionStatus(CloudBlobWrapper blob) { String permissionMetadataValue = getMetadataAttribute(blob, PERMISSION_METADATA_KEY, OLD_PERMISSION_METADATA_KEY); if (permissionMetadataValue != null) { return PermissionStatusJsonSerializer.fromJSONString( permissionMetadataValue); } else { return defaultPermissionNoBlobMetadata(); } }
private AzureException wrongVersionException(String containerVersion) { return new AzureException("The container " + container.getName() + " is at an unsupported version: " + containerVersion + ". Current supported version: " + FIRST_WASB_VERSION); }
/** * Get a self-renewing lease on the specified file. * @param path path whose lease to be renewed. * @return Lease * @throws AzureException when not being able to acquire a lease on the path */ public SelfRenewingLease acquireLease(Path path) throws AzureException { String fullKey = pathToKey(makeAbsolute(path)); return getStore().acquireLease(fullKey); }
private boolean conditionalRedoFolderRenames(PartialListing listing) throws IllegalArgumentException, IOException { boolean renamed = false; for (FileMetadata fileMetadata : listing.getFiles()) { Path subpath = keyToPath(fileMetadata.getKey()); if (isRenamePendingFile(subpath)) { FolderRenamePending pending = new FolderRenamePending(subpath, this); pending.redo(); renamed = true; } } return renamed; }
/** Clean up after execution of rename. * @throws IOException */ public void cleanup() throws IOException { if (fs.getStoreInterface().isAtomicRenameKey(srcKey)) { // Remove RenamePending file fs.delete(getRenamePendingFilePath(), false); // Freeing source folder lease is not necessary since the source // folder file was deleted. } }
/** * Checks that the data in the given file is what I'd expect. * @param file The file to check. * @param expectedSize The expected size of the data in there. */ private void assertDataInFile(Path file, int expectedSize) throws Exception { try(InputStream inStream = getFileSystem().open(file)) { assertDataInStream(inStream, expectedSize); } }
private void injectTransientError(NativeAzureFileSystem fs, final ConnectionRecognizer connectionRecognizer) { fs.getStore().addTestHookToOperationContext(new TestHookOperationContext() { @Override public OperationContext modifyOperationContext(OperationContext original) { original.getSendingRequestEventHandler().addListener( new TransientErrorInjector(connectionRecognizer)); return original; } }); }
private BandwidthGaugeUpdater getBandwidthGaugeUpdater() { NativeAzureFileSystem azureFs = (NativeAzureFileSystem)fs; AzureNativeFileSystemStore azureStore = azureFs.getStore(); return azureStore.getBandwidthGaugeUpdater(); }
@Override public void setUp() throws Exception { super.setUp(); backingStore = getTestAccount().getMockStorage().getBackingStore(); }
/** * Test basic single threaded listStatus scenario. */ @Test public void testSingleThreadedBlockBlobDeleteScenario() throws Throwable { createEmptyFile(createTestAccount(), testPath); fs.delete(testPath, true); boolean deleteResult = fs.delete(testPath, true); assertFalse(deleteResult); }
/** * Get the configuration used to create the filesystem * @return the configuration of the test FS */ protected Configuration getConfiguration() { return getFileSystem().getConf(); }
@Override public Void run() throws Exception { // Add auth rules for dummyuser authorizer.addAuthRule("/", WRITE, getCurrentUserShortName(), true); authorizer.addAuthRule("/testRecursiveDeleteFailsWithStickybit*", WRITE, getCurrentUserShortName(), true); assertFalse(fs.delete(parentDir, true)); return null; } });
private int readInputStream(Path filePath) throws IOException { // Capture the file system from the test account. FileSystem fs = testAccount.getFileSystem(); return readInputStream(fs, filePath); }
private int readInputStream(Path filePath) throws IOException { // Capture the file system from the test account. FileSystem fs = testAccount.getFileSystem(); return readInputStream(fs, filePath); }
@Override public void setUp() throws Exception { super.setUp(); testPath = methodPath(); }
@Override public void setUp() throws Exception { super.setUp(); fs = getFileSystem(); }
/** * Get a self-renewing lease on the specified file. */ public SelfRenewingLease acquireLease(Path path) throws AzureException { String fullKey = pathToKey(makeAbsolute(path)); return getStore().acquireLease(fullKey); }
/** Clean up after execution of rename. * @throws IOException Thrown when fail to clean up. * */ public void cleanup() throws IOException { if (fs.getStoreInterface().isAtomicRenameKey(srcKey)) { // Remove RenamePending file fs.delete(getRenamePendingFilePath(), false); // Freeing source folder lease is not necessary since the source // folder file was deleted. } }
private void injectTransientError(NativeAzureFileSystem fs, final ConnectionRecognizer connectionRecognizer) { fs.getStore().addTestHookToOperationContext(new TestHookOperationContext() { @Override public OperationContext modifyOperationContext(OperationContext original) { original.getSendingRequestEventHandler().addListener( new TransientErrorInjector(connectionRecognizer)); return original; } }); }
private AzureException wrongVersionException(String containerVersion) { return new AzureException("The container " + container.getName() + " is at an unsupported version: " + containerVersion + ". Current supported version: " + FIRST_WASB_VERSION); }