public MemcachedBlockCache(Configuration c) throws IOException { LOG.info("Creating MemcachedBlockCache"); long opTimeout = c.getLong(MEMCACHED_OPTIMEOUT_KEY, MEMCACHED_DEFAULT_TIMEOUT); long queueTimeout = c.getLong(MEMCACHED_TIMEOUT_KEY, opTimeout + MEMCACHED_DEFAULT_TIMEOUT); boolean optimize = c.getBoolean(MEMCACHED_OPTIMIZE_KEY, MEMCACHED_OPTIMIZE_DEFAULT); ConnectionFactoryBuilder builder = new ConnectionFactoryBuilder() .setOpTimeout(opTimeout) .setOpQueueMaxBlockTime(queueTimeout) // Cap the max time before anything times out .setFailureMode(FailureMode.Redistribute) .setShouldOptimize(optimize) .setDaemon(true) // Don't keep threads around past the end of days. .setUseNagleAlgorithm(false) // Ain't nobody got time for that .setReadBufferSize(HConstants.DEFAULT_BLOCKSIZE * 4 * 1024); // Much larger just in case // Assume only the localhost is serving memecached. // A la mcrouter or co-locating memcached with split regionservers. // // If this config is a pool of memecached servers they will all be used according to the // default hashing scheme defined by the memcache client. Spy Memecache client in this // case. String serverListString = c.get(MEMCACHED_CONFIG_KEY,"localhost:11211"); String[] servers = serverListString.split(","); List<InetSocketAddress> serverAddresses = new ArrayList<>(servers.length); for (String s:servers) { serverAddresses.add(Addressing.createInetSocketAddressFromHostAndPortStr(s)); } client = new MemcachedClient(builder.build(), serverAddresses); }
private ConnectionFactoryBuilder newConnectionFactoryBuilder(final Config conf) { ConnectionFactoryBuilder builder = new ConnectionFactoryBuilder(); ifset(conf, "authWaitTime", path -> builder .setAuthWaitTime(conf.getDuration(path, TimeUnit.MILLISECONDS))); ifset(conf, "daemon", path -> builder.setDaemon(conf.getBoolean(path))); ifset(conf, "enableMetrics", path -> builder .setEnableMetrics(enumFor(conf.getString(path), MetricType.values()))); ifset(conf, "failureMode", path -> builder .setFailureMode(enumFor(conf.getString(path), FailureMode.values()))); ifset(conf, "locator", path -> builder .setLocatorType(enumFor(conf.getString(path), Locator.values()))); ifset(conf, "maxReconnectDelay", path -> builder .setMaxReconnectDelay(conf.getDuration(path, TimeUnit.SECONDS))); ifset(conf, "opQueueMaxBlockTime", path -> builder .setOpQueueMaxBlockTime(conf.getDuration(path, TimeUnit.MILLISECONDS))); ifset(conf, "opTimeout", path -> builder .setOpTimeout(conf.getDuration(path, TimeUnit.MILLISECONDS))); ifset(conf, "protocol", path -> builder .setProtocol(enumFor(conf.getString(path), Protocol.values()))); ifset(conf, "readBufferSize", path -> builder .setReadBufferSize(conf.getInt(path))); ifset(conf, "shouldOptimize", path -> builder .setShouldOptimize(conf.getBoolean(path))); ifset(conf, "timeoutExceptionThreshold", path -> builder .setTimeoutExceptionThreshold(conf.getInt(path))); ifset(conf, "useNagleAlgorithm", path -> builder .setUseNagleAlgorithm(conf.getBoolean(path))); return builder; }
public void setUseNagleAlgorithm(final boolean to) { connectionFactoryBuilder.setUseNagleAlgorithm(to); }
public void setUseNagleAlgorithm(final boolean to) { connectionFactoryBuilder.setUseNagleAlgorithm(to); }
public void setUseNagleAlgorithm(final boolean to) { connectionFactoryBuilder.setUseNagleAlgorithm(to); }
public void setUseNagleAlgorithm(final boolean to) { connectionFactoryBuilder.setUseNagleAlgorithm(to); }
public MemcachedBlockCache(Configuration c) throws IOException { LOG.info("Creating MemcachedBlockCache"); long opTimeout = c.getLong(MEMCACHED_OPTIMEOUT_KEY, MEMCACHED_DEFAULT_TIMEOUT); long queueTimeout = c.getLong(MEMCACHED_TIMEOUT_KEY, opTimeout + MEMCACHED_DEFAULT_TIMEOUT); boolean optimize = c.getBoolean(MEMCACHED_OPTIMIZE_KEY, MEMCACHED_OPTIMIZE_DEFAULT); ConnectionFactoryBuilder builder = new ConnectionFactoryBuilder() .setOpTimeout(opTimeout) .setOpQueueMaxBlockTime(queueTimeout) // Cap the max time before anything times out .setFailureMode(FailureMode.Redistribute) .setShouldOptimize(optimize) .setDaemon(true) // Don't keep threads around past the end of days. .setUseNagleAlgorithm(false) // Ain't nobody got time for that .setReadBufferSize(HConstants.DEFAULT_BLOCKSIZE * 4 * 1024); // Much larger just in case // Assume only the localhost is serving memecached. // A la mcrouter or co-locating memcached with split regionservers. // // If this config is a pool of memecached servers they will all be used according to the // default hashing scheme defined by the memcache client. Spy Memecache client in this // case. String serverListString = c.get(MEMCACHED_CONFIG_KEY,"localhost:11211"); String[] servers = serverListString.split(","); List<InetSocketAddress> serverAddresses = new ArrayList<>(servers.length); for (String s:servers) { serverAddresses.add(Addressing.createInetSocketAddressFromHostAndPortStr(s)); } client = new MemcachedClient(builder.build(), serverAddresses); }
private ConnectionFactoryBuilder newConnectionFactoryBuilder(final Config conf) { ConnectionFactoryBuilder builder = new ConnectionFactoryBuilder(); ifset(conf, "authWaitTime", path -> builder .setAuthWaitTime(conf.getDuration(path, TimeUnit.MILLISECONDS))); ifset(conf, "daemon", path -> builder.setDaemon(conf.getBoolean(path))); ifset(conf, "enableMetrics", path -> builder .setEnableMetrics(enumFor(conf.getString(path), MetricType.values()))); ifset(conf, "failureMode", path -> builder .setFailureMode(enumFor(conf.getString(path), FailureMode.values()))); ifset(conf, "locator", path -> builder .setLocatorType(enumFor(conf.getString(path), Locator.values()))); ifset(conf, "maxReconnectDelay", path -> builder .setMaxReconnectDelay(conf.getDuration(path, TimeUnit.SECONDS))); ifset(conf, "opQueueMaxBlockTime", path -> builder .setOpQueueMaxBlockTime(conf.getDuration(path, TimeUnit.MILLISECONDS))); ifset(conf, "opTimeout", path -> builder .setOpTimeout(conf.getDuration(path, TimeUnit.MILLISECONDS))); ifset(conf, "protocol", path -> builder .setProtocol(enumFor(conf.getString(path), Protocol.values()))); ifset(conf, "readBufferSize", path -> builder .setReadBufferSize(conf.getInt(path))); ifset(conf, "shouldOptimize", path -> builder .setShouldOptimize(conf.getBoolean(path))); ifset(conf, "timeoutExceptionThreshold", path -> builder .setTimeoutExceptionThreshold(conf.getInt(path))); ifset(conf, "useNagleAlgorithm", path -> builder .setUseNagleAlgorithm(conf.getBoolean(path))); return builder; }
public ConnectionFactoryBuilder(ConnectionFactory cf) { setAuthDescriptor(cf.getAuthDescriptor()); setDaemon(cf.isDaemon()); setFailureMode(cf.getFailureMode()); setHashAlg(cf.getHashAlg()); setInitialObservers(cf.getInitialObservers()); setMaxReconnectDelay(cf.getMaxReconnectDelay()); setOpQueueMaxBlockTime(cf.getOpQueueMaxBlockTime()); setOpTimeout(cf.getOperationTimeout()); setReadBufferSize(cf.getReadBufSize()); setShouldOptimize(cf.shouldOptimize()); setTimeoutExceptionThreshold(cf.getTimeoutExceptionThreshold()); setTranscoder(cf.getDefaultTranscoder()); setUseNagleAlgorithm(cf.useNagleAlgorithm()); }
public ConnectionFactoryBuilder(ConnectionFactory cf) { setAuthDescriptor(cf.getAuthDescriptor()); setDaemon(cf.isDaemon()); setFailureMode(cf.getFailureMode()); setHashAlg(cf.getHashAlg()); setInitialObservers(cf.getInitialObservers()); setMaxReconnectDelay(cf.getMaxReconnectDelay()); setOpQueueMaxBlockTime(cf.getOpQueueMaxBlockTime()); setOpTimeout(cf.getOperationTimeout()); setReadBufferSize(cf.getReadBufSize()); setShouldOptimize(cf.shouldOptimize()); setTimeoutExceptionThreshold(cf.getTimeoutExceptionThreshold()); setTranscoder(cf.getDefaultTranscoder()); setUseNagleAlgorithm(cf.useNagleAlgorithm()); setEnableMetrics(cf.enableMetrics()); setListenerExecutorService(cf.getListenerExecutorService()); setAuthWaitTime(cf.getAuthWaitTime()); }
public ConnectionFactoryBuilder(ConnectionFactory cf) { setClientMode(cf.getClientMode()); setAuthDescriptor(cf.getAuthDescriptor()); setDaemon(cf.isDaemon()); setFailureMode(cf.getFailureMode()); setHashAlg(cf.getHashAlg()); setInitialObservers(cf.getInitialObservers()); setMaxReconnectDelay(cf.getMaxReconnectDelay()); setOpQueueMaxBlockTime(cf.getOpQueueMaxBlockTime()); setOpTimeout(cf.getOperationTimeout()); setReadBufferSize(cf.getReadBufSize()); setShouldOptimize(cf.shouldOptimize()); setTimeoutExceptionThreshold(cf.getTimeoutExceptionThreshold()); setTranscoder(cf.getDefaultTranscoder()); setUseNagleAlgorithm(cf.useNagleAlgorithm()); setEnableMetrics(cf.enableMetrics()); setListenerExecutorService(cf.getListenerExecutorService()); setAuthWaitTime(cf.getAuthWaitTime()); }
builder.setUseNagleAlgorithm(conf.getUseNagleAlgorithm());
builder.setUseNagleAlgorithm(conf.getUseNagleAlgorithm());