summaryrefslogtreecommitdiff
path: root/zookeeper-server/src/test/java/org/apache/zookeeper/test/StaticHostProviderTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'zookeeper-server/src/test/java/org/apache/zookeeper/test/StaticHostProviderTest.java')
-rw-r--r--zookeeper-server/src/test/java/org/apache/zookeeper/test/StaticHostProviderTest.java34
1 files changed, 17 insertions, 17 deletions
diff --git a/zookeeper-server/src/test/java/org/apache/zookeeper/test/StaticHostProviderTest.java b/zookeeper-server/src/test/java/org/apache/zookeeper/test/StaticHostProviderTest.java
index 905b6cd78..c782e9820 100644
--- a/zookeeper-server/src/test/java/org/apache/zookeeper/test/StaticHostProviderTest.java
+++ b/zookeeper-server/src/test/java/org/apache/zookeeper/test/StaticHostProviderTest.java
@@ -169,7 +169,7 @@ public class StaticHostProviderTest extends ZKTestCase {
hostProvider.onConnected();
// Number of machines increased, my server is not in the new cluster
- newList = new ArrayList<InetSocketAddress>(3);
+ newList = new ArrayList<>(3);
for (byte i = 4; i > 1; i--) { // 10.10.10.4:1238, 10.10.10.3:1237, 10.10.10.2:1236
newList.add(new InetSocketAddress(InetAddress.getByAddress(new byte[]{10, 10, 10, i}), 1234 + i));
}
@@ -203,20 +203,20 @@ public class StaticHostProviderTest extends ZKTestCase {
public void testUpdateMigrationGoesRound() throws UnknownHostException {
HostProvider hostProvider = getHostProvider((byte) 4);
// old list (just the ports): 1238, 1237, 1236, 1235
- Collection<InetSocketAddress> newList = new ArrayList<InetSocketAddress>(10);
+ Collection<InetSocketAddress> newList = new ArrayList<>(10);
for (byte i = 12; i > 2; i--) { // 1246, 1245, 1244, 1243, 1242, 1241,
// 1240, 1239, 1238, 1237
newList.add(new InetSocketAddress(InetAddress.getByAddress(new byte[]{10, 10, 10, i}), 1234 + i));
}
// servers from the old list that appear in the new list
- Collection<InetSocketAddress> oldStaying = new ArrayList<InetSocketAddress>(2);
+ Collection<InetSocketAddress> oldStaying = new ArrayList<>(2);
for (byte i = 4; i > 2; i--) { // 1238, 1237
oldStaying.add(new InetSocketAddress(InetAddress.getByAddress(new byte[]{10, 10, 10, i}), 1234 + i));
}
// servers in the new list that are not in the old list
- Collection<InetSocketAddress> newComing = new ArrayList<InetSocketAddress>(10);
+ Collection<InetSocketAddress> newComing = new ArrayList<>(10);
for (byte i = 12; i > 4; i--) {// 1246, 1245, 1244, 1243, 1242, 1241, 1240, 1139
newComing.add(new InetSocketAddress(InetAddress.getByAddress(new byte[]{10, 10, 10, i}), 1234 + i));
}
@@ -232,7 +232,7 @@ public class StaticHostProviderTest extends ZKTestCase {
// This means reconfigMode = true, and nextHostInReconfigMode will be
// called from next
// Since pNew = 1 we should first try the new servers
- ArrayList<InetSocketAddress> seen = new ArrayList<InetSocketAddress>();
+ ArrayList<InetSocketAddress> seen = new ArrayList<>();
for (int i = 0; i < newComing.size(); i++) {
InetSocketAddress addr = hostProvider.next(0);
assertTrue(newComing.contains(addr));
@@ -325,7 +325,7 @@ public class StaticHostProviderTest extends ZKTestCase {
// remove host number 0 (the first one in the current list)
// and add back hosts 6, 7 and 8
- newList = new ArrayList<InetSocketAddress>(8);
+ newList = new ArrayList<>(8);
for (byte i = 9; i > 1; i--) {
newList.add(new InetSocketAddress(InetAddress.getByAddress(new byte[]{10, 10, 10, i}), 1234 + i));
}
@@ -486,7 +486,7 @@ public class StaticHostProviderTest extends ZKTestCase {
}
private Collection<InetSocketAddress> getServerAddresses(byte size) {
- ArrayList<InetSocketAddress> list = new ArrayList<InetSocketAddress>(size);
+ ArrayList<InetSocketAddress> list = new ArrayList<>(size);
while (size > 0) {
try {
list.add(new InetSocketAddress(InetAddress.getByAddress(new byte[]{10, 10, 10, size}), 1234 + size));
@@ -699,7 +699,7 @@ public class StaticHostProviderTest extends ZKTestCase {
public void testReResolvingSingle() throws UnknownHostException {
// Arrange
byte size = 1;
- ArrayList<InetSocketAddress> list = new ArrayList<InetSocketAddress>(size);
+ ArrayList<InetSocketAddress> list = new ArrayList<>(size);
// Test a hostname that resolves to a single address
list.add(InetSocketAddress.createUnresolved("issues.apache.org", 1234));
@@ -733,7 +733,7 @@ public class StaticHostProviderTest extends ZKTestCase {
public void testReResolvingMultiple() throws UnknownHostException {
// Arrange
byte size = 1;
- ArrayList<InetSocketAddress> list = new ArrayList<InetSocketAddress>(size);
+ ArrayList<InetSocketAddress> list = new ArrayList<>(size);
// Test a hostname that resolves to multiple addresses
list.add(InetSocketAddress.createUnresolved("www.apache.org", 1234));
@@ -748,7 +748,7 @@ public class StaticHostProviderTest extends ZKTestCase {
when(apacheOrg2.toString()).thenReturn("www.apache.org");
when(apacheOrg2.getHostName()).thenReturn("www.apache.org");
- final List<InetAddress> resolvedAddresses = new ArrayList<InetAddress>();
+ final List<InetAddress> resolvedAddresses = new ArrayList<>();
resolvedAddresses.add(apacheOrg1);
resolvedAddresses.add(apacheOrg2);
StaticHostProvider.Resolver resolver = new StaticHostProvider.Resolver() {
@@ -775,10 +775,10 @@ public class StaticHostProviderTest extends ZKTestCase {
@Test
public void testReResolveMultipleOneFailing() throws UnknownHostException {
// Arrange
- final List<InetSocketAddress> list = new ArrayList<InetSocketAddress>();
+ final List<InetSocketAddress> list = new ArrayList<>();
list.add(InetSocketAddress.createUnresolved("www.apache.org", 1234));
- final List<String> ipList = new ArrayList<String>();
- final List<InetAddress> resolvedAddresses = new ArrayList<InetAddress>();
+ final List<String> ipList = new ArrayList<>();
+ final List<InetAddress> resolvedAddresses = new ArrayList<>();
for (int i = 0; i < 3; i++) {
ipList.add(String.format("192.168.1.%d", i + 1));
final InetAddress apacheOrg = mock(InetAddress.class);
@@ -821,10 +821,10 @@ public class StaticHostProviderTest extends ZKTestCase {
@Test
public void testEmptyResolution() throws UnknownHostException {
// Arrange
- final List<InetSocketAddress> list = new ArrayList<InetSocketAddress>();
+ final List<InetSocketAddress> list = new ArrayList<>();
list.add(InetSocketAddress.createUnresolved("www.apache.org", 1234));
list.add(InetSocketAddress.createUnresolved("www.google.com", 1234));
- final List<InetAddress> resolvedAddresses = new ArrayList<InetAddress>();
+ final List<InetAddress> resolvedAddresses = new ArrayList<>();
final InetAddress apacheOrg1 = mock(InetAddress.class);
when(apacheOrg1.getHostAddress()).thenReturn("192.168.1.1");
@@ -865,7 +865,7 @@ public class StaticHostProviderTest extends ZKTestCase {
@Test
public void testReResolvingLocalhost() {
byte size = 2;
- ArrayList<InetSocketAddress> list = new ArrayList<InetSocketAddress>(size);
+ ArrayList<InetSocketAddress> list = new ArrayList<>(size);
// Test a hostname that resolves to multiple addresses
list.add(InetSocketAddress.createUnresolved("localhost", 1234));
@@ -884,7 +884,7 @@ public class StaticHostProviderTest extends ZKTestCase {
}
private Collection<InetSocketAddress> getUnresolvedServerAddresses(byte size) {
- ArrayList<InetSocketAddress> list = new ArrayList<InetSocketAddress>(size);
+ ArrayList<InetSocketAddress> list = new ArrayList<>(size);
while (size > 0) {
list.add(InetSocketAddress.createUnresolved("10.10.10." + size, 1234 + size));
--size;