From 85f7e565d7915c868472a11c74f28a19d54db4df Mon Sep 17 00:00:00 2001 From: sajid riaz Date: Thu, 7 Dec 2023 17:20:34 +0100 Subject: [PATCH] fix format issue --- .../bss/cassandra/ecchronos/core/JmxProxy.java | 9 ++++++++- .../cassandra/ecchronos/core/repair/RepairTask.java | 10 ++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/JmxProxy.java b/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/JmxProxy.java index 54f72a84c..19b0a6b24 100644 --- a/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/JmxProxy.java +++ b/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/JmxProxy.java @@ -109,5 +109,12 @@ public interface JmxProxy extends Closeable */ double getPercentRepaired(TableReference tableReference); - String getNodeStatus() ; + /** + * Retrieves the current operational status of the local Cassandra node via JMX. + * Returns a string indicating the node's state (e.g., "NORMAL", "JOINING", "LEAVING", "MOVING") + * or "Unknown" if the status is undeterminable. + * + * @return A string representing the node's status. + */ + String getNodeStatus(); } diff --git a/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/RepairTask.java b/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/RepairTask.java index bbb5a341d..f7ccd7f9a 100644 --- a/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/RepairTask.java +++ b/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/RepairTask.java @@ -47,6 +47,7 @@ public abstract class RepairTask implements NotificationListener private static final Logger LOG = LoggerFactory.getLogger(RepairTask.class); private static final Pattern RANGE_PATTERN = Pattern.compile("\\((-?[0-9]+),(-?[0-9]+)\\]"); private static final long HANG_PREVENT_TIME_IN_MINUTES = 30; + private static final long HEALTH_CHECK_TIME_IN_MINUTES = 10; private final ScheduledExecutorService myExecutor = Executors.newSingleThreadScheduledExecutor( new ThreadFactoryBuilder().setNameFormat("HangPreventingTask-%d").build()); private final ScheduledExecutorService myHealthCheckExecutor = Executors.newSingleThreadScheduledExecutor( @@ -88,7 +89,7 @@ public void execute() throws ScheduledJobException onExecute(); try (JmxProxy proxy = myJmxProxyFactory.connect()) { - if(!isNodeOperational(proxy)) + if (!isNodeOperational(proxy)) { LOG.debug("Local Cassandra node is down, aborting repair task."); new Exception(); @@ -141,7 +142,7 @@ private void repair(final JmxProxy proxy) throws ScheduledJobException myLastError = new ScheduledJobException("Node became non-operational during repair"); myLatch.countDown(); } - }, 0, 10, TimeUnit.MINUTES); // Check every 10 minute + }, 0, HEALTH_CHECK_TIME_IN_MINUTES, TimeUnit.MINUTES); // Check every 10 minute myLatch.await(); proxy.removeStorageServiceListener(this); verifyRepair(proxy); @@ -173,7 +174,7 @@ private void repair(final JmxProxy proxy) throws ScheduledJobException } } - private boolean isNodeOperational(JmxProxy proxy) + private boolean isNodeOperational(final JmxProxy proxy) { String nodeStatus = proxy.getNodeStatus(); LOG.debug("Node Status {} ", nodeStatus); @@ -291,7 +292,8 @@ private void rescheduleHangPrevention() { myHangPreventFuture.cancel(false); } - myHangPreventFuture = myExecutor.schedule(new HangPreventingTask(), HANG_PREVENT_TIME_IN_MINUTES, TimeUnit.MINUTES); + myHangPreventFuture = myExecutor.schedule(new HangPreventingTask(), + HANG_PREVENT_TIME_IN_MINUTES, TimeUnit.MINUTES); } /**