Skip to content
Snippets Groups Projects
Commit fb1716be authored by jakubs's avatar jakubs
Browse files

SP-45, BIS-21 increase retry count

SVN: 25306
parent d7b2e499
No related branches found
No related tags found
No related merge requests found
......@@ -515,6 +515,12 @@ public abstract class AbstractOmniscientTopLevelDataSetRegistrator<T extends Dat
recoveryMarkerFile.delete();
recoveryFile.delete();
}
else {
// this replaces the recovery file with a new one with increased count
//FIXME: is this safe operation (how to assure, that it won't corrupt the recoveryMarkerFile?)
recoveryInfo.increaseTryCount();
recoveryInfo.writeToFile(recoveryMarkerFile);
}
return true;
}
};
......
......@@ -20,13 +20,7 @@ import java.io.File;
import java.io.Serializable;
import java.util.Date;
import org.apache.log4j.Logger;
import ch.systemsx.cisd.common.exceptions.UserFailureException;
import ch.systemsx.cisd.common.filesystem.FileUtilities;
import ch.systemsx.cisd.common.logging.LogCategory;
import ch.systemsx.cisd.common.logging.LogFactory;
import ch.systemsx.cisd.openbis.dss.generic.shared.dto.DataSetInformation;
/**
* Simple data type with information about recovery state.
......@@ -44,7 +38,7 @@ public class DataSetStorageRecoveryInfo implements Serializable
private final Date lastTry;
private final int tryCount;
private int tryCount;
public DataSetStorageRecoveryInfo(File recoveryStateFile, Date lastTry, int tryCount)
{
......@@ -53,7 +47,12 @@ public class DataSetStorageRecoveryInfo implements Serializable
this.lastTry = lastTry;
this.tryCount = tryCount;
}
public void increaseTryCount()
{
tryCount++;
}
public File getRecoveryStateFile()
{
return recoveryStateFile;
......
......@@ -160,7 +160,7 @@ public class JythonDropboxRecoveryTest extends AbstractJythonDataSetHandlerTest
if (testCase.canRecoverFromError)
{
assertRecoveryMarkerFile();
assertRecoveryFile(0);
assertOriginalMarkerFileExists();
handler.handle(markerFile);
......@@ -192,7 +192,7 @@ public class JythonDropboxRecoveryTest extends AbstractJythonDataSetHandlerTest
break;
case CHECK_FAILED:
assertDirNotEmpty(precommitDirectory, "Precommit directory should not be empty");
assertRecoveryMarkerFile();
assertRecoveryFile(1);
assertOriginalMarkerFileExists();
// marker file is still there
// recovery state file is still there
......@@ -235,15 +235,22 @@ public class JythonDropboxRecoveryTest extends AbstractJythonDataSetHandlerTest
markerFile.exists());
}
private File assertRecoveryMarkerFile()
/**
* @param tryCount - the excepted stored number of tries in a recovery file
*/
private File assertRecoveryFile(int tryCount)
{
File file = getCreatedRecoveryMarkerFile();
assertTrue("The recovery marker file does not exist! " + file, file.exists());
File recoveryFile =
DataSetStorageRecoveryInfo recoveryInfo =
handler.getGlobalState().getStorageRecoveryManager()
.getRecoveryFileFromMarker(file).getRecoveryStateFile();
.getRecoveryFileFromMarker(file);
File recoveryFile = recoveryInfo.getRecoveryStateFile();
assertTrue("The recovery serialized file does not exist! " + recoveryFile,
recoveryFile.exists());
assertEquals("The try count in a recovery file is incorrect", tryCount, recoveryInfo.getTryCount());
return file;
}
......
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