lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject [1/6] lucene-solr:jira/solr-11285: SOLR-11285: Allow for now KeeperException-s to be thrown.
Date Tue, 03 Oct 2017 11:26:29 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/jira/solr-11285 185bcb774 -> efa281e87


SOLR-11285: Allow for now KeeperException-s to be thrown.


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/b1cea153
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/b1cea153
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/b1cea153

Branch: refs/heads/jira/solr-11285
Commit: b1cea153221ec2ccd6d9ef9bb2e07ff11e7f588c
Parents: 185bcb7
Author: Andrzej Bialecki <ab@apache.org>
Authored: Mon Oct 2 10:44:49 2017 +0200
Committer: Andrzej Bialecki <ab@apache.org>
Committed: Mon Oct 2 10:44:49 2017 +0200

----------------------------------------------------------------------
 .../src/java/org/apache/solr/cloud/Assign.java  |  5 +--
 .../cloud/autoscaling/ExecutePlanAction.java    |  3 +-
 .../autoscaling/OverseerTriggerThread.java      |  3 +-
 .../solr/cloud/autoscaling/TriggerBase.java     |  5 +--
 .../cloud/autoscaling/DistribStateManager.java  | 19 +++++------
 .../solrj/impl/ZkDistribStateManager.java       | 34 ++++++--------------
 6 files changed, 29 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b1cea153/solr/core/src/java/org/apache/solr/cloud/Assign.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/Assign.java b/solr/core/src/java/org/apache/solr/cloud/Assign.java
index 08fc7d0..3c81572 100644
--- a/solr/core/src/java/org/apache/solr/cloud/Assign.java
+++ b/solr/core/src/java/org/apache/solr/cloud/Assign.java
@@ -53,6 +53,7 @@ import org.apache.solr.common.util.Utils;
 import org.apache.solr.core.CoreContainer;
 import org.apache.solr.util.NumberUtils;
 import org.apache.zookeeper.CreateMode;
+import org.apache.zookeeper.KeeperException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -84,7 +85,7 @@ public class Assign {
     } catch (InterruptedException e) {
       Thread.interrupted();
       throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Error creating counter
node in Zookeeper for collection:" + collection, e);
-    } catch (IOException e) {
+    } catch (IOException | KeeperException e) {
       throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Error creating counter
node in Zookeeper for collection:" + collection, e);
     }
 
@@ -102,7 +103,7 @@ public class Assign {
         return currentId;
       } catch (BadVersionException e) {
         continue;
-      } catch (IOException e) {
+      } catch (IOException | KeeperException e) {
         throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Error inc and get
counter from Zookeeper for collection:"+collection, e);
       } catch (InterruptedException e) {
         Thread.interrupted();

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b1cea153/solr/core/src/java/org/apache/solr/cloud/autoscaling/ExecutePlanAction.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/autoscaling/ExecutePlanAction.java b/solr/core/src/java/org/apache/solr/cloud/autoscaling/ExecutePlanAction.java
index 8728ecd..873bd1e 100644
--- a/solr/core/src/java/org/apache/solr/cloud/autoscaling/ExecutePlanAction.java
+++ b/solr/core/src/java/org/apache/solr/cloud/autoscaling/ExecutePlanAction.java
@@ -39,6 +39,7 @@ import org.apache.solr.common.cloud.ZkStateReader;
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.common.util.Utils;
 import org.apache.zookeeper.CreateMode;
+import org.apache.zookeeper.KeeperException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -163,7 +164,7 @@ public class ExecutePlanAction extends TriggerActionBase {
    *
    * @return the path of the newly created node in ZooKeeper
    */
-  private String saveAsyncId(DistribStateManager stateManager, TriggerEvent event, String
asyncId) throws InterruptedException, AlreadyExistsException, IOException {
+  private String saveAsyncId(DistribStateManager stateManager, TriggerEvent event, String
asyncId) throws InterruptedException, AlreadyExistsException, IOException, KeeperException
{
     String parentPath = ZkStateReader.SOLR_AUTOSCALING_TRIGGER_STATE_PATH + "/" + event.getSource()
+ "/" + getName();
     stateManager.makePath(parentPath);
     return stateManager.createData(parentPath + "/" + PREFIX, Utils.toJSON(Collections.singletonMap("requestid",
asyncId)), CreateMode.PERSISTENT_SEQUENTIAL);

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b1cea153/solr/core/src/java/org/apache/solr/cloud/autoscaling/OverseerTriggerThread.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/autoscaling/OverseerTriggerThread.java
b/solr/core/src/java/org/apache/solr/cloud/autoscaling/OverseerTriggerThread.java
index 8cf3707..d3641f6 100644
--- a/solr/core/src/java/org/apache/solr/cloud/autoscaling/OverseerTriggerThread.java
+++ b/solr/core/src/java/org/apache/solr/cloud/autoscaling/OverseerTriggerThread.java
@@ -41,6 +41,7 @@ import org.apache.solr.common.util.IOUtils;
 import org.apache.solr.common.util.Utils;
 import org.apache.solr.core.CloudConfig;
 import org.apache.solr.core.SolrResourceLoader;
+import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.Watcher;
 import org.slf4j.Logger;
@@ -121,7 +122,7 @@ public class OverseerTriggerThread implements Runnable, Closeable {
         Thread.currentThread().interrupt();
         log.warn("Interrupted", e);
         break;
-      } catch (IOException e) {
+      } catch (IOException | KeeperException e) {
         log.error("A ZK error has occurred", e);
       }
     }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b1cea153/solr/core/src/java/org/apache/solr/cloud/autoscaling/TriggerBase.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/autoscaling/TriggerBase.java b/solr/core/src/java/org/apache/solr/cloud/autoscaling/TriggerBase.java
index 87dba48..d2b6196 100644
--- a/solr/core/src/java/org/apache/solr/cloud/autoscaling/TriggerBase.java
+++ b/solr/core/src/java/org/apache/solr/cloud/autoscaling/TriggerBase.java
@@ -38,6 +38,7 @@ import org.apache.solr.common.cloud.ZkStateReader;
 import org.apache.solr.common.util.Utils;
 import org.apache.solr.core.SolrResourceLoader;
 import org.apache.zookeeper.CreateMode;
+import org.apache.zookeeper.KeeperException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -86,7 +87,7 @@ public abstract class TriggerBase implements AutoScaling.Trigger {
       if (!stateManager.hasData(ZkStateReader.SOLR_AUTOSCALING_TRIGGER_STATE_PATH)) {
         stateManager.makePath(ZkStateReader.SOLR_AUTOSCALING_TRIGGER_STATE_PATH);
       }
-    } catch (InterruptedException | IOException e) {
+    } catch (InterruptedException | KeeperException | IOException e) {
       LOG.warn("Exception checking ZK path " + ZkStateReader.SOLR_AUTOSCALING_TRIGGER_STATE_PATH,
e);
     }
   }
@@ -205,7 +206,7 @@ public abstract class TriggerBase implements AutoScaling.Trigger {
         stateManager.createData(path, data, CreateMode.PERSISTENT);
       }
       lastState = state;
-    } catch (InterruptedException | BadVersionException | AlreadyExistsException | IOException
e) {
+    } catch (InterruptedException | BadVersionException | AlreadyExistsException | IOException
| KeeperException e) {
       LOG.warn("Exception updating trigger state '" + path + "'", e);
     }
   }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b1cea153/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/DistribStateManager.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/DistribStateManager.java
b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/DistribStateManager.java
index b9d9655..9f69c49 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/DistribStateManager.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/DistribStateManager.java
@@ -21,6 +21,7 @@ import java.util.List;
 import java.util.NoSuchElementException;
 
 import org.apache.zookeeper.CreateMode;
+import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.Op;
 import org.apache.zookeeper.OpResult;
 import org.apache.zookeeper.Watcher;
@@ -32,27 +33,27 @@ public interface DistribStateManager {
 
   // state accessors
 
-  boolean hasData(String path) throws IOException, InterruptedException;
+  boolean hasData(String path) throws IOException, KeeperException, InterruptedException;
 
-  List<String> listData(String path) throws NoSuchElementException, IOException, InterruptedException;
+  List<String> listData(String path) throws NoSuchElementException, IOException, KeeperException,
InterruptedException;
 
-  VersionedData getData(String path, Watcher watcher) throws NoSuchElementException, IOException,
InterruptedException;
+  VersionedData getData(String path, Watcher watcher) throws NoSuchElementException, IOException,
KeeperException, InterruptedException;
 
-  default VersionedData getData(String path) throws NoSuchElementException, IOException,
InterruptedException {
+  default VersionedData getData(String path) throws NoSuchElementException, IOException,
KeeperException, InterruptedException {
     return getData(path, null);
   }
 
   // state mutators
 
-  void makePath(String path) throws IOException, InterruptedException;
+  void makePath(String path) throws IOException, KeeperException, InterruptedException;
 
-  String createData(String path, byte[] data, CreateMode mode) throws AlreadyExistsException,
IOException, InterruptedException;
+  String createData(String path, byte[] data, CreateMode mode) throws AlreadyExistsException,
IOException, KeeperException, InterruptedException;
 
-  void removeData(String path, int version) throws NoSuchElementException, IOException, InterruptedException;
+  void removeData(String path, int version) throws NoSuchElementException, IOException, KeeperException,
InterruptedException;
 
-  void setData(String path, byte[] data, int version) throws BadVersionException, NoSuchElementException,
IOException, InterruptedException;
+  void setData(String path, byte[] data, int version) throws BadVersionException, NoSuchElementException,
IOException, KeeperException, InterruptedException;
 
-  List<OpResult> multi(final Iterable<Op> ops) throws BadVersionException, NoSuchElementException,
AlreadyExistsException, IOException, InterruptedException;
+  List<OpResult> multi(final Iterable<Op> ops) throws BadVersionException, NoSuchElementException,
AlreadyExistsException, IOException, KeeperException, InterruptedException;
 
   AutoScalingConfig getAutoScalingConfig(Watcher watcher) throws InterruptedException, IOException;
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b1cea153/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ZkDistribStateManager.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ZkDistribStateManager.java
b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ZkDistribStateManager.java
index 5816711..f3d2e62 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ZkDistribStateManager.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ZkDistribStateManager.java
@@ -52,100 +52,86 @@ public class ZkDistribStateManager implements DistribStateManager {
   }
 
   @Override
-  public boolean hasData(String path) throws IOException, InterruptedException {
+  public boolean hasData(String path) throws IOException, KeeperException, InterruptedException
{
     try {
       return zkClient.exists(path, true);
-    } catch (KeeperException e) {
-      throw new IOException(e);
     } catch (InterruptedException e) {
       throw e;
     }
   }
 
   @Override
-  public List<String> listData(String path) throws NoSuchElementException, IOException,
InterruptedException {
+  public List<String> listData(String path) throws NoSuchElementException, IOException,
KeeperException, InterruptedException {
     try {
       return zkClient.getChildren(path, null, true);
     } catch (KeeperException.NoNodeException e) {
       throw new NoSuchElementException(path);
-    } catch (KeeperException e) {
-      throw new IOException(e);
     } catch (InterruptedException e) {
       throw e;
     }
   }
 
   @Override
-  public VersionedData getData(String path, Watcher watcher) throws NoSuchElementException,
IOException, InterruptedException {
+  public VersionedData getData(String path, Watcher watcher) throws NoSuchElementException,
IOException, KeeperException, InterruptedException {
     Stat stat = new Stat();
     try {
       byte[] bytes = zkClient.getData(path, watcher, stat, true);
       return new VersionedData(stat.getVersion(), bytes, String.valueOf(stat.getEphemeralOwner()));
     } catch (KeeperException.NoNodeException e) {
       throw new NoSuchElementException(path);
-    } catch (KeeperException e) {
-      throw new IOException(e);
     } catch (InterruptedException e) {
       throw e;
     }
   }
 
   @Override
-  public void makePath(String path) throws IOException, InterruptedException {
+  public void makePath(String path) throws IOException, KeeperException, InterruptedException
{
     try {
       zkClient.makePath(path, true);
     } catch (KeeperException.NodeExistsException e) {
-      // ignore - someone beat it to it
-    } catch (KeeperException e) {
-      throw new IOException(e);
+      // ignore - someone beat us to it
     } catch (InterruptedException e) {
       throw e;
     }
   }
 
   @Override
-  public String createData(String path, byte[] data, CreateMode mode) throws AlreadyExistsException,
IOException, InterruptedException {
+  public String createData(String path, byte[] data, CreateMode mode) throws AlreadyExistsException,
IOException, KeeperException, InterruptedException {
     try {
       return zkClient.create(path, data, mode, true);
     } catch (KeeperException.NodeExistsException e) {
       throw new AlreadyExistsException(path);
-    } catch (KeeperException e) {
-      throw new IOException(e);
     } catch (InterruptedException e) {
       throw e;
     }
   }
 
   @Override
-  public void removeData(String path, int version) throws NoSuchElementException, IOException,
InterruptedException {
+  public void removeData(String path, int version) throws NoSuchElementException, IOException,
KeeperException, InterruptedException {
     try {
       zkClient.delete(path, version, true);
     } catch (KeeperException.NoNodeException e) {
       throw new NoSuchElementException(path);
-    } catch (KeeperException e) {
-      throw new IOException(e);
     } catch (InterruptedException e) {
       throw e;
     }
   }
 
   @Override
-  public void setData(String path, byte[] data, int version) throws BadVersionException,
NoSuchElementException, IOException, InterruptedException {
+  public void setData(String path, byte[] data, int version) throws BadVersionException,
NoSuchElementException, IOException, KeeperException, InterruptedException {
     try {
       zkClient.setData(path, data, version, true);
     } catch (KeeperException.NoNodeException e) {
       throw new NoSuchElementException(path);
     } catch (KeeperException.BadVersionException e) {
       throw new BadVersionException(version, path);
-    } catch (KeeperException e) {
-      throw new IOException(e);
     } catch (InterruptedException e) {
       throw e;
     }
   }
 
   @Override
-  public List<OpResult> multi(Iterable<Op> ops) throws BadVersionException, AlreadyExistsException,
NoSuchElementException, IOException, InterruptedException {
+  public List<OpResult> multi(Iterable<Op> ops) throws BadVersionException, AlreadyExistsException,
NoSuchElementException, IOException, KeeperException, InterruptedException {
     try {
       return zkClient.multi(ops, true);
     } catch (KeeperException.NoNodeException e) {
@@ -154,8 +140,6 @@ public class ZkDistribStateManager implements DistribStateManager {
       throw new AlreadyExistsException(ops.toString());
     } catch (KeeperException.BadVersionException e) {
       throw new BadVersionException(-1, ops.toString());
-    } catch (KeeperException e) {
-      throw new IOException(e);
     } catch (InterruptedException e) {
       throw e;
     }


Mime
View raw message