Update of /cvsroot/archive-crawler/ArchiveOpenCrawler/src/java/org/archive/crawler/admin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18356/src/java/org/archive/crawler/admin
Modified Files:
CrawlJobHandler.java
Log Message:
completion of [ 1093609 ] One-click recover
* CrawlJobHandler.java
While 'logs' and 'state' directories of recovered crawl are not empty, append '-R' to their paths. Eventually a path the generates a new empty directory will be reached, making it safe to 'one-click-recover' even crawls with absolute 'disk', 'logs', or 'state' paths.
Index: CrawlJobHandler.java
===================================================================
RCS file: /cvsroot/archive-crawler/ArchiveOpenCrawler/src/java/org/archive/crawler/admin/CrawlJobHandler.java,v
retrieving revision 1.59
retrieving revision 1.60
diff -C2 -d -r1.59 -r1.60
*** CrawlJobHandler.java 23 Mar 2005 22:27:53 -0000 1.59
--- CrawlJobHandler.java 24 Mar 2005 23:45:13 -0000 1.60
***************
*** 805,809 ****
// set 'recover-from' to be old job's recoevery log path
if(isRecover) {
! copyRecoveryPath(baseOn,newHandler);
}
} catch (AttributeNotFoundException e1) {
--- 805,809 ----
// set 'recover-from' to be old job's recoevery log path
if(isRecover) {
! updateRecoveryPaths(baseOn,newHandler);
}
} catch (AttributeNotFoundException e1) {
***************
*** 877,894 ****
* @throws AttributeNotFoundException
*/
! private void copyRecoveryPath(CrawlJob baseOn, XMLSettingsHandler newHandler) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException {
! File logsDisk = null;
try {
! logsDisk = baseOn.getSettingsHandler().getOrder().getSettingsDir(
CrawlOrder.ATTR_LOGS_PATH);
} catch (AttributeNotFoundException e) {
logger.severe("Failed to get logs directory " + e);
}
! if (logsDisk != null) {
! String recoveryPath = logsDisk.getAbsolutePath() + File.separatorChar
+ FrontierJournal.LOGNAME_RECOVER + RecoveryJournal.GZIP_SUFFIX;
newHandler.getOrder().setAttribute(
new Attribute(CrawlOrder.ATTR_RECOVER_PATH, recoveryPath));
}
}
--- 877,934 ----
* @throws AttributeNotFoundException
*/
! private void updateRecoveryPaths(CrawlJob baseOn, XMLSettingsHandler newHandler) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException {
! // First, bring original crawl's recovery-log path into
! // new job's 'recover-path'
! File oldLogsDisk = null;
try {
! oldLogsDisk = baseOn.getSettingsHandler().getOrder().getSettingsDir(
CrawlOrder.ATTR_LOGS_PATH);
} catch (AttributeNotFoundException e) {
logger.severe("Failed to get logs directory " + e);
}
! if (oldLogsDisk != null) {
! String recoveryPath = oldLogsDisk.getAbsolutePath() + File.separatorChar
+ FrontierJournal.LOGNAME_RECOVER + RecoveryJournal.GZIP_SUFFIX;
newHandler.getOrder().setAttribute(
new Attribute(CrawlOrder.ATTR_RECOVER_PATH, recoveryPath));
}
+ // Now, ensure that 'logs' and 'state' don't overlap with
+ // previous job's files (ok for 'arcs' and 'scratch' to overlap)
+ File newLogsDisk = null;
+ while(true) {
+ try {
+ newLogsDisk = newHandler.getOrder().getSettingsDir(
+ CrawlOrder.ATTR_LOGS_PATH);
+ } catch (AttributeNotFoundException e) {
+ logger.severe("Failed to get logs directory " + e);
+ }
+ if (newLogsDisk.list().length>0) {
+ // 'new' directory is nonempty; rename with trailing '-R'
+ String logsPath = (String) newHandler.getOrder().getAttribute(CrawlOrder.ATTR_LOGS_PATH);
+ newHandler.getOrder().setAttribute(
+ new Attribute(CrawlOrder.ATTR_LOGS_PATH, logsPath+"-R"));
+ } else {
+ // directory is suitably empty; exit loop
+ break;
+ }
+ }
+ File newStateDisk = null;
+ while (true) {
+ try {
+ newStateDisk = newHandler.getOrder().getSettingsDir(
+ CrawlOrder.ATTR_STATE_PATH);
+ } catch (AttributeNotFoundException e) {
+ logger.severe("Failed to get state directory " + e);
+ }
+ if (newStateDisk.list().length>0) {
+ // 'new' directory is nonempty; rename with trailing '-R'
+ String statePath = (String) newHandler.getOrder().getAttribute(CrawlOrder.ATTR_STATE_PATH);
+ newHandler.getOrder().setAttribute(
+ new Attribute(CrawlOrder.ATTR_STATE_PATH, statePath+"-R"));
+ } else {
+ // directory is suitably empty; exit loop
+ break;
+ }
+ }
}
|