org.apache.hadoop.fs.azure.AzureException Java Examples

The following examples show how to use org.apache.hadoop.fs.azure.AzureException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestAzureFileSystemInstrumentation.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test
public void testClientErrorMetrics() throws Exception {
  String directoryName = "metricsTestDirectory_ClientError";
  Path directoryPath = new Path("/" + directoryName);
  assertTrue(fs.mkdirs(directoryPath));
  String leaseID = testAccount.acquireShortLease(directoryName);
  try {
    try {
      fs.delete(directoryPath, true);
      assertTrue("Should've thrown.", false);
    } catch (AzureException ex) {
      assertTrue("Unexpected exception: " + ex,
          ex.getMessage().contains("lease"));
    }
    assertEquals(1, AzureMetricsTestUtil.getLongCounterValue(getInstrumentation(), WASB_CLIENT_ERRORS));
    assertEquals(0, AzureMetricsTestUtil.getLongCounterValue(getInstrumentation(), WASB_SERVER_ERRORS));
  } finally {
    testAccount.releaseLease(leaseID, directoryName);
  }
}
 
Example #2
Source File: TestAzureFileSystemInstrumentation.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test
public void testClientErrorMetrics() throws Exception {
  String directoryName = "metricsTestDirectory_ClientError";
  Path directoryPath = new Path("/" + directoryName);
  assertTrue(fs.mkdirs(directoryPath));
  String leaseID = testAccount.acquireShortLease(directoryName);
  try {
    try {
      fs.delete(directoryPath, true);
      assertTrue("Should've thrown.", false);
    } catch (AzureException ex) {
      assertTrue("Unexpected exception: " + ex,
          ex.getMessage().contains("lease"));
    }
    assertEquals(1, AzureMetricsTestUtil.getLongCounterValue(getInstrumentation(), WASB_CLIENT_ERRORS));
    assertEquals(0, AzureMetricsTestUtil.getLongCounterValue(getInstrumentation(), WASB_SERVER_ERRORS));
  } finally {
    testAccount.releaseLease(leaseID, directoryName);
  }
}
 
Example #3
Source File: AzureFSFactoryTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateFsWithAuthorityMissingCreds() throws Exception {
	String uriString = String.format("%s://[email protected]/testDir", scheme);
	final URI uri = URI.create(uriString);

	exception.expect(AzureException.class);

	AbstractAzureFSFactory factory = getFactory(scheme);
	Configuration config = new Configuration();
	config.setInteger("fs.azure.io.retry.max.retries", 0);
	factory.configure(config);
	factory.create(uri);
}
 
Example #4
Source File: TestReadAndSeekPageBlobAfterWrite.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/**
 * Read "size" bytes of data and verify that what was read and what was written
 * are the same.
 */
private void readRandomDataAndVerify(int size) throws AzureException, IOException {
  byte[] b = new byte[size];
  FSDataInputStream stream = fs.open(PATH);
  int bytesRead = stream.read(b);
  stream.close();
  assertEquals(bytesRead, size);

  // compare the data read to the data written
  assertTrue(comparePrefix(randomData, b, size));
}
 
Example #5
Source File: TestReadAndSeekPageBlobAfterWrite.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Read "size" bytes of data and verify that what was read and what was written
 * are the same.
 */
private void readRandomDataAndVerify(int size) throws AzureException, IOException {
  byte[] b = new byte[size];
  FSDataInputStream stream = fs.open(PATH);
  int bytesRead = stream.read(b);
  stream.close();
  assertEquals(bytesRead, size);

  // compare the data read to the data written
  assertTrue(comparePrefix(randomData, b, size));
}
 
Example #6
Source File: AzureFSFactoryTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateFsWithAuthorityMissingCreds() throws Exception {
	String uriString = String.format("%s://[email protected]/testDir", scheme);
	final URI uri = URI.create(uriString);

	exception.expect(AzureException.class);

	AbstractAzureFSFactory factory = getFactory(scheme);
	Configuration config = new Configuration();
	config.setInteger("fs.azure.io.retry.max.retries", 0);
	factory.configure(config);
	factory.create(uri);
}
 
Example #7
Source File: NativeAzureFileSystem.java    From hadoop with Apache License 2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example #8
Source File: NativeAzureFileSystem.java    From hadoop with Apache License 2.0 4 votes vote down vote up
/**
 * Get a self-renewing Azure blob lease on the source folder zero-byte file.
 */
private SelfRenewingLease leaseSourceFolder(String srcKey)
    throws AzureException {
  return store.acquireLease(srcKey);
}
 
Example #9
Source File: NativeAzureFileSystem.java    From big-c with Apache License 2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example #10
Source File: NativeAzureFileSystem.java    From big-c with Apache License 2.0 4 votes vote down vote up
/**
 * Get a self-renewing Azure blob lease on the source folder zero-byte file.
 */
private SelfRenewingLease leaseSourceFolder(String srcKey)
    throws AzureException {
  return store.acquireLease(srcKey);
}