public Replica(String name, Map<String,Object> propMap) { super(propMap); this.name = name; this.nodeName = (String) propMap.get(ZkStateReader.NODE_NAME_PROP); if (propMap.get(ZkStateReader.STATE_PROP) != null) { this.state = State.getState((String) propMap.get(ZkStateReader.STATE_PROP)); } else { this.state = State.ACTIVE; //Default to ACTIVE propMap.put(ZkStateReader.STATE_PROP, state.toString()); } }
public Replica(String name, Map<String,Object> propMap) { super(propMap); this.name = name; this.nodeName = (String) propMap.get(ZkStateReader.NODE_NAME_PROP); if (propMap.get(ZkStateReader.STATE_PROP) != null) { this.state = State.getState((String) propMap.get(ZkStateReader.STATE_PROP)); } else { this.state = State.ACTIVE; //Default to ACTIVE propMap.put(ZkStateReader.STATE_PROP, state.toString()); } type = Type.get((String) propMap.get(ZkStateReader.REPLICA_TYPE)); }
public Replica.State getState() { if (variables.get(ZkStateReader.STATE_PROP) != null) { return Replica.State.getState((String) variables.get(ZkStateReader.STATE_PROP)); } else { // default to ACTIVE variables.put(ZkStateReader.STATE_PROP, Replica.State.ACTIVE.toString()); return Replica.State.ACTIVE; } }
String node = coreNodeProps.getNodeName(); if (!liveNodes.contains(coreNodeProps.getNodeName()) || Replica.State.getState(coreNodeProps.getState()) != Replica.State.ACTIVE) continue; if (nodes.put(node, nodeProps) == null) { if (!sendToLeaders || coreNodeProps.isLeader()) {
String node = coreNodeProps.getNodeName(); if (!liveNodes.contains(node) // Must be a live node to continue || Replica.State.getState(coreNodeProps.getState()) != Replica.State.ACTIVE) // Must be an ACTIVE replica to continue continue; if (seenNodes.add(node)) { // if we haven't yet collected a URL to this node...
if (verbose) System.err.println(" num:" + num + "\n"); boolean active = Replica.State.getState(props.getStr(ZkStateReader.STATE_PROP)) == Replica.State.ACTIVE; if (active && live) { if (lastNum > -1 && lastNum != num && failMessage == null) {
ZkNodeProps props = cjetty.info; SolrClient client = cjetty.client.solrClient; boolean active = Replica.State.getState(props.getStr(ZkStateReader.STATE_PROP)) == Replica.State.ACTIVE; if (active) { SolrQuery query = new SolrQuery("*:*");
final Replica.State currentState = Replica.State.getState(cjetty.info.getStr(ZkStateReader.STATE_PROP)); if (currentState == Replica.State.ACTIVE && zkStateReader.getClusterState().liveNodesContain(cjetty.info.getStr(ZkStateReader.NODE_NAME_PROP))) {
/** * Executes a query against each live and active replica of the specified shard * and aserts that the results are identical. * * @see #queryAndCompare */ public QueryResponse queryAndCompareReplicas(SolrParams params, String shard) throws Exception { ArrayList<SolrClient> shardClients = new ArrayList<>(7); updateMappingsFromZk(jettys, clients); ZkStateReader zkStateReader = cloudClient.getZkStateReader(); List<CloudJettyRunner> solrJetties = shardToJetty.get(shard); assertNotNull("no jetties found for shard: " + shard, solrJetties); for (CloudJettyRunner cjetty : solrJetties) { ZkNodeProps props = cjetty.info; String nodeName = props.getStr(ZkStateReader.NODE_NAME_PROP); boolean active = Replica.State.getState(props.getStr(ZkStateReader.STATE_PROP)) == Replica.State.ACTIVE; boolean live = zkStateReader.getClusterState().liveNodesContain(nodeName); if (active && live) { shardClients.add(cjetty.client.solrClient); } } return queryAndCompare(params, shardClients); }
private int checkIfKillIsLegal(String sliceName, int numActive) throws KeeperException, InterruptedException { for (CloudJettyRunner cloudJetty : shardToJetty.get(sliceName)) { // get latest cloud state zkStateReader.forceUpdateCollection(collection); DocCollection docCollection = zkStateReader.getClusterState().getCollection(collection); Slice slice = docCollection.getSlice(sliceName); ZkNodeProps props = slice.getReplicasMap().get(cloudJetty.coreNodeName); if (props == null) { throw new RuntimeException("shard name " + cloudJetty.coreNodeName + " not found in " + slice.getReplicasMap().keySet()); } final Replica.State state = Replica.State.getState(props.getStr(ZkStateReader.STATE_PROP)); final String nodeName = props.getStr(ZkStateReader.NODE_NAME_PROP); if (cloudJetty.jetty.isRunning() && state == Replica.State.ACTIVE && zkStateReader.getClusterState().liveNodesContain(nodeName)) { numActive++; } } return numActive; }
private boolean canKillIndexer(String sliceName) throws KeeperException, InterruptedException { int numIndexersFoundInShard = 0; for (CloudJettyRunner cloudJetty : shardToJetty.get(sliceName)) { // get latest cloud state zkStateReader.forceUpdateCollection(collection); DocCollection docCollection = zkStateReader.getClusterState().getCollection(collection); Slice slice = docCollection.getSlice(sliceName); ZkNodeProps props = slice.getReplicasMap().get(cloudJetty.coreNodeName); if (props == null) { throw new RuntimeException("shard name " + cloudJetty.coreNodeName + " not found in " + slice.getReplicasMap().keySet()); } final Replica.State state = Replica.State.getState(props.getStr(ZkStateReader.STATE_PROP)); final Replica.Type replicaType = Replica.Type.valueOf(props.getStr(ZkStateReader.REPLICA_TYPE)); final String nodeName = props.getStr(ZkStateReader.NODE_NAME_PROP); if (cloudJetty.jetty.isRunning() && state == Replica.State.ACTIVE && (replicaType == Replica.Type.TLOG || replicaType == Replica.Type.NRT) && zkStateReader.getClusterState().liveNodesContain(nodeName)) { numIndexersFoundInShard++; } } return numIndexersFoundInShard > 1; }