From 1fe61bc869924d51a3e3133a5894afb3896640af Mon Sep 17 00:00:00 2001 From: Gian Merlino Date: Fri, 7 Jul 2023 05:54:39 -0700 Subject: [PATCH] ChangeRequestHttpSyncer: Don't wait 1ms when checking isInitialized(). (#14547) The wait doesn't seem to serve a purpose, other than causing delays when checking isInitialized() for a large number of things that have not yet been initialized. --- .../apache/druid/indexing/overlord/hrtr/WorkerHolder.java | 8 +------- .../org/apache/druid/client/HttpServerInventoryView.java | 7 +------ .../server/coordination/ChangeRequestHttpSyncer.java | 6 +++--- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/hrtr/WorkerHolder.java b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/hrtr/WorkerHolder.java index a8fc5306048..5e581d815ce 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/overlord/hrtr/WorkerHolder.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/overlord/hrtr/WorkerHolder.java @@ -346,13 +346,7 @@ public class WorkerHolder public boolean isInitialized() { - try { - return syncer.isInitialized(); - } - catch (InterruptedException ignored) { - Thread.currentThread().interrupt(); - return false; - } + return syncer.isInitialized(); } public boolean isEnabled() diff --git a/server/src/main/java/org/apache/druid/client/HttpServerInventoryView.java b/server/src/main/java/org/apache/druid/client/HttpServerInventoryView.java index ebc67527941..2c30c168132 100644 --- a/server/src/main/java/org/apache/druid/client/HttpServerInventoryView.java +++ b/server/src/main/java/org/apache/druid/client/HttpServerInventoryView.java @@ -571,12 +571,7 @@ public class HttpServerInventoryView implements ServerInventoryView, FilteredSer boolean isSyncedSuccessfullyAtleastOnce() { - try { - return syncer.isInitialized(); - } - catch (InterruptedException ex) { - throw new ISE(ex, "Interrupted while waiting for first sync with server[%s].", druidServer.getName()); - } + return syncer.isInitialized(); } private ChangeRequestHttpSyncer.Listener createSyncListener() diff --git a/server/src/main/java/org/apache/druid/server/coordination/ChangeRequestHttpSyncer.java b/server/src/main/java/org/apache/druid/server/coordination/ChangeRequestHttpSyncer.java index 8af89425ae0..2d256b68806 100644 --- a/server/src/main/java/org/apache/druid/server/coordination/ChangeRequestHttpSyncer.java +++ b/server/src/main/java/org/apache/druid/server/coordination/ChangeRequestHttpSyncer.java @@ -172,11 +172,11 @@ public class ChangeRequestHttpSyncer } /** - * Waits upto 1 millisecond for the first successful sync with this server. + * Whether this server has been synced successfully at least once. */ - public boolean isInitialized() throws InterruptedException + public boolean isInitialized() { - return initializationLatch.await(1, TimeUnit.MILLISECONDS); + return initializationLatch.getCount() == 0; } /**