From 8ffc82a84f11e5ff8d1e5df5865ae15fbcd639b4 Mon Sep 17 00:00:00 2001 From: Andrew Ho Date: Fri, 21 Jul 2023 11:41:47 -0700 Subject: [PATCH 1/5] Fix time unit for handoff in CoordinatorBasedSegmentHandoffNotifier --- .../handoff/CoordinatorBasedSegmentHandoffNotifier.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/org/apache/druid/segment/handoff/CoordinatorBasedSegmentHandoffNotifier.java b/server/src/main/java/org/apache/druid/segment/handoff/CoordinatorBasedSegmentHandoffNotifier.java index 09a55003662b..5e3d1761b443 100644 --- a/server/src/main/java/org/apache/druid/segment/handoff/CoordinatorBasedSegmentHandoffNotifier.java +++ b/server/src/main/java/org/apache/druid/segment/handoff/CoordinatorBasedSegmentHandoffNotifier.java @@ -114,7 +114,7 @@ void checkForSegmentHandoffs() catch (Exception e) { log.error( e, - "Exception while checking handoff for dataSource[%s] Segment[%s], Will try again after [%d]secs", + "Exception while checking handoff for dataSource[%s] Segment[%s], Will try again after [%d]ms", dataSource, descriptor, pollDurationMillis @@ -128,7 +128,7 @@ void checkForSegmentHandoffs() catch (Throwable t) { log.error( t, - "Exception while checking handoff for dataSource[%s], Will try again after [%d]secs", + "Exception while checking handoff for dataSource[%s], Will try again after [%d]ms", dataSource, pollDurationMillis ); From 085505031e51d425bd6c335d7616df34d6054dbe Mon Sep 17 00:00:00 2001 From: Andrew Ho Date: Fri, 21 Jul 2023 16:09:13 -0700 Subject: [PATCH 2/5] Log time in ISO 8601 --- .../handoff/CoordinatorBasedSegmentHandoffNotifier.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/server/src/main/java/org/apache/druid/segment/handoff/CoordinatorBasedSegmentHandoffNotifier.java b/server/src/main/java/org/apache/druid/segment/handoff/CoordinatorBasedSegmentHandoffNotifier.java index 5e3d1761b443..b6a8852643b1 100644 --- a/server/src/main/java/org/apache/druid/segment/handoff/CoordinatorBasedSegmentHandoffNotifier.java +++ b/server/src/main/java/org/apache/druid/segment/handoff/CoordinatorBasedSegmentHandoffNotifier.java @@ -27,6 +27,7 @@ import org.apache.druid.query.SegmentDescriptor; import org.apache.druid.server.coordination.DruidServerMetadata; +import java.time.Duration; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -114,10 +115,10 @@ void checkForSegmentHandoffs() catch (Exception e) { log.error( e, - "Exception while checking handoff for dataSource[%s] Segment[%s], Will try again after [%d]ms", + "Exception while checking handoff for dataSource[%s] Segment[%s]; will try again after [%s]", dataSource, descriptor, - pollDurationMillis + Duration.ofMillis(pollDurationMillis).toString() ); } } @@ -128,9 +129,9 @@ void checkForSegmentHandoffs() catch (Throwable t) { log.error( t, - "Exception while checking handoff for dataSource[%s], Will try again after [%d]ms", + "Exception while checking handoff for dataSource[%s]; will try again after [%s]", dataSource, - pollDurationMillis + Duration.ofMillis(pollDurationMillis).toString() ); } } From 0d3465598c05a6066e095f01d69a97c20b41b994 Mon Sep 17 00:00:00 2001 From: Andrew Ho Date: Sat, 22 Jul 2023 19:39:35 -0700 Subject: [PATCH 3/5] Update pollDuration from long to Duration --- .../CoordinatorBasedSegmentHandoffNotifier.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/server/src/main/java/org/apache/druid/segment/handoff/CoordinatorBasedSegmentHandoffNotifier.java b/server/src/main/java/org/apache/druid/segment/handoff/CoordinatorBasedSegmentHandoffNotifier.java index b6a8852643b1..a499896ec1b0 100644 --- a/server/src/main/java/org/apache/druid/segment/handoff/CoordinatorBasedSegmentHandoffNotifier.java +++ b/server/src/main/java/org/apache/druid/segment/handoff/CoordinatorBasedSegmentHandoffNotifier.java @@ -27,7 +27,7 @@ import org.apache.druid.query.SegmentDescriptor; import org.apache.druid.server.coordination.DruidServerMetadata; -import java.time.Duration; +import org.joda.time.Duration; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -44,7 +44,7 @@ public class CoordinatorBasedSegmentHandoffNotifier implements SegmentHandoffNot private final ConcurrentMap> handOffCallbacks = new ConcurrentHashMap<>(); private final CoordinatorClient coordinatorClient; private volatile ScheduledExecutorService scheduledExecutor; - private final long pollDurationMillis; + private final Duration pollDuration; private final String dataSource; public CoordinatorBasedSegmentHandoffNotifier( @@ -55,7 +55,7 @@ public CoordinatorBasedSegmentHandoffNotifier( { this.dataSource = dataSource; this.coordinatorClient = coordinatorClient; - this.pollDurationMillis = config.getPollDuration().getMillis(); + this.pollDuration = config.getPollDuration(); } @Override @@ -81,7 +81,7 @@ public void run() { checkForSegmentHandoffs(); } - }, 0L, pollDurationMillis, TimeUnit.MILLISECONDS + }, 0L, pollDuration.getMillis(), TimeUnit.MILLISECONDS ); } @@ -118,7 +118,7 @@ void checkForSegmentHandoffs() "Exception while checking handoff for dataSource[%s] Segment[%s]; will try again after [%s]", dataSource, descriptor, - Duration.ofMillis(pollDurationMillis).toString() + pollDuration.toString() ); } } @@ -131,7 +131,7 @@ void checkForSegmentHandoffs() t, "Exception while checking handoff for dataSource[%s]; will try again after [%s]", dataSource, - Duration.ofMillis(pollDurationMillis).toString() + pollDuration.toString() ); } } From 9f397d2934f618229ac4cbfcf6d8776fcc3caadd Mon Sep 17 00:00:00 2001 From: Andrew Ho Date: Sat, 22 Jul 2023 22:23:46 -0700 Subject: [PATCH 4/5] Remove unneeded toString --- .../handoff/CoordinatorBasedSegmentHandoffNotifier.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/org/apache/druid/segment/handoff/CoordinatorBasedSegmentHandoffNotifier.java b/server/src/main/java/org/apache/druid/segment/handoff/CoordinatorBasedSegmentHandoffNotifier.java index a499896ec1b0..bee4d298ae55 100644 --- a/server/src/main/java/org/apache/druid/segment/handoff/CoordinatorBasedSegmentHandoffNotifier.java +++ b/server/src/main/java/org/apache/druid/segment/handoff/CoordinatorBasedSegmentHandoffNotifier.java @@ -118,7 +118,7 @@ void checkForSegmentHandoffs() "Exception while checking handoff for dataSource[%s] Segment[%s]; will try again after [%s]", dataSource, descriptor, - pollDuration.toString() + pollDuration ); } } @@ -131,7 +131,7 @@ void checkForSegmentHandoffs() t, "Exception while checking handoff for dataSource[%s]; will try again after [%s]", dataSource, - pollDuration.toString() + pollDuration ); } } From af7af8ed5aa045c20841e4fc29700c11be07f6dd Mon Sep 17 00:00:00 2001 From: Andrew Ho Date: Sun, 23 Jul 2023 10:06:43 -0700 Subject: [PATCH 5/5] Fix checkstyle error --- .../segment/handoff/CoordinatorBasedSegmentHandoffNotifier.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/org/apache/druid/segment/handoff/CoordinatorBasedSegmentHandoffNotifier.java b/server/src/main/java/org/apache/druid/segment/handoff/CoordinatorBasedSegmentHandoffNotifier.java index bee4d298ae55..4e4b4debc9c6 100644 --- a/server/src/main/java/org/apache/druid/segment/handoff/CoordinatorBasedSegmentHandoffNotifier.java +++ b/server/src/main/java/org/apache/druid/segment/handoff/CoordinatorBasedSegmentHandoffNotifier.java @@ -26,8 +26,8 @@ import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.query.SegmentDescriptor; import org.apache.druid.server.coordination.DruidServerMetadata; - import org.joda.time.Duration; + import java.util.Iterator; import java.util.List; import java.util.Map;