Skip to content
Snippets Groups Projects
Commit 83e82ca6 authored by brinn's avatar brinn
Browse files

change: do not send out notify log when data-completed script changes state

SVN: 7442
parent 5fbc8a45
No related branches found
No related tags found
No related merge requests found
...@@ -32,6 +32,7 @@ import ch.systemsx.cisd.common.process.ProcessResult; ...@@ -32,6 +32,7 @@ import ch.systemsx.cisd.common.process.ProcessResult;
import ch.systemsx.cisd.common.utilities.FileUtilities; import ch.systemsx.cisd.common.utilities.FileUtilities;
import ch.systemsx.cisd.common.utilities.OSUtilities; import ch.systemsx.cisd.common.utilities.OSUtilities;
import ch.systemsx.cisd.common.utilities.StoreItem; import ch.systemsx.cisd.common.utilities.StoreItem;
import ch.systemsx.cisd.datamover.DatamoverConstants;
import ch.systemsx.cisd.datamover.filesystem.intf.IFileStore; import ch.systemsx.cisd.datamover.filesystem.intf.IFileStore;
import ch.systemsx.cisd.datamover.filesystem.intf.StoreItemLocation; import ch.systemsx.cisd.datamover.filesystem.intf.StoreItemLocation;
...@@ -57,6 +58,11 @@ public class DataCompletedFilter implements IStoreItemFilter ...@@ -57,6 +58,11 @@ public class DataCompletedFilter implements IStoreItemFilter
private final static Logger notificationLog = private final static Logger notificationLog =
LogFactory.getLogger(LogCategory.NOTIFY, DataCompletedFilter.class); LogFactory.getLogger(LogCategory.NOTIFY, DataCompletedFilter.class);
private final ConditionalNotificationLogger conditionalNotificationLog =
new ConditionalNotificationLogger(operationLog, notificationLog,
DatamoverConstants.IGNORED_ERROR_COUNT_BEFORE_NOTIFICATION);
private final IFileStore fileStore; private final IFileStore fileStore;
private final File dataCompletedScript; private final File dataCompletedScript;
...@@ -156,13 +162,11 @@ public class DataCompletedFilter implements IStoreItemFilter ...@@ -156,13 +162,11 @@ public class DataCompletedFilter implements IStoreItemFilter
describeProcessResult(result), commandLine); describeProcessResult(result), commandLine);
if (ok) if (ok)
{ {
if (notificationLog.isInfoEnabled()) conditionalNotificationLog.reset(null);
{ conditionalNotificationLog.log(LogLevel.INFO, message);
notificationLog.info(message);
}
} else } else
{ {
notificationLog.error(message); conditionalNotificationLog.log(LogLevel.ERROR, message);
} }
result.log(); result.log();
lastProcessResult = result; lastProcessResult = result;
......
...@@ -48,7 +48,6 @@ import ch.systemsx.cisd.common.logging.LogInitializer; ...@@ -48,7 +48,6 @@ import ch.systemsx.cisd.common.logging.LogInitializer;
import ch.systemsx.cisd.common.process.ProcessExecutionHelper; import ch.systemsx.cisd.common.process.ProcessExecutionHelper;
import ch.systemsx.cisd.common.test.LogMonitoringAppender; import ch.systemsx.cisd.common.test.LogMonitoringAppender;
import ch.systemsx.cisd.common.utilities.FileUtilities; import ch.systemsx.cisd.common.utilities.FileUtilities;
import ch.systemsx.cisd.common.utilities.IExitHandler;
import ch.systemsx.cisd.common.utilities.ITimerTaskStatusProvider; import ch.systemsx.cisd.common.utilities.ITimerTaskStatusProvider;
import ch.systemsx.cisd.common.utilities.MockTimeProvider; import ch.systemsx.cisd.common.utilities.MockTimeProvider;
import ch.systemsx.cisd.common.utilities.OSUtilities; import ch.systemsx.cisd.common.utilities.OSUtilities;
...@@ -100,8 +99,6 @@ public final class IncomingProcessorTest ...@@ -100,8 +99,6 @@ public final class IncomingProcessorTest
private File incomingDir; private File incomingDir;
private IExitHandler exitHandler;
private File copyInProgressDir; private File copyInProgressDir;
private File copyCompleteDir; private File copyCompleteDir;
...@@ -139,7 +136,6 @@ public final class IncomingProcessorTest ...@@ -139,7 +136,6 @@ public final class IncomingProcessorTest
fileSysOpertationFactory = context.mock(IFileSysOperationsFactory.class); fileSysOpertationFactory = context.mock(IFileSysOperationsFactory.class);
mover = context.mock(IPathMover.class); mover = context.mock(IPathMover.class);
remover = context.mock(IPathRemover.class); remover = context.mock(IPathRemover.class);
exitHandler = context.mock(IExitHandler.class);
FileUtilities.deleteRecursively(TEST_FOLDER); FileUtilities.deleteRecursively(TEST_FOLDER);
TEST_FOLDER.mkdirs(); TEST_FOLDER.mkdirs();
...@@ -253,10 +249,10 @@ public final class IncomingProcessorTest ...@@ -253,10 +249,10 @@ public final class IncomingProcessorTest
final DataMoverProcess process = final DataMoverProcess process =
createProcess("--" + PropertyNames.INCOMING_TARGET, incomingDir.toString(), "-q", createProcess("--" + PropertyNames.INCOMING_TARGET, incomingDir.toString(), "-q",
"1", "--" + PropertyNames.DATA_COMPLETED_SCRIPT, exampleScript.toString()); "1", "--" + PropertyNames.DATA_COMPLETED_SCRIPT, exampleScript.toString());
final LogMonitoringAppender notifyAppender = final LogMonitoringAppender operationAppender1 =
LogMonitoringAppender.addAppender(LogCategory.NOTIFY, LogMonitoringAppender.addAppender(LogCategory.OPERATION,
"Processing status of data completed script has changed"); "Processing status of data completed script has changed");
final LogMonitoringAppender operationAppender = final LogMonitoringAppender operationAppender2 =
LogMonitoringAppender.addAppender(LogCategory.OPERATION, "Running command", LogMonitoringAppender.addAppender(LogCategory.OPERATION, "Running command",
"process returned with exit value 0"); "process returned with exit value 0");
...@@ -265,8 +261,8 @@ public final class IncomingProcessorTest ...@@ -265,8 +261,8 @@ public final class IncomingProcessorTest
assertFalse(errorMarker.exists()); assertFalse(errorMarker.exists());
dataMoverTimerTask.run(); // 2. round finds that quiet period is over dataMoverTimerTask.run(); // 2. round finds that quiet period is over
assertFalse(errorMarker.exists()); assertFalse(errorMarker.exists());
notifyAppender.verifyLogHasHappened(); operationAppender1.verifyLogHasHappened();
operationAppender.verifyLogHasHappened(); operationAppender2.verifyLogHasHappened();
logRecorder.resetLogContent(); logRecorder.resetLogContent();
dataMoverTimerTask.run(); // 3. round does not change status, thus no log dataMoverTimerTask.run(); // 3. round does not change status, thus no log
...@@ -295,21 +291,21 @@ public final class IncomingProcessorTest ...@@ -295,21 +291,21 @@ public final class IncomingProcessorTest
final TimerTask dataMoverTimerTask = getInstrumentedTimerTaskFrom(process); final TimerTask dataMoverTimerTask = getInstrumentedTimerTaskFrom(process);
dataMoverTimerTask.run(); // 1. round finds a file to process dataMoverTimerTask.run(); // 1. round finds a file to process
dataMoverTimerTask.run(); // 2. round finds that quiet period is over dataMoverTimerTask.run(); // 2. round finds that quiet period is over
final LogMonitoringAppender notifyAppender = final LogMonitoringAppender operationAppender =
LogMonitoringAppender.addAppender(LogCategory.NOTIFY, LogMonitoringAppender.addAppender(LogCategory.OPERATION,
"Processing status of data completed script has changed"); "Processing status of data completed script has changed");
logRecorder.resetLogContent(); logRecorder.resetLogContent();
dataMoverTimerTask.run(); // 3. round does not change status, thus no log dataMoverTimerTask.run(); // 3. round does not change status, thus no log
assertEquals("", logRecorder.getLogContent()); assertEquals("", logRecorder.getLogContent());
notifyAppender.verifyLogHasNotHappened(); operationAppender.verifyLogHasNotHappened();
logRecorder.resetLogContent(); logRecorder.resetLogContent();
notifyAppender.reset(); operationAppender.reset();
TEST_FILE.createNewFile(); TEST_FILE.createNewFile();
dataMoverTimerTask.run(); // 4. round finds changed status, thus log dataMoverTimerTask.run(); // 4. round finds changed status, thus log
assertTrue(logRecorder.getLogContent().length() > 0); assertTrue(logRecorder.getLogContent().length() > 0);
notifyAppender.verifyLogHasHappened(); operationAppender.verifyLogHasHappened();
context.assertIsSatisfied(); context.assertIsSatisfied();
} }
...@@ -341,7 +337,7 @@ public final class IncomingProcessorTest ...@@ -341,7 +337,7 @@ public final class IncomingProcessorTest
private DataMoverProcess createProcess(final String... args) private DataMoverProcess createProcess(final String... args)
{ {
final Parameters parameters = new Parameters(args, exitHandler); final Parameters parameters = new Parameters(args);
final LocalBufferDirs localBufferDirs = final LocalBufferDirs localBufferDirs =
new LocalBufferDirs(new HostAwareFileWithHighwaterMark(TEST_FOLDER), new LocalBufferDirs(new HostAwareFileWithHighwaterMark(TEST_FOLDER),
COPY_IN_PROGRESS_DIR, COPY_COMPLETE_DIR, READY_TO_MOVE_DIR, TEMP_DIR); COPY_IN_PROGRESS_DIR, COPY_COMPLETE_DIR, READY_TO_MOVE_DIR, TEMP_DIR);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment