Search in sources :

Example 6 with Host

use of com.netflix.dyno.connectionpool.Host 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;
}
Also used : HostSupplier(com.netflix.dyno.connectionpool.HostSupplier) ArrayList(java.util.ArrayList) Host(com.netflix.dyno.connectionpool.Host) DynomiteNodeInfo(com.github.diegopacheco.dynomite.cluster.checker.parser.DynomiteNodeInfo)

Example 7 with Host

use of com.netflix.dyno.connectionpool.Host 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 8 with Host

use of com.netflix.dyno.connectionpool.Host in project conductor by Netflix.

the class RedisQueuesDiscoveryProvider method get.

@Override
public RedisQueues get() {
    logger.info("DynoQueueDAO::INIT");
    String domain = configuration.getDomain();
    String cluster = configuration.getCluster();
    final int readConnPort = configuration.getNonQuorumPort();
    EurekaHostsSupplier hostSupplier = new EurekaHostsSupplier(cluster, discoveryClient) {

        @Override
        public List<Host> getHosts() {
            List<Host> hosts = super.getHosts();
            List<Host> updatedHosts = new ArrayList<>(hosts.size());
            hosts.forEach(host -> updatedHosts.add(new HostBuilder().setHostname(host.getHostName()).setIpAddress(host.getIpAddress()).setPort(readConnPort).setRack(host.getRack()).setDatacenter(host.getDatacenter()).setStatus(host.isUp() ? Host.Status.Up : Host.Status.Down).createHost()));
            return updatedHosts;
        }
    };
    DynoJedisClient dynoClient = new DynoJedisClient.Builder().withApplicationName(configuration.getAppId()).withDynomiteClusterName(cluster).withDiscoveryClient(discoveryClient).build();
    DynoJedisClient dynoClientRead = new DynoJedisClient.Builder().withApplicationName(configuration.getAppId()).withDynomiteClusterName(cluster).withHostSupplier(hostSupplier).withConnectionPoolConsistency("DC_ONE").build();
    String region = configuration.getRegion();
    String localDC = configuration.getAvailabilityZone();
    if (localDC == null) {
        throw new Error("Availability zone is not defined.  " + "Ensure Configuration.getAvailabilityZone() returns a non-null and non-empty value.");
    }
    localDC = localDC.replaceAll(region, "");
    ShardSupplier ss = new DynoShardSupplier(dynoClient.getConnPool().getConfiguration().getHostSupplier(), region, localDC);
    RedisQueues queues = new RedisQueues(dynoClient, dynoClientRead, configuration.getQueuePrefix(), ss, 60_000, 60_000);
    logger.info("DynoQueueDAO initialized with prefix " + configuration.getQueuePrefix() + "!");
    return queues;
}
Also used : DynoShardSupplier(com.netflix.dyno.queues.shard.DynoShardSupplier) HostBuilder(com.netflix.dyno.connectionpool.HostBuilder) ArrayList(java.util.ArrayList) DynoJedisClient(com.netflix.dyno.jedis.DynoJedisClient) Host(com.netflix.dyno.connectionpool.Host) RedisQueues(com.netflix.dyno.queues.redis.RedisQueues) HostBuilder(com.netflix.dyno.connectionpool.HostBuilder) ShardSupplier(com.netflix.dyno.queues.ShardSupplier) DynoShardSupplier(com.netflix.dyno.queues.shard.DynoShardSupplier) EurekaHostsSupplier(com.netflix.dyno.contrib.EurekaHostsSupplier)

Example 9 with Host

use of com.netflix.dyno.connectionpool.Host in project conductor by Netflix.

the class ConfigurationHostSupplierProviderTest method getHost.

@Test
public void getHost() {
    configuration.setProperty("workflow.dynomite.cluster.hosts", "dyno1:8102:us-east-1c");
    List<Host> hosts = provider.get().getHosts();
    Assert.assertEquals(1, hosts.size());
    Host firstHost = hosts.get(0);
    Assert.assertEquals("dyno1", firstHost.getHostName());
    Assert.assertEquals(8102, firstHost.getPort());
    Assert.assertEquals("us-east-1c", firstHost.getRack());
    Assert.assertTrue(firstHost.isUp());
}
Also used : Host(com.netflix.dyno.connectionpool.Host) Test(org.junit.Test)

Example 10 with Host

use of com.netflix.dyno.connectionpool.Host in project conductor by Netflix.

the class ConfigurationHostSupplierProviderTest method getMultipleHosts.

@Test
public void getMultipleHosts() {
    configuration.setProperty("workflow.dynomite.cluster.hosts", "dyno1:8102:us-east-1c;dyno2:8103:us-east-1c");
    List<Host> hosts = provider.get().getHosts();
    Assert.assertEquals(2, hosts.size());
    Host firstHost = hosts.get(0);
    Assert.assertEquals("dyno1", firstHost.getHostName());
    Assert.assertEquals(8102, firstHost.getPort());
    Assert.assertEquals("us-east-1c", firstHost.getRack());
    Assert.assertTrue(firstHost.isUp());
    Host secondHost = hosts.get(1);
    Assert.assertEquals("dyno2", secondHost.getHostName());
    Assert.assertEquals(8103, secondHost.getPort());
    Assert.assertEquals("us-east-1c", secondHost.getRack());
    Assert.assertTrue(secondHost.isUp());
}
Also used : Host(com.netflix.dyno.connectionpool.Host) Test(org.junit.Test)

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