/** * Constructs a {@link org.apache.hadoop.hbase.client.RequestController}. * @param conf The {@link Configuration} to use. * @return A RequestController which is built according to the configuration. */ public static RequestController create(Configuration conf) { Class<? extends RequestController> clazz= conf.getClass(REQUEST_CONTROLLER_IMPL_CONF_KEY, SimpleRequestController.class, RequestController.class); return ReflectionUtils.newInstance(clazz, conf); } }
/** * @return The cluster registry implementation to use. */ static AsyncRegistry getRegistry(Configuration conf) { Class<? extends AsyncRegistry> clazz = conf.getClass(REGISTRY_IMPL_CONF_KEY, ZKAsyncRegistry.class, AsyncRegistry.class); return ReflectionUtils.newInstance(clazz, conf); } }
Sink getSink(Configuration configuration, Class clazz) { // In test context, this.sink might be set. Use it if non-null. For testing. return this.sink != null? this.sink: (Sink)ReflectionUtils.newInstance(configuration.getClass("hbase.canary.sink.class", clazz, Sink.class)); }
protected void initializeQueues(final int numQueues) { if (queueInitArgs.length > 0) { currentQueueLimit = (int) queueInitArgs[0]; queueInitArgs[0] = Math.max((int) queueInitArgs[0], DEFAULT_CALL_QUEUE_SIZE_HARD_LIMIT); } for (int i = 0; i < numQueues; ++i) { queues.add(ReflectionUtils.newInstance(queueClass, queueInitArgs)); } }
/** 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; }
public static <R, S, P extends Message, Q extends Message, T extends Message> CompletableFuture<R> median(AsyncTable<AdvancedScanResultConsumer> table, ColumnInterpreter<R, S, P, Q, T> ci, Scan scan) { CompletableFuture<R> future = new CompletableFuture<>(); sumByRegion(table, ci, scan).whenComplete((sumByRegion, error) -> { if (error != null) { future.completeExceptionally(error); } else if (sumByRegion.isEmpty()) { future.completeExceptionally(new NoSuchElementException()); } else { findMedian(future, table, ci, ReflectionUtils.newInstance(scan.getClass(), scan), sumByRegion); } }); return future; } }
static Get toCheckExistenceOnly(Get get) { if (get.isCheckExistenceOnly()) { return get; } return ReflectionUtils.newInstance(get.getClass(), get).setCheckExistenceOnly(true); }
private static BlockCache createExternalBlockcache(Configuration c) { if (LOG.isDebugEnabled()) { LOG.debug("Trying to use External l2 cache"); } Class klass = null; // Get the class, from the config. s try { klass = ExternalBlockCaches .valueOf(c.get(EXTERNAL_BLOCKCACHE_CLASS_KEY, "memcache")).clazz; } catch (IllegalArgumentException exception) { try { klass = c.getClass(EXTERNAL_BLOCKCACHE_CLASS_KEY, Class.forName( "org.apache.hadoop.hbase.io.hfile.MemcachedBlockCache")); } catch (ClassNotFoundException e) { return null; } } // Now try and create an instance of the block cache. try { LOG.info("Creating external block cache of type: " + klass); return (BlockCache) ReflectionUtils.newInstance(klass, c); } catch (Exception e) { LOG.warn("Error creating external block cache", e); } return null; }
} else if (availableImplementations.isEmpty()) { try { return ReflectionUtils.newInstance((Class<MetricRegistries>)Class.forName(defaultClass)); } catch (ClassNotFoundException e) { throw new RuntimeException(e);
public static MonkeyFactory getFactory(String factoryName) { MonkeyFactory fact = FACTORIES.get(factoryName); if (fact == null && factoryName != null && !factoryName.isEmpty()) { Class klass = null; try { klass = Class.forName(factoryName); if (klass != null) { fact = (MonkeyFactory) ReflectionUtils.newInstance(klass); } } catch (Exception e) { LOG.error("Error trying to create " + factoryName + " could not load it by class name"); return null; } } return fact; } }
@Override public ResultScanner getScanner(Scan scan) { return new AsyncTableResultScanner(this, ReflectionUtils.newInstance(scan.getClass(), scan), resultSize2CacheSize( scan.getMaxResultSize() > 0 ? scan.getMaxResultSize() : defaultScannerMaxResultSize)); }
future.complete( user.runAs((PrivilegedExceptionAction<? extends AsyncConnection>)() -> ReflectionUtils.newInstance(clazz, conf, registry, clusterId, user)) ); } catch (Exception e) {
private Scan setDefaultScanConfig(Scan scan) { // always create a new scan object as we may reset the start row later. Scan newScan = ReflectionUtils.newInstance(scan.getClass(), scan); if (newScan.getCaching() <= 0) { newScan.setCaching(defaultScannerCaching); } if (newScan.getMaxResultSize() <= 0) { newScan.setMaxResultSize(defaultScannerMaxResultSize); } return newScan; }
ms = ReflectionUtils.newInstance(DefaultMemStore.class, new Object[] { conf, this.comparator, this.getHRegion().getRegionServicesForStores()}); Class<? extends CompactingMemStore> clz = conf.getClass(MEMSTORE_CLASS_NAME, CompactingMemStore.class, CompactingMemStore.class); ms = ReflectionUtils.newInstance(clz, new Object[]{conf, this.comparator, this, this.getHRegion().getRegionServicesForStores(), inMemoryCompaction});
return (BufferedMutator)ReflectionUtils.newInstance(Class.forName(implementationClassName), this, rpcCallerFactory, rpcControllerFactory, params); } catch (ClassNotFoundException e) {
/** * @return The cluster registry implementation to use. */ static AsyncRegistry getRegistry(Configuration conf) { Class<? extends AsyncRegistry> clazz = conf.getClass(REGISTRY_IMPL_CONF_KEY, ZKAsyncRegistry.class, AsyncRegistry.class); return ReflectionUtils.newInstance(clazz, conf); } }
private Result get(Get get, final boolean checkExistenceOnly) throws IOException { get = ReflectionUtils.newInstance(get.getClass(), get); get.setCheckExistenceOnly(checkExistenceOnly); if (get.getConsistency() == null){
static Get toCheckExistenceOnly(Get get) { if (get.isCheckExistenceOnly()) { return get; } return ReflectionUtils.newInstance(get.getClass(), get).setCheckExistenceOnly(true); }
private Scan setDefaultScanConfig(Scan scan) { // always create a new scan object as we may reset the start row later. Scan newScan = ReflectionUtils.newInstance(scan.getClass(), scan); if (newScan.getCaching() <= 0) { newScan.setCaching(defaultScannerCaching); } if (newScan.getMaxResultSize() <= 0) { newScan.setMaxResultSize(defaultScannerMaxResultSize); } return newScan; }
@Override public ResultScanner getScanner(Scan scan) { return new AsyncTableResultScanner(this, ReflectionUtils.newInstance(scan.getClass(), scan), resultSize2CacheSize( scan.getMaxResultSize() > 0 ? scan.getMaxResultSize() : defaultScannerMaxResultSize)); }