net.spy.memcached.DefaultConnectionFactory Java Examples
The following examples show how to use
net.spy.memcached.DefaultConnectionFactory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExceptionSwallowingMemcachedClient.java From seldon-server with Apache License 2.0 | 6 votes |
@Autowired public ExceptionSwallowingMemcachedClient(GlobalConfigHandler globalConfigHandler, ZkCuratorHandler zkCuratorHandler) throws Exception { logger.info("Initializing..."); Stat stat = zkCuratorHandler.getCurator().checkExists().forPath(ZK_CONFIG_KEY_MEMCACHED_SERVERS_FPATH); if (stat != null) { ObjectMapper mapper = new ObjectMapper(); byte[] bytes = zkCuratorHandler.getCurator().getData().forPath(ZK_CONFIG_KEY_MEMCACHED_SERVERS_FPATH); MemcacheConfig config = mapper.readValue(bytes,MemcacheConfig.class); logger.info(config.toString()); memcachedClient = new MemcachedClient(new ConnectionFactoryBuilder(new DefaultConnectionFactory()).setOpTimeout(MEMCACHE_OP_TIMEOUT).build(), AddrUtil.getAddresses(config.servers)); logger.info(String.format("MemcachedClient initialized using %s[%s]", ZK_CONFIG_KEY_MEMCACHED_SERVERS, config.servers)); MemCachePeer.initialise(config.servers,config.numClients); } if (memcachedClient == null) { throw new Exception("*Warning* Memcached NOT initialized!"); } globalConfigHandler.addSubscriber(ZK_CONFIG_KEY_MEMCACHED_SERVERS, this); }
Example #2
Source File: BaseAsciiConnectionFactory.java From EVCache with Apache License 2.0 | 5 votes |
BaseAsciiConnectionFactory(EVCacheClient client, int len, Property<Integer> _operationTimeout, long opMaxBlockTime) { super(len, DefaultConnectionFactory.DEFAULT_READ_BUFFER_SIZE, DefaultHashAlgorithm.KETAMA_HASH); this.opMaxBlockTime = opMaxBlockTime; this.operationTimeout = _operationTimeout; this.client = client; this.startTime = System.currentTimeMillis(); this.appName = client.getAppName(); this.failureMode = client.getPool().getEVCacheClientPoolManager().getEVCacheConfig().getPropertyRepository().get(this.client.getServerGroupName() + ".failure.mode", String.class).orElseGet(appName + ".failure.mode").orElse("Retry"); this.name = appName + "-" + client.getServerGroupName() + "-" + client.getId(); }
Example #3
Source File: MemcachedConnectionFactory.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
@Override public MetricType enableMetrics() { String metricType = metricsConfig.get("memcached.metricstype"); return metricType == null ? DefaultConnectionFactory.DEFAULT_METRIC_TYPE : MetricType.valueOf(metricType.toUpperCase(Locale.ROOT)); }
Example #4
Source File: MemcachedConnectionFactory.java From kylin with Apache License 2.0 | 4 votes |
@Override public MetricType enableMetrics() { String metricType = metricsConfig.get("memcached.metricstype"); return metricType == null ? DefaultConnectionFactory.DEFAULT_METRIC_TYPE : MetricType.valueOf(metricType.toUpperCase(Locale.ROOT)); }
Example #5
Source File: CacheGrantManual.java From oxAuth with MIT License | 4 votes |
private static MemcachedClient createClients() throws IOException { return new MemcachedClient(new DefaultConnectionFactory(100, 32768), Lists.newArrayList(new InetSocketAddress("localhost", 11211))); }