final Config config; if (configPath == null || configPath.isEmpty()) { config = new Config(); final Iterator<Entry<Object, Object>> iterator = getProperties() .entrySet().iterator(); while (iterator.hasNext()) { final Entry<Object, Object> property = iterator.next(); config.overrideConfig((String)property.getKey(), (String)property.getValue()); config = new Config(configPath);
this.channel_factory = channel_factory; zkclient = new ZKClient(quorum_spec, base_path); config = new Config(); rpc_timeout = config.getInt("hbase.rpc.timeout"); timer = newTimer(config, "HBaseClient"); rpc_timeout_timer = newTimer(config, "RPC Timeout Timer"); flush_interval = config.getShort("hbase.rpcs.buffered_flush_interval"); increment_buffer_size = config.getInt("hbase.increments.buffer_size"); nsre_low_watermark = config.getInt("hbase.nsre.low_watermark"); nsre_high_watermark = config.getInt("hbase.nsre.high_watermark"); if (config.properties.containsKey("hbase.increments.durable")) { increment_buffer_durable = config.getBoolean("hbase.increments.durable"); if (config.hasProperty("hbase.meta.scan")) { scan_meta = config.getBoolean("hbase.meta.scan"); } else { scan_meta = Boolean.parseBoolean( System.getProperty("hbase.meta.scan", "false")); if (config.hasProperty("hbase.meta.split")) { split_meta = config.getBoolean("hbase.meta.split"); } else { split_meta = Boolean.parseBoolean(
throw new IllegalArgumentException("Negative: " + flush_interval); final short prev = config.getShort("hbase.rpcs.buffered_flush_interval"); config.overrideConfig("hbase.rpcs.buffered_flush_interval", Short.toString(flush_interval)); this.flush_interval = flush_interval;
final ClientSocketChannelFactory channel_factory) { this.channel_factory = channel_factory; zkclient = new ZKClient(config.getString("hbase.zookeeper.quorum"), config.getString("hbase.zookeeper.znode.parent")); this.config = config; rpc_timeout = config.getInt("hbase.rpc.timeout"); timer = newTimer(config, "HBaseClient"); rpc_timeout_timer = newTimer(config, "RPC Timeout Timer"); flush_interval = config.getShort("hbase.rpcs.buffered_flush_interval"); increment_buffer_size = config.getInt("hbase.increments.buffer_size"); nsre_low_watermark = config.getInt("hbase.nsre.low_watermark"); nsre_high_watermark = config.getInt("hbase.nsre.high_watermark"); if (config.properties.containsKey("hbase.increments.durable")) { increment_buffer_durable = config.getBoolean("hbase.increments.durable"); if (config.hasProperty("hbase.meta.scan")) { scan_meta = config.getBoolean("hbase.meta.scan"); } else { scan_meta = Boolean.parseBoolean( System.getProperty("hbase.meta.scan", "false")); if (config.hasProperty("hbase.meta.split")) { split_meta = config.getBoolean("hbase.meta.split"); } else { split_meta = Boolean.parseBoolean(
throw new IllegalArgumentException("Negative: " + increment_buffer_size); final int current = config.getInt("hbase.increments.buffer_size"); if (current == increment_buffer_size) { return current; config.overrideConfig("hbase.increments.buffer_size", Integer.toString(increment_buffer_size)); this.increment_buffer_size = increment_buffer_size;
/** * Constructor. * @param quorum_spec The specification of the quorum, e.g. * {@code "host1,host2,host3"}. * @param base_path The base path under which is the znode for the * -ROOT- region. */ public HBaseClient(final String quorum_spec, final String base_path) { this(quorum_spec, base_path, defaultChannelFactory(new Config())); }
/** * Attempts to refresh the ticket by shelling out to the kinit utility */ private void refreshTicketCache() { String cmd = "/usr/bin/kinit"; if (config.hasProperty("asynchbase.security.auth.kinit")) { cmd = config.getString("asynchbase.security.auth.kinit"); } final String args = "-R"; try { LOG.info("Executing kinit command: " + cmd + " " + args); Shell.execCommand(cmd, args); } catch (Exception e) { throw new RuntimeException("Could not renew TGT due to problem " + "running shell command: '" + cmd + " " + args + "';", e); } }
config.getInt("hbase.ipc.client.socket.timeout.connect")); socket_config.setTcpNoDelay( config.getBoolean("hbase.ipc.client.tcpnodelay")); config.getBoolean("hbase.ipc.client.tcpkeepalive")); if (config.hasProperty("hbase.ipc.client.socket.write.high_watermark")) { ((NioChannelConfig)config).setWriteBufferHighWaterMark( config.getInt("hbase.ipc.client.socket.write.high_watermark")); if (config.hasProperty("hbase.ipc.client.socket.write.low_watermark")) { ((NioChannelConfig)config).setWriteBufferLowWaterMark( config.getInt("hbase.ipc.client.socket.write.low_watermark")); if (config.hasProperty("hbase.ipc.client.socket.sendBufferSize")) { socket_config.setOption("sendBufferSize", config.getInt("hbase.ipc.client.socket.sendBufferSize")); if (config.hasProperty("hbase.ipc.client.socket.receiveBufferSize")) { socket_config.setOption("receiveBufferSize", config.getInt("hbase.ipc.client.socket.receiveBufferSize"));
/** * Constructor. * @param hbase_client The HBase client this instance belongs to. */ public RegionClient(final HBaseClient hbase_client) { this.hbase_client = hbase_client; check_write_status = hbase_client.getConfig().getBoolean( "hbase.region_client.check_channel_write_status"); inflight_limit = hbase_client.getConfig().getInt( "hbase.region_client.inflight_limit"); pending_limit = hbase_client.getConfig().getInt( "hbase.region_client.pending_limit"); batch_size = hbase_client.getConfig().getInt("hbase.rpcs.batch.size"); }
/** * Package private timer constructor that provides a useful name for the * timer thread. * @param config The config object used to pull out the tick interval * @param name A name to stash in the timer * @return A timer */ static HashedWheelTimer newTimer(final Config config, final String name) { class TimerThreadNamer implements ThreadNameDeterminer { @Override public String determineThreadName(String currentThreadName, String proposedThreadName) throws Exception { return "AsyncHBase Timer " + name + " #" + TIMER_THREAD_ID.incrementAndGet(); } } if (config == null) { return new HashedWheelTimer(Executors.defaultThreadFactory(), new TimerThreadNamer(), 100, MILLISECONDS, 512); } return new HashedWheelTimer(Executors.defaultThreadFactory(), new TimerThreadNamer(), config.getShort("hbase.timer.tick"), MILLISECONDS, config.getInt("hbase.timer.ticks_per_wheel")); }
new NioClientBossPool(executor, 1, newTimer(config, "Boss Pool"), new BossThreadNamer()); final int num_workers = config.hasProperty("hbase.workers.size") ? config.getInt("hbase.workers.size") : Runtime.getRuntime().availableProcessors() * 2; final NioWorkerPool worker_pool = new NioWorkerPool(executor,
final ChannelBuffer header; if (hbase_client.getConfig().getBoolean("hbase.security.auth.enable") && hbase_client.getConfig().hasProperty("hbase.security.auth.94")) { secure_rpc_helper = new SecureRpcHelper94(hbase_client, this, chan.getRemoteAddress()); } else { if (!hbase_client.has_root || hbase_client.split_meta) { if (hbase_client.getConfig().getBoolean("hbase.security.auth.enable")) { secure_rpc_helper = new SecureRpcHelper96(hbase_client, this, chan.getRemoteAddress());
/** * Checks whether or not an RPC can be retried once more. * @param rpc The RPC we're going to attempt to execute. * @return {@code true} if this RPC already had too many attempts, * {@code false} otherwise (in which case it's OK to retry once more). * @throws NonRecoverableException if the request has had too many attempts * already. */ boolean cannotRetryRequest(final HBaseRpc rpc) { return rpc.attempt > config.getInt("hbase.client.retries.number"); }
final Login client_login = Login.getCurrentLogin(); String server_principal = hbase_client.getConfig().getString(PRINCIPAL_KEY); if (server_principal.contains("_HOST")) { try {
/** * Helper that checks to see if we should encrypt the packets between HBase * based on the client config. If the client has set "integrity" or "privacy" * then the packets will be encrypted. If set to "authentication" then no * encryption is used. Any other value will throw an exception * @return A string to compare against to see if we should wrap or not. * @throws IllegalArgumentException if the config doesn't contain one of * the three strings above. */ private String parseQOP() { final String protection = config.hasProperty(RPC_QOP_KEY) ? config.getString(RPC_QOP_KEY) : "authentication"; if ("integrity".equalsIgnoreCase(protection)) { return "auth-int"; } if ("privacy".equalsIgnoreCase(protection)) { return "auth-conf"; } if ("authentication".equalsIgnoreCase(protection)) { return "auth"; } throw new IllegalArgumentException("Unrecognized rpc protection level: " + protection); }
/** Schedule a timer to retry {@link #getRootRegion} after some time. */ private void retryGetRootRegionLater() { newTimeout(new TimerTask() { public void run(final Timeout timeout) { if (!getRootRegion()) { // Try to read the znodes connectZK(); // unless we need to connect first. } } }, config.getInt("hbase.zookeeper.getroot.retry_delay") /* milliseconds */); }
asyncClientConfig = new Config(); asyncClientConfig.overrideConfig( HBaseSinkConfigurationConstants.ASYNC_ZK_QUORUM_KEY, zkQuorum ); asyncClientConfig.overrideConfig( HBaseSinkConfigurationConstants.ASYNC_ZK_BASEPATH_KEY, zkBaseDir ); for (String property: asyncProperties.keySet()) { asyncClientConfig.overrideConfig(property, asyncProperties.get(property));
/** * Default ctor * @param hbase_client The HBaseClient to fetch configuration and timers from * @throws IllegalArgumentException if the * asynchbase.security.auth.simple.username is missing, null or empty. */ public SimpleClientAuthProvider(final HBaseClient hbase_client) { super(hbase_client); if (!hbase_client.getConfig().hasProperty(USERNAME_KEY)) { throw new IllegalArgumentException("Missing client username"); } username = hbase_client.getConfig().getString(USERNAME_KEY); if (username == null || username.isEmpty()) { throw new IllegalArgumentException("Missing client username"); } }
RegionClientPipeline() { timeout_handler = new IdleStateHandler(timer, 0, 0, config.getInt("hbase.hbase.ipc.client.connection.idle_timeout")); }
Config config = new Config(); config.overrideConfig("hbase.zookeeper.quorum", systemConfig.getValue(Property.HBASE_ZOOKEEPER_CONNECT.getName(), Property.HBASE_ZOOKEEPER_CONNECT.getDefaultValue())); config.overrideConfig("hbase.zookeeper.session.timeout", systemConfig.getValue(Property.HBASE_ZOOKEEPER_SESSION_TIMEOUT.getName(), Property.HBASE_ZOOKEEPER_SESSION_TIMEOUT.getDefaultValue())); config.overrideConfig("hbase.rpcs.batch.size", systemConfig.getValue(Property.HBASE_RPCS_BATCH_SIZE.getName(), Property.HBASE_RPCS_BATCH_SIZE.getDefaultValue())); config.overrideConfig("hbase.rpcs.buffered_flush_interval", systemConfig.getValue(Property.HBASE_RPCS_BUFFERED_FLUSH_INTERVAL.getName(), Property.HBASE_RPCS_BUFFERED_FLUSH_INTERVAL.getDefaultValue())); config.overrideConfig("hbase.rpc.timeout", systemConfig.getValue(Property.HBASE_RPC_TIMEOUT.getName(), Property.HBASE_RPC_TIMEOUT.getDefaultValue())); config.overrideConfig("hbase.security.auth.enable", systemConfig.getValue(Property.HBASE_SECURITY_AUTH_ENABLE.getName(), Property.HBASE_SECURITY_AUTH_ENABLE.getDefaultValue())); config.overrideConfig("hbase.rpc.protection", systemConfig.getValue(Property.HBASE_RPC_PROTECTION.getName(), Property.HBASE_RPC_PROTECTION.getDefaultValue())); config.overrideConfig("hbase.sasl.clientconfig", systemConfig.getValue(Property.HBASE_SASL_CLIENTCONFIG.getName(), Property.HBASE_SASL_CLIENTCONFIG.getDefaultValue())); config.overrideConfig("hbase.kerberos.regionserver.principal", systemConfig.getValue(Property.HBASE_KERBEROS_REGIONSERVER_PRINCIPAL.getName(), Property.HBASE_KERBEROS_REGIONSERVER_PRINCIPAL.getDefaultValue())); config.overrideConfig("hbase.security.authentication", systemConfig.getValue(Property.HBASE_SECURITY_AUTHENTICATION.getName(), Property.HBASE_SECURITY_AUTHENTICATION.getDefaultValue()));