diff --git a/datamover/source/java/ch/systemsx/cisd/datamover/filesystem/remote/rsync/RsyncCopier.java b/datamover/source/java/ch/systemsx/cisd/datamover/filesystem/remote/rsync/RsyncCopier.java index e125a4c44d4ef2907e25ed4ffa200905acafebbc..de724104048d0d223e40f16ae84ef1860252ae4e 100644 --- a/datamover/source/java/ch/systemsx/cisd/datamover/filesystem/remote/rsync/RsyncCopier.java +++ b/datamover/source/java/ch/systemsx/cisd/datamover/filesystem/remote/rsync/RsyncCopier.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import org.apache.commons.lang.time.DateUtils; import org.apache.log4j.Logger; import ch.systemsx.cisd.common.exceptions.ConfigurationFailureException; @@ -42,6 +43,12 @@ import ch.systemsx.cisd.datamover.filesystem.remote.rsync.RsyncVersionChecker.Rs public final class RsyncCopier implements IPathCopier { + /** + * The maximal period to wait for the <code>rsync</code> list process to finish before killing + * it (<i>30s</i>). + */ + private static final long MILLIS_TO_WAIT_BEFORE_TIMEOUT = 30 * DateUtils.MILLIS_PER_SECOND; + /** * The {@link Status} returned if the process was terminated by {@link Process#destroy()}. */ @@ -156,8 +163,8 @@ public final class RsyncCopier implements IPathCopier // { // return false; // } - return true; - } + return true; + } /** * Checks whether the <code>rsync</code> can be executed and has a version >= 2.6.0. @@ -217,7 +224,8 @@ public final class RsyncCopier implements IPathCopier createCommandLine(sourcePath, sourceHostOrNull, destinationDirectory, destinationHostOrNull); final ProcessResult processResult = - ProcessExecutionHelper.run(commandLine, operationLog, machineLog); + ProcessExecutionHelper.run(commandLine, operationLog, machineLog, + MILLIS_TO_WAIT_BEFORE_TIMEOUT); processResult.log(); return createStatus(processResult); } diff --git a/datamover/source/java/ch/systemsx/cisd/datamover/filesystem/store/FileStoreLocal.java b/datamover/source/java/ch/systemsx/cisd/datamover/filesystem/store/FileStoreLocal.java index 7b4483bf123503ba044b506de84a1f2c09504d0c..808e089c4db78ad8cebd5f1d3637f16e5275964b 100644 --- a/datamover/source/java/ch/systemsx/cisd/datamover/filesystem/store/FileStoreLocal.java +++ b/datamover/source/java/ch/systemsx/cisd/datamover/filesystem/store/FileStoreLocal.java @@ -19,6 +19,8 @@ package ch.systemsx.cisd.datamover.filesystem.store; import java.io.File; import java.io.IOException; +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang.time.DateUtils; import org.apache.log4j.Logger; import ch.systemsx.cisd.common.exceptions.CheckedExceptionTunnel; @@ -113,7 +115,7 @@ public class FileStoreLocal extends FileStore implements IExtendedFileStore public final String tryCheckDirectoryFullyAccessible(final long timeOutMillis) { - final boolean available = FileUtilities.isAvailable(getPath(), timeOutMillis); + final boolean available = FileUtils.waitFor(getPath(), (int) (timeOutMillis / DateUtils.MILLIS_PER_SECOND)); if (available == false) { return String.format( diff --git a/datamover/sourceTest/java/ch/systemsx/cisd/datamover/filesystem/remote/CopyActivityMonitorTest.java b/datamover/sourceTest/java/ch/systemsx/cisd/datamover/filesystem/remote/CopyActivityMonitorTest.java index 52d2f4cfcb280dbe3156b3e38589f5b359027e54..24a477c84d4ab53430c81e6ca00a5ab3418c4a4b 100644 --- a/datamover/sourceTest/java/ch/systemsx/cisd/datamover/filesystem/remote/CopyActivityMonitorTest.java +++ b/datamover/sourceTest/java/ch/systemsx/cisd/datamover/filesystem/remote/CopyActivityMonitorTest.java @@ -345,7 +345,8 @@ public class CopyActivityMonitorTest private final static class PathLastChangedCheckerStalled implements ILastChangedChecker { - private final long MAX_TIME = System.currentTimeMillis() + INACTIVITY_PERIOD_MILLIS * 2; + private final static long MAX_TIME = + System.currentTimeMillis() + INACTIVITY_PERIOD_MILLIS * 2; public long lastChangedRelative(StoreItem item, long stopWhenFindYoungerRelative) {