Search in sources :

Example 1 with HostToken

use of com.netflix.dyno.connectionpool.impl.lb.HostToken in project kork by spinnaker.

the class DynomiteDriverProperties method getDynoHostTokens.

public List<HostToken> getDynoHostTokens() {
    List<HostToken> tokens = new ArrayList<>();
    List<Host> dynoHosts = getDynoHosts();
    for (int i = 0; i < dynoHosts.size(); i++) {
        tokens.add(new HostToken(hosts.get(i).token, dynoHosts.get(i)));
    }
    return tokens;
}
Also used : HostToken(com.netflix.dyno.connectionpool.impl.lb.HostToken) ArrayList(java.util.ArrayList) Host(com.netflix.dyno.connectionpool.Host)

Example 2 with HostToken

use of com.netflix.dyno.connectionpool.impl.lb.HostToken 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);
        }
    };
}
Also used : TokenMapSupplier(com.netflix.dyno.connectionpool.TokenMapSupplier) Set(java.util.Set) HostToken(com.netflix.dyno.connectionpool.impl.lb.HostToken) Host(com.netflix.dyno.connectionpool.Host)

Aggregations

Host (com.netflix.dyno.connectionpool.Host)2 HostToken (com.netflix.dyno.connectionpool.impl.lb.HostToken)2 TokenMapSupplier (com.netflix.dyno.connectionpool.TokenMapSupplier)1 ArrayList (java.util.ArrayList)1 Set (java.util.Set)1