use of com.netflix.dyno.connectionpool.Host in project conductor by Netflix.
the class ConfigurationHostSupplierProvider method parseHostsFrom.
private List<Host> parseHostsFrom(String hostConfig) {
List<String> hostConfigs = Arrays.asList(hostConfig.split(";"));
List<Host> hosts = hostConfigs.stream().map(hc -> {
String[] hostConfigValues = hc.split(":");
String host = hostConfigValues[0];
int port = Integer.parseInt(hostConfigValues[1]);
String rack = hostConfigValues[2];
if (hostConfigValues.length >= 4) {
String password = hostConfigValues[3];
return new HostBuilder().setHostname(host).setPort(port).setRack(rack).setStatus(Host.Status.Up).setPassword(password).createHost();
}
return new HostBuilder().setHostname(host).setPort(port).setRack(rack).setStatus(Host.Status.Up).createHost();
}).collect(Collectors.toList());
return hosts;
}
use of com.netflix.dyno.connectionpool.Host 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