Skip to content

Commit

Permalink
Update APIs to compile with dyno-1.6.5-rc.3
Browse files Browse the repository at this point in the history
All Host() objects are changed to be created with a HostBuilder.
  • Loading branch information
smukil committed Aug 26, 2019
1 parent 25571ce commit 623358e
Show file tree
Hide file tree
Showing 12 changed files with 157 additions and 18 deletions.
1 change: 1 addition & 0 deletions dyno-queues-redis/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ dependencies {

compile 'com.netflix.dyno:dyno-core:1.6.5-rc.3'
compile 'com.netflix.dyno:dyno-jedis:1.6.5-rc.3'
compile 'com.netflix.dyno:dyno-demo:1.6.5-rc.3'

compile 'com.netflix.archaius:archaius-core:0.7.5'
compile 'com.netflix.servo:servo-core:0.12.17'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.netflix.discovery.EurekaClient;
import com.netflix.discovery.shared.Application;
import com.netflix.dyno.connectionpool.Host;
import com.netflix.dyno.connectionpool.HostBuilder;
import com.netflix.dyno.connectionpool.HostSupplier;
import com.netflix.dyno.jedis.DynoJedisClient;
import com.netflix.dyno.queues.DynoQueue;
Expand Down Expand Up @@ -236,7 +237,12 @@ public Host apply(InstanceInfo info) {
AmazonInfo amazonInfo = (AmazonInfo) info.getDataCenterInfo();
rack = amazonInfo.get(MetaDataKey.availabilityZone);
}
Host host = new Host(info.getHostName(), info.getIPAddr(), rack, status);
//Host host = new Host(info.getHostName(), info.getIPAddr(), rack, status);
Host host = new HostBuilder()
.setHostname(info.getHostName())
.setIpAddress(info.getIPAddr())
.setRack(rack).setStatus(status)
.createHost();
return host;
}
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.netflix.dyno.queues.redis;

import com.netflix.dyno.connectionpool.Host;
import com.netflix.dyno.connectionpool.HostBuilder;
import com.netflix.dyno.connectionpool.HostSupplier;
import com.netflix.dyno.queues.Message;
import com.netflix.dyno.queues.ShardSupplier;
Expand Down Expand Up @@ -68,9 +69,30 @@ public static void setUpBeforeClass() throws Exception {
@Override
public List<Host> getHosts() {
List<Host> hosts = new LinkedList<>();
hosts.add(new Host("host1", 8102, "rack1", Host.Status.Up));
hosts.add(new Host("host2", 8102, "rack2", Host.Status.Up));
hosts.add(new Host("host3", 8102, "rack3", Host.Status.Up));
hosts.add(
new HostBuilder()
.setHostname("localhost")
.setPort(8102)
.setRack("rack1")
.setStatus(Host.Status.Up)
.createHost()
);
hosts.add(
new HostBuilder()
.setHostname("localhost")
.setPort(8102)
.setRack("rack2")
.setStatus(Host.Status.Up)
.createHost()
);
hosts.add(
new HostBuilder()
.setHostname("localhost")
.setPort(8102)
.setRack("rack3")
.setStatus(Host.Status.Up)
.createHost()
);
return hosts;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.netflix.dyno.queues.redis;

import com.netflix.dyno.connectionpool.Host;
import com.netflix.dyno.connectionpool.HostBuilder;
import com.netflix.dyno.connectionpool.HostSupplier;
import com.netflix.dyno.queues.Message;
import com.netflix.dyno.queues.ShardSupplier;
Expand Down Expand Up @@ -58,9 +59,30 @@ public static void setUpBeforeClass() throws Exception {
@Override
public List<Host> getHosts() {
List<Host> hosts = new LinkedList<>();
hosts.add(new Host("localhost", 8102, "us-east-1d", Host.Status.Up));
hosts.add(new Host("localhost", 8102, "us-east-2d", Host.Status.Up));
hosts.add(new Host("localhost", 8102, "us-east-3d", Host.Status.Up));
hosts.add(
new HostBuilder()
.setHostname("localhost")
.setPort(8102)
.setRack("us-east-1d")
.setStatus(Host.Status.Up)
.createHost()
);
hosts.add(
new HostBuilder()
.setHostname("localhost")
.setPort(8102)
.setRack("us-east-2d")
.setStatus(Host.Status.Up)
.createHost()
);
hosts.add(
new HostBuilder()
.setHostname("localhost")
.setPort(8102)
.setRack("us-east-3d")
.setStatus(Host.Status.Up)
.createHost()
);
return hosts;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.Set;
import java.util.stream.Collectors;

import com.netflix.dyno.connectionpool.HostBuilder;
import org.junit.Test;

import com.netflix.dyno.connectionpool.Host;
Expand All @@ -47,9 +48,30 @@ public void test(){
@Override
public List<Host> getHosts() {
List<Host> hosts = new LinkedList<>();
hosts.add(new Host("host1", 8102, "us-east-1a", Status.Up));
hosts.add(new Host("host1", 8102, "us-east-1b", Status.Up));
hosts.add(new Host("host1", 8102, "us-east-1d", Status.Up));
hosts.add(
new HostBuilder()
.setHostname("host1")
.setPort(8102)
.setRack("us-east-1a")
.setStatus(Host.Status.Up)
.createHost()
);
hosts.add(
new HostBuilder()
.setHostname("host1")
.setPort(8102)
.setRack("us-east-1b")
.setStatus(Host.Status.Up)
.createHost()
);
hosts.add(
new HostBuilder()
.setHostname("host1")
.setPort(8102)
.setRack("us-east-1d")
.setStatus(Host.Status.Up)
.createHost()
);

return hosts;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;

import com.netflix.dyno.connectionpool.HostBuilder;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
Expand Down Expand Up @@ -71,7 +72,14 @@ public static void setUpBeforeClass() throws Exception {
@Override
public List<Host> getHosts() {
List<Host> hosts = new LinkedList<>();
hosts.add(new Host("ec2-11-22-33-444.compute-0.amazonaws.com", 8102, "us-east-1d", Status.Up));
hosts.add(
new HostBuilder()
.setHostname("ec2-11-22-33-444.compute-0.amazonaws.com")
.setPort(8102)
.setRack("us-east-1d")
.setStatus(Host.Status.Up)
.createHost()
);
return hosts;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package com.netflix.dyno.queues.redis.benchmark;

import com.netflix.dyno.connectionpool.Host;
import com.netflix.dyno.connectionpool.HostBuilder;
import com.netflix.dyno.connectionpool.HostSupplier;
import com.netflix.dyno.connectionpool.TokenMapSupplier;
import com.netflix.dyno.connectionpool.impl.ConnectionPoolConfigurationImpl;
Expand All @@ -21,7 +22,16 @@ public class BenchmarkTestsDynoJedis extends QueueBenchmark {
public BenchmarkTestsDynoJedis() {

List<Host> hosts = new ArrayList<>(1);
hosts.add(new Host("localhost", "127.0.0.1", 6379, "us-east-1c", "us-east-1", Host.Status.Up));
hosts.add(
new HostBuilder()
.setHostname("localhost")
.setIpAddress("127.0.0.1")
.setPort(6379)
.setRack("us-east-1c")
.setDatacenter("us-east-1")
.setStatus(Host.Status.Up)
.createHost()
);


QueueBuilder qb = new QueueBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.List;

import com.netflix.dyno.connectionpool.Host;
import com.netflix.dyno.connectionpool.HostBuilder;

import com.netflix.dyno.queues.redis.v2.QueueBuilder;
import redis.clients.jedis.JedisPoolConfig;
Expand All @@ -19,7 +20,14 @@ public class BenchmarkTestsJedis extends QueueBenchmark {

public BenchmarkTestsJedis() {
List<Host> hosts = new LinkedList<>();
hosts.add(new Host("localhost", 6379, "us-east-1a"));
hosts.add(
new HostBuilder()
.setHostname("localhost")
.setPort(6379)
.setRack("us-east-1a")
.createHost()
);

QueueBuilder qb = new QueueBuilder();

JedisPoolConfig config = new JedisPoolConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package com.netflix.dyno.queues.redis.benchmark;

import com.netflix.dyno.connectionpool.Host;
import com.netflix.dyno.connectionpool.HostBuilder;
import com.netflix.dyno.connectionpool.HostSupplier;
import com.netflix.dyno.connectionpool.TokenMapSupplier;
import com.netflix.dyno.connectionpool.impl.ConnectionPoolConfigurationImpl;
Expand All @@ -30,7 +31,16 @@ public BenchmarkTestsNoPipelines() {
String queueName = "nopipequeue";

List<Host> hosts = new ArrayList<>(1);
hosts.add(new Host("localhost", "127.0.0.1", 6379, "us-east-1c", "us-east-1", Host.Status.Up));
hosts.add(
new HostBuilder()
.setHostname("localhost")
.setIpAddress("127.0.0.1")
.setPort(6379)
.setRack("us-east-1c")
.setDatacenter("us-east-1")
.setStatus(Host.Status.Up)
.createHost()
);

DynoJedisClient.Builder builder = new DynoJedisClient.Builder();
HostSupplier hs = new HostSupplier() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.netflix.dyno.queues.redis.v2;

import com.netflix.dyno.connectionpool.Host;
import com.netflix.dyno.connectionpool.HostBuilder;
import com.netflix.dyno.connectionpool.HostSupplier;
import com.netflix.dyno.connectionpool.TokenMapSupplier;
import com.netflix.dyno.connectionpool.impl.ConnectionPoolConfigurationImpl;
Expand Down Expand Up @@ -47,7 +48,16 @@ public DynoJedisTests() {
public DynoQueue getQueue(String redisKeyPrefix, String queueName) {

List<Host> hosts = new ArrayList<>(1);
hosts.add(new Host("localhost", "127.0.0.1", 6379, "us-east-1a", "us-east-1", Host.Status.Up));
hosts.add(
new HostBuilder()
.setHostname("localhost")
.setIpAddress("127.0.0.1")
.setPort(6379)
.setRack("us-east-1a")
.setDatacenter("us-east-1")
.setStatus(Host.Status.Up)
.createHost()
);


QueueBuilder qb = new QueueBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.netflix.dyno.queues.redis.v2;

import com.netflix.dyno.connectionpool.Host;
import com.netflix.dyno.connectionpool.HostBuilder;
import com.netflix.dyno.queues.DynoQueue;
import com.netflix.dyno.queues.redis.BaseQueueTests;
import com.netflix.dyno.queues.redis.v2.QueueBuilder;
Expand Down Expand Up @@ -57,7 +58,13 @@ public DynoQueue getQueue(String redisKeyPrefix, String queueName) {
dynoClient.flushAll();

List<Host> hosts = new LinkedList<>();
hosts.add(new Host("localhost", 6379, "us-east-1a"));
hosts.add(
new HostBuilder()
.setHostname("localhost")
.setPort(6379)
.setRack("us-east-1a")
.createHost()
);

QueueBuilder qb = new QueueBuilder();
DynoQueue queue = qb
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.netflix.dyno.queues.redis.v2;

import com.netflix.dyno.connectionpool.Host;
import com.netflix.dyno.connectionpool.HostBuilder;
import com.netflix.dyno.queues.DynoQueue;
import com.netflix.dyno.queues.Message;
import org.junit.Test;
Expand Down Expand Up @@ -59,8 +60,20 @@ public DynoQueue getQueue(String redisKeyPrefix, String queueName) {
dynoClient.flushAll();

List<Host> hosts = new LinkedList<>();
hosts.add(new Host("localhost", 6379, "us-east-1a"));
hosts.add(new Host("localhost", 6379, "us-east-1b"));
hosts.add(
new HostBuilder()
.setHostname("localhost")
.setPort(6379)
.setRack("us-east-1a")
.createHost()
);
hosts.add(
new HostBuilder()
.setHostname("localhost")
.setPort(6379)
.setRack("us-east-2b")
.createHost()
);

QueueBuilder qb = new QueueBuilder();
DynoQueue queue = qb
Expand Down

0 comments on commit 623358e

Please sign in to comment.