diff --git a/common/source/java/ch/systemsx/cisd/common/concurrent/InactivityMonitor.java b/common/source/java/ch/systemsx/cisd/common/concurrent/InactivityMonitor.java index cab2161405cf38add8996916452446249d61d300..bd0a5651a62b94f349cf76044150a5ce0e6b951a 100644 --- a/common/source/java/ch/systemsx/cisd/common/concurrent/InactivityMonitor.java +++ b/common/source/java/ch/systemsx/cisd/common/concurrent/InactivityMonitor.java @@ -100,7 +100,6 @@ public class InactivityMonitor * detect and signal time out conditions itself. <i>If an operation on this sensor * hangs infinitely, then the InactivityMonitor hangs, too!</i> * @param observer The observer to inform when the inactivity threshold has been exceeded. - * @param checkIntervallMillis The interval the monitor should use for checking activity status. * @param inactivityThresholdMillis The threshold of a period of inactivity that needs to be * exceeded before the inactivity observer gets informed. * @param stopAfterFirstEvent If <code>true</code>, the monitor will stop itself after the @@ -108,11 +107,10 @@ public class InactivityMonitor * will continue to look for such events. */ public InactivityMonitor(IActivitySensor sensor, IInactivityObserver observer, - long checkIntervallMillis, long inactivityThresholdMillis, boolean stopAfterFirstEvent) + long inactivityThresholdMillis, boolean stopAfterFirstEvent) { assert sensor != null; assert observer != null; - assert checkIntervallMillis > 0; assert inactivityThresholdMillis > 0; this.sensor = sensor; @@ -132,7 +130,10 @@ public class InactivityMonitor activityMonitoringTimer = new Timer(threadNamePrefix + "Activity Monitor", true); final InactivityMonitoringTimerTask inactivityMonitoringTimerTask = new InactivityMonitoringTimerTask(); - activityMonitoringTimer.schedule(inactivityMonitoringTimerTask, 0L, checkIntervallMillis); + activityMonitoringTimer.schedule(inactivityMonitoringTimerTask, 0L, + inactivityThresholdMillis / 2); +// activityMonitoringTimer.schedule(inactivityMonitoringTimerTask, 0L, +// Math.max(inactivityThresholdMillis, inactivityThresholdMillis + 10L)); } /** diff --git a/common/sourceTest/java/ch/systemsx/cisd/common/concurrent/InactivityMonitorTest.java b/common/sourceTest/java/ch/systemsx/cisd/common/concurrent/InactivityMonitorTest.java index a6e7449633aec3f36a12098559d5748c8ea3bf90..7c292e4405499f8a2fd4306ba9781303d9eb2f8a 100644 --- a/common/sourceTest/java/ch/systemsx/cisd/common/concurrent/InactivityMonitorTest.java +++ b/common/sourceTest/java/ch/systemsx/cisd/common/concurrent/InactivityMonitorTest.java @@ -39,8 +39,6 @@ import ch.systemsx.cisd.common.test.StoringUncaughtExceptionHandler; */ public class InactivityMonitorTest { - private final static long CHECK_INTERVAL_MILLIS = 10L; - private final static long INACTIVITY_THRESHOLD_MILLIS = 20L; private static final long TIME_TO_WAIT_MILLIS = 4 * INACTIVITY_THRESHOLD_MILLIS; @@ -105,13 +103,13 @@ public class InactivityMonitorTest private final class ReturnNowMinus extends CustomAction { final long lagTimeMillis; - + ReturnNowMinus(long lagTimeMillis) { super("returns now - " + lagTimeMillis); this.lagTimeMillis = lagTimeMillis; } - + public Object invoke(Invocation invocation) throws Throwable { return (System.currentTimeMillis() - lagTimeMillis); @@ -161,8 +159,7 @@ public class InactivityMonitorTest } }); monitorUnderTest = - new InactivityMonitor(sensor, observer, CHECK_INTERVAL_MILLIS, - INACTIVITY_THRESHOLD_MILLIS, true); + new InactivityMonitor(sensor, observer, INACTIVITY_THRESHOLD_MILLIS, true); ConcurrencyUtilities.sleep(TIME_TO_WAIT_MILLIS); monitorUnderTest.stop(); exceptionHandler.checkAndRethrowException(); @@ -186,8 +183,7 @@ public class InactivityMonitorTest } }); monitorUnderTest = - new InactivityMonitor(sensor, observer, CHECK_INTERVAL_MILLIS, - INACTIVITY_THRESHOLD_MILLIS, true); + new InactivityMonitor(sensor, observer, INACTIVITY_THRESHOLD_MILLIS, true); ConcurrencyUtilities.sleep(TIME_TO_WAIT_MILLIS); monitorUnderTest.stop(); exceptionHandler.checkAndRethrowException(); @@ -201,7 +197,8 @@ public class InactivityMonitorTest context.checking(new Expectations() { { - atLeast(3).of(sensor).getTimeOfLastActivityMoreRecentThan(INACTIVITY_THRESHOLD_MILLIS); + atLeast(3).of(sensor).getTimeOfLastActivityMoreRecentThan( + INACTIVITY_THRESHOLD_MILLIS); will(new ReturnNowMinus(2 * INACTIVITY_THRESHOLD_MILLIS)); atLeast(3).of(sensor).describeInactivity(with(new NowMatcher())); will(returnValue(descriptionOfInactivity)); @@ -211,8 +208,7 @@ public class InactivityMonitorTest } }); monitorUnderTest = - new InactivityMonitor(sensor, observer, CHECK_INTERVAL_MILLIS, - INACTIVITY_THRESHOLD_MILLIS, false); + new InactivityMonitor(sensor, observer, INACTIVITY_THRESHOLD_MILLIS, false); ConcurrencyUtilities.sleep(TIME_TO_WAIT_MILLIS); monitorUnderTest.stop(); exceptionHandler.checkAndRethrowException(); diff --git a/datamover/source/java/ch/systemsx/cisd/datamover/filesystem/remote/RemotePathMover.java b/datamover/source/java/ch/systemsx/cisd/datamover/filesystem/remote/RemotePathMover.java index cdd4aedf0f82395f3778d7b62633a203c1039020..54c71efe40d9fe56b122db580a0db3449ad58020 100644 --- a/datamover/source/java/ch/systemsx/cisd/datamover/filesystem/remote/RemotePathMover.java +++ b/datamover/source/java/ch/systemsx/cisd/datamover/filesystem/remote/RemotePathMover.java @@ -93,8 +93,6 @@ public final class RemotePathMover implements IStoreHandler private final long intervallToWaitAfterFailure; - private final long checkIntervallMillis; - private final long inactivityPeriodMillis; private final int maximalNumberOfRetries; @@ -124,7 +122,6 @@ public final class RemotePathMover implements IStoreHandler this.copier = copier; this.intervallToWaitAfterFailure = timingParameters.getIntervalToWaitAfterFailure(); this.maximalNumberOfRetries = timingParameters.getMaximalNumberOfRetries(); - this.checkIntervallMillis = timingParameters.getCheckIntervalMillis(); this.inactivityPeriodMillis = timingParameters.getInactivityPeriodMillis(); assert intervallToWaitAfterFailure >= 0; @@ -150,7 +147,7 @@ public final class RemotePathMover implements IStoreHandler copier.getClass().getName(), descriptionOfInactivity)); copier.terminate(); } - }, checkIntervallMillis, inactivityPeriodMillis, true); + }, inactivityPeriodMillis, true); final Status copyStatus = copier.copy(item); monitor.stop(); return copyStatus;