Search in sources :

Example 1 with RedisQueues

use of com.netflix.dyno.queues.redis.RedisQueues in project conductor by Netflix.

the class MockQueueDAOModule method configureQueueDAO.

@Override
public void configureQueueDAO() {
    DetachedMockFactory detachedMockFactory = new DetachedMockFactory();
    JedisCommands jedisMock = new JedisMock();
    ShardSupplier shardSupplier = new ShardSupplier() {

        @Override
        public Set<String> getQueueShards() {
            return new HashSet<>(Collections.singletonList("a"));
        }

        @Override
        public String getCurrentShard() {
            return "a";
        }

        @Override
        public String getShardForHost(Host host) {
            return "a";
        }
    };
    RedisQueues redisQueues = new RedisQueues(jedisMock, jedisMock, "mockedQueues", shardSupplier, 60000, 120000);
    DynoQueueDAO dynoQueueDAO = new DynoQueueDAO(redisQueues);
    bind(QueueDAO.class).toInstance(detachedMockFactory.Spy(dynoQueueDAO));
    install(new WorkflowExecutorModule());
}
Also used : DynoQueueDAO(com.netflix.conductor.dao.dynomite.queue.DynoQueueDAO) QueueDAO(com.netflix.conductor.dao.QueueDAO) JedisCommands(redis.clients.jedis.commands.JedisCommands) DynoQueueDAO(com.netflix.conductor.dao.dynomite.queue.DynoQueueDAO) WorkflowExecutorModule(com.netflix.conductor.core.execution.WorkflowExecutorModule) JedisMock(com.netflix.conductor.jedis.JedisMock) Host(com.netflix.dyno.connectionpool.Host) RedisQueues(com.netflix.dyno.queues.redis.RedisQueues) DetachedMockFactory(spock.mock.DetachedMockFactory) ShardSupplier(com.netflix.dyno.queues.ShardSupplier) HashSet(java.util.HashSet)

Example 2 with RedisQueues

use of com.netflix.dyno.queues.redis.RedisQueues in project conductor by Netflix.

the class DynoQueueDAO method init.

@Deprecated
private void init() {
    String rootNamespace = config.getProperty("workflow.namespace.queue.prefix", null);
    String stack = config.getStack();
    String prefix = rootNamespace + "." + stack;
    if (domain != null) {
        prefix = prefix + "." + domain;
    }
    queues = new RedisQueues(dynoClient, dynoClientRead, prefix, ss, 60_000, 60_000);
    logger.info("DynoQueueDAO initialized with prefix " + prefix + "!");
}
Also used : RedisQueues(com.netflix.dyno.queues.redis.RedisQueues)

Example 3 with RedisQueues

use of com.netflix.dyno.queues.redis.RedisQueues in project conductor by Netflix.

the class RedisQueuesProvider method get.

@Override
public RedisQueues get() {
    RedisQueues queues = new RedisQueues(dynoClient, dynoClientRead, configuration.getQueuePrefix(), shardSupplier, 60_000, 60_000, shardingStrategy);
    logger.info("DynoQueueDAO initialized with prefix " + configuration.getQueuePrefix() + "!");
    return queues;
}
Also used : RedisQueues(com.netflix.dyno.queues.redis.RedisQueues)

Example 4 with RedisQueues

use of com.netflix.dyno.queues.redis.RedisQueues 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)

Aggregations

RedisQueues (com.netflix.dyno.queues.redis.RedisQueues)4 Host (com.netflix.dyno.connectionpool.Host)2 ShardSupplier (com.netflix.dyno.queues.ShardSupplier)2 WorkflowExecutorModule (com.netflix.conductor.core.execution.WorkflowExecutorModule)1 QueueDAO (com.netflix.conductor.dao.QueueDAO)1 DynoQueueDAO (com.netflix.conductor.dao.dynomite.queue.DynoQueueDAO)1 JedisMock (com.netflix.conductor.jedis.JedisMock)1 HostBuilder (com.netflix.dyno.connectionpool.HostBuilder)1 EurekaHostsSupplier (com.netflix.dyno.contrib.EurekaHostsSupplier)1 DynoJedisClient (com.netflix.dyno.jedis.DynoJedisClient)1 DynoShardSupplier (com.netflix.dyno.queues.shard.DynoShardSupplier)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 JedisCommands (redis.clients.jedis.commands.JedisCommands)1 DetachedMockFactory (spock.mock.DetachedMockFactory)1