This commit is contained in:
Shinsuke Sugaya 2014-09-12 16:50:17 +09:00
parent 278b8e97b5
commit 363ba6eb52

View file

@ -62,6 +62,10 @@ public class CrawlJob {
protected int documentExpires = -2;
protected int retryCountToDeleteTempDir = 10;
protected long retryIntervalToDeleteTempDir = 5000;
public CrawlJob jobExecutor(final JobExecutor jobExecutor) {
this.jobExecutor = jobExecutor;
return this;
@ -102,6 +106,12 @@ public class CrawlJob {
return this;
}
public void retryToDeleteTempDir(final int retryCount,
final long retryInterval) {
retryCountToDeleteTempDir = retryCount;
retryIntervalToDeleteTempDir = retryInterval;
}
public String execute(final JobExecutor jobExecutor) {
jobExecutor(jobExecutor);
operation(Constants.COMMIT);
@ -332,14 +342,32 @@ public class CrawlJob {
} catch (final Exception e) {
throw new FessSystemException("Crawler Process terminated.", e);
} finally {
jobHelper.destroyCrawlerProcess(sessionId);
if (ownTmpDir != null && !ownTmpDir.delete()) {
logger.warn("Could not delete a temp dir: "
+ ownTmpDir.getAbsolutePath());
try {
jobHelper.destroyCrawlerProcess(sessionId);
} finally {
deleteTempDir(ownTmpDir);
}
}
}
protected void deleteTempDir(final File ownTmpDir) {
if (ownTmpDir == null) {
return;
}
for (int i = 0; i < retryCountToDeleteTempDir; i++) {
if (ownTmpDir.delete()) {
return;
}
try {
Thread.sleep(retryIntervalToDeleteTempDir);
} catch (final InterruptedException e) {
// ignore
}
}
logger.warn("Could not delete a temp dir: "
+ ownTmpDir.getAbsolutePath());
}
protected void appendJarFile(final String cpSeparator,
final ServletContext servletContext, final StringBuilder buf,
final String libDirPath, final String basePath) {