From deb6ecf91909d41678465fd37b2c8e5999443fd8 Mon Sep 17 00:00:00 2001 From: Nishant Date: Tue, 12 Apr 2016 21:52:00 +0530 Subject: [PATCH] handle review comments for PR 2784 https://github.com/druid-io/druid/pull/2784#discussion_r59062021 --- docs/content/configuration/index.md | 3 +- .../BatchDataSegmentAnnouncer.java | 7 +--- .../BatchDataSegmentAnnouncerConfig.java | 14 ++----- .../BatchDataSegmentAnnouncerTest.java | 39 +++---------------- 4 files changed, 11 insertions(+), 52 deletions(-) diff --git a/docs/content/configuration/index.md b/docs/content/configuration/index.md index 7913e89a7c1..4ab9f91e483 100644 --- a/docs/content/configuration/index.md +++ b/docs/content/configuration/index.md @@ -296,7 +296,6 @@ In current Druid, multiple data segments may be announced under the same Znode. |--------|-----------|-------| |`druid.announcer.segmentsPerNode`|Each Znode contains info for up to this many segments.|50| |`druid.announcer.maxBytesPerNode`|Max byte size for Znode.|524288| -|`druid.announcer.skipDimensions`|Skip Dimension list from segment announcements. NOTE: Enabling this will also remove the dimensions list from coordinator and broker endpoints.|false| -|`druid.announcer.skipMetrics`|Skip Metrics list from segment announcements. NOTE: Enabling this will also remove the metrics list from coordinator and broker endpoints.|false| +|`druid.announcer.skipDimensionsAndMetrics`|Skip Dimensions and Metrics list from segment announcements. NOTE: Enabling this will also remove the dimensions and metrics list from coordinator and broker endpoints.|false| |`druid.announcer.skipLoadSpec`|Skip segment LoadSpec from segment announcements. NOTE: Enabling this will also remove the loadspec from coordinator and broker endpoints.|false| diff --git a/server/src/main/java/io/druid/server/coordination/BatchDataSegmentAnnouncer.java b/server/src/main/java/io/druid/server/coordination/BatchDataSegmentAnnouncer.java index 8aef0f2ff41..027d43721e6 100644 --- a/server/src/main/java/io/druid/server/coordination/BatchDataSegmentAnnouncer.java +++ b/server/src/main/java/io/druid/server/coordination/BatchDataSegmentAnnouncer.java @@ -85,11 +85,8 @@ public class BatchDataSegmentAnnouncer extends AbstractDataSegmentAnnouncer public DataSegment apply(DataSegment input) { DataSegment rv = input; - if (config.isSkipDimensions()) { - rv = rv.withDimensions(null); - } - if (config.isSkipMetrics()) { - rv = rv.withMetrics(null); + if (config.isSkipDimensionsAndMetrics()) { + rv = rv.withDimensions(null).withMetrics(null); } if (config.isSkipLoadSpec()) { rv = rv.withLoadSpec(null); diff --git a/server/src/main/java/io/druid/server/initialization/BatchDataSegmentAnnouncerConfig.java b/server/src/main/java/io/druid/server/initialization/BatchDataSegmentAnnouncerConfig.java index 7c31679ae9a..ce7e9552196 100644 --- a/server/src/main/java/io/druid/server/initialization/BatchDataSegmentAnnouncerConfig.java +++ b/server/src/main/java/io/druid/server/initialization/BatchDataSegmentAnnouncerConfig.java @@ -43,11 +43,7 @@ public class BatchDataSegmentAnnouncerConfig // Skip dimension list from segment announcements @JsonProperty - private boolean skipDimensions = false; - - // Skip metrics list from segment announcements - @JsonProperty - private boolean skipMetrics = false; + private boolean skipDimensionsAndMetrics = false; public int getSegmentsPerNode() { @@ -64,13 +60,9 @@ public class BatchDataSegmentAnnouncerConfig return skipLoadSpec; } - public boolean isSkipDimensions() + public boolean isSkipDimensionsAndMetrics() { - return skipDimensions; + return skipDimensionsAndMetrics; } - public boolean isSkipMetrics() - { - return skipMetrics; - } } diff --git a/server/src/test/java/io/druid/server/coordination/coordination/BatchDataSegmentAnnouncerTest.java b/server/src/test/java/io/druid/server/coordination/coordination/BatchDataSegmentAnnouncerTest.java index 9c1ef0992b9..359631aa832 100644 --- a/server/src/test/java/io/druid/server/coordination/coordination/BatchDataSegmentAnnouncerTest.java +++ b/server/src/test/java/io/druid/server/coordination/coordination/BatchDataSegmentAnnouncerTest.java @@ -69,8 +69,7 @@ public class BatchDataSegmentAnnouncerTest private Set testSegments; private final AtomicInteger maxBytesPerNode = new AtomicInteger(512 * 1024); - private Boolean skipDimensions; - private Boolean skipMetrics; + private Boolean skipDimensionsAndMetrics; private Boolean skipLoadSpec; @@ -98,8 +97,7 @@ public class BatchDataSegmentAnnouncerTest announcer.start(); segmentReader = new SegmentReader(cf, jsonMapper); - skipDimensions = false; - skipMetrics = false; + skipDimensionsAndMetrics = false; skipLoadSpec = false; segmentAnnouncer = new BatchDataSegmentAnnouncer( new DruidServerMetadata( @@ -125,15 +123,9 @@ public class BatchDataSegmentAnnouncerTest } @Override - public boolean isSkipDimensions() + public boolean isSkipDimensionsAndMetrics() { - return skipDimensions; - } - - @Override - public boolean isSkipMetrics() - { - return skipMetrics; + return skipDimensionsAndMetrics; } @Override @@ -208,7 +200,7 @@ public class BatchDataSegmentAnnouncerTest @Test public void testSkipDimensions() throws Exception { - skipDimensions = true; + skipDimensionsAndMetrics = true; Iterator segIter = testSegments.iterator(); DataSegment firstSegment = segIter.next(); @@ -220,27 +212,6 @@ public class BatchDataSegmentAnnouncerTest DataSegment announcedSegment = Iterables.getOnlyElement(segmentReader.read(joiner.join(testSegmentsPath, zNode))); Assert.assertEquals(announcedSegment, firstSegment); Assert.assertTrue(announcedSegment.getDimensions().isEmpty()); - } - - segmentAnnouncer.unannounceSegment(firstSegment); - - Assert.assertTrue(cf.getChildren().forPath(testSegmentsPath).isEmpty()); - } - - @Test - public void testSkipMetrics() throws Exception - { - skipMetrics = true; - Iterator segIter = testSegments.iterator(); - DataSegment firstSegment = segIter.next(); - - segmentAnnouncer.announceSegment(firstSegment); - - List zNodes = cf.getChildren().forPath(testSegmentsPath); - - for (String zNode : zNodes) { - DataSegment announcedSegment = Iterables.getOnlyElement(segmentReader.read(joiner.join(testSegmentsPath, zNode))); - Assert.assertEquals(announcedSegment, firstSegment); Assert.assertTrue(announcedSegment.getMetrics().isEmpty()); }