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();
}
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;
}
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;
}
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;
}
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;
}
Aggregations