Skip to content

Apache Lucene open-source search software

SOLR-4596: DistributedQueue should ensure its full path exists in the constructor.

Mark Robert Miller2549f2e1ef4b
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index d02b53327f1..ec3260ba1e1 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -158,6 +158,9 @@ Other Changes
* SOLR-4571: SolrZkClient#setData should return Stat object. (Mark Miller)
+* SOLR-4596: DistributedQueue should ensure its full path exists in the constructor.
+ (Mark Miller)
+
================== 4.2.0 ==================
Versions of Major Components
diff --git a/solr/core/src/java/org/apache/solr/cloud/DistributedQueue.java b/solr/core/src/java/org/apache/solr/cloud/DistributedQueue.java
index d012d5ef71c..bbb42dff636 100644
--- a/solr/core/src/java/org/apache/solr/cloud/DistributedQueue.java
+++ b/solr/core/src/java/org/apache/solr/cloud/DistributedQueue.java
@@ -22,7 +22,10 @@ import java.util.List;
import java.util.NoSuchElementException;
import java.util.TreeMap;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.common.cloud.SolrZkClient;
+import org.apache.solr.common.cloud.ZkCmdExecutor;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.WatchedEvent;
@@ -53,6 +56,16 @@ public class DistributedQueue {
public DistributedQueue(SolrZkClient zookeeper, String dir, List<ACL> acl) {
this.dir = dir;
+ ZkCmdExecutor cmdExecutor = new ZkCmdExecutor(30);
+ try {
+ cmdExecutor.ensureExists(dir, zookeeper);
+ } catch (KeeperException e) {
+ throw new SolrException(ErrorCode.SERVER_ERROR, e);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new SolrException(ErrorCode.SERVER_ERROR, e);
+ }
+
if (acl != null) {
this.acl = acl;
}