@@ -103,24 +103,25 @@ void start() {
103103 logger .log (
104104 Level .WARNING ,
105105 "Provided channelPrimer not an instance of BigtableChannelPrimer, not checking channel health." );
106- } else {
107- Duration initialDelayProbe =
108- Duration .ofMillis (ThreadLocalRandom .current ().nextLong (PROBE_INTERVAL .toMillis ()));
109- this .probeTaskScheduledFuture =
110- executor .scheduleAtFixedRate (
111- this ::runProbes ,
112- initialDelayProbe .toMillis (),
113- PROBE_INTERVAL .toMillis (),
114- TimeUnit .MILLISECONDS );
115- Duration initialDelayDetect =
116- Duration .ofMillis (ThreadLocalRandom .current ().nextLong (PROBE_INTERVAL .toMillis ()));
117- this .detectAndRemoveTaskScheduledFuture =
118- executor .scheduleAtFixedRate (
119- this ::detectAndRemoveOutlierEntries ,
120- initialDelayDetect .toMillis (),
121- PROBE_INTERVAL .toMillis (),
122- TimeUnit .MILLISECONDS );
106+ return ;
123107 }
108+
109+ Duration initialDelayProbe =
110+ Duration .ofMillis (ThreadLocalRandom .current ().nextLong (PROBE_INTERVAL .toMillis ()));
111+ this .probeTaskScheduledFuture =
112+ executor .scheduleAtFixedRate (
113+ this ::runProbes ,
114+ initialDelayProbe .toMillis (),
115+ PROBE_INTERVAL .toMillis (),
116+ TimeUnit .MILLISECONDS );
117+ Duration initialDelayDetect =
118+ Duration .ofMillis (ThreadLocalRandom .current ().nextLong (PROBE_INTERVAL .toMillis ()));
119+ this .detectAndRemoveTaskScheduledFuture =
120+ executor .scheduleAtFixedRate (
121+ this ::detectAndRemoveOutlierEntries ,
122+ initialDelayDetect .toMillis (),
123+ PROBE_INTERVAL .toMillis (),
124+ TimeUnit .MILLISECONDS );
124125 }
125126
126127 /** Stop running health checking */
@@ -140,15 +141,13 @@ void runProbes() {
140141 channelPrimer instanceof BigtableChannelPrimer ,
141142 "Health checking can only be enabled with BigtableChannelPrimer, found %s" ,
142143 channelPrimer );
143- for (Entry entry : this .entrySupplier .get ()) {
144- final Instant startTime = clock .instant ();
145- final ApiFuture <PingAndWarmResponse > probeFuture ;
146-
147- BigtableChannelPrimer primer = (BigtableChannelPrimer ) channelPrimer ;
148- probeFuture = primer .sendPrimeRequestsAsync (entry .getManagedChannel ());
144+ BigtableChannelPrimer primer = (BigtableChannelPrimer ) channelPrimer ;
149145
146+ for (Entry entry : this .entrySupplier .get ()) {
147+ ApiFuture <PingAndWarmResponse > probeFuture =
148+ primer .sendPrimeRequestsAsync (entry .getManagedChannel ());
150149 probeFuture .addListener (
151- () -> onComplete (entry , startTime , probeFuture ), MoreExecutors .directExecutor ());
150+ () -> onComplete (entry , clock . instant () , probeFuture ), MoreExecutors .directExecutor ());
152151 }
153152 }
154153
@@ -161,7 +160,7 @@ void onComplete(Entry entry, Instant startTime, ApiFuture<PingAndWarmResponse> p
161160 success = true ;
162161 } catch (Exception e ) {
163162 success = false ;
164- logger .log (Level .WARNING , "Probe failed" );
163+ logger .log (Level .WARNING , "Probe failed" , e );
165164 }
166165 addProbeResult (entry , ProbeResult .create (startTime , success ));
167166 }
0 commit comments