use of com.netflix.dyno.connectionpool.TokenMapSupplier 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.netflix.dyno.connectionpool.TokenMapSupplier 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;
}
use of com.netflix.dyno.connectionpool.TokenMapSupplier in project conductor by Netflix.
the class TokenMapSupplierProvider method get.
@Override
public TokenMapSupplier get() {
return new TokenMapSupplier() {
@Override
public List<HostToken> getTokens(Set<Host> activeHosts) {
long i = activeHosts.size();
for (Host host : activeHosts) {
HostToken hostToken = new HostToken(i, host);
hostTokens.add(hostToken);
i--;
}
return hostTokens;
}
@Override
public HostToken getTokenForHost(Host host, Set<Host> activeHosts) {
return CollectionUtils.find(hostTokens, token -> token.getHost().compareTo(host) == 0);
}
};
}
Aggregations