NativeFSLockFactory nativeLockFactory = this.getNativeLockFactory();
lock = nativeLockFactory.makeLock(BACKGROUND_LOCKNAME);
} catch (IOException e) {
String msg = pfx+" "+e.getMessage();
getLogger().log(Level.WARNING,pfx,e);
throw new LockObtainFailedException(msg);
}
} else {
try {
File fDir = new File(this.luceneConfig.getIndexLocation());
SimpleFSLockFactory factory = new SimpleFSLockFactory(fDir);
factory.setLockPrefix("lucene-simple");
lock = factory.makeLock(BACKGROUND_LOCKNAME);
} catch (IOException e) {
String msg = pfx+" "+e.getMessage();
getLogger().log(Level.WARNING,pfx,e);
throw new LockObtainFailedException(msg);
}
}
try {
boolean wasObtained = lock.obtain();
if (!wasObtained) {
String msg = "Unable to obtain background lock for: "+lock.toString();
throw new LockObtainFailedException(msg);
}
return lock;
} catch (LockObtainFailedException e) {
throw e;
} catch (IOException e) {
String msg = pfx+" "+e.getMessage();
getLogger().log(Level.WARNING,pfx,e);
throw new LockObtainFailedException(msg);
}
}