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

The following examples show how to use org.apache.hadoop.conf.Configuration#getClasses() . 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
Source Project: hadoop   File: HttpServer.java    License: Apache License 2.0 6 votes vote down vote up
/** Get an array of FilterConfiguration specified in the conf */
private static FilterInitializer[] getFilterInitializers(Configuration conf) {
  if (conf == null) {
    return null;
  }

  Class<?>[] classes = conf.getClasses(FILTER_INITIALIZER_PROPERTY);
  if (classes == null) {
    return null;
  }

  FilterInitializer[] initializers = new FilterInitializer[classes.length];
  for(int i = 0; i < classes.length; i++) {
    initializers[i] = (FilterInitializer)ReflectionUtils.newInstance(
        classes[i], conf);
  }
  return initializers;
}
 
Example 2
Source Project: hadoop   File: HttpServer2.java    License: Apache License 2.0 6 votes vote down vote up
/** Get an array of FilterConfiguration specified in the conf */
private static FilterInitializer[] getFilterInitializers(Configuration conf) {
  if (conf == null) {
    return null;
  }

  Class<?>[] classes = conf.getClasses(FILTER_INITIALIZER_PROPERTY);
  if (classes == null) {
    return null;
  }

  FilterInitializer[] initializers = new FilterInitializer[classes.length];
  for(int i = 0; i < classes.length; i++) {
    initializers[i] = (FilterInitializer)ReflectionUtils.newInstance(
        classes[i], conf);
  }
  return initializers;
}
 
Example 3
Source Project: big-c   File: HttpServer.java    License: Apache License 2.0 6 votes vote down vote up
/** Get an array of FilterConfiguration specified in the conf */
private static FilterInitializer[] getFilterInitializers(Configuration conf) {
  if (conf == null) {
    return null;
  }

  Class<?>[] classes = conf.getClasses(FILTER_INITIALIZER_PROPERTY);
  if (classes == null) {
    return null;
  }

  FilterInitializer[] initializers = new FilterInitializer[classes.length];
  for(int i = 0; i < classes.length; i++) {
    initializers[i] = (FilterInitializer)ReflectionUtils.newInstance(
        classes[i], conf);
  }
  return initializers;
}
 
Example 4
Source Project: big-c   File: HttpServer2.java    License: Apache License 2.0 6 votes vote down vote up
/** Get an array of FilterConfiguration specified in the conf */
private static FilterInitializer[] getFilterInitializers(Configuration conf) {
  if (conf == null) {
    return null;
  }

  Class<?>[] classes = conf.getClasses(FILTER_INITIALIZER_PROPERTY);
  if (classes == null) {
    return null;
  }

  FilterInitializer[] initializers = new FilterInitializer[classes.length];
  for(int i = 0; i < classes.length; i++) {
    initializers[i] = (FilterInitializer)ReflectionUtils.newInstance(
        classes[i], conf);
  }
  return initializers;
}
 
Example 5
Source Project: lucene-solr   File: HttpServer2.java    License: Apache License 2.0 6 votes vote down vote up
/** Get an array of FilterConfiguration specified in the conf */
private static FilterInitializer[] getFilterInitializers(Configuration conf) {
  if (conf == null) {
    return null;
  }

  Class<?>[] classes = conf.getClasses(FILTER_INITIALIZER_PROPERTY);
  if (classes == null) {
    return null;
  }

  FilterInitializer[] initializers = new FilterInitializer[classes.length];
  for(int i = 0; i < classes.length; i++) {
    initializers[i] = (FilterInitializer)ReflectionUtils.newInstance(
        classes[i], conf);
  }
  return initializers;
}
 
Example 6
Source Project: hbase   File: HttpServer.java    License: Apache License 2.0 6 votes vote down vote up
/** Get an array of FilterConfiguration specified in the conf */
private static FilterInitializer[] getFilterInitializers(Configuration conf) {
  if (conf == null) {
    return null;
  }

  Class<?>[] classes = conf.getClasses(FILTER_INITIALIZERS_PROPERTY);
  if (classes == null) {
    return null;
  }

  FilterInitializer[] initializers = new FilterInitializer[classes.length];
  for(int i = 0; i < classes.length; i++) {
    initializers[i] = (FilterInitializer)ReflectionUtils.newInstance(classes[i]);
  }
  return initializers;
}
 
Example 7
Source Project: knox   File: HttpServer2.java    License: Apache License 2.0 6 votes vote down vote up
/** Get an array of FilterConfiguration specified in the conf */
private static FilterInitializer[] getFilterInitializers(Configuration conf) {
  if (conf == null) {
    return null;
  }

  Class<?>[] classes = conf.getClasses(FILTER_INITIALIZER_PROPERTY);
  if (classes == null) {
    return null;
  }

  FilterInitializer[] initializers = new FilterInitializer[classes.length];
  for(int i = 0; i < classes.length; i++) {
    initializers[i] = (FilterInitializer)ReflectionUtils.newInstance(
        classes[i], conf);
  }
  return initializers;
}
 
Example 8
Source Project: knox   File: HttpServer2.java    License: Apache License 2.0 6 votes vote down vote up
/** Get an array of FilterConfiguration specified in the conf */
private static FilterInitializer[] getFilterInitializers(Configuration conf) {
  if (conf == null) {
    return null;
  }

  Class<?>[] classes = conf.getClasses(FILTER_INITIALIZER_PROPERTY);
  if (classes == null) {
    return null;
  }

  FilterInitializer[] initializers = new FilterInitializer[classes.length];
  for(int i = 0; i < classes.length; i++) {
    initializers[i] = (FilterInitializer)ReflectionUtils.newInstance(
        classes[i], conf);
  }
  return initializers;
}
 
Example 9
Source Project: RDFS   File: HttpServer.java    License: Apache License 2.0 6 votes vote down vote up
/** Get an array of FilterConfiguration specified in the conf */
private static FilterInitializer[] getFilterInitializers(Configuration conf) {
  if (conf == null) {
    return null;
  }

  Class<?>[] classes = conf.getClasses(FILTER_INITIALIZER_PROPERTY);
  if (classes == null) {
    return null;
  }

  FilterInitializer[] initializers = new FilterInitializer[classes.length];
  for(int i = 0; i < classes.length; i++) {
    initializers[i] = (FilterInitializer)ReflectionUtils.newInstance(
        classes[i], conf);
  }
  return initializers;
}
 
Example 10
Source Project: hadoop-gpu   File: HttpServer.java    License: Apache License 2.0 6 votes vote down vote up
/** Get an array of FilterConfiguration specified in the conf */
private static FilterInitializer[] getFilterInitializers(Configuration conf) {
  if (conf == null) {
    return null;
  }

  Class<?>[] classes = conf.getClasses(FILTER_INITIALIZER_PROPERTY);
  if (classes == null) {
    return null;
  }

  FilterInitializer[] initializers = new FilterInitializer[classes.length];
  for(int i = 0; i < classes.length; i++) {
    initializers[i] = (FilterInitializer)ReflectionUtils.newInstance(
        classes[i], conf);
  }
  return initializers;
}
 
Example 11
Source Project: datawave   File: ConfigurationHelper.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get the value of the <code>name</code> property as a <code>List</code> of objects implementing the interface specified by <code>xface</code>.
 * 
 * An exception is thrown if any of the classes does not exist, or if it does not implement the named interface.
 * 
 * @param name
 *            the property name.
 * @param xface
 *            the interface implemented by the classes named by <code>name</code>.
 * @return a <code>List</code> of objects implementing <code>xface</code>.
 */
@SuppressWarnings("unchecked")
public static <U> List<U> getInstances(Configuration conf, String name, Class<U> xface) {
    List<U> ret = new ArrayList<>();
    Class<?>[] classes = conf.getClasses(name);
    for (Class<?> cl : classes) {
        if (!xface.isAssignableFrom(cl)) {
            throw new RuntimeException(cl + " does not implement " + xface);
        }
        ret.add((U) ReflectionUtils.newInstance(cl, conf));
    }
    return ret;
}
 
Example 12
/**
 * Get the value of the <code>name</code> property as a <code>List</code>
 * of objects implementing the interface specified by <code>xface</code>.
 *
 * An exception is thrown if any of the classes does not exist, or if it does
 * not implement the named interface.
 *
 * @param name the property name.
 * @param xface the interface implemented by the classes named by
 *        <code>name</code>.
 * @return a <code>List</code> of objects implementing <code>xface</code>.
 */
@SuppressWarnings("unchecked")
public static <U> List<U> getInstances(Configuration conf,
                                            String name, Class<U> xface) {
  List<U> ret = new ArrayList<U>();
  Class<?>[] classes = conf.getClasses(name);
  for (Class<?> cl: classes) {
    if (!xface.isAssignableFrom(cl)) {
      throw new RuntimeException(cl + " does not implement " + xface);
    }
    ret.add((U) ReflectionUtils.newInstance(cl, conf));
  }
  return ret;
}
 
Example 13
Source Project: hadoop   File: ResourceUsageMatcher.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Configure the {@link ResourceUsageMatcher} to load the configured plugins
 * and initialize them.
 */
@SuppressWarnings("unchecked")
public void configure(Configuration conf, ResourceCalculatorPlugin monitor, 
                      ResourceUsageMetrics metrics, Progressive progress) {
  Class[] plugins = conf.getClasses(RESOURCE_USAGE_EMULATION_PLUGINS);
  if (plugins == null) {
    System.out.println("No resource usage emulator plugins configured.");
  } else {
    for (Class clazz : plugins) {
      if (clazz != null) {
        if (ResourceUsageEmulatorPlugin.class.isAssignableFrom(clazz)) {
          ResourceUsageEmulatorPlugin plugin = 
            (ResourceUsageEmulatorPlugin) ReflectionUtils.newInstance(clazz, 
                                                                      conf);
          emulationPlugins.add(plugin);
        } else {
          throw new RuntimeException("Misconfigured resource usage plugins. " 
              + "Class " + clazz.getClass().getName() + " is not a resource "
              + "usage plugin as it does not extend "
              + ResourceUsageEmulatorPlugin.class.getName());
        }
      }
    }
  }

  // initialize the emulators once all the configured emulator plugins are
  // loaded
  for (ResourceUsageEmulatorPlugin emulator : emulationPlugins) {
    emulator.initialize(conf, metrics, monitor, progress);
  }
}
 
Example 14
Source Project: big-c   File: ResourceUsageMatcher.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Configure the {@link ResourceUsageMatcher} to load the configured plugins
 * and initialize them.
 */
@SuppressWarnings("unchecked")
public void configure(Configuration conf, ResourceCalculatorPlugin monitor, 
                      ResourceUsageMetrics metrics, Progressive progress) {
  Class[] plugins = conf.getClasses(RESOURCE_USAGE_EMULATION_PLUGINS);
  if (plugins == null) {
    System.out.println("No resource usage emulator plugins configured.");
  } else {
    for (Class clazz : plugins) {
      if (clazz != null) {
        if (ResourceUsageEmulatorPlugin.class.isAssignableFrom(clazz)) {
          ResourceUsageEmulatorPlugin plugin = 
            (ResourceUsageEmulatorPlugin) ReflectionUtils.newInstance(clazz, 
                                                                      conf);
          emulationPlugins.add(plugin);
        } else {
          throw new RuntimeException("Misconfigured resource usage plugins. " 
              + "Class " + clazz.getClass().getName() + " is not a resource "
              + "usage plugin as it does not extend "
              + ResourceUsageEmulatorPlugin.class.getName());
        }
      }
    }
  }

  // initialize the emulators once all the configured emulator plugins are
  // loaded
  for (ResourceUsageEmulatorPlugin emulator : emulationPlugins) {
    emulator.initialize(conf, metrics, monitor, progress);
  }
}
 
Example 15
Source Project: RDFS   File: TaskTracker.java    License: Apache License 2.0 4 votes vote down vote up
public static Class<?>[] getInstrumentationClasses(Configuration conf) {
  return conf.getClasses("mapred.tasktracker.instrumentation",
      TaskTrackerMetricsInst.class);
}