diff --git a/datastore_server/source/java/ch/systemsx/cisd/etlserver/postregistration/EagerShufflingTask.java b/datastore_server/source/java/ch/systemsx/cisd/etlserver/postregistration/EagerShufflingTask.java index 61642adfbf34022e8e90904f8fa755410f309772..a7f7db4e041f7a106ec89239fd062b2ad118f369 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/etlserver/postregistration/EagerShufflingTask.java +++ b/datastore_server/source/java/ch/systemsx/cisd/etlserver/postregistration/EagerShufflingTask.java @@ -31,6 +31,7 @@ import ch.systemsx.cisd.common.logging.ISimpleLogger; import ch.systemsx.cisd.common.logging.Log4jSimpleLogger; import ch.systemsx.cisd.common.logging.LogCategory; import ch.systemsx.cisd.common.logging.LogFactory; +import ch.systemsx.cisd.common.logging.LogLevel; import ch.systemsx.cisd.common.utilities.ClassUtils; import ch.systemsx.cisd.common.utilities.PropertyParametersUtil; import ch.systemsx.cisd.common.utilities.PropertyUtils; @@ -160,6 +161,8 @@ public class EagerShufflingTask extends AbstractPostRegistrationTask shareWithMostFreeOrNull = finder.tryToFindShare(dataSet, shares); if (shareWithMostFreeOrNull == null) { + logger.log(LogLevel.WARN, "No share found for shuffling data set " + dataSetCode + + "."); return new NoCleanupTask(); } return new NoCleanupTask(); @@ -178,6 +181,9 @@ public class EagerShufflingTask extends AbstractPostRegistrationTask dataSetMover.moveDataSetToAnotherShare( new File(share, dataSet.getDataSetLocation()), shareWithMostFreeOrNull.getShare(), logger); + logger.log(LogLevel.INFO, "Data set " + dataSetCode + + " succesffully moved from share " + dataSet.getDataSetShareId() + " to " + + shareWithMostFreeOrNull.getShareId() + "."); } } } diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/postregistration/EagerShufflingTaskTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/postregistration/EagerShufflingTaskTest.java index d6d65bdc873f8a8d5220d04cf70dd38465c173fb..841946b16af5b216aacdbf0bd05865f99d1b3882 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/postregistration/EagerShufflingTaskTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/postregistration/EagerShufflingTaskTest.java @@ -39,6 +39,7 @@ import ch.systemsx.cisd.common.filesystem.HostAwareFile; import ch.systemsx.cisd.common.filesystem.IFreeSpaceProvider; import ch.systemsx.cisd.common.logging.BufferedAppender; import ch.systemsx.cisd.common.logging.ISimpleLogger; +import ch.systemsx.cisd.common.logging.LogLevel; import ch.systemsx.cisd.common.test.RecordingMatcher; import ch.systemsx.cisd.etlserver.plugins.IDataSetMover; import ch.systemsx.cisd.openbis.dss.generic.shared.IEncapsulatedOpenBISService; @@ -115,6 +116,7 @@ public class EagerShufflingTaskTest extends AbstractFileSystemTestCase prepareFreeSpaceProvider(hostAwareFileMatcher, 200, 100, 300, 400); prepareListDataSets(); prepareGetShareId(); + RecordingMatcher<String> infoMessageMatcher = prepareLogging(LogLevel.INFO); context.checking(new Expectations() { { @@ -126,6 +128,8 @@ public class EagerShufflingTaskTest extends AbstractFileSystemTestCase executor.createCleanupTask(); executor.execute(); + assertEquals("Data set ds-1 succesffully moved from share 1 to 4.", + infoMessageMatcher.recordedObject()); assertHostAwareFile(hostAwareFileMatcher); context.assertIsSatisfied(); } @@ -139,6 +143,7 @@ public class EagerShufflingTaskTest extends AbstractFileSystemTestCase prepareFreeSpaceProvider(hostAwareFileMatcher, 200, 100, 10, 0); prepareListDataSets(); prepareGetShareId(); + RecordingMatcher<String> infoMessageMatcher = prepareLogging(LogLevel.INFO); context.checking(new Expectations() { { @@ -150,6 +155,8 @@ public class EagerShufflingTaskTest extends AbstractFileSystemTestCase executor.createCleanupTask(); executor.execute(); + assertEquals("Data set ds-1 succesffully moved from share 1 to 2.", + infoMessageMatcher.recordedObject()); assertHostAwareFile(hostAwareFileMatcher); context.assertIsSatisfied(); } @@ -162,15 +169,30 @@ public class EagerShufflingTaskTest extends AbstractFileSystemTestCase new RecordingMatcher<HostAwareFile>(); prepareFreeSpaceProvider(hostAwareFileMatcher, 200, 10, 10, 0); prepareListDataSets(); + RecordingMatcher<String> logMessageMatcher = prepareLogging(LogLevel.WARN); IPostRegistrationTaskExecutor executor = task.createExecutor(DATA_SET_CODE1); executor.createCleanupTask(); executor.execute(); + assertEquals("No share found for shuffling data set ds-1.", + logMessageMatcher.recordedObject()); assertHostAwareFile(hostAwareFileMatcher); context.assertIsSatisfied(); } + private RecordingMatcher<String> prepareLogging(final LogLevel level) + { + final RecordingMatcher<String> logMessageMatcher = new RecordingMatcher<String>(); + context.checking(new Expectations() + { + { + one(logger).log(with(level), with(logMessageMatcher)); + } + }); + return logMessageMatcher; + } + private void prepareListDataSets() { context.checking(new Expectations()