Search in sources :

Example 11 with Host

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;
}
Also used : Inject(javax.inject.Inject) Arrays(java.util.Arrays) List(java.util.List) DynomiteConfiguration(com.netflix.conductor.dyno.DynomiteConfiguration) HostBuilder(com.netflix.dyno.connectionpool.HostBuilder) Logger(org.slf4j.Logger) Host(com.netflix.dyno.connectionpool.Host) Provider(javax.inject.Provider) LoggerFactory(org.slf4j.LoggerFactory) HostSupplier(com.netflix.dyno.connectionpool.HostSupplier) Collectors(java.util.stream.Collectors) Host(com.netflix.dyno.connectionpool.Host) HostBuilder(com.netflix.dyno.connectionpool.HostBuilder)

Example 12 with Host

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);
        }
    };
}
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)12 ArrayList (java.util.ArrayList)4 HostSupplier (com.netflix.dyno.connectionpool.HostSupplier)3 ShardSupplier (com.netflix.dyno.queues.ShardSupplier)3 Test (org.junit.Test)3 DynomiteNodeInfo (com.github.diegopacheco.dynomite.cluster.checker.parser.DynomiteNodeInfo)2 DynoQueueDAO (com.netflix.conductor.dao.dynomite.queue.DynoQueueDAO)2 HostBuilder (com.netflix.dyno.connectionpool.HostBuilder)2 HostToken (com.netflix.dyno.connectionpool.impl.lb.HostToken)2 RedisQueues (com.netflix.dyno.queues.redis.RedisQueues)2 HashSet (java.util.HashSet)2 JedisCommands (redis.clients.jedis.commands.JedisCommands)2 TestConfiguration (com.netflix.conductor.config.TestConfiguration)1 WorkflowExecutorModule (com.netflix.conductor.core.execution.WorkflowExecutorModule)1 QueueDAO (com.netflix.conductor.dao.QueueDAO)1 JedisMock (com.netflix.conductor.dao.redis.JedisMock)1 DynomiteConfiguration (com.netflix.conductor.dyno.DynomiteConfiguration)1 JedisMock (com.netflix.conductor.jedis.JedisMock)1 TokenMapSupplier (com.netflix.dyno.connectionpool.TokenMapSupplier)1 EurekaHostsSupplier (com.netflix.dyno.contrib.EurekaHostsSupplier)1