Skip to content
Snippets Groups Projects
Commit 9f6640ed authored by brinn's avatar brinn
Browse files

change:

- make DirectoryScanningTimerTask a IRecoverable
- do not run recovery automatically in order to give better control

SVN: 1881
parent 91fa7a55
No related branches found
No related tags found
No related merge requests found
...@@ -42,7 +42,7 @@ import ch.systemsx.cisd.common.logging.LogFactory; ...@@ -42,7 +42,7 @@ import ch.systemsx.cisd.common.logging.LogFactory;
* *
* @author Bernd Rinn * @author Bernd Rinn
*/ */
public final class DirectoryScanningTimerTask extends TimerTask implements ISelfTestable public final class DirectoryScanningTimerTask extends TimerTask implements ISelfTestable, IRecoverable
{ {
public static final String FAULTY_PATH_FILENAME = ".faulty_paths"; public static final String FAULTY_PATH_FILENAME = ".faulty_paths";
...@@ -91,8 +91,6 @@ public final class DirectoryScanningTimerTask extends TimerTask implements ISelf ...@@ -91,8 +91,6 @@ public final class DirectoryScanningTimerTask extends TimerTask implements ISelf
/** /**
* Creates a <var>DirectoryScanningTimerTask</var>. * Creates a <var>DirectoryScanningTimerTask</var>.
* <p>
* Performs a recovery if <var>recoverableOrNull</var> is not <code>null</code>.
* *
* @param sourceDirectory The directory to scan for entries. * @param sourceDirectory The directory to scan for entries.
* @param filter The file filter that picks the entries to handle. * @param filter The file filter that picks the entries to handle.
...@@ -115,20 +113,19 @@ public final class DirectoryScanningTimerTask extends TimerTask implements ISelf ...@@ -115,20 +113,19 @@ public final class DirectoryScanningTimerTask extends TimerTask implements ISelf
this.faultyPaths = new HashSet<File>(); this.faultyPaths = new HashSet<File>();
this.faultyPathsFile = new File(sourceDirectory, FAULTY_PATH_FILENAME); this.faultyPathsFile = new File(sourceDirectory, FAULTY_PATH_FILENAME);
faultyPathsFile.delete(); faultyPathsFile.delete();
runRecover();
} }
/** /**
* Handles all entries in the source directory that are picked by the filter. * Handles all entries in the source directory that are picked by the filter.
*/ */
@Override @Override
public void run() public synchronized void run()
{ {
try try
{ {
if (recoveryTriggerFile.exists()) if (recoveryTriggerFile.exists())
{ {
runRecover(); recover();
recoveryTriggerFile.delete(); recoveryTriggerFile.delete();
} }
if (operationLog.isTraceEnabled()) if (operationLog.isTraceEnabled())
...@@ -158,7 +155,7 @@ public final class DirectoryScanningTimerTask extends TimerTask implements ISelf ...@@ -158,7 +155,7 @@ public final class DirectoryScanningTimerTask extends TimerTask implements ISelf
} }
} }
private void runRecover() public synchronized void recover()
{ {
if (recoverableOrNull != null) if (recoverableOrNull != null)
{ {
......
...@@ -208,8 +208,7 @@ public class DirectoryScanningTimerTaskTest ...@@ -208,8 +208,7 @@ public class DirectoryScanningTimerTaskTest
final RecordingRecoverable mockRecoverable = new RecordingRecoverable(); final RecordingRecoverable mockRecoverable = new RecordingRecoverable();
final DirectoryScanningTimerTask scanner = final DirectoryScanningTimerTask scanner =
new DirectoryScanningTimerTask(workingDirectory, ACCEPT_ALL_FILTER, mockPathHandler, mockRecoverable); new DirectoryScanningTimerTask(workingDirectory, ACCEPT_ALL_FILTER, mockPathHandler, mockRecoverable);
assertTrue(mockRecoverable.recoveryCalled); assertFalse(mockRecoverable.recoveryCalled);
mockRecoverable.recoveryCalled = false;
assertEquals(0, mockPathHandler.handledPaths.size()); assertEquals(0, mockPathHandler.handledPaths.size());
scanner.run(); scanner.run();
assertFalse(mockRecoverable.recoveryCalled); assertFalse(mockRecoverable.recoveryCalled);
......
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