From 623358ed420faed7fc0ed9aaa5bb10f9eb1da2ec Mon Sep 17 00:00:00 2001 From: Sailesh Mukil Date: Mon, 26 Aug 2019 16:52:02 -0700 Subject: [PATCH] Update APIs to compile with dyno-1.6.5-rc.3 All Host() objects are changed to be created with a HostBuilder. --- dyno-queues-redis/build.gradle | 1 + .../dyno/queues/redis/v2/QueueBuilder.java | 8 +++++- .../redis/CustomShardingStrategyTest.java | 28 +++++++++++++++++-- .../redis/DefaultShardingStrategyTest.java | 28 +++++++++++++++++-- .../queues/redis/DynoShardSupplierTest.java | 28 +++++++++++++++++-- .../dyno/queues/redis/RedisDynoQueueTest.java | 10 ++++++- .../benchmark/BenchmarkTestsDynoJedis.java | 12 +++++++- .../redis/benchmark/BenchmarkTestsJedis.java | 10 ++++++- .../benchmark/BenchmarkTestsNoPipelines.java | 12 +++++++- .../dyno/queues/redis/v2/DynoJedisTests.java | 12 +++++++- .../dyno/queues/redis/v2/JedisTests.java | 9 +++++- .../dyno/queues/redis/v2/MultiQueueTests.java | 17 +++++++++-- 12 files changed, 157 insertions(+), 18 deletions(-) diff --git a/dyno-queues-redis/build.gradle b/dyno-queues-redis/build.gradle index 5fe2651..d7daf51 100644 --- a/dyno-queues-redis/build.gradle +++ b/dyno-queues-redis/build.gradle @@ -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' diff --git a/dyno-queues-redis/src/main/java/com/netflix/dyno/queues/redis/v2/QueueBuilder.java b/dyno-queues-redis/src/main/java/com/netflix/dyno/queues/redis/v2/QueueBuilder.java index 0195312..a38d8be 100644 --- a/dyno-queues-redis/src/main/java/com/netflix/dyno/queues/redis/v2/QueueBuilder.java +++ b/dyno-queues-redis/src/main/java/com/netflix/dyno/queues/redis/v2/QueueBuilder.java @@ -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; @@ -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; } })); diff --git a/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/CustomShardingStrategyTest.java b/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/CustomShardingStrategyTest.java index 44f1cbc..ce15585 100644 --- a/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/CustomShardingStrategyTest.java +++ b/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/CustomShardingStrategyTest.java @@ -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; @@ -68,9 +69,30 @@ public static void setUpBeforeClass() throws Exception { @Override public List getHosts() { List 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; } }; diff --git a/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/DefaultShardingStrategyTest.java b/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/DefaultShardingStrategyTest.java index d0f42bc..3bb6ed0 100644 --- a/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/DefaultShardingStrategyTest.java +++ b/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/DefaultShardingStrategyTest.java @@ -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; @@ -58,9 +59,30 @@ public static void setUpBeforeClass() throws Exception { @Override public List getHosts() { List 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; } }; diff --git a/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/DynoShardSupplierTest.java b/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/DynoShardSupplierTest.java index d4827cd..c93d9c5 100644 --- a/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/DynoShardSupplierTest.java +++ b/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/DynoShardSupplierTest.java @@ -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; @@ -47,9 +48,30 @@ public void test(){ @Override public List getHosts() { List 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; } diff --git a/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/RedisDynoQueueTest.java b/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/RedisDynoQueueTest.java index 112a26a..82907d2 100644 --- a/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/RedisDynoQueueTest.java +++ b/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/RedisDynoQueueTest.java @@ -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; @@ -71,7 +72,14 @@ public static void setUpBeforeClass() throws Exception { @Override public List getHosts() { List 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; } }; diff --git a/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/benchmark/BenchmarkTestsDynoJedis.java b/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/benchmark/BenchmarkTestsDynoJedis.java index c532bfe..a0cbdf8 100644 --- a/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/benchmark/BenchmarkTestsDynoJedis.java +++ b/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/benchmark/BenchmarkTestsDynoJedis.java @@ -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; @@ -21,7 +22,16 @@ public class BenchmarkTestsDynoJedis extends QueueBenchmark { public BenchmarkTestsDynoJedis() { List 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(); diff --git a/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/benchmark/BenchmarkTestsJedis.java b/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/benchmark/BenchmarkTestsJedis.java index 8b7258e..73b937b 100644 --- a/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/benchmark/BenchmarkTestsJedis.java +++ b/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/benchmark/BenchmarkTestsJedis.java @@ -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; @@ -19,7 +20,14 @@ public class BenchmarkTestsJedis extends QueueBenchmark { public BenchmarkTestsJedis() { List 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(); diff --git a/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/benchmark/BenchmarkTestsNoPipelines.java b/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/benchmark/BenchmarkTestsNoPipelines.java index c3147b7..841f107 100644 --- a/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/benchmark/BenchmarkTestsNoPipelines.java +++ b/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/benchmark/BenchmarkTestsNoPipelines.java @@ -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; @@ -30,7 +31,16 @@ public BenchmarkTestsNoPipelines() { String queueName = "nopipequeue"; List 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() { diff --git a/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/v2/DynoJedisTests.java b/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/v2/DynoJedisTests.java index efbc5f0..c22d17e 100644 --- a/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/v2/DynoJedisTests.java +++ b/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/v2/DynoJedisTests.java @@ -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; @@ -47,7 +48,16 @@ public DynoJedisTests() { public DynoQueue getQueue(String redisKeyPrefix, String queueName) { List 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(); diff --git a/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/v2/JedisTests.java b/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/v2/JedisTests.java index 085033a..1dd924a 100644 --- a/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/v2/JedisTests.java +++ b/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/v2/JedisTests.java @@ -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; @@ -57,7 +58,13 @@ public DynoQueue getQueue(String redisKeyPrefix, String queueName) { dynoClient.flushAll(); List 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 diff --git a/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/v2/MultiQueueTests.java b/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/v2/MultiQueueTests.java index 58653fa..14aa31e 100644 --- a/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/v2/MultiQueueTests.java +++ b/dyno-queues-redis/src/test/java/com/netflix/dyno/queues/redis/v2/MultiQueueTests.java @@ -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; @@ -59,8 +60,20 @@ public DynoQueue getQueue(String redisKeyPrefix, String queueName) { dynoClient.flushAll(); List 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