Search in sources :

Example 1 with DynomiteNodeInfo

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

the class ListJsonPrinter method print.

public static String print(ExecutionReport rr) {
    List<? extends JsonPrinter> list = rr.getNodesReport();
    StringBuffer sb = new StringBuffer("{\n\r");
    sb.append(" \"timeToRun\": \"" + rr.getTimeToRun() + " seconds" + "\",\n\r");
    sb.append(" \"failoverStatus\": \"" + rr.getFailoverStatus() + "\",\n\r");
    sb.append(" \"replicationCount\": \"" + rr.getReplicationCount() + "\",\n\r");
    sb.append(" \"redisReplicationCount\": \"" + rr.getRedisReplicationCount() + "\",\n\r");
    if (rr.getOfflineNodes() != null && rr.getOfflineNodes().size() >= 1) {
        sb.append(" \"badNodes\": [");
        int i = 0;
        for (DynomiteNodeInfo node : rr.getOfflineNodes()) {
            sb.append("\"" + node.toString() + "\"");
            if ((i + 1) < rr.getOfflineNodes().size())
                sb.append(", ");
            i++;
        }
        sb.append(" ], \n\r");
    } else {
        sb.append(" \"badNodes\": [], \n\r");
    }
    sb.append(" \"nodesReport\":\n\r");
    Object[] array = list.toArray();
    sb.append("[\n\r");
    for (int i = 0; i < array.length; i++) {
        sb.append(((JsonPrinter) array[i]).toPrettyJson() + resolveComma(array, i));
    }
    sb.append("]\n\r");
    sb.append("}\n\r");
    return sb.toString();
}
Also used : DynomiteNodeInfo(com.github.diegopacheco.dynomite.cluster.checker.parser.DynomiteNodeInfo)

Example 2 with DynomiteNodeInfo

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

the class SimpleConnectionTest method toHostSupplier.

private static HostSupplier toHostSupplier(List<DynomiteNodeInfo> nodes) {
    final List<Host> hosts = new ArrayList<Host>();
    for (DynomiteNodeInfo node : nodes) {
        hosts.add(buildHost(node));
    }
    final HostSupplier customHostSupplier = new HostSupplier() {

        @Override
        public Collection<Host> getHosts() {
            return hosts;
        }
    };
    return customHostSupplier;
}
Also used : HostSupplier(com.netflix.dyno.connectionpool.HostSupplier) ArrayList(java.util.ArrayList) Host(com.netflix.dyno.connectionpool.Host) DynomiteNodeInfo(com.github.diegopacheco.dynomite.cluster.checker.parser.DynomiteNodeInfo)

Example 3 with DynomiteNodeInfo

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

the class HostSupplierFactory method build.

public static HostSupplier build(List<DynomiteNodeInfo> nodes) {
    final List<Host> hosts = new ArrayList<Host>();
    for (DynomiteNodeInfo node : nodes) {
        hosts.add(node.toHOST());
    }
    final HostSupplier customHostSupplier = new HostSupplier() {

        @Override
        public Collection<Host> getHosts() {
            return hosts;
        }
    };
    return customHostSupplier;
}
Also used : HostSupplier(com.netflix.dyno.connectionpool.HostSupplier) ArrayList(java.util.ArrayList) Host(com.netflix.dyno.connectionpool.Host) DynomiteNodeInfo(com.github.diegopacheco.dynomite.cluster.checker.parser.DynomiteNodeInfo)

Example 4 with DynomiteNodeInfo

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

the class TokenMapSupplierFactory method build.

/**
 * SAMPLE
 *
 *  *  {
 *      "dc": "eu-west-1",
 *      "hostname": "ec2-52-208-92-24.eu-west-1.compute.amazonaws.com",
 *      "ip": "52.208.92.24",
 *      "rack": "dyno_sandbox--euwest1c",
 *      "token": "1383429731",
 *      "zone": "eu-west-1c"
 *  },
 *
 * @param nodes
 * @return
 */
public static TokenMapSupplier build(List<DynomiteNodeInfo> nodes) {
    StringBuilder jsonSB = new StringBuilder("[");
    int count = 0;
    final Map<String, DynomiteNodeInfo> mapNodes = new HashMap<>();
    for (DynomiteNodeInfo node : nodes) {
        mapNodes.put(node.getServer(), node);
        jsonSB.append(node.toJsonTopology());
        count++;
        if (count < nodes.size())
            jsonSB.append(" , ");
    }
    jsonSB.append(" ]\"");
    final String json = jsonSB.toString();
    TokenMapSupplier testTokenMapSupplier = new AbstractTokenMapSupplier() {

        @Override
        public String getTopologyJsonPayload(String hostname) {
            return json;
        }

        @Override
        public String getTopologyJsonPayload(Set<Host> activeHosts) {
            return json;
        }
    };
    return testTokenMapSupplier;
}
Also used : AbstractTokenMapSupplier(com.netflix.dyno.connectionpool.impl.lb.AbstractTokenMapSupplier) TokenMapSupplier(com.netflix.dyno.connectionpool.TokenMapSupplier) Set(java.util.Set) AbstractTokenMapSupplier(com.netflix.dyno.connectionpool.impl.lb.AbstractTokenMapSupplier) HashMap(java.util.HashMap) DynomiteNodeInfo(com.github.diegopacheco.dynomite.cluster.checker.parser.DynomiteNodeInfo)

Example 5 with DynomiteNodeInfo

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

the class SimpleConnectionTest method toTokenMapSupplier.

private static TokenMapSupplier toTokenMapSupplier(List<DynomiteNodeInfo> nodes) {
    StringBuilder jsonSB = new StringBuilder("[");
    int count = 0;
    for (DynomiteNodeInfo node : nodes) {
        jsonSB.append(" {\"token\":\"" + node.getTokens() + "\",\"hostname\":\"" + node.getServer() + "\",\"zone\":\"" + node.getDc() + "\"} ");
        count++;
        if (count < nodes.size())
            jsonSB.append(" , ");
    }
    jsonSB.append(" ]\"");
    final String json = jsonSB.toString();
    TokenMapSupplier testTokenMapSupplier = new AbstractTokenMapSupplier() {

        @Override
        public String getTopologyJsonPayload(String hostname) {
            return json;
        }

        @Override
        public String getTopologyJsonPayload(Set<Host> activeHosts) {
            return json;
        }
    };
    return testTokenMapSupplier;
}
Also used : AbstractTokenMapSupplier(com.netflix.dyno.connectionpool.impl.lb.AbstractTokenMapSupplier) TokenMapSupplier(com.netflix.dyno.connectionpool.TokenMapSupplier) Set(java.util.Set) AbstractTokenMapSupplier(com.netflix.dyno.connectionpool.impl.lb.AbstractTokenMapSupplier) DynomiteNodeInfo(com.github.diegopacheco.dynomite.cluster.checker.parser.DynomiteNodeInfo)

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