Search in sources :

Example 6 with DynomiteNodeInfo

use of com.github.diegopacheco.dynomite.cluster.checker.parser.DynomiteNodeInfo 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 7 with DynomiteNodeInfo

use of com.github.diegopacheco.dynomite.cluster.checker.parser.DynomiteNodeInfo in project dynomite-cluster-checker by diegopacheco.

the class CheckDataReplicationTask method getKeys.

private void getKeys(ExecutionContext ec) {
    Chronometer stopWatch = new Chronometer();
    stopWatch.start();
    NodeCheckerResponse nodeReport = new NodeCheckerResponse();
    int count = 0;
    for (DynomiteNodeInfo node : ec.getOnlineNodes()) {
        try {
            nodeReport.setSeeds(node.toString());
            nodeReport.setServer(node.getServer());
            String result = node.getNodeClient().get(ec.getReplicationKey());
            if (result != null && (!"".equals(result))) {
                count++;
                nodeReport.setConsistency(true);
            } else {
                nodeReport.setConsistency(false);
            }
        } catch (Throwable t) {
            logger.error("Could not get KEY on node : " + node + " - EX: " + t);
            nodeReport.setGetError(t.getMessage());
        } finally {
            stopWatch.stop();
            nodeReport.setGetTime(stopWatch.getDiffAsString());
            ec.getExecutionReport().getNodesReport().add(nodeReport);
            nodeReport = new NodeCheckerResponse();
        }
    }
    ec.getExecutionReport().setReplicationCount(count);
}
Also used : Chronometer(com.github.diegopacheco.dynomite.cluster.checker.util.Chronometer) NodeCheckerResponse(com.github.diegopacheco.dynomite.cluster.checker.context.NodeCheckerResponse) DynomiteNodeInfo(com.github.diegopacheco.dynomite.cluster.checker.parser.DynomiteNodeInfo)

Example 8 with DynomiteNodeInfo

use of com.github.diegopacheco.dynomite.cluster.checker.parser.DynomiteNodeInfo in project dynomite-cluster-checker by diegopacheco.

the class RedisReplicationTask method execute.

@Override
public void execute(ExecutionContext ec) {
    int replicationCount = 0;
    List<DynomiteNodeInfo> nodes = ec.getOnlineNodes();
    for (DynomiteNodeInfo node : nodes) {
        Jedis redisCliet = RedisClientCache.get(node.toSeedRedis());
        if (redisCliet != null) {
            String result = "";
            try {
                result = redisCliet.get(ec.getReplicationKey());
            } catch (Exception e) {
                logger.error("Error to read " + ec.getReplicationKey() + " from Redis - EX: " + e);
            }
            if (result != null && (!"".equals(result)) && ec.getReplicationValue().equals(result)) {
                replicationCount++;
                List<NodeCheckerResponse> onlineDynNodes = ec.getExecutionReport().getNodesReport();
                List<NodeCheckerResponse> resultFilter = onlineDynNodes.stream().filter(n -> node.toSeedRedis().equals(n.getSeeds())).collect(Collectors.toList());
                if (resultFilter != null && resultFilter.size() == 1) {
                    resultFilter.get(0).setConsistencyRedis(true);
                }
            }
        }
    }
    ec.getExecutionReport().setRedisReplicationCount(replicationCount);
}
Also used : ExecutionContext(com.github.diegopacheco.dynomite.cluster.checker.context.ExecutionContext) Logger(org.apache.log4j.Logger) List(java.util.List) RedisClientCache(com.github.diegopacheco.dynomite.cluster.checker.cluster.cache.RedisClientCache) Jedis(redis.clients.jedis.Jedis) Collectors(java.util.stream.Collectors) NodeCheckerResponse(com.github.diegopacheco.dynomite.cluster.checker.context.NodeCheckerResponse) DynomiteNodeInfo(com.github.diegopacheco.dynomite.cluster.checker.parser.DynomiteNodeInfo) Jedis(redis.clients.jedis.Jedis) NodeCheckerResponse(com.github.diegopacheco.dynomite.cluster.checker.context.NodeCheckerResponse) DynomiteNodeInfo(com.github.diegopacheco.dynomite.cluster.checker.parser.DynomiteNodeInfo)

Example 9 with DynomiteNodeInfo

use of com.github.diegopacheco.dynomite.cluster.checker.parser.DynomiteNodeInfo 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)

Aggregations

DynomiteNodeInfo (com.github.diegopacheco.dynomite.cluster.checker.parser.DynomiteNodeInfo)9 ArrayList (java.util.ArrayList)3 NodeCheckerResponse (com.github.diegopacheco.dynomite.cluster.checker.context.NodeCheckerResponse)2 Host (com.netflix.dyno.connectionpool.Host)2 HostSupplier (com.netflix.dyno.connectionpool.HostSupplier)2 TokenMapSupplier (com.netflix.dyno.connectionpool.TokenMapSupplier)2 AbstractTokenMapSupplier (com.netflix.dyno.connectionpool.impl.lb.AbstractTokenMapSupplier)2 DynoJedisClient (com.netflix.dyno.jedis.DynoJedisClient)2 Set (java.util.Set)2 Jedis (redis.clients.jedis.Jedis)2 RedisClientCache (com.github.diegopacheco.dynomite.cluster.checker.cluster.cache.RedisClientCache)1 ExecutionContext (com.github.diegopacheco.dynomite.cluster.checker.context.ExecutionContext)1 Chronometer (com.github.diegopacheco.dynomite.cluster.checker.util.Chronometer)1 ArchaiusConnectionPoolConfiguration (com.netflix.dyno.contrib.ArchaiusConnectionPoolConfiguration)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Logger (org.apache.log4j.Logger)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1