use of com.microsoft.azure.storage.blob.BlobOutputStream in project hadoop by apache.
the class TestContainerChecks method testContainerExistAfterDoesNotExist.
@Test
public void testContainerExistAfterDoesNotExist() throws Exception {
testAccount = AzureBlobStorageTestAccount.create("", EnumSet.noneOf(CreateOptions.class));
assumeNotNull(testAccount);
CloudBlobContainer container = testAccount.getRealContainer();
FileSystem fs = testAccount.getFileSystem();
// Starting off with the container not there
assertFalse(container.exists());
// state to DoesNotExist
try {
fs.listStatus(new Path("/"));
assertTrue("Should've thrown.", false);
} catch (FileNotFoundException ex) {
assertTrue("Unexpected exception: " + ex, ex.getMessage().contains("does not exist."));
}
assertFalse(container.exists());
// Create a container outside of the WASB FileSystem
container.create();
// Add a file to the container outside of the WASB FileSystem
CloudBlockBlob blob = testAccount.getBlobReference("foo");
BlobOutputStream outputStream = blob.openOutputStream();
outputStream.write(new byte[10]);
outputStream.close();
// Make sure the file is visible
assertTrue(fs.exists(new Path("/foo")));
assertTrue(container.exists());
}
use of com.microsoft.azure.storage.blob.BlobOutputStream in project hadoop by apache.
the class TestOutOfBandAzureBlobOperationsLive method outOfBandFolder_rename_rootLevelFiles.
// WASB must force explicit parent directories in create, delete, mkdirs, rename.
// scenario for this particular test described at MONARCH-HADOOP-764
@Test
public void outOfBandFolder_rename_rootLevelFiles() throws Exception {
// NOTE: manual use of CloubBlockBlob targets working directory explicitly.
// WASB driver methods prepend working directory implicitly.
CloudBlockBlob blob = testAccount.getBlobReference("fileX");
BlobOutputStream s = blob.openOutputStream();
s.close();
Path srcFilePath = new Path("/fileX");
assertTrue(fs.exists(srcFilePath));
Path destFilePath = new Path("/fileXrename");
fs.rename(srcFilePath, destFilePath);
}
use of com.microsoft.azure.storage.blob.BlobOutputStream in project hadoop by apache.
the class TestOutOfBandAzureBlobOperationsLive method outOfBandSingleFile_rename.
// Verify that you can rename a file which is the only file in an implicit folder in the
// WASB file system.
// scenario for this particular test described at MONARCH-HADOOP-892
@Test
public void outOfBandSingleFile_rename() throws Exception {
//NOTE: manual use of CloubBlockBlob targets working directory explicitly.
// WASB driver methods prepend working directory implicitly.
String workingDir = "user/" + UserGroupInformation.getCurrentUser().getShortUserName() + "/";
CloudBlockBlob blob = testAccount.getBlobReference(workingDir + "testFolder5/a/input/file");
BlobOutputStream s = blob.openOutputStream();
s.close();
Path srcFilePath = new Path("testFolder5/a/input/file");
assertTrue(fs.exists(srcFilePath));
Path destFilePath = new Path("testFolder5/file2");
fs.rename(srcFilePath, destFilePath);
}
use of com.microsoft.azure.storage.blob.BlobOutputStream in project hadoop by apache.
the class TestOutOfBandAzureBlobOperationsLive method outOfBandFolder_uncleMkdirs.
// scenario for this particular test described at MONARCH-HADOOP-764
// creating a file out-of-band would confuse mkdirs("<oobfilesUncleFolder>")
// eg oob creation of "user/<name>/testFolder/a/input/file"
// Then wasb creation of "user/<name>/testFolder/a/output" fails
@Test
public void outOfBandFolder_uncleMkdirs() throws Exception {
// NOTE: manual use of CloubBlockBlob targets working directory explicitly.
// WASB driver methods prepend working directory implicitly.
String workingDir = "user/" + UserGroupInformation.getCurrentUser().getShortUserName() + "/";
CloudBlockBlob blob = testAccount.getBlobReference(workingDir + "testFolder1/a/input/file");
BlobOutputStream s = blob.openOutputStream();
s.close();
assertTrue(fs.exists(new Path("testFolder1/a/input/file")));
Path targetFolder = new Path("testFolder1/a/output");
assertTrue(fs.mkdirs(targetFolder));
}
Aggregations