类org.apache.hadoop.fs.azure.AzureException源码实例Demo

下面列出了怎么用org.apache.hadoop.fs.azure.AzureException的API类实例代码及写法,或者点击链接到github查看源代码。


@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);
  }
}
 

@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);
  }
}
 
源代码3 项目: flink   文件: AzureFSFactoryTest.java

@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);
}
 

/**
 * 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));
}
 

/**
 * 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));
}
 
源代码6 项目: flink   文件: AzureFSFactoryTest.java

@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);
}
 
源代码7 项目: hadoop   文件: NativeAzureFileSystem.java

/**
 * 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);
}
 
源代码8 项目: hadoop   文件: NativeAzureFileSystem.java

/**
 * 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);
}
 
源代码9 项目: big-c   文件: NativeAzureFileSystem.java

/**
 * 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);
}
 
源代码10 项目: big-c   文件: NativeAzureFileSystem.java

/**
 * 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);
}
 
 类所在包
 同包方法