Java Code Examples for org.apache.hadoop.conf.Configuration#setTimeDuration()

The following examples show how to use org.apache.hadoop.conf.Configuration#setTimeDuration() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
@Test
public void testListStatusRootOneByOne() throws Exception {
  {
    DFS.ListStatusContinuationHandle handle = DFS.ListStatusContinuationHandle.newBuilder().setId("test-handle").build();

    DFS.ListStatusResponse listStatusInitialResponse = DFS.ListStatusResponse.newBuilder()
        .addStatuses(newFileStatus(42, true, 0, 0, 456, 879, 0755, "root", "wheel", "/foo"))
        .setHandle(handle)
        .build();
    DFS.ListStatusResponse listStatusLastResponse = DFS.ListStatusResponse.newBuilder()
        .addStatuses(newFileStatus(1024, false, 1, 4096, 354, 435, 0644, "admin", "admin", "/bar"))
        .build();

    setupRPC(
        DFS.RpcType.LIST_STATUS_REQUEST,
        Arrays.asList(
            DFS.ListStatusRequest.newBuilder().setPath("/").setLimit(1).build(),
            DFS.ListStatusRequest.newBuilder().setPath("/").setHandle(handle).setLimit(1).build()),
        DFS.RpcType.LIST_STATUS_RESPONSE,
        Arrays.asList(listStatusInitialResponse, listStatusLastResponse),
        Arrays.asList((ByteBuf) null, null)
        );
  }
  // Limit the number of results per batch
  final Configuration configuration = new Configuration(false);
  configuration.setTimeDuration(RemoteNodeFileSystem.RPC_TIMEOUT_KEY, TEST_RPC_TIMEOUT_MS, TimeUnit.MILLISECONDS);
  configuration.setInt(RemoteNodeFileSystem.LIST_STATUS_BATCH_SIZE_KEY, 1);

  FileSystem fs = newRemoteNodeFileSystem(configuration);

  Path root = new Path("/");
  FileStatus[] statuses = fs.listStatus(root);

  assertEquals(ENDPOINTS_LIST.size(), statuses.length);

  assertEquals(new Path("sabot://10.0.0.2:1234/foo"), statuses[0].getPath());
  assertTrue(statuses[0].isDirectory());
  assertEquals(0755, statuses[0].getPermission().toExtendedShort());

  assertEquals(new Path("sabot://10.0.0.2:1234/bar"), statuses[1].getPath());
  assertFalse(statuses[1].isDirectory());
  assertEquals(0644, statuses[1].getPermission().toExtendedShort());
}
 
Example 2
/**
 * Creates a pseudo distributed filesystem with the provided context
 *
 * @param context
 * @return
 * @throws IOException
 */
private RemoteNodeFileSystem newRemoteNodeFileSystem() throws IOException {
  final Configuration configuration = new Configuration(false);
  configuration.setTimeDuration(RemoteNodeFileSystem.RPC_TIMEOUT_KEY, TEST_RPC_TIMEOUT_MS, TimeUnit.MILLISECONDS);
  return newRemoteNodeFileSystem(configuration);
}