From f12cfa99fac06342f3c067df445f69cf05b1c810 Mon Sep 17 00:00:00 2001 From: Bingkun Guo Date: Mon, 21 Dec 2015 11:07:43 -0600 Subject: [PATCH 01/24] another effort on fixing the transient error for Broker/CoordinatorServerViewTest happend on Travis build --- .../io/druid/curator/CuratorTestBase.java | 56 +++++++++++-------- 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/server/src/test/java/io/druid/curator/CuratorTestBase.java b/server/src/test/java/io/druid/curator/CuratorTestBase.java index a8aab93f650..11246ffeeaa 100644 --- a/server/src/test/java/io/druid/curator/CuratorTestBase.java +++ b/server/src/test/java/io/druid/curator/CuratorTestBase.java @@ -20,6 +20,7 @@ package io.druid.curator; import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.api.client.repackaged.com.google.common.base.Throwables; import com.metamx.common.guava.CloseQuietly; import io.druid.client.DruidServer; import io.druid.server.initialization.ZkPathsConfig; @@ -29,6 +30,7 @@ import org.apache.curator.retry.RetryOneTime; import org.apache.curator.test.TestingServer; import org.apache.curator.test.Timing; import org.apache.curator.utils.ZKPaths; +import org.apache.zookeeper.KeeperException; /** */ @@ -54,35 +56,45 @@ public class CuratorTestBase } protected void setupZNodeForServer(DruidServer server, ZkPathsConfig zkPathsConfig, ObjectMapper jsonMapper) - throws Exception { final String announcementsPath = zkPathsConfig.getAnnouncementsPath(); final String inventoryPath = zkPathsConfig.getLiveSegmentsPath(); - final String zNodePathAnnounce = ZKPaths.makePath(announcementsPath, server.getHost()); - final String zNodePathSegment = ZKPaths.makePath(inventoryPath, server.getHost()); - - /* - * Explicitly check whether the zNodes we are about to create exist or not, - * if exist, delete them to make sure we have a clean state on zookeeper. - * Address issue: https://github.com/druid-io/druid/issues/1512 - */ - if (curator.checkExists().forPath(zNodePathAnnounce) != null) { - curator.delete().guaranteed().forPath(zNodePathAnnounce); + try { + curator.create() + .creatingParentsIfNeeded() + .forPath( + ZKPaths.makePath(announcementsPath, server.getHost()), + jsonMapper.writeValueAsBytes(server.getMetadata()) + ); + curator.create() + .creatingParentsIfNeeded() + .forPath(ZKPaths.makePath(inventoryPath, server.getHost())); } - if (curator.checkExists().forPath(zNodePathSegment) != null) { - curator.delete().guaranteed().forPath(zNodePathSegment); + catch (KeeperException.NodeExistsException e) { + /* + * For some reason, Travis build sometimes fails here because of + * org.apache.zookeeper.KeeperException$NodeExistsException: KeeperErrorCode = NodeExists, though it should never + * happen because zookeeper should be in a clean state for each run of tests. + * Address issue: https://github.com/druid-io/druid/issues/1512 + */ + try { + curator.setData() + .forPath( + ZKPaths.makePath(announcementsPath, server.getHost()), + jsonMapper.writeValueAsBytes(server.getMetadata()) + ); + curator.setData() + .forPath(ZKPaths.makePath(inventoryPath, server.getHost())); + } + catch (Exception e1) { + Throwables.propagate(e1); + } + } + catch (Exception e) { + Throwables.propagate(e); } - curator.create() - .creatingParentsIfNeeded() - .forPath( - ZKPaths.makePath(announcementsPath, server.getHost()), - jsonMapper.writeValueAsBytes(server.getMetadata()) - ); - curator.create() - .creatingParentsIfNeeded() - .forPath(ZKPaths.makePath(inventoryPath, server.getHost())); } protected void tearDownServerAndCurator() From 5cc56cf9e72fab672479484b06b50bccd7d833b5 Mon Sep 17 00:00:00 2001 From: Bingkun Guo Date: Mon, 21 Dec 2015 13:05:38 -0600 Subject: [PATCH 02/24] build #2 --- server/src/test/java/io/druid/curator/CuratorTestBase.java | 1 + 1 file changed, 1 insertion(+) diff --git a/server/src/test/java/io/druid/curator/CuratorTestBase.java b/server/src/test/java/io/druid/curator/CuratorTestBase.java index 11246ffeeaa..777e9e4ab0f 100644 --- a/server/src/test/java/io/druid/curator/CuratorTestBase.java +++ b/server/src/test/java/io/druid/curator/CuratorTestBase.java @@ -102,4 +102,5 @@ public class CuratorTestBase CloseQuietly.close(curator); CloseQuietly.close(server); } + } From 47a8f2d3f16404a8b1ae9f0f3593cac964154a57 Mon Sep 17 00:00:00 2001 From: Bingkun Guo Date: Mon, 21 Dec 2015 13:56:43 -0600 Subject: [PATCH 03/24] build #3 --- server/src/test/java/io/druid/curator/CuratorTestBase.java | 1 - 1 file changed, 1 deletion(-) diff --git a/server/src/test/java/io/druid/curator/CuratorTestBase.java b/server/src/test/java/io/druid/curator/CuratorTestBase.java index 777e9e4ab0f..11246ffeeaa 100644 --- a/server/src/test/java/io/druid/curator/CuratorTestBase.java +++ b/server/src/test/java/io/druid/curator/CuratorTestBase.java @@ -102,5 +102,4 @@ public class CuratorTestBase CloseQuietly.close(curator); CloseQuietly.close(server); } - } From 52261c5539f30d54a6538207900c740559ef6ab2 Mon Sep 17 00:00:00 2001 From: Bingkun Guo Date: Mon, 21 Dec 2015 14:41:38 -0600 Subject: [PATCH 04/24] build #4 --- server/src/test/java/io/druid/curator/CuratorTestBase.java | 1 + 1 file changed, 1 insertion(+) diff --git a/server/src/test/java/io/druid/curator/CuratorTestBase.java b/server/src/test/java/io/druid/curator/CuratorTestBase.java index 11246ffeeaa..777e9e4ab0f 100644 --- a/server/src/test/java/io/druid/curator/CuratorTestBase.java +++ b/server/src/test/java/io/druid/curator/CuratorTestBase.java @@ -102,4 +102,5 @@ public class CuratorTestBase CloseQuietly.close(curator); CloseQuietly.close(server); } + } From f8342ca2404ddced13b15cf688d06c3db13fd0e0 Mon Sep 17 00:00:00 2001 From: Bingkun Guo Date: Mon, 21 Dec 2015 15:10:37 -0600 Subject: [PATCH 05/24] build #5 --- server/src/test/java/io/druid/curator/CuratorTestBase.java | 1 - 1 file changed, 1 deletion(-) diff --git a/server/src/test/java/io/druid/curator/CuratorTestBase.java b/server/src/test/java/io/druid/curator/CuratorTestBase.java index 777e9e4ab0f..11246ffeeaa 100644 --- a/server/src/test/java/io/druid/curator/CuratorTestBase.java +++ b/server/src/test/java/io/druid/curator/CuratorTestBase.java @@ -102,5 +102,4 @@ public class CuratorTestBase CloseQuietly.close(curator); CloseQuietly.close(server); } - } From 9ed843ea219b3952fddd0166d6089f0373a2ba81 Mon Sep 17 00:00:00 2001 From: Bingkun Guo Date: Mon, 21 Dec 2015 15:41:23 -0600 Subject: [PATCH 06/24] build #6 --- server/src/test/java/io/druid/curator/CuratorTestBase.java | 1 + 1 file changed, 1 insertion(+) diff --git a/server/src/test/java/io/druid/curator/CuratorTestBase.java b/server/src/test/java/io/druid/curator/CuratorTestBase.java index 11246ffeeaa..777e9e4ab0f 100644 --- a/server/src/test/java/io/druid/curator/CuratorTestBase.java +++ b/server/src/test/java/io/druid/curator/CuratorTestBase.java @@ -102,4 +102,5 @@ public class CuratorTestBase CloseQuietly.close(curator); CloseQuietly.close(server); } + } From 293f2ad65d51e23bec1058f495808146ab4dcdde Mon Sep 17 00:00:00 2001 From: Bingkun Guo Date: Mon, 21 Dec 2015 16:09:19 -0600 Subject: [PATCH 07/24] build #7 --- server/src/test/java/io/druid/curator/CuratorTestBase.java | 1 - 1 file changed, 1 deletion(-) diff --git a/server/src/test/java/io/druid/curator/CuratorTestBase.java b/server/src/test/java/io/druid/curator/CuratorTestBase.java index 777e9e4ab0f..11246ffeeaa 100644 --- a/server/src/test/java/io/druid/curator/CuratorTestBase.java +++ b/server/src/test/java/io/druid/curator/CuratorTestBase.java @@ -102,5 +102,4 @@ public class CuratorTestBase CloseQuietly.close(curator); CloseQuietly.close(server); } - } From 627c311923971b37c14ba9d3479ec55de5c45d74 Mon Sep 17 00:00:00 2001 From: Bingkun Guo Date: Mon, 21 Dec 2015 17:06:37 -0600 Subject: [PATCH 08/24] build #8 --- server/src/test/java/io/druid/curator/CuratorTestBase.java | 1 + 1 file changed, 1 insertion(+) diff --git a/server/src/test/java/io/druid/curator/CuratorTestBase.java b/server/src/test/java/io/druid/curator/CuratorTestBase.java index 11246ffeeaa..777e9e4ab0f 100644 --- a/server/src/test/java/io/druid/curator/CuratorTestBase.java +++ b/server/src/test/java/io/druid/curator/CuratorTestBase.java @@ -102,4 +102,5 @@ public class CuratorTestBase CloseQuietly.close(curator); CloseQuietly.close(server); } + } From 471dd7e16435ca420f277beb9ae16a2836715377 Mon Sep 17 00:00:00 2001 From: Bingkun Guo Date: Mon, 21 Dec 2015 17:35:18 -0600 Subject: [PATCH 09/24] build number 9 --- server/src/test/java/io/druid/curator/CuratorTestBase.java | 1 - 1 file changed, 1 deletion(-) diff --git a/server/src/test/java/io/druid/curator/CuratorTestBase.java b/server/src/test/java/io/druid/curator/CuratorTestBase.java index 777e9e4ab0f..11246ffeeaa 100644 --- a/server/src/test/java/io/druid/curator/CuratorTestBase.java +++ b/server/src/test/java/io/druid/curator/CuratorTestBase.java @@ -102,5 +102,4 @@ public class CuratorTestBase CloseQuietly.close(curator); CloseQuietly.close(server); } - } From 93a91e5633be9023ade862cc7eb421a1ae476832 Mon Sep 17 00:00:00 2001 From: Bingkun Guo Date: Mon, 21 Dec 2015 18:21:15 -0600 Subject: [PATCH 10/24] build number 10 --- server/src/test/java/io/druid/curator/CuratorTestBase.java | 1 + 1 file changed, 1 insertion(+) diff --git a/server/src/test/java/io/druid/curator/CuratorTestBase.java b/server/src/test/java/io/druid/curator/CuratorTestBase.java index 11246ffeeaa..777e9e4ab0f 100644 --- a/server/src/test/java/io/druid/curator/CuratorTestBase.java +++ b/server/src/test/java/io/druid/curator/CuratorTestBase.java @@ -102,4 +102,5 @@ public class CuratorTestBase CloseQuietly.close(curator); CloseQuietly.close(server); } + } From 06c220ae7b107d683fbcaca3319c6dd4deda3699 Mon Sep 17 00:00:00 2001 From: Bingkun Guo Date: Mon, 21 Dec 2015 19:40:47 -0600 Subject: [PATCH 11/24] build number 11 --- server/src/test/java/io/druid/curator/CuratorTestBase.java | 1 - 1 file changed, 1 deletion(-) diff --git a/server/src/test/java/io/druid/curator/CuratorTestBase.java b/server/src/test/java/io/druid/curator/CuratorTestBase.java index 777e9e4ab0f..11246ffeeaa 100644 --- a/server/src/test/java/io/druid/curator/CuratorTestBase.java +++ b/server/src/test/java/io/druid/curator/CuratorTestBase.java @@ -102,5 +102,4 @@ public class CuratorTestBase CloseQuietly.close(curator); CloseQuietly.close(server); } - } From bc573484f3ea228af4edd69403b611220680e6a2 Mon Sep 17 00:00:00 2001 From: Bingkun Guo Date: Tue, 22 Dec 2015 00:52:58 -0600 Subject: [PATCH 12/24] build number 12 --- server/src/test/java/io/druid/curator/CuratorTestBase.java | 1 + 1 file changed, 1 insertion(+) diff --git a/server/src/test/java/io/druid/curator/CuratorTestBase.java b/server/src/test/java/io/druid/curator/CuratorTestBase.java index 11246ffeeaa..777e9e4ab0f 100644 --- a/server/src/test/java/io/druid/curator/CuratorTestBase.java +++ b/server/src/test/java/io/druid/curator/CuratorTestBase.java @@ -102,4 +102,5 @@ public class CuratorTestBase CloseQuietly.close(curator); CloseQuietly.close(server); } + } From 2ffeda5d251497e9473335d2a504aa0508a5294a Mon Sep 17 00:00:00 2001 From: Bingkun Guo Date: Tue, 22 Dec 2015 10:19:39 -0600 Subject: [PATCH 13/24] build number 13 --- server/src/test/java/io/druid/curator/CuratorTestBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/test/java/io/druid/curator/CuratorTestBase.java b/server/src/test/java/io/druid/curator/CuratorTestBase.java index 777e9e4ab0f..cc15daeb0e1 100644 --- a/server/src/test/java/io/druid/curator/CuratorTestBase.java +++ b/server/src/test/java/io/druid/curator/CuratorTestBase.java @@ -102,5 +102,5 @@ public class CuratorTestBase CloseQuietly.close(curator); CloseQuietly.close(server); } - + } From 455980d659be4d2eefc0cc3c8db258946cdfa558 Mon Sep 17 00:00:00 2001 From: Bingkun Guo Date: Tue, 22 Dec 2015 13:06:20 -0600 Subject: [PATCH 14/24] address another node exists failure --- .../io/druid/client/BrokerServerViewTest.java | 40 ++------------ .../client/CoordinatorServerViewTest.java | 33 ++++------- .../io/druid/curator/CuratorTestBase.java | 55 +++++++++++++++++++ 3 files changed, 70 insertions(+), 58 deletions(-) diff --git a/server/src/test/java/io/druid/client/BrokerServerViewTest.java b/server/src/test/java/io/druid/client/BrokerServerViewTest.java index 08b44f8de62..6298ecba363 100644 --- a/server/src/test/java/io/druid/client/BrokerServerViewTest.java +++ b/server/src/test/java/io/druid/client/BrokerServerViewTest.java @@ -25,7 +25,6 @@ import com.fasterxml.jackson.dataformat.smile.SmileGenerator; import com.google.common.base.Function; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.metamx.common.Pair; @@ -47,8 +46,6 @@ import io.druid.timeline.TimelineObjectHolder; import io.druid.timeline.partition.NoneShardSpec; import io.druid.timeline.partition.PartitionHolder; import io.druid.timeline.partition.SingleElementPartitionChunk; -import org.apache.curator.utils.ZKPaths; -import org.apache.zookeeper.CreateMode; import org.easymock.EasyMock; import org.joda.time.Interval; import org.junit.After; @@ -65,8 +62,6 @@ public class BrokerServerViewTest extends CuratorTestBase { private final ObjectMapper jsonMapper; private final ZkPathsConfig zkPathsConfig; - private final String announcementsPath; - private final String inventoryPath; private CountDownLatch segmentViewInitLatch; private CountDownLatch segmentAddedLatch; @@ -79,8 +74,6 @@ public class BrokerServerViewTest extends CuratorTestBase { jsonMapper = new DefaultObjectMapper(); zkPathsConfig = new ZkPathsConfig(); - announcementsPath = zkPathsConfig.getAnnouncementsPath(); - inventoryPath = zkPathsConfig.getLiveSegmentsPath(); } @Before @@ -111,7 +104,7 @@ public class BrokerServerViewTest extends CuratorTestBase setupZNodeForServer(druidServer, zkPathsConfig, jsonMapper); final DataSegment segment = dataSegmentWithIntervalAndVersion("2014-10-20T00:00:00Z/P1D", "v1"); - announceSegmentForServer(druidServer, segment); + announceSegmentForServer(druidServer, segment, zkPathsConfig, jsonMapper); Assert.assertTrue(timing.forWaiting().awaitLatch(segmentViewInitLatch)); Assert.assertTrue(timing.forWaiting().awaitLatch(segmentAddedLatch)); @@ -137,7 +130,7 @@ public class BrokerServerViewTest extends CuratorTestBase Assert.assertEquals(segment, selector.getSegment()); Assert.assertEquals(druidServer, selector.pick().getServer()); - unannounceSegmentForServer(druidServer, segment); + unannounceSegmentForServer(druidServer, segment, zkPathsConfig); Assert.assertTrue(timing.forWaiting().awaitLatch(segmentRemovedLatch)); Assert.assertEquals( @@ -199,7 +192,7 @@ public class BrokerServerViewTest extends CuratorTestBase ); for (int i = 0; i < 5; ++i) { - announceSegmentForServer(druidServers.get(i), segments.get(i)); + announceSegmentForServer(druidServers.get(i), segments.get(i), zkPathsConfig, jsonMapper); } Assert.assertTrue(timing.forWaiting().awaitLatch(segmentViewInitLatch)); Assert.assertTrue(timing.forWaiting().awaitLatch(segmentAddedLatch)); @@ -219,7 +212,7 @@ public class BrokerServerViewTest extends CuratorTestBase ); // unannounce the segment created by dataSegmentWithIntervalAndVersion("2011-04-01/2011-04-09", "v2") - unannounceSegmentForServer(druidServers.get(2), segments.get(2)); + unannounceSegmentForServer(druidServers.get(2), segments.get(2), zkPathsConfig); Assert.assertTrue(timing.forWaiting().awaitLatch(segmentRemovedLatch)); // renew segmentRemovedLatch since we still have 4 segments to unannounce @@ -244,7 +237,7 @@ public class BrokerServerViewTest extends CuratorTestBase for (int i = 0; i < 5; ++i) { // skip the one that was previously unannounced if (i != 2) { - unannounceSegmentForServer(druidServers.get(i), segments.get(i)); + unannounceSegmentForServer(druidServers.get(i), segments.get(i), zkPathsConfig); } } Assert.assertTrue(timing.forWaiting().awaitLatch(segmentRemovedLatch)); @@ -255,29 +248,6 @@ public class BrokerServerViewTest extends CuratorTestBase ); } - private void announceSegmentForServer(DruidServer druidServer, DataSegment segment) throws Exception - { - curator.create() - .compressed() - .withMode(CreateMode.EPHEMERAL) - .forPath( - ZKPaths.makePath(ZKPaths.makePath(inventoryPath, druidServer.getHost()), segment.getIdentifier()), - jsonMapper.writeValueAsBytes( - ImmutableSet.of(segment) - ) - ); - } - - private void unannounceSegmentForServer(DruidServer druidServer, DataSegment segment) throws Exception - { - curator.delete().guaranteed().forPath( - ZKPaths.makePath( - ZKPaths.makePath(inventoryPath, druidServer.getHost()), - segment.getIdentifier() - ) - ); - } - private Pair>> createExpected( String intervalStr, String version, diff --git a/server/src/test/java/io/druid/client/CoordinatorServerViewTest.java b/server/src/test/java/io/druid/client/CoordinatorServerViewTest.java index bcfba7453be..3e01804df09 100644 --- a/server/src/test/java/io/druid/client/CoordinatorServerViewTest.java +++ b/server/src/test/java/io/druid/client/CoordinatorServerViewTest.java @@ -23,7 +23,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Function; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.metamx.common.Pair; @@ -38,7 +37,6 @@ import io.druid.timeline.TimelineObjectHolder; import io.druid.timeline.partition.NoneShardSpec; import io.druid.timeline.partition.PartitionHolder; import org.apache.curator.utils.ZKPaths; -import org.apache.zookeeper.CreateMode; import org.joda.time.Interval; import org.junit.After; import org.junit.Assert; @@ -54,7 +52,6 @@ public class CoordinatorServerViewTest extends CuratorTestBase { private final ObjectMapper jsonMapper; private final ZkPathsConfig zkPathsConfig; - private final String announcementsPath; private final String inventoryPath; private CountDownLatch segmentViewInitLatch; @@ -68,7 +65,6 @@ public class CoordinatorServerViewTest extends CuratorTestBase { jsonMapper = new DefaultObjectMapper(); zkPathsConfig = new ZkPathsConfig(); - announcementsPath = zkPathsConfig.getAnnouncementsPath(); inventoryPath = zkPathsConfig.getLiveSegmentsPath(); } @@ -100,7 +96,7 @@ public class CoordinatorServerViewTest extends CuratorTestBase setupZNodeForServer(druidServer, zkPathsConfig, jsonMapper); final DataSegment segment = dataSegmentWithIntervalAndVersion("2014-10-20T00:00:00Z/P1D", "v1"); - announceSegmentForServer(druidServer, segment); + announceSegmentForServer(druidServer, segment, zkPathsConfig, jsonMapper); Assert.assertTrue(timing.forWaiting().awaitLatch(segmentViewInitLatch)); Assert.assertTrue(timing.forWaiting().awaitLatch(segmentAddedLatch)); @@ -122,7 +118,10 @@ public class CoordinatorServerViewTest extends CuratorTestBase SegmentLoadInfo segmentLoadInfo = actualPartitionHolder.iterator().next().getObject(); Assert.assertFalse(segmentLoadInfo.isEmpty()); - Assert.assertEquals(druidServer.getMetadata(), Iterables.getOnlyElement(segmentLoadInfo.toImmutableSegmentLoadInfo().getServers())); + Assert.assertEquals( + druidServer.getMetadata(), + Iterables.getOnlyElement(segmentLoadInfo.toImmutableSegmentLoadInfo().getServers()) + ); unannounceSegmentForServer(druidServer, segment); Assert.assertTrue(timing.forWaiting().awaitLatch(segmentRemovedLatch)); @@ -186,7 +185,7 @@ public class CoordinatorServerViewTest extends CuratorTestBase ); for (int i = 0; i < 5; ++i) { - announceSegmentForServer(druidServers.get(i), segments.get(i)); + announceSegmentForServer(druidServers.get(i), segments.get(i), zkPathsConfig, jsonMapper); } Assert.assertTrue(timing.forWaiting().awaitLatch(segmentViewInitLatch)); Assert.assertTrue(timing.forWaiting().awaitLatch(segmentAddedLatch)); @@ -242,19 +241,6 @@ public class CoordinatorServerViewTest extends CuratorTestBase ); } - private void announceSegmentForServer(DruidServer druidServer, DataSegment segment) throws Exception - { - curator.create() - .compressed() - .withMode(CreateMode.EPHEMERAL) - .forPath( - ZKPaths.makePath(ZKPaths.makePath(inventoryPath, druidServer.getHost()), segment.getIdentifier()), - jsonMapper.writeValueAsBytes( - ImmutableSet.of(segment) - ) - ); - } - private void unannounceSegmentForServer(DruidServer druidServer, DataSegment segment) throws Exception { curator.delete().guaranteed().forPath( @@ -283,7 +269,7 @@ public class CoordinatorServerViewTest extends CuratorTestBase for (int i = 0; i < expected.size(); ++i) { Pair>> expectedPair = expected.get(i); - TimelineObjectHolder actualTimelineObjectHolder = actual.get(i); + TimelineObjectHolder actualTimelineObjectHolder = actual.get(i); Assert.assertEquals(expectedPair.lhs, actualTimelineObjectHolder.getInterval()); Assert.assertEquals(expectedPair.rhs.lhs, actualTimelineObjectHolder.getVersion()); @@ -292,9 +278,10 @@ public class CoordinatorServerViewTest extends CuratorTestBase Assert.assertTrue(actualPartitionHolder.isComplete()); Assert.assertEquals(1, Iterables.size(actualPartitionHolder)); - SegmentLoadInfo segmentLoadInfo = actualPartitionHolder.iterator().next().getObject(); + SegmentLoadInfo segmentLoadInfo = actualPartitionHolder.iterator().next().getObject(); Assert.assertFalse(segmentLoadInfo.isEmpty()); - Assert.assertEquals(expectedPair.rhs.rhs.lhs.getMetadata(),Iterables.getOnlyElement(segmentLoadInfo.toImmutableSegmentLoadInfo().getServers())); + Assert.assertEquals(expectedPair.rhs.rhs.lhs.getMetadata(), + Iterables.getOnlyElement(segmentLoadInfo.toImmutableSegmentLoadInfo().getServers())); } } diff --git a/server/src/test/java/io/druid/curator/CuratorTestBase.java b/server/src/test/java/io/druid/curator/CuratorTestBase.java index cc15daeb0e1..5d8b35a3e1a 100644 --- a/server/src/test/java/io/druid/curator/CuratorTestBase.java +++ b/server/src/test/java/io/druid/curator/CuratorTestBase.java @@ -21,15 +21,18 @@ package io.druid.curator; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.api.client.repackaged.com.google.common.base.Throwables; +import com.google.common.collect.ImmutableSet; import com.metamx.common.guava.CloseQuietly; import io.druid.client.DruidServer; import io.druid.server.initialization.ZkPathsConfig; +import io.druid.timeline.DataSegment; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.CuratorFrameworkFactory; import org.apache.curator.retry.RetryOneTime; import org.apache.curator.test.TestingServer; import org.apache.curator.test.Timing; import org.apache.curator.utils.ZKPaths; +import org.apache.zookeeper.CreateMode; import org.apache.zookeeper.KeeperException; /** @@ -94,7 +97,57 @@ public class CuratorTestBase catch (Exception e) { Throwables.propagate(e); } + } + protected void announceSegmentForServer( + DruidServer druidServer, + DataSegment segment, + ZkPathsConfig zkPathsConfig, + ObjectMapper jsonMapper + ) + { + final String segmentAnnouncementPath = ZKPaths.makePath(ZKPaths.makePath( + zkPathsConfig.getLiveSegmentsPath(), + druidServer.getHost() + ), segment.getIdentifier()); + + try { + curator.create() + .compressed() + .withMode(CreateMode.EPHEMERAL) + .forPath( + segmentAnnouncementPath, + jsonMapper.writeValueAsBytes( + ImmutableSet.of(segment) + ) + ); + } + catch (KeeperException.NodeExistsException e) { + try { + curator.setData() + .forPath( + segmentAnnouncementPath, + jsonMapper.writeValueAsBytes(ImmutableSet.of(segment)) + ); + } + catch (Exception e1) { + Throwables.propagate(e1); + } + } + catch (Exception e) { + Throwables.propagate(e); + } + } + + protected void unannounceSegmentForServer(DruidServer druidServer, DataSegment segment, ZkPathsConfig zkPathsConfig) + throws Exception + { + curator.delete().guaranteed().forPath( + ZKPaths.makePath( + ZKPaths.makePath(zkPathsConfig.getLiveSegmentsPath(), druidServer.getHost()), + segment.getIdentifier() + ) + ); } protected void tearDownServerAndCurator() @@ -104,3 +157,5 @@ public class CuratorTestBase } } + +// build #13 \ No newline at end of file From 849ab2d9585035d13f7cc3edf5c1821441c9a7b7 Mon Sep 17 00:00:00 2001 From: Bingkun Guo Date: Tue, 22 Dec 2015 13:08:29 -0600 Subject: [PATCH 15/24] build at --- server/src/test/java/io/druid/curator/CuratorTestBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/test/java/io/druid/curator/CuratorTestBase.java b/server/src/test/java/io/druid/curator/CuratorTestBase.java index 5d8b35a3e1a..4d62824b0dc 100644 --- a/server/src/test/java/io/druid/curator/CuratorTestBase.java +++ b/server/src/test/java/io/druid/curator/CuratorTestBase.java @@ -158,4 +158,4 @@ public class CuratorTestBase } -// build #13 \ No newline at end of file +//Build at Tue Dec 22 13:08:29 CST 2015 From 0a635a11d6187654ee756bc633908e0dd9a0c97f Mon Sep 17 00:00:00 2001 From: Bingkun Guo Date: Tue, 22 Dec 2015 13:40:00 -0600 Subject: [PATCH 16/24] build at Tue Dec 22 13:40:00 CST 2015 --- server/src/test/java/io/druid/curator/CuratorTestBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/test/java/io/druid/curator/CuratorTestBase.java b/server/src/test/java/io/druid/curator/CuratorTestBase.java index 4d62824b0dc..28b299e3400 100644 --- a/server/src/test/java/io/druid/curator/CuratorTestBase.java +++ b/server/src/test/java/io/druid/curator/CuratorTestBase.java @@ -158,4 +158,4 @@ public class CuratorTestBase } -//Build at Tue Dec 22 13:08:29 CST 2015 +//Build at Tue Dec 22 13:40:00 CST 2015 From 4961b8c0bd807bac8e7a4d56542f30a985f3848e Mon Sep 17 00:00:00 2001 From: Bingkun Guo Date: Tue, 22 Dec 2015 14:00:00 -0600 Subject: [PATCH 17/24] build at Tue Dec 22 14:00:00 CST 2015 --- server/src/test/java/io/druid/curator/CuratorTestBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/test/java/io/druid/curator/CuratorTestBase.java b/server/src/test/java/io/druid/curator/CuratorTestBase.java index 28b299e3400..d5f59e8a45d 100644 --- a/server/src/test/java/io/druid/curator/CuratorTestBase.java +++ b/server/src/test/java/io/druid/curator/CuratorTestBase.java @@ -158,4 +158,4 @@ public class CuratorTestBase } -//Build at Tue Dec 22 13:40:00 CST 2015 +//Build at Tue Dec 22 14:00:00 CST 2015 From 4e61261c6868c682218325928b3f3ca26fa07cf7 Mon Sep 17 00:00:00 2001 From: Bingkun Guo Date: Tue, 22 Dec 2015 14:30:00 -0600 Subject: [PATCH 18/24] build at Tue Dec 22 14:30:00 CST 2015 --- server/src/test/java/io/druid/curator/CuratorTestBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/test/java/io/druid/curator/CuratorTestBase.java b/server/src/test/java/io/druid/curator/CuratorTestBase.java index d5f59e8a45d..99dc202b923 100644 --- a/server/src/test/java/io/druid/curator/CuratorTestBase.java +++ b/server/src/test/java/io/druid/curator/CuratorTestBase.java @@ -158,4 +158,4 @@ public class CuratorTestBase } -//Build at Tue Dec 22 14:00:00 CST 2015 +//Build at Tue Dec 22 14:30:00 CST 2015 From 6f54c1b60d940a55e93236c41386419bf2bf5dee Mon Sep 17 00:00:00 2001 From: Bingkun Guo Date: Tue, 22 Dec 2015 15:00:01 -0600 Subject: [PATCH 19/24] build at Tue Dec 22 15:00:00 CST 2015 --- server/src/test/java/io/druid/curator/CuratorTestBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/test/java/io/druid/curator/CuratorTestBase.java b/server/src/test/java/io/druid/curator/CuratorTestBase.java index 99dc202b923..4f7694aad78 100644 --- a/server/src/test/java/io/druid/curator/CuratorTestBase.java +++ b/server/src/test/java/io/druid/curator/CuratorTestBase.java @@ -158,4 +158,4 @@ public class CuratorTestBase } -//Build at Tue Dec 22 14:30:00 CST 2015 +//Build at Tue Dec 22 15:00:00 CST 2015 From ffdb9407e5d6052e563c433568776dcccee35af9 Mon Sep 17 00:00:00 2001 From: Bingkun Guo Date: Tue, 22 Dec 2015 15:30:00 -0600 Subject: [PATCH 20/24] build at Tue Dec 22 15:30:00 CST 2015 --- server/src/test/java/io/druid/curator/CuratorTestBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/test/java/io/druid/curator/CuratorTestBase.java b/server/src/test/java/io/druid/curator/CuratorTestBase.java index 4f7694aad78..6ed35c4f428 100644 --- a/server/src/test/java/io/druid/curator/CuratorTestBase.java +++ b/server/src/test/java/io/druid/curator/CuratorTestBase.java @@ -158,4 +158,4 @@ public class CuratorTestBase } -//Build at Tue Dec 22 15:00:00 CST 2015 +//Build at Tue Dec 22 15:30:00 CST 2015 From b8d9860dbc860a2f972a84493b97748ebabfd326 Mon Sep 17 00:00:00 2001 From: Bingkun Guo Date: Tue, 22 Dec 2015 16:00:00 -0600 Subject: [PATCH 21/24] build at Tue Dec 22 16:00:00 CST 2015 --- server/src/test/java/io/druid/curator/CuratorTestBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/test/java/io/druid/curator/CuratorTestBase.java b/server/src/test/java/io/druid/curator/CuratorTestBase.java index 6ed35c4f428..9a6ea4b3642 100644 --- a/server/src/test/java/io/druid/curator/CuratorTestBase.java +++ b/server/src/test/java/io/druid/curator/CuratorTestBase.java @@ -158,4 +158,4 @@ public class CuratorTestBase } -//Build at Tue Dec 22 15:30:00 CST 2015 +//Build at Tue Dec 22 16:00:00 CST 2015 From 4b93528334f0ddfe9c23eeee25d178be02ddb203 Mon Sep 17 00:00:00 2001 From: Bingkun Guo Date: Tue, 22 Dec 2015 17:00:01 -0600 Subject: [PATCH 22/24] build at Tue Dec 22 17:00:01 CST 2015 --- server/src/test/java/io/druid/curator/CuratorTestBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/test/java/io/druid/curator/CuratorTestBase.java b/server/src/test/java/io/druid/curator/CuratorTestBase.java index 9a6ea4b3642..75ca6404b53 100644 --- a/server/src/test/java/io/druid/curator/CuratorTestBase.java +++ b/server/src/test/java/io/druid/curator/CuratorTestBase.java @@ -158,4 +158,4 @@ public class CuratorTestBase } -//Build at Tue Dec 22 16:00:00 CST 2015 +//Build at Tue Dec 22 17:00:01 CST 2015 From a110eafff74af742012e658e71ac476ffef4ad18 Mon Sep 17 00:00:00 2001 From: Bingkun Guo Date: Tue, 22 Dec 2015 17:30:00 -0600 Subject: [PATCH 23/24] build at Tue Dec 22 17:30:00 CST 2015 --- server/src/test/java/io/druid/curator/CuratorTestBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/test/java/io/druid/curator/CuratorTestBase.java b/server/src/test/java/io/druid/curator/CuratorTestBase.java index 75ca6404b53..8500e14796b 100644 --- a/server/src/test/java/io/druid/curator/CuratorTestBase.java +++ b/server/src/test/java/io/druid/curator/CuratorTestBase.java @@ -158,4 +158,4 @@ public class CuratorTestBase } -//Build at Tue Dec 22 17:00:01 CST 2015 +//Build at Tue Dec 22 17:30:00 CST 2015 From 89e2a9a6d24bb4c37a3d54df3201de2111bf8f7b Mon Sep 17 00:00:00 2001 From: Bingkun Guo Date: Tue, 22 Dec 2015 21:30:00 -0600 Subject: [PATCH 24/24] build at Tue Dec 22 21:30:00 CST 2015 --- server/src/test/java/io/druid/curator/CuratorTestBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/test/java/io/druid/curator/CuratorTestBase.java b/server/src/test/java/io/druid/curator/CuratorTestBase.java index 8500e14796b..165f0bde741 100644 --- a/server/src/test/java/io/druid/curator/CuratorTestBase.java +++ b/server/src/test/java/io/druid/curator/CuratorTestBase.java @@ -158,4 +158,4 @@ public class CuratorTestBase } -//Build at Tue Dec 22 17:30:00 CST 2015 +//Build at Tue Dec 22 21:30:00 CST 2015