From 03e1fb6f3f3396ec0dc968d6896e6398a82edf9a Mon Sep 17 00:00:00 2001 From: nishantmonu51 Date: Thu, 5 Jun 2014 23:14:51 +0530 Subject: [PATCH] reduce memory usage for end points do not copy entire segments when not needed, reduces memory pressure on the coordinator when no. of segments is large enough. --- .../server/coordinator/DruidCoordinator.java | 19 ++++++++++++++++++- .../DruidCoordinatorSegmentInfoLoader.java | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/io/druid/server/coordinator/DruidCoordinator.java b/server/src/main/java/io/druid/server/coordinator/DruidCoordinator.java index f57bd87ebd5..97c1a3eab61 100644 --- a/server/src/main/java/io/druid/server/coordinator/DruidCoordinator.java +++ b/server/src/main/java/io/druid/server/coordinator/DruidCoordinator.java @@ -422,7 +422,7 @@ public class DruidCoordinator } } - public Set getAvailableDataSegments() + public Set getOrderedAvailableDataSegments() { Set availableSegments = Sets.newTreeSet(Comparators.inverse(DataSegment.bucketMonthComparator())); @@ -452,6 +452,23 @@ public class DruidCoordinator return availableSegments; } + public Iterable getAvailableDataSegments() + { + return Iterables.concat( + Iterables.transform( + databaseSegmentManager.getInventory(), + new Function>() + { + @Override + public Iterable apply(DruidDataSource input) + { + return input.getSegments(); + } + } + ) + ); + } + @LifecycleStart public void start() { diff --git a/server/src/main/java/io/druid/server/coordinator/helper/DruidCoordinatorSegmentInfoLoader.java b/server/src/main/java/io/druid/server/coordinator/helper/DruidCoordinatorSegmentInfoLoader.java index 8980bfded90..ea5485cb2b6 100644 --- a/server/src/main/java/io/druid/server/coordinator/helper/DruidCoordinatorSegmentInfoLoader.java +++ b/server/src/main/java/io/druid/server/coordinator/helper/DruidCoordinatorSegmentInfoLoader.java @@ -41,7 +41,7 @@ public class DruidCoordinatorSegmentInfoLoader implements DruidCoordinatorHelper public DruidCoordinatorRuntimeParams run(DruidCoordinatorRuntimeParams params) { // Display info about all available segments - final Set availableSegments = coordinator.getAvailableDataSegments(); + final Set availableSegments = coordinator.getOrderedAvailableDataSegments(); if (log.isDebugEnabled()) { log.debug("Available DataSegments"); for (DataSegment dataSegment : availableSegments) {