diff --git a/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v2/JythonTopLevelDataSetHandlerV2.java b/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v2/JythonTopLevelDataSetHandlerV2.java index a89c7482116b764874c255b91d9f6f98f6aa7cc8..0b1563110eca34572f0d2a8d9c16f68964f6343c 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v2/JythonTopLevelDataSetHandlerV2.java +++ b/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v2/JythonTopLevelDataSetHandlerV2.java @@ -151,7 +151,7 @@ public class JythonTopLevelDataSetHandlerV2<T extends DataSetInformation> extend } } - private static final int MAX_RETRY_COUNT = 3; + private static final int MAX_RETRY_COUNT = 50; private static final int RETRY_SLEEP = 100; diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/registrator/JythonDropboxRecoveryTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/registrator/JythonDropboxRecoveryTest.java index 4c08a05e468438741dc29f1cd2a03fe7b983cdc1..66440d00bd2b59a8b146fc57b22401ab12469402 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/registrator/JythonDropboxRecoveryTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/registrator/JythonDropboxRecoveryTest.java @@ -904,6 +904,68 @@ public class JythonDropboxRecoveryTest extends AbstractJythonDataSetHandlerTest } } + // INFO: testcase that verifies the repeating of the jython process works. + @Test + public void testRetryProcessing() + { + RecoveryTestCase testCase = new RecoveryTestCase("No name"); + setUpHomeDataBaseExpectations(); + + createData(); + + Properties properties = + createThreadPropertiesRelativeToScriptsFolder("v2-retry-process.py", + testCase.overrideProperties); + + createHandler(properties, true, false); + + final RecordingMatcher<ch.systemsx.cisd.openbis.generic.shared.dto.AtomicEntityOperationDetails> atomicatOperationDetails = + new RecordingMatcher<ch.systemsx.cisd.openbis.generic.shared.dto.AtomicEntityOperationDetails>(); + + // create expectations + context.checking(new RetryProcessExpectations(atomicatOperationDetails, 20)); + + handler.handle(markerFile); + + JythonHookTestTool.assertMessagesInWorkingDirectory(workingDirectory, + "pre_metadata_registration", "post_metadata_registration", "post_storage"); + + assertStorageProcess(atomicatOperationDetails.getRecordedObjects().get(0), DATA_SET_CODE, + "sub_data_set_1", 0); + + assertNoOriginalMarkerFileExists(); + assertNoRecoveryMarkerFile(); + + assertDirEmpty(precommitDirectory); + } + + class RetryProcessExpectations extends AbstractExpectations + { + public RetryProcessExpectations( + final RecordingMatcher<AtomicEntityOperationDetails> atomicatOperationDetails, int retryCount) + { + super(atomicatOperationDetails); + prepareExpectations(retryCount); + } + + private void prepareExpectations(int retryCount) + { + // create dataset + for (int i = 0; i < retryCount; i++) + { + one(openBisService).createDataSetCode(); + will(returnValue(DATA_SET_CODE + i)); // this dataset will never get done anything + // about + } + + initialExpectations(); + + registerDataSetsAndSucceed(); + + setStorageConfirmed(false); + } + } + // INFO: the test that checks all possible recovery points one by one in single registration @DataProvider(name = "multipleCheckpointsDataProvider") public Object[][] multipleCheckpointsData() diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/registrator/v2-retry-process.py b/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/registrator/v2-retry-process.py new file mode 100644 index 0000000000000000000000000000000000000000..d2db7e161122cfed0788d5f41bef0e32536405a1 --- /dev/null +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/registrator/v2-retry-process.py @@ -0,0 +1,18 @@ +execfile("sourceTest/java/ch/systemsx/cisd/etlserver/registrator/all-hooks.py") + +def should_retry_processing(map, error): + lastResult = transaction.getPersistentMap().get("RETRY_COUNT") + if (lastResult == None): + lastResult = 0 + transaction.getPersistentMap().put("RETRY_COUNT", lastResult + 1) + print "RETRY TRANSACTION PUTS THE SCORE %d" % (lastResult + 1) + +def process(): + key = transaction.getPersistentMap().get("RETRY_COUNT"); + dataSet = transaction.createNewDataSet() + transaction.moveFile(incoming.getPath() + '/sub_data_set_1', dataSet) + dataSet.setDataSetType('O1') + dataSet.setExperiment(transaction.getExperiment('/SPACE/PROJECT/EXP')) + if (key < 20): + # do here the real throwing of the exception + raise Exception("error in the script at the retry %d" % key) \ No newline at end of file