@@ -74,12 +74,15 @@ public class LocalNewSessionQueue extends NewSessionQueue {
74
74
private final ScheduledExecutorService executorService =
75
75
Executors .newSingleThreadScheduledExecutor ();
76
76
private final Thread shutdownHook = new Thread (this ::callExecutorShutdown );
77
- private final String timedOutErrorMessage =
78
- String . format ( "New session request rejected after being in the queue for more than %s" ,
79
- requestTimeout );
77
+ private final String timedOutErrorMessage = String . format (
78
+ "New session request rejected after being in the queue for more than %s" ,
79
+ format ( requestTimeout ) );
80
80
81
- public LocalNewSessionQueue (Tracer tracer , EventBus bus , Duration retryInterval ,
82
- Duration requestTimeout ) {
81
+ public LocalNewSessionQueue (
82
+ Tracer tracer ,
83
+ EventBus bus ,
84
+ Duration retryInterval ,
85
+ Duration requestTimeout ) {
83
86
super (tracer , retryInterval , requestTimeout );
84
87
this .bus = Require .nonNull ("Event bus" , bus );
85
88
Runtime .getRuntime ().addShutdownHook (shutdownHook );
@@ -301,5 +304,21 @@ public void callExecutorShutdown() {
301
304
LOG .info ("Shutting down session queue executor service" );
302
305
executorService .shutdown ();
303
306
}
307
+
308
+ private static String format (Duration duration ) {
309
+ long hours = duration .toHours ();
310
+ int minutes = (int ) duration .toMinutes () % 60 ;
311
+ int secs = (int ) (duration .getSeconds () % 60 );
312
+
313
+ StringBuilder toReturn = new StringBuilder ();
314
+ if (hours != 0 ) {
315
+ toReturn .append (hours ).append ("h " );
316
+ }
317
+ if (hours != 0 || minutes != 0 ) {
318
+ toReturn .append (minutes ).append ("m " );
319
+ }
320
+ toReturn .append (secs ).append ("s" );
321
+ return toReturn .toString ();
322
+ }
304
323
}
305
324
0 commit comments