Netflix / dyno

Java client for Dynomite
https://github.com/Netflix/dynomite
Apache License 2.0
186 stars 94 forks source link

Is DynoClient Supports Single ton Implementation #258

Open ghost opened 5 years ago

ghost commented 5 years ago

I build a dynomite cluster of 3 racks. Each rack consists of two nodes. I implemented dyno client for Java. I used singleton Implementation. if one of the node is getting down. then I am observed errors of peer not connected. if I again establish the connection when one of the node get down. it works properly

`public static DynoJedisClient establishingConnection() {

DynoJedisClient dynoclient = null;
String client = Configuration.getProperty(CacheConstants.DYNOMITE_CLIENT, "dynomiteclient");
String cluster = Configuration.getProperty(CacheConstants.DYNOMITE_CLUSTER, "dynomitecluster");
String seeds = Configuration.getProperty(CacheConstants.DYNOMITE_SEEDS, "RedisMaster:192.168.56.221:8102:rack1:dc1:0|RedisSlave01:192.168.56.222:8102:rack2:dc1:0|RedisSlave02:192.168.56.223:8102:rack3:dc1:0");
System.out.println(seeds);
List<DynomiteNodeInfo> nodes = DynomiteSeedsParser.parse(seeds);
ArchiesProperties properties = DynomiteProperties.setProperties(client, seeds, 10, 3000,3,2000);
dynoclient = new DynoJedisClient.Builder()
        .withApplicationName(client)
        .withDynomiteClusterName(cluster)
        .withCPConfig(new ArchaiusConnectionPoolConfiguration(client)
                .withTokenSupplier(properties.getTokenMapSupplier())
                .setMaxConnsPerHost(properties.getMaxConnectionPerHost())
                .setConnectTimeout(properties.getConnectionTimeout()))
        .withHostSupplier(TokenMapSupplierHelper.toHostSupplier(nodes))
        .build();
return dynoclient;

}``

single ton implementation

public static DynoJedisClient build() { DynoJedisClient dynoClient = dynoJedisClient.get(module); if (dynoJedisClient.get(module) == null) { synchronized(DynomiteConnection.class) { if (dynoJedisClient.get(module) == null) { dynoClient = establishingConnection() ; dynoJedisClient.put(module,dynoClient); } } } return dynoClient; }

ghost commented 5 years ago

please give any examples or links for singleton Implementation of dyno client

smukil commented 5 years ago

@chinmayvenkat I don't understand your issue properly. If a node is down, you won't be able to talk to it and you'll fallback to a different replica which you say works correctly. The DynoJedisDemo has implementations of how to use the Dyno client: https://github.com/Netflix/dyno/blob/158f807083ea8e9b09c8089cb07f98e954ad5b23/dyno-demo/src/main/java/com/netflix/dyno/demo/redis/DynoJedisDemo.java