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 2011/12/09 14:58:19 UTC
svn commit: r1212426 - in /lucene/dev/branches/solrcloud/solr:
core/src/java/org/apache/solr/cloud/ core/src/java/org/apache/solr/update/
core/src/java/org/apache/solr/update/processor/
core/src/test/org/apache/solr/cloud/ solrj/src/java/org/apache/sol...
Author: markrmiller
Date: Fri Dec 9 13:58:19 2011
New Revision: 1212426
URL: http://svn.apache.org/viewvc?rev=1212426&view=rev
Log:
commit sami's recent overseer improvements
Removed:
lucene/dev/branches/solrcloud/solr/solrj/src/java/org/apache/solr/common/cloud/CloudStateUtility.java
Modified:
lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/AssignShard.java
lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/NodeStateWatcher.java
lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/Overseer.java
lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/OverseerElector.java
lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/ZkController.java
lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java
lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java
lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java
lucene/dev/branches/solrcloud/solr/solrj/src/java/org/apache/solr/common/cloud/CloudState.java
lucene/dev/branches/solrcloud/solr/solrj/src/java/org/apache/solr/common/cloud/CoreAssignment.java
lucene/dev/branches/solrcloud/solr/solrj/src/java/org/apache/solr/common/cloud/CoreState.java
lucene/dev/branches/solrcloud/solr/solrj/src/java/org/apache/solr/common/cloud/ZkNodeProps.java
lucene/dev/branches/solrcloud/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
Modified: lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/AssignShard.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/AssignShard.java?rev=1212426&r1=1212425&r2=1212426&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/AssignShard.java (original)
+++ lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/AssignShard.java Fri Dec 9 13:58:19 2011
@@ -26,7 +26,6 @@ import java.util.Map;
import org.apache.solr.common.cloud.CloudState;
import org.apache.solr.common.cloud.Slice;
-import org.apache.solr.common.cloud.ZkNodeProps;
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.zookeeper.KeeperException;
@@ -42,31 +41,9 @@ public class AssignShard {
* @throws InterruptedException
* @throws KeeperException
*/
- public static String assignShard(String collection,
- ZkNodeProps collectionProperties, CloudState state) {
+ public static String assignShard(String collection, CloudState state) {
- int shards = 0;
- String numShardsString = null;
- if (collectionProperties != null) {
- numShardsString = collectionProperties.get(ZkStateReader.NUM_SHARDS_PROP);
- }
-
- if (numShardsString == null) {
- System.out.println("no shards count specified for collection "
- + collection);
- if (System.getProperty("numShards") == null) {
- System.out.println("no shards count specified in system property, using 1");
- shards = 1;
- } else {
- shards = Integer.parseInt(System.getProperty("numShards")); // XXXX
- System.out.println("Shard count (System.property): " + shards);
- }
- } else {
- shards = Integer.parseInt(numShardsString);
- }
-
-
- //System.out.println("final shard count: " + shards);
+ int shards = Integer.getInteger(ZkStateReader.NUM_SHARDS_PROP,1);
String returnShardId = null;
Map<String, Slice> sliceMap = state.getSlices(collection);
Modified: lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/NodeStateWatcher.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/NodeStateWatcher.java?rev=1212426&r1=1212425&r2=1212426&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/NodeStateWatcher.java (original)
+++ lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/NodeStateWatcher.java Fri Dec 9 13:58:19 2011
@@ -17,7 +17,6 @@ package org.apache.solr.cloud;
* the License.
*/
-import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
@@ -41,11 +40,8 @@ public class NodeStateWatcher implements
private static Logger log = LoggerFactory.getLogger(NodeStateWatcher.class);
public static interface NodeStateChangeListener {
- void coreCreated(String shardZkNodeName, Set<CoreState> cores) throws IOException, KeeperException;
-
- void coreDeleted(String shardZkNodeName, Set<CoreState> cores);
-
- void coreChanged(String nodeName, Set<CoreState> cores) throws IOException, KeeperException;
+ void coreCreated(String shardZkNodeName, Set<CoreState> cores) throws KeeperException;
+ void coreChanged(String nodeName, Set<CoreState> cores) throws KeeperException;
}
private final SolrZkClient zkClient;
@@ -92,19 +88,12 @@ public class NodeStateWatcher implements
void processStateChange(byte[] data) {
if (data != null) {
- try {
CoreState[] states = CoreState.load(data);
List<CoreState> stateList = Arrays.asList(states);
-
- // get new cores:
HashSet<CoreState> newCores = new HashSet<CoreState>();
newCores.addAll(stateList);
newCores.removeAll(currentState);
- HashSet<CoreState> deadCores = new HashSet<CoreState>();
- deadCores.addAll(currentState);
- deadCores.removeAll(stateList);
-
HashSet<CoreState> newState = new HashSet<CoreState>();
newState.addAll(stateList);
@@ -130,30 +119,17 @@ public class NodeStateWatcher implements
try {
listener.coreCreated(nodeName, Collections.unmodifiableSet(newCores));
} catch (KeeperException e) {
- //zk error, stop
-// stop=true;
log.warn("Could not talk to ZK", e);
}
}
- if (deadCores.size() > 0) {
- listener.coreDeleted(nodeName, Collections.unmodifiableSet(deadCores));
- }
if (changedCores.size() > 0) {
try {
listener.coreChanged(nodeName, Collections.unmodifiableSet(changedCores));
} catch (KeeperException e) {
log.warn("Could not talk to ZK", e);
- //zk error, stop
- // stop=true;
}
}
-
-
- } catch (IOException e) {
- e.printStackTrace();
- }
-
} else {
// ignore null state
}
Modified: lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/Overseer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/Overseer.java?rev=1212426&r1=1212425&r2=1212426&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/Overseer.java (original)
+++ lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/Overseer.java Fri Dec 9 13:58:19 2011
@@ -17,7 +17,6 @@ package org.apache.solr.cloud;
* the License.
*/
-import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -39,8 +38,6 @@ import org.apache.zookeeper.KeeperExcept
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import sun.rmi.transport.LiveRef;
-
/**
* Cluster leader. Responsible node assignments, cluster state file?
*/
@@ -48,35 +45,18 @@ public class Overseer implements NodeSta
private static Logger log = LoggerFactory.getLogger(Overseer.class);
- private SolrZkClient zkClient;
-
- private volatile CloudState cloudState = new CloudState();
-
- // desired collection configuration
- private HashMap<String,ZkNodeProps> collections = new HashMap<String, ZkNodeProps>();
-
-// // live nodes
-// private HashMap<String,ZkNodeProps> liveNodes = new HashMap<String, ZkNodeProps>();
+ private final SolrZkClient zkClient;
+ private final ZkStateReader reader;
// node stateWatches
private HashMap<String,NodeStateWatcher> nodeStateWatches = new HashMap<String,NodeStateWatcher>();
- public Overseer(final SolrZkClient zkClient) throws KeeperException {
+ public Overseer(final SolrZkClient zkClient, final ZkStateReader reader) throws KeeperException, InterruptedException {
log.info("Constructing new Overseer");
this.zkClient = zkClient;
-
- try {
- createZkNodes(zkClient);
- createClusterStateWatchersAndUpdate();
- } catch (InterruptedException e) {
- // nocommit
- e.printStackTrace();
- } catch (KeeperException e) {
- // nocommit
- e.printStackTrace();
- } catch (IOException e) {
- throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,"",e);
- }
+ this.reader = reader;
+ createZkNodes(zkClient);
+ createWatches();
}
public static void createZkNodes(SolrZkClient zkClient) throws KeeperException, InterruptedException {
@@ -88,15 +68,12 @@ public class Overseer implements NodeSta
if (e.code() != KeeperException.Code.NODEEXISTS) {
throw e;
}
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
}
}
}
- public synchronized void createClusterStateWatchersAndUpdate()
- throws KeeperException, InterruptedException, IOException {
+ public synchronized void createWatches()
+ throws KeeperException, InterruptedException {
// We need to fetch the current cluster state and the set of live nodes
if (!zkClient.exists(ZkStateReader.CLUSTER_STATE)) {
@@ -111,48 +88,7 @@ public class Overseer implements NodeSta
}
}
- log.info("Getting the existing cluster state from ZooKeeper... ");
- cloudState = CloudStateUtility.get(zkClient, null);
-
- //watch for live nodes
addLiveNodesWatch();
-
- // watch collections
- addCollectionsWatch();
- }
-
- private void addCollectionsWatch() throws KeeperException,
- InterruptedException {
- final List<String> collections = zkClient.getChildren(
- ZkStateReader.COLLECTIONS_ZKNODE, new Watcher() {
-
- @Override
- public void process(WatchedEvent event) {
- log.info("Updating collections");
- try {
- List<String> collections = zkClient.getChildren(
- ZkStateReader.COLLECTIONS_ZKNODE, this);
- processCollectionChange(cloudState.getCollections(), collections);
- } catch (KeeperException e) {
- if (e.code() == KeeperException.Code.SESSIONEXPIRED
- || e.code() == KeeperException.Code.CONNECTIONLOSS) {
- log.warn("ZooKeeper watch triggered, but Solr cannot talk to ZK");
- return;
- }
- log.error("", e);
- throw new ZooKeeperException(
- SolrException.ErrorCode.SERVER_ERROR, "", e);
- } catch (InterruptedException e) {
- // Restore the interrupted status
- Thread.currentThread().interrupt();
- log.error("", e);
- throw new ZooKeeperException(
- SolrException.ErrorCode.SERVER_ERROR, "", e);
- }
- }
- });
-
- processCollectionChange(cloudState.getCollections(), collections);
}
private void addLiveNodesWatch() throws KeeperException,
@@ -167,7 +103,7 @@ public class Overseer implements NodeSta
ZkStateReader.LIVE_NODES_ZKNODE, this);
Set<String> liveNodesSet = new HashSet<String>();
liveNodesSet.addAll(liveNodes);
- processLiveNodesChanged(cloudState.getLiveNodes(), liveNodes);
+ processLiveNodesChanged(nodeStateWatches.keySet(), liveNodes);
} catch (KeeperException e) {
if (e.code() == KeeperException.Code.SESSIONEXPIRED
|| e.code() == KeeperException.Code.CONNECTIONLOSS) {
@@ -190,30 +126,21 @@ public class Overseer implements NodeSta
processLiveNodesChanged(Collections.EMPTY_SET, liveNodes);
}
- private void processCollectionChange(Set<String> oldCollections,
- List<String> newCollections) {
- Set<String> downCollections = complement(oldCollections, newCollections);
- if (downCollections.size() > 0) {
- collectionsDown(downCollections);
- }
- Set<String> upCollections = complement(newCollections, oldCollections);
- if (upCollections.size() > 0) {
- collectionsUp(upCollections);
- }
- }
-
private void processLiveNodesChanged(Collection<String> oldLiveNodes,
Collection<String> liveNodes) {
- Set<String> downNodes = complement(oldLiveNodes, liveNodes);
- if (downNodes.size() > 0) {
- nodesDown(downNodes);
- }
Set<String> upNodes = complement(liveNodes, oldLiveNodes);
if (upNodes.size() > 0) {
- nodesUp(upNodes);
addNodeStateWatches(upNodes);
}
+
+ Set<String> downNodes = complement(oldLiveNodes, liveNodes);
+ for(String node: downNodes) {
+ NodeStateWatcher watcher = nodeStateWatches.remove(node);
+ if(watcher!=null) {
+ watcher.close();
+ }
+ }
}
private void addNodeStateWatches(Set<String> nodeNames) {
@@ -228,11 +155,13 @@ public class Overseer implements NodeSta
}
} catch (KeeperException e1) {
if (e1.code() != Code.NODEEXISTS) {
- e1.printStackTrace();
+ throw new SolrException(
+ SolrException.ErrorCode.SERVER_ERROR, "Could not create node for watch. Connection lost?", e1);
}
} catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ Thread.currentThread().interrupt();
+ throw new SolrException(
+ SolrException.ErrorCode.SERVER_ERROR, "Could not create node for watch. Connection lost?", e);
}
NodeStateWatcher nsw = new NodeStateWatcher(zkClient, nodeName, path, this);
@@ -241,14 +170,15 @@ public class Overseer implements NodeSta
byte[] state = zkClient.getData(path, nsw, null);
nsw.processStateChange(state);
} catch (KeeperException e) {
- //nocommit
- log.error("", e);
+ throw new SolrException(
+ SolrException.ErrorCode.SERVER_ERROR, "Could not read initial node state. Connection lost?", e);
} catch (InterruptedException e) {
- //nocommit
+ Thread.currentThread().interrupt();
+ throw new SolrException(
+ SolrException.ErrorCode.SERVER_ERROR, "Could not read initial node state. Connection lost?", e);
}
-
} else {
- log.info("watch already added");
+ log.debug("watch already added");
}
}
}
@@ -257,18 +187,15 @@ public class Overseer implements NodeSta
/**
* Try to assign core to the cluster
*/
- private void updateState(CoreState coreState) {
-
- //System.out.println("updateState called for core:" + coreState);
-
+ private void updateState(String nodeName, CoreState coreState) {
String collection = coreState.getCollectionName();
String coreName = coreState.getCoreName();
- synchronized (cloudState) {
+ synchronized (reader.getUpdateLock()) {
String shardId;
+ CloudState state = reader.getCloudState();
if (coreState.getProperties().get(ZkStateReader.SHARD_ID_PROP) == null) {
- shardId = AssignShard.assignShard(collection,
- collections.get(collection), cloudState);
+ shardId = AssignShard.assignShard(collection, state);
} else {
shardId = coreState.getProperties().get(ZkStateReader.SHARD_ID_PROP);
}
@@ -278,122 +205,53 @@ public class Overseer implements NodeSta
props.put(entry.getKey(), entry.getValue());
}
ZkNodeProps zkProps = new ZkNodeProps(props);
- Slice slice = cloudState.getSlice(collection, shardId);
+ Slice slice = state.getSlice(collection, shardId);
Map<String,ZkNodeProps> shardProps;
if (slice == null) {
shardProps = new HashMap<String,ZkNodeProps>();
} else {
- shardProps = cloudState.getSlice(collection, shardId).getShardsCopy();
+ shardProps = state.getSlice(collection, shardId).getShardsCopy();
}
shardProps.put(coreName, zkProps);
slice = new Slice(shardId, shardProps);
- CloudState state = new CloudState(cloudState.getLiveNodes(),
- cloudState.getCollectionStates());
- state.addSlice(collection, slice);
- cloudState = state;
- publishCloudState();
- }
- }
-
- /*
- * Let others know about state change.
- */
- private void publishCloudState() {
- try {
- CloudStateUtility.update(zkClient, cloudState, null);
- } catch (KeeperException e) {
- log.error("Could not publish cloud state.", e);
- } catch (InterruptedException e) {
- log.error("Could not publish cloud state.", e);
- } catch (IOException e) {
- log.error("Could not publish cloud state.", e);
- }
- }
-
- protected void nodesUp(Set<String> nodes) {
- log.debug("nodes appeared: " + nodes);
- synchronized (cloudState) {
- HashSet<String> currentNodes = new HashSet<String>();
- currentNodes.addAll(cloudState.getLiveNodes());
- currentNodes.addAll(nodes);
- CloudState state = new CloudState(currentNodes,
- cloudState.getCollectionStates());
- cloudState = state;
- }
- }
-
- protected void nodesDown(Set<String> nodes) {
- synchronized (cloudState) {
- HashSet<String> currentNodes = new HashSet<String>();
- currentNodes.addAll(cloudState.getLiveNodes());
- currentNodes.removeAll(nodes);
- CloudState state = new CloudState(currentNodes,
- cloudState.getCollectionStates());
- cloudState = state;
- }
- for(String node: nodes) {
- NodeStateWatcher watcher = nodeStateWatches.remove(node);
- if(watcher!=null) {
- watcher.close();
- }
- }
- }
-
- private void collectionsUp(Set<String> upCollections) {
- log.debug("Collections up: " + upCollections);
- for (String collection : upCollections) {
+ CloudState newCloudState = new CloudState(state.getLiveNodes(),
+ state.getCollectionStates());
+ newCloudState.addSlice(collection, slice);
try {
- byte[] data = zkClient.getData(ZkStateReader.COLLECTIONS_ZKNODE + "/"
- + collection, null, null);
- if (data != null) {
- ZkNodeProps props = new ZkNodeProps();
- try {
- props = ZkNodeProps.load(data);
- } catch (IOException e) {
- log.error("Could not load ZkNodeProps", e);
- }
- collections.put(collection, props);
- log.info("Registered collection " + collection + " with following properties: "
- + props);
- } else {
- log.info("Collection " + collection + " had no properties.");
- }
-
+ zkClient.setData(ZkStateReader.CLUSTER_STATE,
+ ZkStateReader.toJSON(newCloudState));
+ publishNodeAssignments(nodeName, newCloudState, nodeStateWatches.get(nodeName).getCurrentState());
} catch (KeeperException e) {
- log.error("Could not read collection settings.", e);
+ throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
+ "Could not publish new state. Connection lost?", e);
} catch (InterruptedException e) {
- log.error("Could not read collection settings.", e);
+ Thread.currentThread().interrupt();
+ throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
+ "Could not publish new state. Connection lost?", e);
}
}
- }
-
- private void collectionsDown(Set<String> downCollections) {
- log.info("Collections deleted: " + downCollections);
+
}
@Override
- public void coreCreated(String nodeName, Set<CoreState> states) throws IOException, KeeperException {
- log.info("Cores created: " + nodeName + " states:" +states);
+ public void coreCreated(String nodeName, Set<CoreState> states) throws KeeperException {
+ log.debug("Cores created: " + nodeName + " states:" +states);
for (CoreState state : states) {
- updateState(state);
+ updateState(nodeName, state);
}
-
- publishNodeAssignments(nodeName, cloudState, nodeStateWatches.get(nodeName).getCurrentState());
- }
-
- @Override
- public void coreDeleted(String nodeName, Set<CoreState> states) {
- log.info("Cores " + states + " deleted from node:" + nodeName);
}
/**
* Publish assignments for node
+ *
* @param node
- * @throws IOException
+ * @param cloudState
+ * @param states
+ * @throws KeeperException
*/
private void publishNodeAssignments(String node, CloudState cloudState,
- Set<CoreState> states) throws IOException, KeeperException {
+ Set<CoreState> states) throws KeeperException, InterruptedException {
ArrayList<CoreAssignment> assignments = new ArrayList<CoreAssignment>();
for(CoreState coreState: states) {
final String coreName = coreState.getCoreName();
@@ -406,30 +264,23 @@ public class Overseer implements NodeSta
coreProperties.put(ZkStateReader.SHARD_ID_PROP, entry.getKey());
}
}
-
CoreAssignment assignment = new CoreAssignment(coreName, collection, coreProperties);
assignments.add(assignment);
}
//serialize
byte[] content = ZkStateReader.toJSON(assignments);
- try {
- final String nodeName = "/node_assignments/" + node;
- if(!zkClient.exists(nodeName)) {
- try {
- zkClient.makePath(nodeName);
- } catch (KeeperException ke) {
- if(ke.code() != Code.NODEEXISTS) {
- throw ke;
- }
+ final String nodeName = "/node_assignments/" + node;
+ if (!zkClient.exists(nodeName)) {
+ try {
+ zkClient.makePath(nodeName);
+ } catch (KeeperException ke) {
+ if (ke.code() != Code.NODEEXISTS) {
+ throw ke;
}
}
-
- zkClient.setData(nodeName, content);
- } catch (InterruptedException e) {
- // nocommit
- e.printStackTrace();
}
+ zkClient.setData(nodeName, content);
}
private Set<String> complement(Collection<String> next,
@@ -441,13 +292,10 @@ public class Overseer implements NodeSta
}
@Override
- public void coreChanged(String nodeName, Set<CoreState> states) throws IOException, KeeperException {
- log.info("Cores changed: " + nodeName + " states:" + states);
+ public void coreChanged(String nodeName, Set<CoreState> states) throws KeeperException {
+ log.debug("Cores changed: " + nodeName + " states:" + states);
for (CoreState state : states) {
- updateState(state);
+ updateState(nodeName, state);
}
-
- publishNodeAssignments(nodeName, cloudState, nodeStateWatches.get(nodeName).getCurrentState());
}
-
-}
+}
\ No newline at end of file
Modified: lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/OverseerElector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/OverseerElector.java?rev=1212426&r1=1212425&r2=1212426&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/OverseerElector.java (original)
+++ lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/OverseerElector.java Fri Dec 9 13:58:19 2011
@@ -17,26 +17,35 @@ package org.apache.solr.cloud;
* limitations under the License.
*/
-import java.io.IOException;
-
import org.apache.solr.common.cloud.SolrZkClient;
+import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.zookeeper.KeeperException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
- * Overseer Election process. Simplify this.
+ * Overseer Elector.
*/
public class OverseerElector extends LeaderElector {
- SolrZkClient client;
+ private final SolrZkClient client;
+ private final ZkStateReader reader;
+ private static Logger log = LoggerFactory.getLogger(OverseerElector.class);
- public OverseerElector(SolrZkClient client) {
+ public OverseerElector(SolrZkClient client, ZkStateReader stateReader) {
super(client);
this.client = client;
+ this.reader = stateReader;
}
@Override
- protected void runIamLeaderProcess(ElectionContext context)
- throws KeeperException, InterruptedException, IOException {
- Overseer overseer = new Overseer(client);
+ protected void runIamLeaderProcess(ElectionContext context) {
+ try {
+ new Overseer(client, reader);
+ } catch (KeeperException e) {
+ log.error("Could not start overseer.", e);
+ } catch (InterruptedException e) {
+ log.error("Could not start overseer.", e);
+ }
}
}
Modified: lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/ZkController.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/ZkController.java?rev=1212426&r1=1212425&r2=1212426&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/ZkController.java (original)
+++ lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/ZkController.java Fri Dec 9 13:58:19 2011
@@ -93,7 +93,7 @@ public final class ZkController {
private OverseerElector overseerElector;
- private int numShards;
+ private int numShards; //not used anywhere now
private Map<String, CoreAssignment> assignments = new HashMap<String, CoreAssignment>();
@@ -305,7 +305,7 @@ public final class ZkController {
createEphemeralLiveNode();
setUpCollectionsNode();
- setupOverseerNodes();
+ createAssignmentsNode();
byte[] assignments = zkClient.getData(getAssignmentsNode(), new Watcher(){
@@ -336,7 +336,7 @@ public final class ZkController {
processAssignmentsUpdate(assignments);
- overseerElector = new OverseerElector(zkClient);
+ overseerElector = new OverseerElector(zkClient, zkStateReader);
ElectionContext context = new OverseerElectionContext(getNodeName());
overseerElector.setup(context);
overseerElector.joinElection(context);
@@ -502,8 +502,7 @@ public final class ZkController {
ElectionContext context = new ShardLeaderElectionContext(shardId, collection, shardZkNodeName, ZkStateReader.toJSON(zkProps));
leaderElector.setup(context);
- // leader election
- doLeaderElectionProcess(context);
+ leaderElector.joinElection(context);
// should be fine if we do this rather than read from cloud state since it's rare?
String leaderUrl = zkStateReader.getLeader(collection, cloudDesc.getShardId());
@@ -586,10 +585,8 @@ public final class ZkController {
Map<String,String> finalProps = new HashMap<String,String>();
finalProps.put(ZkStateReader.URL_PROP, shardUrl);
finalProps.put(ZkStateReader.NODE_NAME_PROP, getNodeName());
- finalProps.put(ZkStateReader.ROLES_PROP, cloudDesc.getRoles());
finalProps.put(ZkStateReader.STATE_PROP, ZkStateReader.ACTIVE);
finalProps.put(ZkStateReader.SHARD_ID_PROP, shardId);
-
publishState(cloudDesc, shardZkNodeName, finalProps);
}
@@ -617,12 +614,6 @@ public final class ZkController {
return true;
}
- private void doLeaderElectionProcess(ElectionContext context) throws KeeperException,
- InterruptedException, IOException {
-
- leaderElector.joinElection(context);
- }
-
/**
* @param coreName
* @param cloudDesc
@@ -684,7 +675,7 @@ public final class ZkController {
}
- private void setupOverseerNodes() throws KeeperException, InterruptedException {
+ private void createAssignmentsNode() throws KeeperException, InterruptedException {
String nodeName = getAssignmentsNode();
try {
@@ -709,7 +700,6 @@ public final class ZkController {
throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR,
"", e);
}
-
}
public void createCollectionZkNode(CloudDescriptor cd) throws KeeperException, InterruptedException, IOException {
@@ -788,7 +778,6 @@ public final class ZkController {
}
}
- collectionProps.put(ZkStateReader.NUM_SHARDS_PROP, Integer.toString(numShards));
ZkNodeProps zkProps = new ZkNodeProps(collectionProps);
zkClient.makePath(collectionPath, ZkStateReader.toJSON(zkProps), CreateMode.PERSISTENT, null, true);
@@ -861,7 +850,6 @@ public final class ZkController {
return assignment.getProperties().get(ZkStateReader.SHARD_ID_PROP);
}
-// System.out.println("current assignments:" + assignments);
try {
assignments.wait(500);
} catch (InterruptedException e) {
Modified: lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java?rev=1212426&r1=1212425&r2=1212426&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java (original)
+++ lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java Fri Dec 9 13:58:19 2011
@@ -357,7 +357,7 @@ public class SolrCmdDistributor {
newMsg, se.getCause());
} else {
e = new SolrException(SolrException.ErrorCode.SERVER_ERROR,
- "newMsg", e);
+ newMsg, e);
}
rsp.setException(e);
}
Modified: lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java?rev=1212426&r1=1212425&r2=1212426&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java (original)
+++ lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java Fri Dec 9 13:58:19 2011
@@ -186,10 +186,7 @@ public class DistributedUpdateProcessor
Thread.currentThread().interrupt();
throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR, "",
e);
- } catch (IOException e) {
- throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR, "",
- e);
- }
+ }
}
return shards;
Modified: lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java?rev=1212426&r1=1212425&r2=1212426&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java (original)
+++ lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java Fri Dec 9 13:58:19 2011
@@ -1,5 +1,22 @@
package org.apache.solr.cloud;
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
import java.io.File;
import java.util.HashMap;
import java.util.List;
@@ -47,8 +64,10 @@ public class OverseerTest extends SolrTe
zkClient = new SolrZkClient(server.getZkAddress(), TIMEOUT);
+ System.setProperty(ZkStateReader.NUM_SHARDS_PROP, "3");
+
zkController = new ZkController(server.getZkAddress(), TIMEOUT, 10000,
- "localhost", "8983", "solr", 3, new CurrentCoreDescriptorProvider() {
+ "localhost", "8983", "solr",3, new CurrentCoreDescriptorProvider() {
@Override
public List<CoreDescriptor> getCurrentDescriptors() {
@@ -59,20 +78,10 @@ public class OverseerTest extends SolrTe
System.setProperty("bootstrap_confdir", getFile("solr/conf")
.getAbsolutePath());
-
+
CloudDescriptor collection1Desc = new CloudDescriptor();
collection1Desc.setCollectionName("collection1");
- CloudDescriptor collection2Desc = new CloudDescriptor();
- collection2Desc.setCollectionName("collection2");
-
- //create collection specs
- Map<String,String> props = new HashMap<String,String>();
-
- props.put(ZkStateReader.NUM_SHARDS_PROP, "3");
- ZkNodeProps zkProps = new ZkNodeProps(props);
- zkClient.makePath("/collections/collection1", ZkStateReader.toJSON(zkProps));
-
CoreDescriptor desc = new CoreDescriptor(null, "core1", "");
desc.setCloudDescriptor(collection1Desc);
String shard1 = zkController.register("core1", desc);
@@ -119,29 +128,28 @@ public class OverseerTest extends SolrTe
}
server.shutdown();
}
-
+
+ System.clearProperty(ZkStateReader.NUM_SHARDS_PROP);
}
- private String getCoreName(String core) {
- return "localhost:8983_solr_" + core;
- }
-
//wait until i slices for collection have appeared
private void waitForSliceCount(ZkStateReader stateReader, String collection, int i) throws InterruptedException {
waitForCollections(stateReader, collection);
- while (true) {
+ int maxIterations = 100;
+ while (0 < maxIterations--) {
CloudState state = stateReader.getCloudState();
Map<String,Slice> sliceMap = state.getSlices(collection);
if (sliceMap.keySet().size() == i) {
return;
}
- Thread.sleep(10);
+ Thread.sleep(50);
}
}
//wait until collections are available
private void waitForCollections(ZkStateReader stateReader, String... collections) throws InterruptedException {
- while(true) {
+ int maxIterations = 100;
+ while (0 < maxIterations--) {
Set<String> availableCollections = stateReader.getCloudState().getCollections();
int availableCount = 0;
for(String requiredCollection: collections) {
@@ -149,7 +157,7 @@ public class OverseerTest extends SolrTe
availableCount++;
}
if(availableCount == collections.length) return;
- Thread.sleep(10);
+ Thread.sleep(50);
}
}
}
@@ -171,18 +179,17 @@ public class OverseerTest extends SolrTe
AbstractZkTestCase.tryCleanSolrZkNode(server.getZkHost());
AbstractZkTestCase.makeSolrZkNode(server.getZkHost());
zkClient.makePath("/live_nodes");
-
- // create collections
- Map<String,String> props = new HashMap<String,String>();
- props.put(ZkStateReader.NUM_SHARDS_PROP, "2");
- ZkNodeProps zkProps = new ZkNodeProps(props);
- zkClient.makePath("/collections/collection1", ZkStateReader.toJSON(zkProps));
+
+ System.setProperty(ZkStateReader.NUM_SHARDS_PROP, "2");
//live node
String nodePath = ZkStateReader.LIVE_NODES_ZKNODE + "/" + "node1";
zkClient.makePath(nodePath,CreateMode.EPHEMERAL);
-
- OverseerElector elector1 = new OverseerElector(zkClient);
+
+ reader = new ZkStateReader(zkClient);
+ reader.createClusterStateWatchersAndUpdate();
+
+ OverseerElector elector1 = new OverseerElector(zkClient, reader);
ElectionContext ec = new OverseerElectionContext("node1");
elector1.setup(ec);
@@ -190,8 +197,6 @@ public class OverseerTest extends SolrTe
Thread.sleep(1000);
- reader = new ZkStateReader(zkClient);
- reader.createClusterStateWatchersAndUpdate();
HashMap<String, String> coreProps = new HashMap<String,String>();
coreProps.put(ZkStateReader.URL_PROP, "http://127.0.0.1/solr");
@@ -231,6 +236,8 @@ public class OverseerTest extends SolrTe
assertEquals("Illegal state", ZkStateReader.ACTIVE, reader.getCloudState().getSlice("collection1", "shard1").getShards().get("core1").get(ZkStateReader.STATE_PROP));
} finally {
+ System.clearProperty(ZkStateReader.NUM_SHARDS_PROP);
+
if (zkClient != null) {
zkClient.close();
}
@@ -239,6 +246,8 @@ public class OverseerTest extends SolrTe
}
server.shutdown();
}
+
+
}
@Test
@@ -267,16 +276,20 @@ public class OverseerTest extends SolrTe
ZkNodeProps zkProps = new ZkNodeProps(props);
zkClient.makePath("/collections/collection1",
ZkStateReader.toJSON(zkProps));
-
- OverseerElector elector1 = new OverseerElector(zkClient);
+
+ reader = new ZkStateReader(zkClient2);
+ reader.createClusterStateWatchersAndUpdate();
+
+ OverseerElector elector1 = new OverseerElector(zkClient, reader);
ElectionContext ec = new OverseerElectionContext("node1");
elector1.setup(ec);
elector1.joinElection(ec);
Thread.sleep(50);
-
- OverseerElector elector2 = new OverseerElector(zkClient2);
+
+
+ OverseerElector elector2 = new OverseerElector(zkClient2, reader);
elector2.setup(ec);
elector2.joinElection(ec);
@@ -285,13 +298,8 @@ public class OverseerTest extends SolrTe
String nodePath = ZkStateReader.LIVE_NODES_ZKNODE + "/" + "node1";
zkClient2.makePath(nodePath, CreateMode.EPHEMERAL);
- reader = new ZkStateReader(zkClient2);
- reader.createClusterStateWatchersAndUpdate();
HashMap<String,String> coreProps = new HashMap<String,String>();
- coreProps.put(ZkStateReader.URL_PROP, "http://127.0.0.1/solr");
- coreProps.put(ZkStateReader.NODE_NAME_PROP, "node1");
- coreProps.put(ZkStateReader.ROLES_PROP, "");
coreProps.put(ZkStateReader.STATE_PROP, ZkStateReader.RECOVERING);
CoreState state = new CoreState("core1", "collection1", coreProps);
@@ -327,7 +335,7 @@ public class OverseerTest extends SolrTe
zkClient2
.setData(nodePath, ZkStateReader.toJSON(new CoreState[] {state}));
- Thread.sleep(200); // wait for data to update
+ Thread.sleep(1000); // wait for data to update
// zkClient2.printLayoutToStdOut();
Modified: lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java?rev=1212426&r1=1212425&r2=1212426&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java (original)
+++ lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java Fri Dec 9 13:58:19 2011
@@ -131,88 +131,6 @@ public class ZkControllerTest extends So
}
- @Test
- public void testAutoShard() throws Exception {
- String zkDir = dataDir.getAbsolutePath() + File.separator
- + "zookeeper/server1/data";
-
- ZkTestServer server = new ZkTestServer(zkDir);
-
-
- ZkController zkController = null;
- try {
- server.run();
- AbstractZkTestCase.tryCleanSolrZkNode(server.getZkHost());
- AbstractZkTestCase.makeSolrZkNode(server.getZkHost());
-
- zkController = new ZkController(server.getZkAddress(),
- TIMEOUT, 10000, "localhost", "8983", "solr", 3, new CurrentCoreDescriptorProvider() {
-
- @Override
- public List<CoreDescriptor> getCurrentDescriptors() {
- // do nothing
- return null;
- }
- });
-
- System.setProperty("bootstrap_confdir", getFile("solr/conf").getAbsolutePath());
-
- // ensure our shards node for the collection exists - other tests can mess with this
-
- CloudDescriptor cloudDesc = new CloudDescriptor();
- cloudDesc.setCollectionName("collection1");
-
-
- zkController.createCollectionZkNode(cloudDesc);
-
- CoreDescriptor desc = new CoreDescriptor(null, "core1", "");
- desc.setCloudDescriptor(cloudDesc);
- String shard1 = zkController.register("core1", desc);
- cloudDesc.setShardId(null);
- desc = new CoreDescriptor(null, "core2", "");
- desc.setCloudDescriptor(cloudDesc);
- String shard2 = zkController.register("core2", desc);
- cloudDesc.setShardId(null);
- desc = new CoreDescriptor(null, "core3", "");
- desc.setCloudDescriptor(cloudDesc);
- String shard3 = zkController.register("core3", desc);
- cloudDesc.setShardId(null);
- desc = new CoreDescriptor(null, "core4", "");
- desc.setCloudDescriptor(cloudDesc);
- String shard4 = zkController.register("core4", desc);
- cloudDesc.setShardId(null);
- desc = new CoreDescriptor(null, "core5", "");
- desc.setCloudDescriptor(cloudDesc);
- String shard5 = zkController.register("core5", desc);
- cloudDesc.setShardId(null);
- desc = new CoreDescriptor(null, "core6", "");
- desc.setCloudDescriptor(cloudDesc);
- String shard6 = zkController.register("core6", desc);
- cloudDesc.setShardId(null);
-
- assertEquals("shard1", shard1);
-
- assertEquals("shard2", shard2);
- assertEquals("shard3", shard3);
- assertEquals("shard1", shard4);
- assertEquals("shard2", shard5);
- assertEquals("shard3", shard6);
-
- } finally {
- if (DEBUG) {
- if (zkController != null) {
- zkController.printLayoutToStdOut();
- }
- }
-
- if (zkController != null) {
- zkController.close();
- }
- server.shutdown();
- }
-
- }
-
@Override
public void tearDown() throws Exception {
SolrConfig.severeErrors.clear();
Modified: lucene/dev/branches/solrcloud/solr/solrj/src/java/org/apache/solr/common/cloud/CloudState.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/solrj/src/java/org/apache/solr/common/cloud/CloudState.java?rev=1212426&r1=1212425&r2=1212426&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/solrj/src/java/org/apache/solr/common/cloud/CloudState.java (original)
+++ lucene/dev/branches/solrcloud/solr/solrj/src/java/org/apache/solr/common/cloud/CloudState.java Fri Dec 9 13:58:19 2011
@@ -17,7 +17,6 @@ package org.apache.solr.common.cloud;
* limitations under the License.
*/
-import java.io.IOException;
import java.util.*;
import org.apache.noggit.*;
@@ -104,13 +103,13 @@ public class CloudState implements JSONW
return sb.toString();
}
- public static CloudState load(SolrZkClient zkClient, Set<String> liveNodes) throws KeeperException, InterruptedException, IOException {
+ public static CloudState load(SolrZkClient zkClient, Set<String> liveNodes) throws KeeperException, InterruptedException {
byte[] state = zkClient.getData(ZkStateReader.CLUSTER_STATE,
null, null);
return load(state, liveNodes);
}
- public static CloudState load(byte[] bytes, Set<String> liveNodes) throws KeeperException, InterruptedException, IOException {
+ public static CloudState load(byte[] bytes, Set<String> liveNodes) throws KeeperException, InterruptedException {
if (bytes == null || bytes.length == 0) {
return new CloudState(liveNodes, Collections.<String, Map<String,Slice>>emptyMap());
}
Modified: lucene/dev/branches/solrcloud/solr/solrj/src/java/org/apache/solr/common/cloud/CoreAssignment.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/solrj/src/java/org/apache/solr/common/cloud/CoreAssignment.java?rev=1212426&r1=1212425&r2=1212426&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/solrj/src/java/org/apache/solr/common/cloud/CoreAssignment.java (original)
+++ lucene/dev/branches/solrcloud/solr/solrj/src/java/org/apache/solr/common/cloud/CoreAssignment.java Fri Dec 9 13:58:19 2011
@@ -24,7 +24,6 @@ import java.util.*;
public class CoreAssignment implements JSONWriter.Writable {
- private static String COLLECTION="collection";
private static String CORE="core";
private final Map<String, String> properties;
@@ -40,7 +39,6 @@ public class CoreAssignment implements J
public CoreAssignment(String coreName, String collectionName, Map<String,String> properties) {
HashMap<String,String> props = new HashMap<String,String>();
props.putAll(properties);
- props.put(COLLECTION, collectionName);
props.put(CORE, coreName);
this.properties = Collections.unmodifiableMap(props);
}
@@ -49,10 +47,6 @@ public class CoreAssignment implements J
return properties.get(CORE);
}
- public String getCollectionName() {
- return properties.get(COLLECTION);
- }
-
@Override
public void write(JSONWriter jsonWriter) {
jsonWriter.write(properties);
@@ -82,7 +76,7 @@ public class CoreAssignment implements J
@Override
public String toString() {
- return "coll:" + getCollectionName() + " core:" + getCoreName() + " props:" + properties;
+ return "Core:" + getCoreName() + " props:" + properties;
}
}
Modified: lucene/dev/branches/solrcloud/solr/solrj/src/java/org/apache/solr/common/cloud/CoreState.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/solrj/src/java/org/apache/solr/common/cloud/CoreState.java?rev=1212426&r1=1212425&r2=1212426&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/solrj/src/java/org/apache/solr/common/cloud/CoreState.java (original)
+++ lucene/dev/branches/solrcloud/solr/solrj/src/java/org/apache/solr/common/cloud/CoreState.java Fri Dec 9 13:58:19 2011
@@ -58,7 +58,7 @@ public class CoreState implements JSONWr
}
- public static CoreState[] load(byte[] bytes) throws IOException {
+ public static CoreState[] load(byte[] bytes) {
List<Map<String, String>> stateMaps = (List<Map<String, String>>) ZkStateReader.fromJSON(bytes);
CoreState[] states = new CoreState[stateMaps.size()];
Modified: lucene/dev/branches/solrcloud/solr/solrj/src/java/org/apache/solr/common/cloud/ZkNodeProps.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/solrj/src/java/org/apache/solr/common/cloud/ZkNodeProps.java?rev=1212426&r1=1212425&r2=1212426&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/solrj/src/java/org/apache/solr/common/cloud/ZkNodeProps.java (original)
+++ lucene/dev/branches/solrcloud/solr/solrj/src/java/org/apache/solr/common/cloud/ZkNodeProps.java Fri Dec 9 13:58:19 2011
@@ -17,7 +17,6 @@ package org.apache.solr.common.cloud;
* limitations under the License.
*/
-import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -53,7 +52,7 @@ public class ZkNodeProps implements JSON
return Collections.unmodifiableMap(propMap);
}
- public static ZkNodeProps load(byte[] bytes) throws IOException {
+ public static ZkNodeProps load(byte[] bytes) {
Map<String, String> props = (Map<String, String>) ZkStateReader.fromJSON(bytes);
return new ZkNodeProps(props);
}
Modified: lucene/dev/branches/solrcloud/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java?rev=1212426&r1=1212425&r2=1212426&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java (original)
+++ lucene/dev/branches/solrcloud/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java Fri Dec 9 13:58:19 2011
@@ -135,28 +135,24 @@ public class ZkStateReader {
log.error("", e);
throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR,
"", e);
- } catch (IOException e) {
- throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,"",e);
- }
+ }
}
});
}
// load and publish a new CollectionInfo
- public void updateCloudState(boolean immediate) throws KeeperException, InterruptedException,
- IOException {
+ public void updateCloudState(boolean immediate) throws KeeperException, InterruptedException {
updateCloudState(immediate, false);
}
// load and publish a new CollectionInfo
- public void updateLiveNodes() throws KeeperException, InterruptedException,
- IOException {
+ public void updateLiveNodes() throws KeeperException, InterruptedException {
updateCloudState(true, true);
}
public synchronized void createClusterStateWatchersAndUpdate() throws KeeperException,
- InterruptedException, IOException {
+ InterruptedException {
// We need to fetch the current cluster state and the set of live nodes
synchronized (getUpdateLock()) {
@@ -205,9 +201,6 @@ public class ZkStateReader {
Thread.currentThread().interrupt();
log.warn("", e);
return;
- } catch (IOException e) {
- throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
- "Could not serialize cloud state", e);
}
}
@@ -261,7 +254,7 @@ public class ZkStateReader {
// load and publish a new CollectionInfo
private synchronized void updateCloudState(boolean immediate,
final boolean onlyLiveNodes) throws KeeperException,
- InterruptedException, IOException {
+ InterruptedException {
log.info("Manual update of cluster state initiated");
// build immutable CloudInfo
@@ -330,9 +323,7 @@ public class ZkStateReader {
log.error("", e);
throw new ZooKeeperException(
SolrException.ErrorCode.SERVER_ERROR, "", e);
- } catch (IOException e) {
- throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "",e);
- }
+ }
// update volatile
ZkStateReader.this.cloudState = cloudState;
}