public RackManager(Configuration conf) { switchMapping = ReflectionUtils.instantiateWithCustomCtor( conf.getClass("hbase.util.ip.to.rack.determiner", ScriptBasedMapping.class, DNSToSwitchMapping.class).getName(), new Class<?>[]{Configuration.class}, new Object[]{conf}); }
public static ClientBackoffPolicy create(Configuration conf) { // create the backoff policy String className = conf.get(ClientBackoffPolicy.BACKOFF_POLICY_CLASS, NoBackoffPolicy.class .getName()); return ReflectionUtils.instantiateWithCustomCtor(className, new Class<?>[] { Configuration.class }, new Object[] { conf }); }
protected void createCompactor(Configuration conf, HStore store) throws IOException { String className = conf.get(DEFAULT_COMPACTOR_CLASS_KEY, DEFAULT_COMPACTOR_CLASS.getName()); try { compactor = ReflectionUtils.instantiateWithCustomCtor(className, new Class[] { Configuration.class, HStore.class }, new Object[] { conf, store }); } catch (Exception e) { throw new IOException("Unable to load configured compactor '" + className + "'", e); } }
protected void createCompactionPolicy(Configuration conf, HStore store) throws IOException { String className = conf.get( DEFAULT_COMPACTION_POLICY_CLASS_KEY, DEFAULT_COMPACTION_POLICY_CLASS.getName()); try { compactionPolicy = ReflectionUtils.instantiateWithCustomCtor(className, new Class[] { Configuration.class, StoreConfigInformation.class }, new Object[] { conf, store }); } catch (Exception e) { throw new IOException("Unable to load configured compaction policy '" + className + "'", e); } }
protected void createStoreFlusher(Configuration conf, HStore store) throws IOException { String className = conf.get( DEFAULT_STORE_FLUSHER_CLASS_KEY, DEFAULT_STORE_FLUSHER_CLASS.getName()); try { storeFlusher = ReflectionUtils.instantiateWithCustomCtor(className, new Class[] { Configuration.class, HStore.class }, new Object[] { conf, store }); } catch (Exception e) { throw new IOException("Unable to load configured store flusher '" + className + "'", e); } }
static MemStoreLAB newInstance(Configuration conf) { MemStoreLAB memStoreLAB = null; if (isEnabled(conf)) { String className = conf.get(MSLAB_CLASS_NAME, MemStoreLABImpl.class.getName()); memStoreLAB = ReflectionUtils.instantiateWithCustomCtor(className, new Class[] { Configuration.class }, new Object[] { conf }); } return memStoreLAB; }
@Override public T newChannel() { try { return ReflectionUtils.instantiateWithCustomCtor(clazz.getName(), new Class[] { InternetProtocolFamily.class }, new Object[] { family }); } catch (Throwable t) { throw new ChannelException("Unable to create Channel from class " + clazz, t); } }
/** * Creates a new RpcClient by the class defined in the configuration or falls back to * RpcClientImpl * @param conf configuration * @param clusterId the cluster id * @param localAddr client socket bind address. * @param metrics the connection metrics * @return newly created RpcClient */ public static RpcClient createClient(Configuration conf, String clusterId, SocketAddress localAddr, MetricsConnection metrics) { String rpcClientClass = getRpcClientClass(conf); return ReflectionUtils.instantiateWithCustomCtor(rpcClientClass, new Class[] { Configuration.class, String.class, SocketAddress.class, MetricsConnection.class }, new Object[] { conf, clusterId, localAddr, metrics }); } }
/** * Create and setup a {@link WALCellCodec} from the * CompressionContext. * Cell Codec classname is read from {@link Configuration}. * Fully prepares the codec for use. * @param conf {@link Configuration} to read for the user-specified codec. If none is specified, * uses a {@link WALCellCodec}. * @param compression compression the codec should use * @return a {@link WALCellCodec} ready for use. * @throws UnsupportedOperationException if the codec cannot be instantiated */ public static WALCellCodec create(Configuration conf, CompressionContext compression) throws UnsupportedOperationException { String cellCodecClsName = getWALCellCodecClass(conf).getName(); return ReflectionUtils.instantiateWithCustomCtor(cellCodecClsName, new Class[] { Configuration.class, CompressionContext.class }, new Object[] { conf, compression }); }
/** * Create and setup a {@link WALCellCodec} from the {@code cellCodecClsName} and * CompressionContext, if {@code cellCodecClsName} is specified. * Otherwise Cell Codec classname is read from {@link Configuration}. * Fully prepares the codec for use. * @param conf {@link Configuration} to read for the user-specified codec. If none is specified, * uses a {@link WALCellCodec}. * @param cellCodecClsName name of codec * @param compression compression the codec should use * @return a {@link WALCellCodec} ready for use. * @throws UnsupportedOperationException if the codec cannot be instantiated */ public static WALCellCodec create(Configuration conf, String cellCodecClsName, CompressionContext compression) throws UnsupportedOperationException { if (cellCodecClsName == null) { cellCodecClsName = getWALCellCodecClass(conf).getName(); } return ReflectionUtils.instantiateWithCustomCtor(cellCodecClsName, new Class[] { Configuration.class, CompressionContext.class }, new Object[] { conf, compression }); }
public static RpcControllerFactory instantiate(Configuration configuration) { String rpcControllerFactoryClazz = configuration.get(CUSTOM_CONTROLLER_CONF_KEY, RpcControllerFactory.class.getName()); try { return ReflectionUtils.instantiateWithCustomCtor(rpcControllerFactoryClazz, new Class[] { Configuration.class }, new Object[] { configuration }); } catch (UnsupportedOperationException | NoClassDefFoundError ex) { // HBASE-14960: In case the RPCController is in a non-HBase jar (Phoenix), but the application // is a pure HBase application, we want to fallback to the default one. String msg = "Cannot load configured \"" + CUSTOM_CONTROLLER_CONF_KEY + "\" (" + rpcControllerFactoryClazz + ") from hbase-site.xml, falling back to use " + "default RpcControllerFactory"; if (LOG.isDebugEnabled()) { LOG.warn(msg, ex); // if DEBUG enabled, we want the exception, but still log in WARN level } else { LOG.warn(msg); } return new RpcControllerFactory(configuration); } } }
/** * Create the StoreEngine configured for the given Store. * @param store The store. An unfortunate dependency needed due to it * being passed to coprocessors via the compactor. * @param conf Store configuration. * @param cellComparator CellComparator for storeFileManager. * @return StoreEngine to use. */ public static StoreEngine<?, ?, ?, ?> create( HStore store, Configuration conf, CellComparator cellComparator) throws IOException { String className = conf.get(STORE_ENGINE_CLASS_KEY, DEFAULT_STORE_ENGINE_CLASS.getName()); try { StoreEngine<?,?,?,?> se = ReflectionUtils.instantiateWithCustomCtor( className, new Class[] { }, new Object[] { }); se.createComponentsOnce(conf, store, cellComparator); return se; } catch (Exception e) { throw new IOException("Unable to load configured store engine '" + className + "'", e); } } }
public static RpcRetryingCallerFactory instantiate(Configuration configuration, RetryingCallerInterceptor interceptor, ServerStatisticTracker stats) { String clazzName = RpcRetryingCallerFactory.class.getName(); String rpcCallerFactoryClazz = configuration.get(RpcRetryingCallerFactory.CUSTOM_CALLER_CONF_KEY, clazzName); RpcRetryingCallerFactory factory; if (rpcCallerFactoryClazz.equals(clazzName)) { factory = new RpcRetryingCallerFactory(configuration, interceptor); } else { factory = ReflectionUtils.instantiateWithCustomCtor( rpcCallerFactoryClazz, new Class[] { Configuration.class }, new Object[] { configuration }); } // setting for backwards compat with existing caller factories, rather than in the ctor factory.setStatisticTracker(stats); return factory; } }
public static RpcServer createRpcServer(final Server server, final String name, final List<BlockingServiceAndInterface> services, final InetSocketAddress bindAddress, Configuration conf, RpcScheduler scheduler, boolean reservoirEnabled) throws IOException { String rpcServerClass = conf.get(CUSTOM_RPC_SERVER_IMPL_CONF_KEY, NettyRpcServer.class.getName()); StringBuilder servicesList = new StringBuilder(); for (BlockingServiceAndInterface s: services) { ServiceDescriptor sd = s.getBlockingService().getDescriptorForType(); if (sd == null) continue; // Can be null for certain tests like TestTokenAuthentication if (servicesList.length() > 0) servicesList.append(", "); servicesList.append(sd.getFullName()); } LOG.info("Creating " + rpcServerClass + " hosting " + servicesList); return ReflectionUtils.instantiateWithCustomCtor(rpcServerClass, new Class[] { Server.class, String.class, List.class, InetSocketAddress.class, Configuration.class, RpcScheduler.class, boolean.class }, new Object[] { server, name, services, bindAddress, conf, scheduler, reservoirEnabled }); } }
public DateTieredCompactionPolicy(Configuration conf, StoreConfigInformation storeConfigInfo) throws IOException { super(conf, storeConfigInfo); try { compactionPolicyPerWindow = ReflectionUtils.instantiateWithCustomCtor( comConf.getCompactionPolicyForDateTieredWindow(), new Class[] { Configuration.class, StoreConfigInformation.class }, new Object[] { conf, storeConfigInfo }); } catch (Exception e) { throw new IOException("Unable to load configured compaction policy '" + comConf.getCompactionPolicyForDateTieredWindow() + "'", e); } try { windowFactory = ReflectionUtils.instantiateWithCustomCtor( comConf.getDateTieredCompactionWindowFactory(), new Class[] { CompactionConfiguration.class }, new Object[] { comConf }); } catch (Exception e) { throw new IOException("Unable to load configured window factory '" + comConf.getDateTieredCompactionWindowFactory() + "'", e); } }
compactor = ReflectionUtils.instantiateWithCustomCtor(className, new Class[] { Configuration.class, FileSystem.class, TableName.class, ColumnFamilyDescriptor.class, ExecutorService.class }, new Object[] { conf, fs, tableName, hcd, pool });
this.cp = ReflectionUtils.instantiateWithCustomCtor(cpClass.getName(), new Class[] {Configuration.class, StoreConfigInformation.class }, new Object[] {configuration, store });
public static ClientBackoffPolicy create(Configuration conf) { // create the backoff policy String className = conf.get(ClientBackoffPolicy.BACKOFF_POLICY_CLASS, NoBackoffPolicy.class .getName()); return ReflectionUtils.instantiateWithCustomCtor(className, new Class<?>[] { Configuration.class }, new Object[] { conf }); }
/** * Creates a new RpcClient by the class defined in the configuration or falls back to * RpcClientImpl * @param conf configuration * @param clusterId the cluster id * @param localAddr client socket bind address. * @param metrics the connection metrics * @return newly created RpcClient */ public static RpcClient createClient(Configuration conf, String clusterId, SocketAddress localAddr, MetricsConnection metrics) { String rpcClientClass = getRpcClientClass(conf); return ReflectionUtils.instantiateWithCustomCtor(rpcClientClass, new Class[] { Configuration.class, String.class, SocketAddress.class, MetricsConnection.class }, new Object[] { conf, clusterId, localAddr, metrics }); } }
public static RpcRetryingCallerFactory instantiate(Configuration configuration, RetryingCallerInterceptor interceptor, ServerStatisticTracker stats) { String clazzName = RpcRetryingCallerFactory.class.getName(); String rpcCallerFactoryClazz = configuration.get(RpcRetryingCallerFactory.CUSTOM_CALLER_CONF_KEY, clazzName); RpcRetryingCallerFactory factory; if (rpcCallerFactoryClazz.equals(clazzName)) { factory = new RpcRetryingCallerFactory(configuration, interceptor); } else { factory = ReflectionUtils.instantiateWithCustomCtor( rpcCallerFactoryClazz, new Class[] { Configuration.class }, new Object[] { configuration }); } // setting for backwards compat with existing caller factories, rather than in the ctor factory.setStatisticTracker(stats); return factory; } }