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;
import ch.systemsx.cisd.common.utilities.FileUtilities;
import ch.systemsx.cisd.common.utilities.OSUtilities;
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.StoreItemLocation;
......@@ -57,6 +58,11 @@ public class DataCompletedFilter implements IStoreItemFilter
private final static Logger notificationLog =
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 File dataCompletedScript;
......@@ -156,13 +162,11 @@ public class DataCompletedFilter implements IStoreItemFilter
describeProcessResult(result), commandLine);
if (ok)
{
if (notificationLog.isInfoEnabled())
{
notificationLog.info(message);
}
conditionalNotificationLog.reset(null);
conditionalNotificationLog.log(LogLevel.INFO, message);
} else
{
notificationLog.error(message);
conditionalNotificationLog.log(LogLevel.ERROR, message);
}
result.log();
lastProcessResult = result;
......
......@@ -48,7 +48,6 @@ import ch.systemsx.cisd.common.logging.LogInitializer;
import ch.systemsx.cisd.common.process.ProcessExecutionHelper;
import ch.systemsx.cisd.common.test.LogMonitoringAppender;
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.MockTimeProvider;
import ch.systemsx.cisd.common.utilities.OSUtilities;
......@@ -100,8 +99,6 @@ public final class IncomingProcessorTest
private File incomingDir;
private IExitHandler exitHandler;
private File copyInProgressDir;
private File copyCompleteDir;
......@@ -139,7 +136,6 @@ public final class IncomingProcessorTest
fileSysOpertationFactory = context.mock(IFileSysOperationsFactory.class);
mover = context.mock(IPathMover.class);
remover = context.mock(IPathRemover.class);
exitHandler = context.mock(IExitHandler.class);
FileUtilities.deleteRecursively(TEST_FOLDER);
TEST_FOLDER.mkdirs();
......@@ -253,10 +249,10 @@ public final class IncomingProcessorTest
final DataMoverProcess process =
createProcess("--" + PropertyNames.INCOMING_TARGET, incomingDir.toString(), "-q",
"1", "--" + PropertyNames.DATA_COMPLETED_SCRIPT, exampleScript.toString());
final LogMonitoringAppender notifyAppender =
LogMonitoringAppender.addAppender(LogCategory.NOTIFY,
final LogMonitoringAppender operationAppender1 =
LogMonitoringAppender.addAppender(LogCategory.OPERATION,
"Processing status of data completed script has changed");
final LogMonitoringAppender operationAppender =
final LogMonitoringAppender operationAppender2 =
LogMonitoringAppender.addAppender(LogCategory.OPERATION, "Running command",
"process returned with exit value 0");
......@@ -265,8 +261,8 @@ public final class IncomingProcessorTest
assertFalse(errorMarker.exists());
dataMoverTimerTask.run(); // 2. round finds that quiet period is over
assertFalse(errorMarker.exists());
notifyAppender.verifyLogHasHappened();
operationAppender.verifyLogHasHappened();
operationAppender1.verifyLogHasHappened();
operationAppender2.verifyLogHasHappened();
logRecorder.resetLogContent();
dataMoverTimerTask.run(); // 3. round does not change status, thus no log
......@@ -295,21 +291,21 @@ public final class IncomingProcessorTest
final TimerTask dataMoverTimerTask = getInstrumentedTimerTaskFrom(process);
dataMoverTimerTask.run(); // 1. round finds a file to process
dataMoverTimerTask.run(); // 2. round finds that quiet period is over
final LogMonitoringAppender notifyAppender =
LogMonitoringAppender.addAppender(LogCategory.NOTIFY,
final LogMonitoringAppender operationAppender =
LogMonitoringAppender.addAppender(LogCategory.OPERATION,
"Processing status of data completed script has changed");
logRecorder.resetLogContent();
dataMoverTimerTask.run(); // 3. round does not change status, thus no log
assertEquals("", logRecorder.getLogContent());
notifyAppender.verifyLogHasNotHappened();
operationAppender.verifyLogHasNotHappened();
logRecorder.resetLogContent();
notifyAppender.reset();
operationAppender.reset();
TEST_FILE.createNewFile();
dataMoverTimerTask.run(); // 4. round finds changed status, thus log
assertTrue(logRecorder.getLogContent().length() > 0);
notifyAppender.verifyLogHasHappened();
operationAppender.verifyLogHasHappened();
context.assertIsSatisfied();
}
......@@ -341,7 +337,7 @@ public final class IncomingProcessorTest
private DataMoverProcess createProcess(final String... args)
{
final Parameters parameters = new Parameters(args, exitHandler);
final Parameters parameters = new Parameters(args);
final LocalBufferDirs localBufferDirs =
new LocalBufferDirs(new HostAwareFileWithHighwaterMark(TEST_FOLDER),
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