Skip to content

Commit

Permalink
fix format issue
Browse files Browse the repository at this point in the history
  • Loading branch information
sajid riaz committed Dec 7, 2023
1 parent 8aebf63 commit 85f7e56
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit 85f7e56

Please sign in to comment.