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:org.kiji.mapreduce.bulkimport.impl.KijiBulkImporters.java
License:Apache License
/** * <p>Create an instance of the bulk importer specified by the * {@link org.apache.hadoop.conf.Configuration}.</p> * * The configuration would have stored the bulk importer * name only if it was configured by a KijiBulkImportJob, so don't try * calling this method with any old Configuration object. * * @param <K> The map input key for the bulk importer. * @param <V> The map input value for the bulk importer. * @param conf The job configuration.// w ww. j a v a2 s . co m * @return a brand-spankin'-new KijiBulkImporter instance. * @throws IOException If the bulk importer cannot be loaded. */ @SuppressWarnings("unchecked") public static <K, V> KijiBulkImporter<K, V> create(Configuration conf) throws IOException { final Class<? extends KijiBulkImporter> bulkImporterClass = conf .getClass(KijiConfKeys.KIJI_BULK_IMPORTER_CLASS, null, KijiBulkImporter.class); if (null == bulkImporterClass) { throw new IOException("Unable to load bulk importer class"); } return ReflectionUtils.newInstance(bulkImporterClass, conf); }
From source file:org.kiji.mapreduce.gather.impl.GatherMapper.java
License:Apache License
/** * Initialize the gatherer instance to execute. * * @param conf the Configuration to use to initialize the gatherer instance. * @return a KijiGatherer instance./*from w ww.j a va 2 s . co m*/ */ protected KijiGatherer<K, V> createGatherer(Configuration conf) { @SuppressWarnings("unchecked") Class<? extends KijiGatherer<K, V>> gatherClass = (Class<? extends KijiGatherer<K, V>>) conf .getClass(KijiConfKeys.KIJI_GATHERER_CLASS, null, KijiGatherer.class); if (null == gatherClass) { LOG.error("Null " + KijiConfKeys.KIJI_GATHERER_CLASS + " in createGatherer()?"); return null; } return ReflectionUtils.newInstance(gatherClass, conf); }
From source file:org.kiji.mapreduce.pivot.impl.KijiPivoters.java
License:Apache License
/** * Create an instance of {@link KijiPivoter} as specified from a given * {@link org.apache.hadoop.conf.Configuration}. * * @param conf The job configuration./* w w w . ja va 2s . c o m*/ * @return a new {@link KijiPivoter} instance. * @throws IOException if the class cannot be loaded. */ public static KijiPivoter create(Configuration conf) throws IOException { final Class<? extends KijiPivoter> tableMapperClass = conf.getClass(KijiConfKeys.KIJI_PIVOTER_CLASS, null, KijiPivoter.class); if (null == tableMapperClass) { throw new IOException("Unable to load pivoter class"); } return ReflectionUtils.newInstance(tableMapperClass, conf); }
From source file:org.kiji.mapreduce.produce.impl.KijiProducers.java
License:Apache License
/** * Creates an instance of the producer specified by the * {@link org.apache.hadoop.conf.Configuration}. * * <p>The configuration would have stored the producer name only if * it was configured by a KijiProduceJobBuilder, so don't try calling this * method with any old Configuration object.</p> * * @param conf The job configuration.// w w w .j a v a 2 s.c om * @return a brand-spankin'-new KijiProducer instance. * @throws IOException If the producer name cannot be instantiated from the configuration. */ public static KijiProducer create(Configuration conf) throws IOException { final Class<? extends KijiProducer> producerClass = conf.getClass(KijiConfKeys.KIJI_PRODUCER_CLASS, null, KijiProducer.class); if (null == producerClass) { throw new IOException("Producer class could not be found in configuration."); } return ReflectionUtils.newInstance(producerClass, conf); }
From source file:org.lab41.mapreduce.blueprints.BlueprintsGraphOutputMapReduce.java
License:Apache License
public static Graph generateGraph(final Configuration config) { final Class<? extends OutputFormat> format = config.getClass(FaunusGraph.FAUNUS_GRAPH_OUTPUT_FORMAT, OutputFormat.class, OutputFormat.class); if (TitanOutputFormat.class.isAssignableFrom(format)) { return GraphFactory.generateGraph(config, TitanOutputFormat.FAUNUS_GRAPH_OUTPUT_TITAN); } else {/*from w ww.ja v a 2 s . com*/ // TODO: this is where Rexster can come into play here throw new RuntimeException("The provide graph output format is not supported: " + format.getName()); } }
From source file:org.Microsoft.Telemetry.IntermediateHistoryStore.java
License:Open Source License
/** * This method Initializes all objects of the Telemetry service. * * @throws IOException ,YarnException/*from ww w. j a v a2s . co m*/ */ private void initialization(Configuration conf) throws YarnException, IOException { originalStorage = ReflectionUtils .newInstance(conf.getClass(YarnConfiguration.TIMELINE_SERVICE_STORE + "-old", LeveldbTimelineStore.class, TimelineStore.class), conf); serviceInformation.initialization(conf); if (originalStorage != null) { LOG.info(PATTERN_LOG_INFO + "Timeline server Storage initialized successfully....!"); LOG2.info(PATTERN_LOG_INFO + "Timeline server Storage initialized successfully....!"); } else { LOG.error(PATTERN_LOG_ERROR + "Timeline server Storage Initialization failed"); } }
From source file:org.warcbase.mapreduce.lib.Chain.java
License:Apache License
/** * Setup the chain.// w w w . j a v a 2s .c o m * * @param jobConf * chain job's {@link Configuration}. */ @SuppressWarnings("unchecked") void setup(Configuration jobConf) { String prefix = getPrefix(); int index = jobConf.getInt(prefix + CHAIN_MAPPER_SIZE, 0); for (int i = 0; i < index; i++) { Class<? extends Mapper> klass = jobConf.getClass(prefix + CHAIN_MAPPER_CLASS + i, null, Mapper.class); Configuration mConf = getChainElementConf(jobConf, prefix + CHAIN_MAPPER_CONFIG + i); confList.add(mConf); Mapper mapper = ReflectionUtils.newInstance(klass, mConf); mappers.add(mapper); } }