mirror of
https://github.com/internetarchive/heritrix3.git
synced 2026-09-16 10:45:47 +00:00
[HER-1800] H3: Incomplete checkpoint listed in combo box
* CheckpointService.java
use static method on Checkpoint for validity check
* Checkpoint.java
throw early-startup exception if attempting resumption of invalid checkpoint
This commit is contained in:
@@ -31,13 +31,14 @@ import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Required;
|
||||
import org.springframework.context.Lifecycle;
|
||||
|
||||
/**
|
||||
* Represents a single checkpoint, by its name and main store directory.
|
||||
*
|
||||
* @contributor gojomo
|
||||
*/
|
||||
public class Checkpoint implements InitializingBean {
|
||||
public class Checkpoint implements InitializingBean, Lifecycle {
|
||||
private final static Logger LOGGER =
|
||||
Logger.getLogger(Checkpoint.class.getName());
|
||||
|
||||
@@ -51,7 +52,9 @@ public class Checkpoint implements InitializingBean {
|
||||
boolean success = false;
|
||||
|
||||
/**
|
||||
* Checkpoints directory
|
||||
* Checkpoints directory; either an absolute path, or relative to the
|
||||
* CheckpointService's checkpointsDirectory (which will be inserted as
|
||||
* the COnfigPath base before the Checkpoint is consulted).
|
||||
*/
|
||||
protected ConfigPath checkpointDir =
|
||||
new ConfigPath("checkpoint directory","");
|
||||
@@ -89,6 +92,24 @@ public class Checkpoint implements InitializingBean {
|
||||
shortName = name.substring(0, name.indexOf("-"));
|
||||
}
|
||||
|
||||
boolean isRunning = false;
|
||||
public boolean isRunning() {
|
||||
return isRunning;
|
||||
}
|
||||
public void start() {
|
||||
if(isRunning) {
|
||||
return;
|
||||
}
|
||||
isRunning = true;
|
||||
if(!Checkpoint.hasValidStamp(checkpointDir.getFile())) {
|
||||
throw new RuntimeException("checkpoint '"+checkpointDir.getFile().getAbsolutePath()+"' missing validity stamp file");
|
||||
}
|
||||
}
|
||||
public void stop() {
|
||||
isRunning = false;
|
||||
}
|
||||
|
||||
|
||||
public void setSuccess(boolean b) {
|
||||
success = b;
|
||||
}
|
||||
@@ -137,4 +158,8 @@ public class Checkpoint implements InitializingBean {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean hasValidStamp(File checkpointDirectory) {
|
||||
return (new File(checkpointDirectory,Checkpoint.VALIDITY_STAMP_FILENAME)).exists();
|
||||
}
|
||||
}
|
||||
@@ -298,7 +298,7 @@ public class CheckpointService implements Lifecycle, ApplicationContextAware {
|
||||
Iterator<File> iter = dirsList.iterator();
|
||||
while(iter.hasNext()) {
|
||||
File cpDir = iter.next();
|
||||
if(! (new File(cpDir,Checkpoint.VALIDITY_STAMP_FILENAME)).exists()) {
|
||||
if(!Checkpoint.hasValidStamp(cpDir)) {
|
||||
LOGGER.warning("checkpoint '"+cpDir+"' missing validity stamp file; ignoring");
|
||||
iter.remove();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user