List of usage examples for org.apache.hadoop.conf Configuration getClass
public <U> Class<? extends U> getClass(String name, Class<? extends U> defaultValue, Class<U> xface)
name
property as a Class
implementing the interface specified by xface
. From source file:com.chinamobile.bcbsp.io.BSPFileInputFormat.java
License:Apache License
/** * Get a PathFilter instance of the filter set for the input paths. * * @param context A read-only view of the job that is provided to * the tasks while they are running.// ww w . ja v a 2 s . c o m * @return the PathFilter instance set for the job, NULL if none has been set. */ public static PathFilter getInputPathFilter(JobContext context) { Configuration conf = context.getConfiguration(); Class<?> filterClass = conf.getClass("mapred.input.pathFilter.class", null, PathFilter.class); return (filterClass != null) ? (PathFilter) ReflectionUtils.newInstance(filterClass, conf) : null; }
From source file:com.cloudera.hadoop.hdfs.nfs.nfs4.UserIDMapper.java
License:Apache License
public static synchronized UserIDMapper get(Configuration conf) { boolean cache = conf.getBoolean(USER_ID_MAPPER_CACHE, true); Class<?> clazz = conf.getClass(USER_ID_MAPPER_CLASS, UserIDMapperSystem.class, UserIDMapper.class); if (cache) {//from w w w . ja v a 2 s . c o m UserIDMapper mapper = classUserIdMapperMap.get(clazz); if (mapper == null) { mapper = (UserIDMapper) ReflectionUtils.newInstance(clazz, conf); classUserIdMapperMap.put(clazz, mapper); } return mapper; } return (UserIDMapper) ReflectionUtils.newInstance(clazz, conf); }
From source file:com.cloudera.llama.am.cache.ResourceCache.java
License:Apache License
@SuppressWarnings("unchecked") public ResourceCache(String queue, Configuration conf, Listener listener) { this.queue = ParamChecker.notEmpty(queue, "queue"); this.listener = ParamChecker.notNull(listener, "listener"); Class<? extends EvictionPolicy> klass = conf.getClass(LlamaAM.EVICTION_POLICY_CLASS_KEY, LlamaAM.EVICTION_POLICY_CLASS_DEFAULT, EvictionPolicy.class); evictionPolicy = ReflectionUtils.newInstance(klass, conf); evictionRunInterval = conf.getInt(LlamaAM.EVICTION_RUN_INTERVAL_KEY, LlamaAM.EVICTION_RUN_INTERVAL_DEFAULT); }
From source file:com.cloudera.llama.am.impl.SingleQueueLlamaAM.java
License:Apache License
public static Class<? extends RMConnector> getRMConnectorClass(Configuration conf) { return conf.getClass(LlamaAM.RM_CONNECTOR_CLASS_KEY, YarnRMConnector.class, RMConnector.class); }
From source file:com.cloudera.llama.am.MiniLlama.java
License:Apache License
public MiniLlama(Configuration conf) { ParamChecker.notNull(conf, "conf"); Class<? extends AbstractServer> klass = conf.getClass(MINI_SERVER_CLASS_KEY, LlamaAMServer.class, AbstractServer.class); server = ReflectionUtils.newInstance(klass, conf); this.conf = server.getConf(); useExternalHadoop = conf.getBoolean(MINI_USE_EXTERNAL_HADOOP_KEY, false); }
From source file:com.cloudera.llama.server.AbstractMain.java
License:Apache License
public int run(String[] args) throws Exception { String confDir = System.getProperty(CONF_DIR_SYS_PROP); initLogging(confDir);//from w w w. j a va2s .co m logServerInfo(); LOG.info("Configuration directory: {}", confDir); Configuration llamaConf = loadConfiguration(confDir); if (args != null) { for (String arg : args) { if (arg.startsWith("-D")) { String[] s = arg.substring(2).split("="); if (s.length == 2) { llamaConf.set(s[0], s[1]); } } } } Class<? extends AbstractServer> klass = llamaConf.getClass(SERVER_CLASS_KEY, getServerClass(), AbstractServer.class); LOG.info("Server: {}", klass.getName()); LOG.info("-----------------------------------------------------------------"); AbstractServer server = ReflectionUtils.newInstance(klass, llamaConf); addShutdownHook(server); try { server.start(); runningLatch.await(); server.stop(); } catch (Exception ex) { LOG.error("Server error: {}", ex.toString(), ex); server.stop(); return 1; } stopLatch.countDown(); return server.getExitCode(); }
From source file:com.conductor.hadoop.WritableValueInputFormat.java
License:Apache License
@SuppressWarnings("unchecked") private V getV(final Configuration conf) { final Class<? extends Writable> valueClass = conf.getClass(VALUE_TYPE_CONF, null, Writable.class); try {/*from w ww. ja v a2s .c om*/ // note that, since valueClass is Writable, it should have a default constructor. return (V) valueClass.newInstance(); } catch (InstantiationException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } }
From source file:com.dinglicom.clouder.mapreduce.input.FileInputFormat.java
License:Apache License
/** * Get a PathFilter instance of the filter set for the input paths. * * @return the PathFilter instance set for the job, NULL if none has been set. *//*from ww w. ja v a 2 s. com*/ public static PathFilter getInputPathFilter(JobContext context) { Configuration conf = context.getConfiguration(); Class<?> filterClass = conf.getClass(PATHFILTER_CLASS, null, PathFilter.class); return (filterClass != null) ? (PathFilter) ReflectionUtils.newInstance(filterClass, conf) : null; }
From source file:com.facebook.hiveio.conf.ClassConfOption.java
License:Apache License
/** * Lookup value/* w w w . j a v a 2s . co m*/ * @param conf Configuration * @return Class set for key, or defaultClass */ public Class<? extends C> get(Configuration conf) { return conf.getClass(getKey(), defaultClass, interfaceClass); }
From source file:com.facebook.hiveio.conf.ClassConfOption.java
License:Apache License
/** * Lookup with user specified default value * @param conf Configuration/* ww w . ja v a2s . c om*/ * @param defaultValue default value * @return Class */ public Class<? extends C> getWithDefault(Configuration conf, Class<? extends C> defaultValue) { return conf.getClass(getKey(), defaultValue, interfaceClass); }