You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2014/01/13 21:58:44 UTC
svn commit: r1557848 - in /lucene/dev/branches/lucene_solr_4_6: ./ solr/
solr/CHANGES.txt solr/core/
solr/core/src/java/org/apache/solr/store/hdfs/HdfsLockFactory.java
solr/core/src/test/org/apache/solr/store/hdfs/HdfsLockFactoryTest.java
Author: markrmiller
Date: Mon Jan 13 20:58:43 2014
New Revision: 1557848
URL: http://svn.apache.org/r1557848
Log:
SOLR-5540: HdfsLockFactory should explicitly create the lock parent directory if necessary.
Modified:
lucene/dev/branches/lucene_solr_4_6/ (props changed)
lucene/dev/branches/lucene_solr_4_6/solr/ (props changed)
lucene/dev/branches/lucene_solr_4_6/solr/CHANGES.txt (contents, props changed)
lucene/dev/branches/lucene_solr_4_6/solr/core/ (props changed)
lucene/dev/branches/lucene_solr_4_6/solr/core/src/java/org/apache/solr/store/hdfs/HdfsLockFactory.java
lucene/dev/branches/lucene_solr_4_6/solr/core/src/test/org/apache/solr/store/hdfs/HdfsLockFactoryTest.java
Modified: lucene/dev/branches/lucene_solr_4_6/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_6/solr/CHANGES.txt?rev=1557848&r1=1557847&r2=1557848&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_6/solr/CHANGES.txt (original)
+++ lucene/dev/branches/lucene_solr_4_6/solr/CHANGES.txt Mon Jan 13 20:58:43 2014
@@ -88,6 +88,9 @@ Bug Fixes
* SOLR-5587: ElectionContext implementations should use
ZkCmdExecutor#ensureExists to ensure their election paths are properly
created. (Mark Miller)
+
+* SOLR-5540: HdfsLockFactory should explicitly create the lock parent directory if
+ necessary. (Mark Miller)
* SOLR-4709: The core reload after replication if config files have changed
can fail due to a race condition. (Mark Miller, Hossman))
Modified: lucene/dev/branches/lucene_solr_4_6/solr/core/src/java/org/apache/solr/store/hdfs/HdfsLockFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_6/solr/core/src/java/org/apache/solr/store/hdfs/HdfsLockFactory.java?rev=1557848&r1=1557847&r2=1557848&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_6/solr/core/src/java/org/apache/solr/store/hdfs/HdfsLockFactory.java (original)
+++ lucene/dev/branches/lucene_solr_4_6/solr/core/src/java/org/apache/solr/store/hdfs/HdfsLockFactory.java Mon Jan 13 20:58:43 2014
@@ -21,14 +21,18 @@ import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.fs.FileAlreadyExistsException;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.lucene.store.Lock;
import org.apache.lucene.store.LockFactory;
import org.apache.lucene.store.LockReleaseFailedException;
import org.apache.solr.util.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class HdfsLockFactory extends LockFactory {
+ public static Logger log = LoggerFactory.getLogger(HdfsLockFactory.class);
private Path lockPath;
private Configuration configuration;
@@ -98,9 +102,14 @@ public class HdfsLockFactory extends Loc
FileSystem fs = null;
try {
fs = FileSystem.newInstance(lockPath.toUri(), conf);
-
+ if (!fs.exists(lockPath)) {
+ fs.mkdirs(lockPath);
+ }
file = fs.create(new Path(lockPath, lockName), false);
- } catch (IOException e) {
+ } catch (FileAlreadyExistsException e) {
+ return false;
+ }catch (IOException e) {
+ log.error("Error creating lock file", e);
return false;
} finally {
IOUtils.closeQuietly(file);
Modified: lucene/dev/branches/lucene_solr_4_6/solr/core/src/test/org/apache/solr/store/hdfs/HdfsLockFactoryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_6/solr/core/src/test/org/apache/solr/store/hdfs/HdfsLockFactoryTest.java?rev=1557848&r1=1557847&r2=1557848&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_6/solr/core/src/test/org/apache/solr/store/hdfs/HdfsLockFactoryTest.java (original)
+++ lucene/dev/branches/lucene_solr_4_6/solr/core/src/test/org/apache/solr/store/hdfs/HdfsLockFactoryTest.java Mon Jan 13 20:58:43 2014
@@ -68,7 +68,7 @@ public class HdfsLockFactoryTest extends
@Test
public void testBasic() throws IOException {
URI uri = dfsCluster.getURI();
- Path lockPath = new Path(uri.toString(), "/lock");
+ Path lockPath = new Path(uri.toString(), "/basedir/lock");
HdfsLockFactory lockFactory = new HdfsLockFactory(lockPath, new Configuration());
Lock lock = lockFactory.makeLock("testlock");
boolean success = lock.obtain();