From c401efe9115f65e000a76e625c7cf9bc29106655 Mon Sep 17 00:00:00 2001 From: buczekp <buczekp> Date: Tue, 9 Feb 2010 15:22:04 +0000 Subject: [PATCH] [DMV-39] added logging on StoreItem transfer start and finish SVN: 14660 --- .../ch/systemsx/cisd/datamover/DataMover.java | 39 ++++++++++++++++++- .../cisd/datamover/IncomingProcessor.java | 4 +- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/datamover/source/java/ch/systemsx/cisd/datamover/DataMover.java b/datamover/source/java/ch/systemsx/cisd/datamover/DataMover.java index 9c2c348d037..be8f5b70373 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 cc6ed80fb97..5427f392360 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); -- GitLab