diff --git a/datamover/source/java/ch/systemsx/cisd/datamover/IncomingProcessor.java b/datamover/source/java/ch/systemsx/cisd/datamover/IncomingProcessor.java index 2006e8d6b37cdac73111e00bc2524e75df4b4b89..913f6a584bfd4833005dfa4e2e357880cc238290 100644 --- a/datamover/source/java/ch/systemsx/cisd/datamover/IncomingProcessor.java +++ b/datamover/source/java/ch/systemsx/cisd/datamover/IncomingProcessor.java @@ -142,37 +142,38 @@ public class IncomingProcessor { return new IPathHandler() { - public boolean handle(File sourceFile) + public void handle(File sourceFile) { if (isIncomingRemote) { - return moveFromRemoteIncoming(sourceFile, sourceHostOrNull, localProcessor); + moveFromRemoteIncoming(sourceFile, sourceHostOrNull, localProcessor); } else { - return moveFromLocalIncoming(sourceFile, localProcessor); + moveFromLocalIncoming(sourceFile, localProcessor); } } }; } - private boolean moveFromLocalIncoming(File source, IPathHandler localProcessor) + private void moveFromLocalIncoming(File source, IPathHandler localProcessor) { final File finalFile = tryMoveLocal(source, bufferDirs.getCopyCompleteDir(), parameters.getPrefixForIncoming()); if (finalFile == null) { - return false; + return; } - return localProcessor.handle(finalFile); + localProcessor.handle(finalFile); } - private boolean moveFromRemoteIncoming(File source, String sourceHostOrNull, IPathHandler localProcessor) + private void moveFromRemoteIncoming(File source, String sourceHostOrNull, IPathHandler localProcessor) { // 1. move from incoming: copy, delete, create copy-finished-marker final File copyInProgressDir = bufferDirs.getCopyInProgressDir(); - final boolean ok = moveFromRemoteToLocal(source, sourceHostOrNull, copyInProgressDir); - if (ok == false) + moveFromRemoteToLocal(source, sourceHostOrNull, copyInProgressDir); + final File destFile = new File(copyInProgressDir, source.getName()); + if (destFile.exists() == false) { - return false; + return; } final File copiedFile = new File(copyInProgressDir, source.getName()); assert copiedFile.exists() : copiedFile.getAbsolutePath(); @@ -183,12 +184,11 @@ public class IncomingProcessor final File finalFile = tryMoveFromInProgressToFinished(copiedFile, markerFile, bufferDirs.getCopyCompleteDir()); if (finalFile == null) { - return false; + return; } // 3. schedule local processing, always successful localProcessor.handle(finalFile); - return true; } private File tryMoveFromInProgressToFinished(File copiedFile, File markerFileOrNull, File copyCompleteDir) @@ -207,9 +207,9 @@ public class IncomingProcessor } } - private boolean moveFromRemoteToLocal(File source, String sourceHostOrNull, File localDestDir) + private void moveFromRemoteToLocal(File source, String sourceHostOrNull, File localDestDir) { - return createRemotePathMover(sourceHostOrNull, localDestDir, null).handle(source); + createRemotePathMover(sourceHostOrNull, localDestDir, null).handle(source); } private IPathHandler createRemotePathMover(String sourceHost, File destinationDirectory, String destinationHost) diff --git a/datamover/source/java/ch/systemsx/cisd/datamover/LocalProcessor.java b/datamover/source/java/ch/systemsx/cisd/datamover/LocalProcessor.java index 252be2a7306c72319e524d36df7756c813f7e956..16fcfaec4638097763c12e060527228afdf95ddc 100644 --- a/datamover/source/java/ch/systemsx/cisd/datamover/LocalProcessor.java +++ b/datamover/source/java/ch/systemsx/cisd/datamover/LocalProcessor.java @@ -147,15 +147,14 @@ public class LocalProcessor implements IPathHandler // ---------------- - public boolean handle(File path) + public void handle(File path) { - final Boolean result = tryMoveManualOrClean(path); - if (result != null) + final boolean continueProcessing = doMoveManualOrClean(path); + if (continueProcessing == false) { - return result.booleanValue(); // stop processing + return; // stop processing } - boolean ok = true; File extraTmpCopy = null; if (extraCopyDirOrNull != null) { @@ -163,7 +162,6 @@ public class LocalProcessor implements IPathHandler if (extraTmpCopy == null) { notificationLog.error(String.format("Creating extra copy of '%s' failed.", path)); - ok = false; } } @@ -175,7 +173,6 @@ public class LocalProcessor implements IPathHandler { notificationLog.error(String .format("Moving '%s' to '%s' for final moving process failed.", path, outputDir)); - ok = false; } if (extraTmpCopy != null) @@ -186,22 +183,20 @@ public class LocalProcessor implements IPathHandler { notificationLog.error(String.format("Moving temporary extra copy '%s' to destination '%s' failed.", extraTmpCopy, extraCopyDirOrNull)); - ok = false; } } - return ok; } - // @return true if succeeded, false if failed, null if succeeded and file still exists - private Boolean tryMoveManualOrClean(File file) + // @return true if processing needs to continue, false otherwise + private boolean doMoveManualOrClean(File file) { final EFileManipResult manualMoveStatus = doManualIntervention(file); if (manualMoveStatus == EFileManipResult.FAILURE) { - return Boolean.FALSE; + return false; // stop processing } else if (manualMoveStatus == EFileManipResult.STOP) { - return Boolean.TRUE; + return false; // stop processing } else if (manualMoveStatus == EFileManipResult.CONTINUE) { // continue processing @@ -209,9 +204,9 @@ public class LocalProcessor implements IPathHandler final boolean wholeDeleted = doCleansing(file); if (wholeDeleted) { - return Boolean.TRUE; + return false; // stop processing } - return null; // else continue processing + return true; // continue processing } @@ -245,7 +240,7 @@ public class LocalProcessor implements IPathHandler manualInterventionFilter.add(PathType.ALL, manualInterventionRegex); } - boolean filtered = manualInterventionFilter.accept(resource); + final boolean filtered = manualInterventionFilter.accept(resource); if (filtered) { log(resource, "Moving to manual intervention directory"); 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 39674887f4eb21251db22747ef947edf2deba353..3861410b30b8f7e75b4ff38d55b297b9a26d1dfb 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 @@ -120,11 +120,11 @@ public final class RemotePathMover implements DirectoryScanningTimerTask.IPathHa assert maximalNumberOfRetries >= 0; } - public boolean handle(File path) + public void handle(File path) { if (isDeletionInProgress(path)) { - // That is a recovery situation: we have been interrupted removing the path and now finish the job. + // This is a recovery situation: we have been interrupted removing the path and now finish the job. if (operationLog.isInfoEnabled()) { operationLog.info(String.format( @@ -132,7 +132,8 @@ public final class RemotePathMover implements DirectoryScanningTimerTask.IPathHa .getAbsolutePath())); } remove(path); - return markAsFinished(path); + markAsFinished(path); + return; } int tryCount = 0; do @@ -162,9 +163,8 @@ public final class RemotePathMover implements DirectoryScanningTimerTask.IPathHa .getPath(), (endTime - startTime) / 1000.0)); } remove(path); - // Note: we return true even if removal of the directory failed. There is no point in retrying the - // operation. - return markAsFinished(path); + markAsFinished(path); + return; } else { operationLog.warn(String.format(COPYING_PATH_TO_REMOTE_FAILED, path.getPath(), destinationDirectory @@ -190,7 +190,6 @@ public final class RemotePathMover implements DirectoryScanningTimerTask.IPathHa } while (true); notificationLog.error(String.format(MOVING_PATH_TO_REMOTE_FAILED_TEMPLATE, path, destinationDirectory)); - return false; } private void remove(File path) diff --git a/datamover/source/java/ch/systemsx/cisd/datamover/utils/QueuingPathHandler.java b/datamover/source/java/ch/systemsx/cisd/datamover/utils/QueuingPathHandler.java index 613dbd938abdf3723829702a48a74fd12db35488..555642de976461eb88a4debe44e4f36d65903698 100644 --- a/datamover/source/java/ch/systemsx/cisd/datamover/utils/QueuingPathHandler.java +++ b/datamover/source/java/ch/systemsx/cisd/datamover/utils/QueuingPathHandler.java @@ -77,8 +77,8 @@ public class QueuingPathHandler implements ITerminable, IPathHandler try { File resource = queue.take(); // blocks if empty - boolean ok = handler.handle(resource); - logHandlingResult(resource, ok); + handler.handle(resource); + logHandlingResult(resource, resource.exists() == false); } catch (InterruptedException ex) { return; @@ -118,14 +118,11 @@ public class QueuingPathHandler implements ITerminable, IPathHandler /** * queues resource processing and exits immediately - * - * @return always true */ - public boolean handle(File resource) + public void handle(File resource) { assert thread.isInterrupted() == false; thread.process(resource); - return true; } } diff --git a/datamover/sourceTest/java/ch/systemsx/cisd/datamover/utils/QueuingPathHandlerTest.java b/datamover/sourceTest/java/ch/systemsx/cisd/datamover/utils/QueuingPathHandlerTest.java index b3c7992b14675f281ddf10fc7b12aff446073d67..5b5521fb471e005117e362d4abfd619f757fccb9 100644 --- a/datamover/sourceTest/java/ch/systemsx/cisd/datamover/utils/QueuingPathHandlerTest.java +++ b/datamover/sourceTest/java/ch/systemsx/cisd/datamover/utils/QueuingPathHandlerTest.java @@ -58,7 +58,7 @@ public class QueuingPathHandlerTest this(0, 0L); } - public boolean handle(File path) + public void handle(File path) { if (handled.size() + 1 == blockBeforeFile) { @@ -68,11 +68,10 @@ public class QueuingPathHandlerTest } catch (InterruptedException ex) { interrupted = true; - return false; + return; } } handled.add(path); - return true; } List<File> getHandledFiles()