static boolean isSuspectedFailureCredible(String instanceName) { long timeNow = System.currentTimeMillis(); Long suspectedFailureTimeMillis = (Long) suspectedFailures.get((String) instanceName); if (suspectedFailureTimeMillis != null) { removeSuspectedFailure(instanceName); if ((timeNow - suspectedFailureTimeMillis.longValue()) < 6000) { System.out.println("credible suspected failure of " + instanceName); return true; } else { System.out.println("suspected failure is not pending or more than 6 sec old"); // add the new suspected failure addSuspectedFailure(instanceName); return false; } } else { // this is the first suspected failure - adding it System.out.println( "Received Suspected Failure Notification: adding suspected failure for" + instanceName); addSuspectedFailure(instanceName); return false; } }
static void addSuspectedFailure(String instanceName) { suspectedFailures.put(instanceName, new Long(System.currentTimeMillis())); }