use of com.netflix.dyno.jedis.DynoJedisClient in project dynomite-cluster-checker by diegopacheco.
the class CheckNodesConnectivityTask method connectWholeCluster.
private void connectWholeCluster(ExecutionContext ec) {
try {
DynoJedisClient client = DynoClientCache.get(ec.getRawSeeds());
if (client == null) {
client = DCCConnectionManager.createCluster(DynomiteConfig.CLUSTER_NAME, ec.getOnlineNodes());
DynoClientCache.put(ec.getRawSeeds(), client);
}
String prefix = "awesomeSbrubles_";
client.get(prefix);
ec.setWholeClusterClient(client);
} catch (Throwable t) {
logger.error("Could not Connet on Whole cluster : " + ec.getOnlineNodes() + " EX: " + t);
} finally {
}
}
use of com.netflix.dyno.jedis.DynoJedisClient in project dynomite-cluster-checker by diegopacheco.
the class DCCConnectionManager method createCluster.
public static DynoJedisClient createCluster(String clusterName, final List<DynomiteNodeInfo> nodes) {
ConfigurationManager.getConfigInstance().setProperty("dyno." + clusterName + ".retryPolicy", "RetryNTimes:1:true");
DynoJedisClient dynoClient = new DynoJedisClient.Builder().withApplicationName(clusterName).withDynomiteClusterName(clusterName).withCPConfig(new ArchaiusConnectionPoolConfiguration(clusterName).withTokenSupplier(TokenMapSupplierFactory.build(nodes)).setMaxConnsPerHost(1).setRetryPolicyFactory(new RetryNTimes.RetryFactory(1, true))).withHostSupplier(HostSupplierFactory.build(nodes)).build();
return dynoClient;
}
use of com.netflix.dyno.jedis.DynoJedisClient in project dynomite-cluster-checker by diegopacheco.
the class CheckNodesConnectivityTask method checkNodeConnectivity.
private List<DynomiteNodeInfo> checkNodeConnectivity(ExecutionContext ec) {
List<DynomiteNodeInfo> onlineNodes = new ArrayList<>();
for (DynomiteNodeInfo node : ec.getOriginalNodes()) {
try {
DynoJedisClient client = DynoClientCache.get(node.toSeed());
if (client == null) {
client = DCCConnectionManager.createSingleNodeCluster(DynomiteConfig.CLUSTER_NAME, node);
DynoClientCache.put(node.toSeed(), client);
}
try {
Jedis redisClient = RedisClientCache.get(node.toSeedRedis());
if (redisClient == null) {
redisClient = RedisNodeConnectionManager.createNodeConnection(node);
RedisClientCache.put(node.toSeedRedis(), redisClient);
}
} catch (Exception e) {
logger.error("Could not Connet on Redis Node: " + node + " EX: " + e);
}
String prefix = "awesomeSbrubles";
client.get(prefix);
node.setNodeClient(client);
onlineNodes.add(node);
} catch (Throwable t) {
logger.error("Could not Connet on Node: " + node + " EX: " + t);
} finally {
}
}
ec.setOnlineNodes(onlineNodes);
return onlineNodes;
}
use of com.netflix.dyno.jedis.DynoJedisClient in project dynomite-cluster-checker by diegopacheco.
the class SimpleConnectionTest method testConnection.
@Ignore
@Test
public /**
* Should have the same result(connectivity-like) as:
* ./gradlew execute -Dexec.args="127.0.0.1:8102:rack1:local-dc:100"
*/
void testConnection() {
String clusterName = "local-cluster";
DynomiteNodeInfo node = new DynomiteNodeInfo("127.0.0.1", "8102", "rack1", "local-dc", "100");
DynoJedisClient dynoClient = new DynoJedisClient.Builder().withApplicationName(DynomiteConfig.CLIENT_NAME).withDynomiteClusterName(clusterName).withCPConfig(new ArchaiusConnectionPoolConfiguration(DynomiteConfig.CLIENT_NAME).withTokenSupplier(toTokenMapSupplier(Arrays.asList(node))).setMaxConnsPerHost(1).setConnectTimeout(2000).setPoolShutdownDelay(0).setFailOnStartupIfNoHosts(true).setFailOnStartupIfNoHostsSeconds(2).setMaxTimeoutWhenExhausted(2000).setSocketTimeout(2000).setRetryPolicyFactory(new RetryNTimes.RetryFactory(1))).withHostSupplier(toHostSupplier(Arrays.asList(node))).build();
dynoClient.set("Z", "200");
System.out.println("Z: " + dynoClient.get("Z"));
}
use of com.netflix.dyno.jedis.DynoJedisClient in project conductor by Netflix.
the class RedisQueuesDiscoveryProvider method get.
@Override
public RedisQueues get() {
logger.info("DynoQueueDAO::INIT");
String domain = configuration.getDomain();
String cluster = configuration.getCluster();
final int readConnPort = configuration.getNonQuorumPort();
EurekaHostsSupplier hostSupplier = new EurekaHostsSupplier(cluster, discoveryClient) {
@Override
public List<Host> getHosts() {
List<Host> hosts = super.getHosts();
List<Host> updatedHosts = new ArrayList<>(hosts.size());
hosts.forEach(host -> updatedHosts.add(new HostBuilder().setHostname(host.getHostName()).setIpAddress(host.getIpAddress()).setPort(readConnPort).setRack(host.getRack()).setDatacenter(host.getDatacenter()).setStatus(host.isUp() ? Host.Status.Up : Host.Status.Down).createHost()));
return updatedHosts;
}
};
DynoJedisClient dynoClient = new DynoJedisClient.Builder().withApplicationName(configuration.getAppId()).withDynomiteClusterName(cluster).withDiscoveryClient(discoveryClient).build();
DynoJedisClient dynoClientRead = new DynoJedisClient.Builder().withApplicationName(configuration.getAppId()).withDynomiteClusterName(cluster).withHostSupplier(hostSupplier).withConnectionPoolConsistency("DC_ONE").build();
String region = configuration.getRegion();
String localDC = configuration.getAvailabilityZone();
if (localDC == null) {
throw new Error("Availability zone is not defined. " + "Ensure Configuration.getAvailabilityZone() returns a non-null and non-empty value.");
}
localDC = localDC.replaceAll(region, "");
ShardSupplier ss = new DynoShardSupplier(dynoClient.getConnPool().getConfiguration().getHostSupplier(), region, localDC);
RedisQueues queues = new RedisQueues(dynoClient, dynoClientRead, configuration.getQueuePrefix(), ss, 60_000, 60_000);
logger.info("DynoQueueDAO initialized with prefix " + configuration.getQueuePrefix() + "!");
return queues;
}
Aggregations