Search in sources :

Example 1 with DynoJedisClient

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 {
    }
}
Also used : DynoJedisClient(com.netflix.dyno.jedis.DynoJedisClient)

Example 2 with DynoJedisClient

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;
}
Also used : DynoJedisClient(com.netflix.dyno.jedis.DynoJedisClient) ArchaiusConnectionPoolConfiguration(com.netflix.dyno.contrib.ArchaiusConnectionPoolConfiguration)

Example 3 with DynoJedisClient

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;
}
Also used : Jedis(redis.clients.jedis.Jedis) ArrayList(java.util.ArrayList) DynoJedisClient(com.netflix.dyno.jedis.DynoJedisClient) DynomiteNodeInfo(com.github.diegopacheco.dynomite.cluster.checker.parser.DynomiteNodeInfo)

Example 4 with DynoJedisClient

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"));
}
Also used : DynoJedisClient(com.netflix.dyno.jedis.DynoJedisClient) ArchaiusConnectionPoolConfiguration(com.netflix.dyno.contrib.ArchaiusConnectionPoolConfiguration) DynomiteNodeInfo(com.github.diegopacheco.dynomite.cluster.checker.parser.DynomiteNodeInfo) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 5 with DynoJedisClient

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;
}
Also used : DynoShardSupplier(com.netflix.dyno.queues.shard.DynoShardSupplier) HostBuilder(com.netflix.dyno.connectionpool.HostBuilder) ArrayList(java.util.ArrayList) DynoJedisClient(com.netflix.dyno.jedis.DynoJedisClient) Host(com.netflix.dyno.connectionpool.Host) RedisQueues(com.netflix.dyno.queues.redis.RedisQueues) HostBuilder(com.netflix.dyno.connectionpool.HostBuilder) ShardSupplier(com.netflix.dyno.queues.ShardSupplier) DynoShardSupplier(com.netflix.dyno.queues.shard.DynoShardSupplier) EurekaHostsSupplier(com.netflix.dyno.contrib.EurekaHostsSupplier)

Aggregations

DynoJedisClient (com.netflix.dyno.jedis.DynoJedisClient)5 DynomiteNodeInfo (com.github.diegopacheco.dynomite.cluster.checker.parser.DynomiteNodeInfo)2 ArchaiusConnectionPoolConfiguration (com.netflix.dyno.contrib.ArchaiusConnectionPoolConfiguration)2 ArrayList (java.util.ArrayList)2 Host (com.netflix.dyno.connectionpool.Host)1 HostBuilder (com.netflix.dyno.connectionpool.HostBuilder)1 EurekaHostsSupplier (com.netflix.dyno.contrib.EurekaHostsSupplier)1 ShardSupplier (com.netflix.dyno.queues.ShardSupplier)1 RedisQueues (com.netflix.dyno.queues.redis.RedisQueues)1 DynoShardSupplier (com.netflix.dyno.queues.shard.DynoShardSupplier)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1 Jedis (redis.clients.jedis.Jedis)1