use of com.netflix.dyno.queues.shard.DynoShardSupplier 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;
}
Aggregations