Issue #1489 Harvester directories not created causing harvester to not start
Change-Id: Id5caa14ebc33451f95e5d1e9d685c4094091ff63 Former-commit-id:e5b4934da1
[formerly34577b50dd
] [formerly9b75eaf869
] [formerlyb6bf73134e
[formerly9b75eaf869
[formerly 08b944fa708ba12ac6df63b64501ff20f4738063]]] Former-commit-id:b6bf73134e
Former-commit-id: 3db6fe5b5d30defe833550d4242d81c1a27c008e [formerlyccf832dd38
] Former-commit-id:fa9dc500a3
This commit is contained in:
parent
eedb2903b1
commit
e45aff44f4
1 changed files with 8 additions and 0 deletions
|
@ -154,8 +154,15 @@ public abstract class Crawler {
|
||||||
File lockFileDir, String crawlType) {
|
File lockFileDir, String crawlType) {
|
||||||
FileChannel channel = null;
|
FileChannel channel = null;
|
||||||
FileOutputStream fos = null;
|
FileOutputStream fos = null;
|
||||||
|
// if lock file directories don't exist, create
|
||||||
|
if (!lockFileDir.exists()) {
|
||||||
|
lockFileDir.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
File lockFile = new File(lockFileDir, crawlType + "-crawl.lock");
|
File lockFile = new File(lockFileDir, crawlType + "-crawl.lock");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// if lock file doesn't exist, create it
|
||||||
if (!lockFile.exists()) {
|
if (!lockFile.exists()) {
|
||||||
lockFile.createNewFile();
|
lockFile.createNewFile();
|
||||||
}
|
}
|
||||||
|
@ -165,6 +172,7 @@ public abstract class Crawler {
|
||||||
// Try acquiring the lock without blocking. This method returns
|
// Try acquiring the lock without blocking. This method returns
|
||||||
// null or throws an exception if the file is already locked.
|
// null or throws an exception if the file is already locked.
|
||||||
FileLock lock = channel.tryLock();
|
FileLock lock = channel.tryLock();
|
||||||
|
|
||||||
if (lock == null) {
|
if (lock == null) {
|
||||||
// Someone else has the lock
|
// Someone else has the lock
|
||||||
statusHandler
|
statusHandler
|
||||||
|
|
Loading…
Add table
Reference in a new issue