use of net.spy.memcached.MemcachedClient in project hazelcast by hazelcast.
the class AdvancedNetworkingCommunicationIntegrationTest method testMemcacheConnectionToEndpoints.
@Test
public void testMemcacheConnectionToEndpoints() throws Exception {
Config config = createCompleteMultiSocketConfig();
JoinConfig join = config.getAdvancedNetworkConfig().getJoin();
join.getMulticastConfig().setEnabled(false);
join.getTcpIpConfig().setEnabled(false);
HazelcastInstance hz = newHazelcastInstance(config);
MemcachedClient client = null;
try {
client = getMemcachedClient(hz, MEMCACHE_PORT);
client.get("whatever");
} finally {
shutdownQuietly(client);
}
testMemcacheCallFailsOnPort(hz, MEMBER_PORT);
testMemcacheCallFailsOnPort(hz, CLIENT_PORT);
testMemcacheCallFailsOnPort(hz, WAN1_PORT);
testMemcacheCallFailsOnPort(hz, REST_PORT);
}
use of net.spy.memcached.MemcachedClient in project hazelcast by hazelcast.
the class AdvancedNetworkingCommunicationIntegrationTest method getMemcachedClient.
private MemcachedClient getMemcachedClient(HazelcastInstance instance, int port) throws Exception {
String hostName = instance.getCluster().getLocalMember().getSocketAddress().getHostName();
InetSocketAddress address = new InetSocketAddress(hostName, port);
ConnectionFactory factory = new ConnectionFactoryBuilder().setOpTimeout(3000).setDaemon(true).setFailureMode(FailureMode.Retry).build();
return new MemcachedClient(factory, Collections.singletonList(address));
}
use of net.spy.memcached.MemcachedClient in project hazelcast by hazelcast.
the class AdvancedNetworkingCommunicationIntegrationTest method testMemcacheCallFailsOnPort.
private void testMemcacheCallFailsOnPort(HazelcastInstance hz, int port) throws Exception {
MemcachedClient client = null;
try {
client = getMemcachedClient(hz, port);
try {
client.get("whatever");
fail("Memcache call should throw SocketException for port " + port);
} catch (Exception ex) {
// expected
}
} finally {
shutdownQuietly(client);
}
}
use of net.spy.memcached.MemcachedClient in project druid by druid-io.
the class MemcachedCacheBenchmark method setUp.
@Override
protected void setUp() throws Exception {
SerializingTranscoder transcoder = new SerializingTranscoder(// 50 MB
50 * 1024 * 1024);
// disable compression
transcoder.setCompressionThreshold(Integer.MAX_VALUE);
client = new MemcachedClient(new ConnectionFactoryBuilder().setProtocol(ConnectionFactoryBuilder.Protocol.BINARY).setHashAlg(DefaultHashAlgorithm.FNV1A_64_HASH).setLocatorType(ConnectionFactoryBuilder.Locator.CONSISTENT).setDaemon(true).setFailureMode(FailureMode.Retry).setTranscoder(transcoder).setShouldOptimize(true).build(), AddrUtil.getAddresses(hosts));
cache = new MemcachedCache(Suppliers.<ResourceHolder<MemcachedClientIF>>ofInstance(StupidResourceHolder.create(client)), new MemcachedCacheConfig() {
@Override
public String getMemcachedPrefix() {
return "druid-memcached-benchmark";
}
@Override
public int getTimeout() {
return 30000;
}
@Override
public int getExpiration() {
return 3600;
}
}, MemcachedCacheTest.NOOP_MONITOR);
randBytes = new byte[objectSize * 1024];
new Random(0).nextBytes(randBytes);
}
use of net.spy.memcached.MemcachedClient in project hazelcast by hazelcast.
the class MemcacheTest method getMemcacheClient.
private MemcachedClient getMemcacheClient(HazelcastInstance instance) throws Exception {
InetSocketAddress address = instance.getCluster().getLocalMember().getSocketAddress();
ConnectionFactory factory = new ConnectionFactoryBuilder().setOpTimeout(60 * 60 * 60).setDaemon(true).setFailureMode(FailureMode.Retry).build();
return new MemcachedClient(factory, Collections.singletonList(address));
}
Aggregations