Skip to content

Commit a56e728

Browse files
committed
Addressed review feedback for TimeValue instead of just seconds
1 parent 0514724 commit a56e728

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

server/src/main/java/org/elasticsearch/cluster/NodeConnectionsService.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -402,17 +402,17 @@ public void onNodeConnected(DiscoveryNode node, Transport.Connection connection)
402402

403403
if (disconnectionHistory != null) {
404404
long millisSinceDisconnect = threadPool.absoluteTimeInMillis() - disconnectionHistory.disconnectTimeMillis;
405-
long secondsSinceDisconnect = millisSinceDisconnect / 1000;
405+
TimeValue timeValueSinceDisconnect = TimeValue.timeValueMillis(millisSinceDisconnect);
406406
if (disconnectionHistory.disconnectCause != null) {
407407
logger.warn(
408408
() -> format(
409409
"""
410410
reopened transport connection to node [%s] \
411-
which disconnected exceptionally [%ds/%dms] ago but did not \
411+
which disconnected exceptionally [%s/%dms] ago but did not \
412412
restart, so the disconnection is unexpected; \
413413
see [%s] for troubleshooting guidance""",
414414
node.descriptionWithoutAttributes(),
415-
secondsSinceDisconnect,
415+
timeValueSinceDisconnect,
416416
millisSinceDisconnect,
417417
ReferenceDocs.NETWORK_DISCONNECT_TROUBLESHOOTING
418418
),
@@ -422,11 +422,11 @@ public void onNodeConnected(DiscoveryNode node, Transport.Connection connection)
422422
logger.warn(
423423
"""
424424
reopened transport connection to node [{}] \
425-
which disconnected gracefully [{}s/{}ms] ago but did not \
425+
which disconnected gracefully [{}/{}ms] ago but did not \
426426
restart, so the disconnection is unexpected; \
427427
see [{}] for troubleshooting guidance""",
428428
node.descriptionWithoutAttributes(),
429-
secondsSinceDisconnect,
429+
timeValueSinceDisconnect,
430430
millisSinceDisconnect,
431431
ReferenceDocs.NETWORK_DISCONNECT_TROUBLESHOOTING
432432
);

server/src/test/java/org/elasticsearch/cluster/NodeConnectionsServiceTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ public void testDisconnectionHistory() {
253253
final DeterministicTaskQueue deterministicTaskQueue = new DeterministicTaskQueue();
254254
final ThreadPool threadPool = deterministicTaskQueue.getThreadPool();
255255
final long reconnectIntervalMillis = CLUSTER_NODE_RECONNECT_INTERVAL_SETTING.get(Settings.EMPTY).millis();
256-
final long reconnectIntervalSeconds = reconnectIntervalMillis / 1000;
256+
final TimeValue reconnectIntervalTimeValue = TimeValue.timeValueMillis(reconnectIntervalMillis);
257257

258258
MockTransport transport = new MockTransport(threadPool);
259259
TestTransportService transportService = new TestTransportService(transport, threadPool);
@@ -297,8 +297,8 @@ public void testDisconnectionHistory() {
297297
"reopened transport connection to node ["
298298
+ gracefulClose.descriptionWithoutAttributes()
299299
+ "] which disconnected gracefully ["
300-
+ reconnectIntervalSeconds
301-
+ "s/"
300+
+ reconnectIntervalTimeValue
301+
+ "/"
302302
+ reconnectIntervalMillis
303303
+ "ms] ago "
304304
+ "but did not restart, so the disconnection is unexpected; "
@@ -313,8 +313,8 @@ public void testDisconnectionHistory() {
313313
"reopened transport connection to node ["
314314
+ exceptionalClose.descriptionWithoutAttributes()
315315
+ "] which disconnected exceptionally ["
316-
+ reconnectIntervalSeconds
317-
+ "s/"
316+
+ reconnectIntervalTimeValue
317+
+ "/"
318318
+ reconnectIntervalMillis
319319
+ "ms] ago "
320320
+ "but did not restart, so the disconnection is unexpected; "

0 commit comments

Comments
 (0)