From 3d858c9fa85c2affc6911e4736548e40a624bffc Mon Sep 17 00:00:00 2001 From: tpylak <tpylak> Date: Wed, 8 Apr 2009 11:38:20 +0000 Subject: [PATCH] LMS-823 minor refactoring SVN: 10628 --- .../filesystem/ILastModificationChecker.java | 37 +++++++++++++++++++ .../filesystem/QuietPeriodFileFilter.java | 18 --------- .../filesystem/QuietPeriodFileFilterTest.java | 1 - .../datamover/filesystem/intf/IFileStore.java | 2 +- .../ch/systemsx/cisd/etlserver/ETLDaemon.java | 13 ++++++- 5 files changed, 49 insertions(+), 22 deletions(-) create mode 100644 common/source/java/ch/systemsx/cisd/common/filesystem/ILastModificationChecker.java 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 00000000000..902a30646c1 --- /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 b9a56e5e62a..6e517acbc58 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 b0510a93af3..51416be7f69 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 3276d90fba9..b56e8fa32ee 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 3814d579432..70a74ccce2f 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) { -- GitLab