diff --git a/common/source/java/ch/systemsx/cisd/common/filesystem/ILastModificationChecker.java b/common/source/java/ch/systemsx/cisd/common/filesystem/ILastModificationChecker.java new file mode 100644 index 0000000000000000000000000000000000000000..902a30646c168a45549ed7b92c54a860d220a68f --- /dev/null +++ b/common/source/java/ch/systemsx/cisd/common/filesystem/ILastModificationChecker.java @@ -0,0 +1,37 @@ +/* + * Copyright 2009 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.common.filesystem; + +import ch.systemsx.cisd.common.exceptions.StatusWithResult; + +public interface ILastModificationChecker +{ + /** + * Returns the last time when there was a write access to <var>item</var>. + * + * @param item The {@link StoreItem} to check. + * @param stopWhenFindYounger The time measured from the beginning of the epoch. If > 0, + * the recursive search for younger file will be stopped when a file or directory + * is found that is younger than the time specified in this parameter. Supposed + * to be used when one does not care about the absolutely youngest entry, but + * only, if there are entries that are "young enough". + * @return The time (in milliseconds since the start of the epoch) when <var>resource</var> + * was last changed or error status if checking failed. + */ + public StatusWithResult<Long> lastChanged(StoreItem item, long stopWhenFindYounger); + +} \ No newline at end of file diff --git a/common/source/java/ch/systemsx/cisd/common/filesystem/QuietPeriodFileFilter.java b/common/source/java/ch/systemsx/cisd/common/filesystem/QuietPeriodFileFilter.java index b9a56e5e62a9b7c3dab05deeab5659da488b1cc7..6e517acbc58df11c87ea5926118ebce54e984488 100644 --- a/common/source/java/ch/systemsx/cisd/common/filesystem/QuietPeriodFileFilter.java +++ b/common/source/java/ch/systemsx/cisd/common/filesystem/QuietPeriodFileFilter.java @@ -79,24 +79,6 @@ public class QuietPeriodFileFilter implements IStoreItemFilter private int callCounter; - public interface ILastModificationChecker - { - /** - * Returns the last time when there was a write access to <var>item</var>. - * - * @param item The {@link StoreItem} to check. - * @param stopWhenFindYounger The time measured from the beginning of the epoch. If > 0, - * the recursive search for younger file will be stopped when a file or directory - * is found that is younger than the time specified in this parameter. Supposed - * to be used when one does not care about the absolutely youngest entry, but - * only, if there are entries that are "young enough". - * @return The time (in milliseconds since the start of the epoch) when <var>resource</var> - * was last changed or error status if checking failed. - */ - public StatusWithResult<Long> lastChanged(StoreItem item, long stopWhenFindYounger); - - } - /** * A value object that holds the information about the last check performed for a path. */ diff --git a/common/sourceTest/java/ch/systemsx/cisd/common/filesystem/QuietPeriodFileFilterTest.java b/common/sourceTest/java/ch/systemsx/cisd/common/filesystem/QuietPeriodFileFilterTest.java index b0510a93af304c931de8c04d95c0bfb9d9ebeb17..51416be7f695ee1ffd2c867b394324b66569aec8 100644 --- a/common/sourceTest/java/ch/systemsx/cisd/common/filesystem/QuietPeriodFileFilterTest.java +++ b/common/sourceTest/java/ch/systemsx/cisd/common/filesystem/QuietPeriodFileFilterTest.java @@ -33,7 +33,6 @@ import ch.rinn.restrictions.Friend; import ch.systemsx.cisd.common.exceptions.StatusWithResult; import ch.systemsx.cisd.common.filesystem.QuietPeriodFileFilter; import ch.systemsx.cisd.common.filesystem.StoreItem; -import ch.systemsx.cisd.common.filesystem.QuietPeriodFileFilter.ILastModificationChecker; import ch.systemsx.cisd.common.logging.LogCategory; import ch.systemsx.cisd.common.test.LogMonitoringAppender; import ch.systemsx.cisd.common.utilities.ITimeProvider; diff --git a/datamover/source/java/ch/systemsx/cisd/datamover/filesystem/intf/IFileStore.java b/datamover/source/java/ch/systemsx/cisd/datamover/filesystem/intf/IFileStore.java index 3276d90fba9eeb679daa117b403bbb1070aa4140..b56e8fa32ee0b98eb1470a0262e564b71d616ce6 100644 --- a/datamover/source/java/ch/systemsx/cisd/datamover/filesystem/intf/IFileStore.java +++ b/datamover/source/java/ch/systemsx/cisd/datamover/filesystem/intf/IFileStore.java @@ -18,8 +18,8 @@ package ch.systemsx.cisd.datamover.filesystem.intf; import ch.systemsx.cisd.common.exceptions.Status; import ch.systemsx.cisd.common.exceptions.StatusWithResult; +import ch.systemsx.cisd.common.filesystem.ILastModificationChecker; import ch.systemsx.cisd.common.filesystem.StoreItem; -import ch.systemsx.cisd.common.filesystem.QuietPeriodFileFilter.ILastModificationChecker; import ch.systemsx.cisd.common.highwatermark.HighwaterMarkWatcher; import ch.systemsx.cisd.common.logging.ISimpleLogger; import ch.systemsx.cisd.common.utilities.ISelfTestable; diff --git a/datastore_server/source/java/ch/systemsx/cisd/etlserver/ETLDaemon.java b/datastore_server/source/java/ch/systemsx/cisd/etlserver/ETLDaemon.java index 3814d5794327bba9cfe78ef4a0af7cff6b8b55f8..70a74ccce2f34b6241688eae6d6fe14c81db9c62 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/etlserver/ETLDaemon.java +++ b/datastore_server/source/java/ch/systemsx/cisd/etlserver/ETLDaemon.java @@ -28,6 +28,7 @@ import java.util.Timer; import java.util.concurrent.TimeUnit; import org.apache.commons.io.filefilter.FileFilterUtils; +import org.apache.commons.io.filefilter.IOFileFilter; import org.apache.commons.io.filefilter.NameFileFilter; import org.apache.log4j.Level; import org.apache.log4j.Logger; @@ -347,8 +348,7 @@ public final class ETLDaemon createDirectoryScanningHandler(pathHandler, highwaterMarkWatcher, incomingDataDirectory, storeRootDir, processorFactories.values()); final DirectoryScanningTimerTask dataMonitorTask = - new DirectoryScanningTimerTask(incomingDataDirectory, FileFilterUtils - .prefixFileFilter(Constants.IS_FINISHED_PREFIX), pathHandler, + createDirectoryScanningTimerTask(incomingDataDirectory, pathHandler, directoryScanningHandler); selfTest(incomingDataDirectory, authorizedLimsService, pathHandler); final String timerThreadName = @@ -359,6 +359,15 @@ public final class ETLDaemon threadParameters.getThreadName()); } + private static DirectoryScanningTimerTask createDirectoryScanningTimerTask( + final File incomingDataDirectory, final TransferredDataSetHandler pathHandler, + final HighwaterMarkDirectoryScanningHandler directoryScanningHandler) + { + IOFileFilter filter = FileFilterUtils.prefixFileFilter(Constants.IS_FINISHED_PREFIX); + return new DirectoryScanningTimerTask(incomingDataDirectory, filter, pathHandler, + directoryScanningHandler); + } + private static void addShutdownHookForCleanup(final Timer workerTimer, final TransferredDataSetHandler mover, final long timeoutMillis, final String threadName) {