diff --git a/datamover/source/java/ch/systemsx/cisd/datamover/DataMover.java b/datamover/source/java/ch/systemsx/cisd/datamover/DataMover.java index 9c2c348d0370ba8841c10604d4eb9096e2ffb404..be8f5b7037305696c1fec9427fd253efd1608ff7 100644 --- a/datamover/source/java/ch/systemsx/cisd/datamover/DataMover.java +++ b/datamover/source/java/ch/systemsx/cisd/datamover/DataMover.java @@ -263,7 +263,8 @@ public final class DataMover final IFileStore readyToMoveStore = FileStoreFactory.createLocal(sourceDirectory, "ready-to-move", factory, false); final IStoreHandler remoteStoreMover = - createOutgoingPathMover(readyToMoveStore, outgoingStore); + wrapHandleWithLogging(createOutgoingPathMover(readyToMoveStore, outgoingStore), + null, "FINISHED_TRANSFER"); final HighwaterMarkDirectoryScanningHandler directoryScanningHandler = new HighwaterMarkDirectoryScanningHandler(new FaultyPathDirectoryScanningHandler( sourceDirectory, remoteStoreMover), outgoingStore.getHighwaterMarkWatcher()); @@ -321,9 +322,43 @@ public final class DataMover } // - // Helper classes + // Helper methods and classes // + /** + * Wraps {@link IStoreHandler} into another one with additional option of logging before and + * after handling an item is performed by the <var>originalHandler</var>. + * + * @param prefixBeforeOrNull if not <code>null</code> a message with this prefix and handled + * item name will be logged before item handling + * @param prefixAfterOrNull if not <code>null</code> a message with this prefix and handled item + * name will be logged after item handling + */ + public final static IStoreHandler wrapHandleWithLogging(final IStoreHandler originalHandler, + final String prefixBeforeOrNull, final String prefixAfterOrNull) + { + return new IStoreHandler() + { + public void handle(StoreItem item) + { + if (prefixBeforeOrNull != null) + { + operationLog.info(prefixBeforeOrNull + ": " + item); + } + originalHandler.handle(item); + if (prefixAfterOrNull != null) + { + operationLog.info(prefixAfterOrNull + ": " + item); + } + } + + public boolean isStopped() + { + return originalHandler.isStopped(); + } + }; + } + private final static class RunOnceMoreAfterTerminateDataMoverProcess extends DataMoverProcess { RunOnceMoreAfterTerminateDataMoverProcess(final TimerTask timerTask, final String taskName, diff --git a/datamover/source/java/ch/systemsx/cisd/datamover/IncomingProcessor.java b/datamover/source/java/ch/systemsx/cisd/datamover/IncomingProcessor.java index cc6ed80fb97166f10a8557386a7ae8630eaf80ae..5427f3923608e17ec31318583609d9ee09fe3013 100644 --- a/datamover/source/java/ch/systemsx/cisd/datamover/IncomingProcessor.java +++ b/datamover/source/java/ch/systemsx/cisd/datamover/IncomingProcessor.java @@ -165,7 +165,9 @@ public class IncomingProcessor implements IRecoverableTimerTaskFactory final File copyInProgressDir = bufferDirs.getCopyInProgressDir(); final HighwaterMarkWatcher highwaterMarkWatcher = new HighwaterMarkWatcher(bufferDirs.getBufferDirHighwaterMark()); - final IStoreHandler pathHandler = createIncomingMovingPathHandler(); + final IStoreHandler pathHandler = + DataMover.wrapHandleWithLogging(createIncomingMovingPathHandler(), + "STARTED_TRANSFER", null); final HighwaterMarkDirectoryScanningHandler directoryScanningHandler = new HighwaterMarkDirectoryScanningHandler(new FaultyPathDirectoryScanningHandler( copyInProgressDir, pathHandler), highwaterMarkWatcher, copyInProgressDir);