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

The following are Jave code examples for showing how to use getInstances() of the org.apache.hadoop.conf.Configuration class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: hadoop-oss   File: TestIdentityProviders.java   Source Code and License Vote up 6 votes
@Test
public void testPluggableIdentityProvider() {
  Configuration conf = new Configuration();
  conf.set(CommonConfigurationKeys.IPC_CALLQUEUE_IDENTITY_PROVIDER_KEY,
    "org.apache.hadoop.ipc.UserIdentityProvider");

  List<IdentityProvider> providers = conf.getInstances(
    CommonConfigurationKeys.IPC_CALLQUEUE_IDENTITY_PROVIDER_KEY,
    IdentityProvider.class);

  assertTrue(providers.size() == 1);

  IdentityProvider ip = providers.get(0);
  assertNotNull(ip);
  assertEquals(ip.getClass(), UserIdentityProvider.class);
}
 
Example 2
Project: hadoop   File: NameNode.java   Source Code and License Vote up 6 votes
/** Start the services common to active and standby states */
private void startCommonServices(Configuration conf) throws IOException {
  namesystem.startCommonServices(conf, haContext);
  registerNNSMXBean();
  if (NamenodeRole.NAMENODE != role) {
    startHttpServer(conf);
    httpServer.setNameNodeAddress(getNameNodeAddress());
    httpServer.setFSImage(getFSImage());
  }
  rpcServer.start();
  plugins = conf.getInstances(DFS_NAMENODE_PLUGINS_KEY,
      ServicePlugin.class);
  for (ServicePlugin p: plugins) {
    try {
      p.start(this);
    } catch (Throwable t) {
      LOG.warn("ServicePlugin " + p + " could not be started", t);
    }
  }
  LOG.info(getRole() + " RPC up at: " + rpcServer.getRpcAddress());
  if (rpcServer.getServiceRpcAddress() != null) {
    LOG.info(getRole() + " service RPC up at: "
        + rpcServer.getServiceRpcAddress());
  }
}
 
Example 3
Project: hadoop   File: TestIdentityProviders.java   Source Code and License Vote up 6 votes
@Test
public void testPluggableIdentityProvider() {
  Configuration conf = new Configuration();
  conf.set(CommonConfigurationKeys.IPC_CALLQUEUE_IDENTITY_PROVIDER_KEY,
    "org.apache.hadoop.ipc.UserIdentityProvider");

  List<IdentityProvider> providers = conf.getInstances(
    CommonConfigurationKeys.IPC_CALLQUEUE_IDENTITY_PROVIDER_KEY,
    IdentityProvider.class);

  assertTrue(providers.size() == 1);

  IdentityProvider ip = providers.get(0);
  assertNotNull(ip);
  assertEquals(ip.getClass(), UserIdentityProvider.class);
}
 
Example 4
Project: hadoop-oss   File: DecayRpcScheduler.java   Source Code and License Vote up 5 votes
private IdentityProvider parseIdentityProvider(String ns, Configuration conf) {
  List<IdentityProvider> providers = conf.getInstances(
    ns + "." + CommonConfigurationKeys.IPC_CALLQUEUE_IDENTITY_PROVIDER_KEY,
    IdentityProvider.class);

  if (providers.size() < 1) {
    LOG.info("IdentityProvider not specified, " +
      "defaulting to UserIdentityProvider");
    return new UserIdentityProvider();
  }

  return providers.get(0); // use the first
}
 
Example 5
Project: hadoop   File: DataNode.java   Source Code and License Vote up 5 votes
private void startPlugins(Configuration conf) {
  plugins = conf.getInstances(DFS_DATANODE_PLUGINS_KEY, ServicePlugin.class);
  for (ServicePlugin p: plugins) {
    try {
      p.start(this);
      LOG.info("Started plug-in " + p);
    } catch (Throwable t) {
      LOG.warn("ServicePlugin " + p + " could not be started", t);
    }
  }
}
 
Example 6
Project: hadoop   File: DecayRpcScheduler.java   Source Code and License Vote up 5 votes
private IdentityProvider parseIdentityProvider(String ns, Configuration conf) {
  List<IdentityProvider> providers = conf.getInstances(
    ns + "." + CommonConfigurationKeys.IPC_CALLQUEUE_IDENTITY_PROVIDER_KEY,
    IdentityProvider.class);

  if (providers.size() < 1) {
    LOG.info("IdentityProvider not specified, " +
      "defaulting to UserIdentityProvider");
    return new UserIdentityProvider();
  }

  return providers.get(0); // use the first
}