diff --git a/solr/core/src/java/org/apache/solr/cloud/CloudDescriptor.java b/solr/core/src/java/org/apache/solr/cloud/CloudDescriptor.java index b00ca523dd15..ffd004d7a6ee 100644 --- a/solr/core/src/java/org/apache/solr/cloud/CloudDescriptor.java +++ b/solr/core/src/java/org/apache/solr/cloud/CloudDescriptor.java @@ -26,6 +26,8 @@ import org.apache.solr.common.util.PropertiesUtil; import org.apache.solr.core.CoreDescriptor; +import static org.apache.solr.common.params.CommonParams.REPLICA_NAME; + /** * SolrCloud metadata attached to a {@link CoreDescriptor}. */ @@ -64,7 +66,7 @@ public CloudDescriptor(CoreDescriptor cd, String coreName, Properties props) { // If no collection name is specified, we default to the core name this.collectionName = props.getProperty(CoreDescriptor.CORE_COLLECTION, coreName); this.roles = props.getProperty(CoreDescriptor.CORE_ROLES, null); - this.nodeName = props.getProperty(CoreDescriptor.CORE_NODE_NAME); + this.nodeName = props.getProperty(REPLICA_NAME); if (Strings.isNullOrEmpty(nodeName)) this.nodeName = null; this.numShards = PropertiesUtil.toInteger(props.getProperty(CloudDescriptor.NUM_SHARDS), null); @@ -146,15 +148,27 @@ public Integer getNumShards() { public void setNumShards(int numShards) { this.numShards = numShards; } - + + @Deprecated public String getCoreNodeName() { return nodeName; } + public String getReplicaName() { + return nodeName; + } + + public void setReplicaName(String nodeName) { + this.nodeName = nodeName; + if(nodeName==null) cd.getPersistableStandardProperties().remove(REPLICA_NAME); + else cd.getPersistableStandardProperties().setProperty(REPLICA_NAME, nodeName); + } + + @Deprecated public void setCoreNodeName(String nodeName) { this.nodeName = nodeName; - if(nodeName==null) cd.getPersistableStandardProperties().remove(CoreDescriptor.CORE_NODE_NAME); - else cd.getPersistableStandardProperties().setProperty(CoreDescriptor.CORE_NODE_NAME, nodeName); + if(nodeName==null) cd.getPersistableStandardProperties().remove(REPLICA_NAME); + else cd.getPersistableStandardProperties().setProperty(REPLICA_NAME, nodeName); } public void reload(CloudDescriptor reloadFrom) { diff --git a/solr/core/src/java/org/apache/solr/cloud/CloudUtil.java b/solr/core/src/java/org/apache/solr/cloud/CloudUtil.java index 3dffb724a4fd..2d6b79826b4a 100644 --- a/solr/core/src/java/org/apache/solr/cloud/CloudUtil.java +++ b/solr/core/src/java/org/apache/solr/cloud/CloudUtil.java @@ -56,7 +56,7 @@ public class CloudUtil { public static final int DEFAULT_TIMEOUT = 90; /** - * See if coreNodeName has been taken over by another baseUrl and unload core + * See if replicaName has been taken over by another baseUrl and unload core * + throw exception if it has been. */ public static void checkSharedFSFailoverReplaced(CoreContainer cc, CoreDescriptor desc) { @@ -103,12 +103,12 @@ public static void checkSharedFSFailoverReplaced(CoreContainer cc, CoreDescripto } } - public static boolean replicaExists(ClusterState clusterState, String collection, String shard, String coreNodeName) { + public static boolean replicaExists(ClusterState clusterState, String collection, String shard, String replicaName) { DocCollection docCollection = clusterState.getCollectionOrNull(collection); if (docCollection != null) { Slice slice = docCollection.getSlice(shard); if (slice != null) { - return slice.getReplica(coreNodeName) != null; + return slice.getReplica(replicaName) != null; } } return false; diff --git a/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java b/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java index 13985709a7bf..72e20b3a0790 100644 --- a/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java +++ b/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java @@ -35,10 +35,10 @@ public abstract class ElectionContext implements Closeable { volatile String leaderSeqPath; private SolrZkClient zkClient; - public ElectionContext(final String coreNodeName, + public ElectionContext(final String relicaName, final String electionPath, final String leaderPath, final ZkNodeProps leaderProps, final SolrZkClient zkClient) { assert zkClient != null; - this.id = coreNodeName; + this.id = relicaName; this.electionPath = electionPath; this.leaderPath = leaderPath; this.leaderProps = leaderProps; diff --git a/solr/core/src/java/org/apache/solr/cloud/RecoveringCoreTermWatcher.java b/solr/core/src/java/org/apache/solr/cloud/RecoveringCoreTermWatcher.java index 1fa31ad28ec7..4ca95c8a21fa 100644 --- a/solr/core/src/java/org/apache/solr/cloud/RecoveringCoreTermWatcher.java +++ b/solr/core/src/java/org/apache/solr/cloud/RecoveringCoreTermWatcher.java @@ -54,11 +54,11 @@ public boolean onTermChanged(ShardTerms terms) { } if (solrCore.getCoreDescriptor() == null || solrCore.getCoreDescriptor().getCloudDescriptor() == null) return true; - String coreNodeName = solrCore.getCoreDescriptor().getCloudDescriptor().getCoreNodeName(); - if (terms.haveHighestTermValue(coreNodeName)) return true; - if (lastTermDoRecovery.get() < terms.getTerm(coreNodeName)) { - log.info("Start recovery on {} because core's term is less than leader's term", coreNodeName); - lastTermDoRecovery.set(terms.getTerm(coreNodeName)); + String replicaName = solrCore.getCoreDescriptor().getCloudDescriptor().getReplicaName(); + if (terms.haveHighestTermValue(replicaName)) return true; + if (lastTermDoRecovery.get() < terms.getTerm(replicaName)) { + log.info("Start recovery on {} because core's term is less than leader's term", replicaName); + lastTermDoRecovery.set(terms.getTerm(replicaName)); solrCore.getUpdateHandler().getSolrCoreState().doRecovery(solrCore.getCoreContainer(), solrCore.getCoreDescriptor()); } } catch (Exception e) { diff --git a/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java b/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java index eaeba2d099b5..4cc8b3f9aa21 100644 --- a/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java +++ b/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java @@ -119,7 +119,7 @@ public static interface RecoveryListener { private RecoveryListener recoveryListener; private ZkController zkController; private String baseUrl; - private String coreZkNodeName; + private String replicaName; private ZkStateReader zkStateReader; private volatile String coreName; private int retries; @@ -137,7 +137,7 @@ protected RecoveryStrategy(CoreContainer cc, CoreDescriptor cd, RecoveryListener zkController = cc.getZkController(); zkStateReader = zkController.getZkStateReader(); baseUrl = zkController.getBaseUrl(); - coreZkNodeName = cd.getCloudDescriptor().getCoreNodeName(); + replicaName = cd.getCloudDescriptor().getCoreNodeName(); replicaType = cd.getCloudDescriptor().getReplicaType(); } @@ -193,7 +193,7 @@ final public void close() { if (prevSendPreRecoveryHttpUriRequest != null) { prevSendPreRecoveryHttpUriRequest.abort(); } - log.warn("Stopping recovery for core=[{}] coreNodeName=[{}]", coreName, coreZkNodeName); + log.warn("Stopping recovery for core=[{}] replicaName=[{}]", coreName, replicaName); } final private void recoveryFailed(final ZkController zkController, @@ -847,7 +847,7 @@ final private void sendPrepRecoveryCmd(String leaderBaseUrl, String leaderCoreNa WaitForState prepCmd = new WaitForState(); prepCmd.setCoreName(leaderCoreName); prepCmd.setNodeName(zkController.getNodeName()); - prepCmd.setCoreNodeName(coreZkNodeName); + prepCmd.setCoreNodeName(replicaName); prepCmd.setState(Replica.State.RECOVERING); prepCmd.setCheckLive(true); prepCmd.setOnlyIfLeader(true); diff --git a/solr/core/src/java/org/apache/solr/cloud/ShardLeaderElectionContext.java b/solr/core/src/java/org/apache/solr/cloud/ShardLeaderElectionContext.java index 68b062ed876e..8fd74e2def21 100644 --- a/solr/core/src/java/org/apache/solr/cloud/ShardLeaderElectionContext.java +++ b/solr/core/src/java/org/apache/solr/cloud/ShardLeaderElectionContext.java @@ -56,8 +56,8 @@ final class ShardLeaderElectionContext extends ShardLeaderElectionContextBase { public ShardLeaderElectionContext(LeaderElector leaderElector, final String shardId, final String collection, - final String coreNodeName, ZkNodeProps props, ZkController zkController, CoreContainer cc) { - super(leaderElector, shardId, collection, coreNodeName, props, + final String replicaName, ZkNodeProps props, ZkController zkController, CoreContainer cc) { + super(leaderElector, shardId, collection, replicaName, props, zkController); this.cc = cc; syncStrategy = new SyncStrategy(cc); @@ -133,7 +133,7 @@ void runLeaderProcess(boolean weAreReplacement, int pauseBeforeStart) throws Kee } Replica.Type replicaType; - String coreNodeName; + String replicaName; boolean setTermToMax = false; try (SolrCore core = cc.getCore(coreName)) { @@ -142,11 +142,11 @@ void runLeaderProcess(boolean weAreReplacement, int pauseBeforeStart) throws Kee } replicaType = core.getCoreDescriptor().getCloudDescriptor().getReplicaType(); - coreNodeName = core.getCoreDescriptor().getCloudDescriptor().getCoreNodeName(); + replicaName = core.getCoreDescriptor().getCloudDescriptor().getReplicaName(); // should I be leader? ZkShardTerms zkShardTerms = zkController.getShardTerms(collection, shardId); - if (zkShardTerms.registered(coreNodeName) && !zkShardTerms.canBecomeLeader(coreNodeName)) { - if (!waitForEligibleBecomeLeaderAfterTimeout(zkShardTerms, coreNodeName, leaderVoteWait)) { + if (zkShardTerms.registered(replicaName) && !zkShardTerms.canBecomeLeader(replicaName)) { + if (!waitForEligibleBecomeLeaderAfterTimeout(zkShardTerms, replicaName, leaderVoteWait)) { rejoinLeaderElection(core); return; } else { @@ -255,8 +255,8 @@ void runLeaderProcess(boolean weAreReplacement, int pauseBeforeStart) throws Kee // in case of leaderVoteWait timeout, a replica with lower term can win the election if (setTermToMax) { log.error("WARNING: Potential data loss -- Replica {} became leader after timeout (leaderVoteWait) {}" - , "without being up-to-date with the previous leader", coreNodeName); - zkController.getShardTerms(collection, shardId).setTermEqualsToLeader(coreNodeName); + , "without being up-to-date with the previous leader", replicaName); + zkController.getShardTerms(collection, shardId).setTermEqualsToLeader(replicaName); } super.runLeaderProcess(weAreReplacement, 0); try (SolrCore core = cc.getCore(coreName)) { @@ -314,15 +314,15 @@ void runLeaderProcess(boolean weAreReplacement, int pauseBeforeStart) throws Kee * @return true if after {@code timeout} there are no other replicas with higher term participate in the election, * false if otherwise */ - private boolean waitForEligibleBecomeLeaderAfterTimeout(ZkShardTerms zkShardTerms, String coreNodeName, int timeout) throws InterruptedException { + private boolean waitForEligibleBecomeLeaderAfterTimeout(ZkShardTerms zkShardTerms, String replicaName, int timeout) throws InterruptedException { long timeoutAt = System.nanoTime() + TimeUnit.NANOSECONDS.convert(timeout, TimeUnit.MILLISECONDS); while (!isClosed && !cc.isShutDown()) { if (System.nanoTime() > timeoutAt) { log.warn("After waiting for {}ms, no other potential leader was found, {} try to become leader anyway (core_term:{}, highest_term:{})", - timeout, coreNodeName, zkShardTerms.getTerm(coreNodeName), zkShardTerms.getHighestTerm()); + timeout, replicaName, zkShardTerms.getTerm(replicaName), zkShardTerms.getHighestTerm()); return true; } - if (replicasWithHigherTermParticipated(zkShardTerms, coreNodeName)) { + if (replicasWithHigherTermParticipated(zkShardTerms, replicaName)) { log.info("Can't become leader, other replicas with higher term participated in leader election"); return false; } @@ -336,17 +336,17 @@ private boolean waitForEligibleBecomeLeaderAfterTimeout(ZkShardTerms zkShardTerm * * @return true if other replicas with higher term participated in the election, false if otherwise */ - private boolean replicasWithHigherTermParticipated(ZkShardTerms zkShardTerms, String coreNodeName) { + private boolean replicasWithHigherTermParticipated(ZkShardTerms zkShardTerms, String replicaName) { ClusterState clusterState = zkController.getClusterState(); DocCollection docCollection = clusterState.getCollectionOrNull(collection); Slice slices = (docCollection == null) ? null : docCollection.getSlice(shardId); if (slices == null) return false; - long replicaTerm = zkShardTerms.getTerm(coreNodeName); - boolean isRecovering = zkShardTerms.isRecovering(coreNodeName); + long replicaTerm = zkShardTerms.getTerm(replicaName); + boolean isRecovering = zkShardTerms.isRecovering(replicaName); for (Replica replica : slices.getReplicas()) { - if (replica.getName().equals(coreNodeName)) continue; + if (replica.getName().equals(replicaName)) continue; if (clusterState.getLiveNodes().contains(replica.getNodeName())) { long otherTerm = zkShardTerms.getTerm(replica.getName()); diff --git a/solr/core/src/java/org/apache/solr/cloud/ShardLeaderElectionContextBase.java b/solr/core/src/java/org/apache/solr/cloud/ShardLeaderElectionContextBase.java index 531294a83906..f58e0df9f88e 100644 --- a/solr/core/src/java/org/apache/solr/cloud/ShardLeaderElectionContextBase.java +++ b/solr/core/src/java/org/apache/solr/cloud/ShardLeaderElectionContextBase.java @@ -54,9 +54,9 @@ class ShardLeaderElectionContextBase extends ElectionContext { private final Object lock = new Object(); public ShardLeaderElectionContextBase(LeaderElector leaderElector, - final String shardId, final String collection, final String coreNodeName, + final String shardId, final String collection, final String replicaName, ZkNodeProps props, ZkController zkController) { - super(coreNodeName, ZkStateReader.COLLECTIONS_ZKNODE + "/" + collection + super(replicaName, ZkStateReader.COLLECTIONS_ZKNODE + "/" + collection + "/leader_elect/" + shardId, ZkStateReader.getShardLeadersPath( collection, shardId), props, zkController.getZkClient()); this.leaderElector = leaderElector; diff --git a/solr/core/src/java/org/apache/solr/cloud/SyncStrategy.java b/solr/core/src/java/org/apache/solr/cloud/SyncStrategy.java index c73e57ba6b8b..bb23f33333ea 100644 --- a/solr/core/src/java/org/apache/solr/cloud/SyncStrategy.java +++ b/solr/core/src/java/org/apache/solr/cloud/SyncStrategy.java @@ -155,7 +155,7 @@ private PeerSync.PeerSyncResult syncReplicas(ZkController zkController, SolrCore private PeerSync.PeerSyncResult syncWithReplicas(ZkController zkController, SolrCore core, ZkNodeProps props, String collection, String shardId, boolean peerSyncOnlyWithActive) throws Exception { List nodes = zkController.getZkStateReader() - .getReplicaProps(collection, shardId,core.getCoreDescriptor().getCloudDescriptor().getCoreNodeName()); + .getReplicaProps(collection, shardId,core.getCoreDescriptor().getCloudDescriptor().getReplicaName()); if (isClosed) { log.info("We have been closed, won't sync with replicas"); @@ -197,7 +197,7 @@ private void syncToMe(ZkController zkController, String collection, List nodes = zkController .getZkStateReader() .getReplicaProps(collection, shardId, - cd.getCloudDescriptor().getCoreNodeName()); + cd.getCloudDescriptor().getReplicaName()); if (nodes == null) { if (log.isInfoEnabled()) { log.info("{} has no replicas", ZkCoreNodeProps.getCoreUrl(leaderProps)); diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkCollectionTerms.java b/solr/core/src/java/org/apache/solr/cloud/ZkCollectionTerms.java index 671bb469e6ec..99a908946093 100644 --- a/solr/core/src/java/org/apache/solr/cloud/ZkCollectionTerms.java +++ b/solr/core/src/java/org/apache/solr/cloud/ZkCollectionTerms.java @@ -47,9 +47,9 @@ public ZkShardTerms getShard(String shardId) { } } - public void register(String shardId, String coreNodeName) { + public void register(String shardId, String replicaName) { synchronized (terms) { - getShard(shardId).registerTerm(coreNodeName); + getShard(shardId).registerTerm(replicaName); } } diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkController.java b/solr/core/src/java/org/apache/solr/cloud/ZkController.java index 0e573ad2dfc4..f52d843baef6 100644 --- a/solr/core/src/java/org/apache/solr/cloud/ZkController.java +++ b/solr/core/src/java/org/apache/solr/cloud/ZkController.java @@ -139,11 +139,11 @@ public class ZkController implements Closeable { static class ContextKey { private String collection; - private String coreNodeName; + private String replicaName; - public ContextKey(String collection, String coreNodeName) { + public ContextKey(String collection, String replicaName) { this.collection = collection; - this.coreNodeName = coreNodeName; + this.replicaName = replicaName; } @Override @@ -153,7 +153,7 @@ public int hashCode() { result = prime * result + ((collection == null) ? 0 : collection.hashCode()); result = prime * result - + ((coreNodeName == null) ? 0 : coreNodeName.hashCode()); + + ((replicaName == null) ? 0 : replicaName.hashCode()); return result; } @@ -166,15 +166,15 @@ public boolean equals(Object obj) { if (collection == null) { if (other.collection != null) return false; } else if (!collection.equals(other.collection)) return false; - if (coreNodeName == null) { - if (other.coreNodeName != null) return false; - } else if (!coreNodeName.equals(other.coreNodeName)) return false; + if (replicaName == null) { + if (other.replicaName != null) return false; + } else if (!replicaName.equals(other.replicaName)) return false; return true; } @Override public String toString() { - return collection + ':' + coreNodeName; + return collection + ':' + replicaName; } } @@ -209,7 +209,7 @@ public String toString() { private int leaderVoteWait; private int leaderConflictResolveWait; - private boolean genericCoreNodeNames; + private boolean genericReplicaNames; private int clientTimeout; @@ -284,7 +284,7 @@ public ZkController(final CoreContainer cc, String zkServerAddress, int zkClient this.cloudConfig = cloudConfig; - this.genericCoreNodeNames = cloudConfig.getGenericCoreNodeNames(); + this.genericReplicaNames = cloudConfig.getGenericReplicaNames(); // be forgiving and strip this off leading/trailing slashes // this allows us to support users specifying hostContext="/" in @@ -554,10 +554,10 @@ private void registerAllCoresAsDown( Thread.currentThread().interrupt(); } - final String coreZkNodeName = descriptor.getCloudDescriptor().getCoreNodeName(); + final String replicaName = descriptor.getCloudDescriptor().getReplicaName(); try { - log.debug("calling waitForLeaderToSeeDownState for coreZkNodeName={} collection={} shard={}", new Object[]{coreZkNodeName, collection, slice}); - waitForLeaderToSeeDownState(descriptor, coreZkNodeName); + log.debug("calling waitForLeaderToSeeDownState for replicaName={} collection={} shard={}", new Object[]{replicaName, collection, slice}); + waitForLeaderToSeeDownState(descriptor, replicaName); } catch (Exception e) { log.warn("There was a problem while making a best effort to ensure the leader has seen us as down, this is not unexpected as Zookeeper has just reconnected after a session expiration", e); if (isClosed) { @@ -584,9 +584,9 @@ private void closeOutstandingElections(final Supplier> regi private ContextKey closeExistingElectionContext(CoreDescriptor cd) { // look for old context - if we find it, cancel it String collection = cd.getCloudDescriptor().getCollectionName(); - final String coreNodeName = cd.getCloudDescriptor().getCoreNodeName(); + final String replicaName = cd.getCloudDescriptor().getReplicaName(); - ContextKey contextKey = new ContextKey(collection, coreNodeName); + ContextKey contextKey = new ContextKey(collection, replicaName); ElectionContext prevContext = electionContexts.get(contextKey); if (prevContext != null) { @@ -709,7 +709,7 @@ public void giveupLeadership(CoreDescriptor cd) { if (shard == null) return; // if this replica is not a leader, it will be put in recovery state by the leader - String leader = cd.getCloudDescriptor().getCoreNodeName(); + String leader = cd.getCloudDescriptor().getReplicaName(); if (shard.getReplica(leader) != shard.getLeader()) return; Set liveNodes = getClusterState().getLiveNodes(); @@ -1041,7 +1041,7 @@ public void publishAndWaitForDownStates(int timeoutSeconds) throws KeeperExcepti boolean foundStates = true; for (CoreDescriptor coreDescriptor : cc.getCoreDescriptors()) { if (coreDescriptor.getCloudDescriptor().getCollectionName().equals(collectionWithLocalReplica)) { - Replica replica = collectionState.getReplica(coreDescriptor.getCloudDescriptor().getCoreNodeName()); + Replica replica = collectionState.getReplica(coreDescriptor.getCloudDescriptor().getReplicaName()); if (replica == null || replica.getState() != Replica.State.DOWN) { foundStates = false; } @@ -1160,24 +1160,24 @@ public String register(String coreName, final CoreDescriptor desc, boolean recov final CloudDescriptor cloudDesc = desc.getCloudDescriptor(); final String collection = cloudDesc.getCollectionName(); final String shardId = cloudDesc.getShardId(); - final String coreZkNodeName = cloudDesc.getCoreNodeName(); - assert coreZkNodeName != null : "we should have a coreNodeName by now"; + final String replicaName = cloudDesc.getReplicaName(); + assert replicaName != null : "we should have a replicaName by now"; // check replica's existence in clusterstate first try { zkStateReader.waitForState(collection, 100, TimeUnit.MILLISECONDS, - (collectionState) -> getReplicaOrNull(collectionState, shardId, coreZkNodeName) != null); + (collectionState) -> getReplicaOrNull(collectionState, shardId, replicaName) != null); } catch (TimeoutException e) { throw new SolrException(ErrorCode.SERVER_ERROR, "Error registering SolrCore, timeout waiting for replica present in clusterstate"); } - Replica replica = getReplicaOrNull(zkStateReader.getClusterState().getCollectionOrNull(collection), shardId, coreZkNodeName); + Replica replica = getReplicaOrNull(zkStateReader.getClusterState().getCollectionOrNull(collection), shardId, replicaName); if (replica == null) { throw new SolrException(ErrorCode.SERVER_ERROR, "Error registering SolrCore, replica is removed from clusterstate"); } if (replica.getType() != Type.PULL) { - getCollectionTerms(collection).register(cloudDesc.getShardId(), coreZkNodeName); + getCollectionTerms(collection).register(cloudDesc.getShardId(), replicaName); } ZkShardTerms shardTerms = getShardTerms(collection, cloudDesc.getShardId()); @@ -1192,9 +1192,9 @@ public String register(String coreName, final CoreDescriptor desc, boolean recov joinElection(desc, afterExpiration, joinAtHead); } else if (replica.getType() == Type.PULL) { if (joinAtHead) { - log.warn("Replica {} was designated as preferred leader but it's type is {}, It won't join election", coreZkNodeName, Type.PULL); + log.warn("Replica {} was designated as preferred leader but it's type is {}, It won't join election", replicaName, Type.PULL); } - log.debug("Replica {} skipping election because it's type is {}", coreZkNodeName, Type.PULL); + log.debug("Replica {} skipping election because it's type is {}", replicaName, Type.PULL); startReplicationFromLeader(coreName, false); } } catch (InterruptedException e) { @@ -1255,7 +1255,7 @@ public String register(String coreName, final CoreDescriptor desc, boolean recov } } boolean didRecovery - = checkRecovery(recoverReloadedCores, isLeader, skipRecovery, collection, coreZkNodeName, shardId, core, cc, afterExpiration); + = checkRecovery(recoverReloadedCores, isLeader, skipRecovery, collection, replicaName, shardId, core, cc, afterExpiration); if (!didRecovery) { if (isTlogReplicaAndNotLeader) { startReplicationFromLeader(coreName, true); @@ -1277,20 +1277,20 @@ public String register(String coreName, final CoreDescriptor desc, boolean recov zkStateReader.forceUpdateCollection(collection); // the watcher is added to a set so multiple calls of this method will left only one watcher zkStateReader.registerDocCollectionWatcher(cloudDesc.getCollectionName(), - new UnloadCoreOnDeletedWatcher(coreZkNodeName, shardId, desc.getName())); + new UnloadCoreOnDeletedWatcher(replicaName, shardId, desc.getName())); return shardId; } finally { MDCLoggingContext.clear(); } } - private Replica getReplicaOrNull(DocCollection docCollection, String shard, String coreNodeName) { + private Replica getReplicaOrNull(DocCollection docCollection, String shard, String replicaName) { if (docCollection == null) return null; Slice slice = docCollection.getSlice(shard); if (slice == null) return null; - Replica replica = slice.getReplica(coreNodeName); + Replica replica = slice.getReplica(replicaName); if (replica == null) return null; if (!getNodeName().equals(replica.getNodeName())) return null; @@ -1422,9 +1422,9 @@ private void joinElection(CoreDescriptor cd, boolean afterExpiration, boolean jo throws InterruptedException, KeeperException, IOException { // look for old context - if we find it, cancel it String collection = cd.getCloudDescriptor().getCollectionName(); - final String coreNodeName = cd.getCloudDescriptor().getCoreNodeName(); + final String replicaName = cd.getCloudDescriptor().getCoreNodeName(); - ContextKey contextKey = new ContextKey(collection, coreNodeName); + ContextKey contextKey = new ContextKey(collection, replicaName); ElectionContext prevContext = electionContexts.get(contextKey); @@ -1438,14 +1438,14 @@ private void joinElection(CoreDescriptor cd, boolean afterExpiration, boolean jo // we only put a subset of props into the leader node props.put(ZkStateReader.CORE_NAME_PROP, cd.getName()); props.put(ZkStateReader.NODE_NAME_PROP, getNodeName()); - props.put(ZkStateReader.CORE_NODE_NAME_PROP, coreNodeName); + props.put(ZkStateReader.CORE_NODE_NAME_PROP, replicaName); ZkNodeProps ourProps = new ZkNodeProps(props); LeaderElector leaderElector = new LeaderElector(zkClient, contextKey, electionContexts); ElectionContext context = new ShardLeaderElectionContext(leaderElector, shardId, - collection, coreNodeName, ourProps, this, cc); + collection, replicaName, ourProps, this, cc); leaderElector.setup(context); electionContexts.put(contextKey, context); @@ -1529,7 +1529,7 @@ public void publish(final CoreDescriptor cd, final Replica.State state, boolean String shardId = cd.getCloudDescriptor().getShardId(); - String coreNodeName = cd.getCloudDescriptor().getCoreNodeName(); + String replicaName = cd.getCloudDescriptor().getReplicaName(); Map props = new HashMap<>(); props.put(Overseer.QUEUE_OPERATION, "state"); @@ -1544,8 +1544,8 @@ public void publish(final CoreDescriptor cd, final Replica.State state, boolean if (numShards != null) { props.put(ZkStateReader.NUM_SHARDS_PROP, numShards.toString()); } - if (coreNodeName != null) { - props.put(ZkStateReader.CORE_NODE_NAME_PROP, coreNodeName); + if (replicaName != null) { + props.put(CommonParams.REPLICA_NAME, replicaName); } try (SolrCore core = cc.getCore(cd.getName())) { if (core != null && state == Replica.State.ACTIVE) { @@ -1572,10 +1572,10 @@ public void publish(final CoreDescriptor cd, final Replica.State state, boolean if (state == Replica.State.RECOVERING && cd.getCloudDescriptor().getReplicaType() != Type.PULL) { // state is used by client, state of replica can change from RECOVERING to DOWN without needed to finish recovery // by calling this we will know that a replica actually finished recovery or not - getShardTerms(collection, shardId).startRecovering(coreNodeName); + getShardTerms(collection, shardId).startRecovering(replicaName); } if (state == Replica.State.ACTIVE && cd.getCloudDescriptor().getReplicaType() != Type.PULL) { - getShardTerms(collection, shardId).doneRecovering(coreNodeName); + getShardTerms(collection, shardId).doneRecovering(replicaName); } ZkNodeProps m = new ZkNodeProps(props); @@ -1584,14 +1584,14 @@ public void publish(final CoreDescriptor cd, final Replica.State state, boolean cd.getCloudDescriptor().setLastPublished(state); } DocCollection coll = zkStateReader.getCollection(collection); - if (forcePublish || sendToOverseer(coll, coreNodeName)) { + if (forcePublish || sendToOverseer(coll, replicaName)) { overseerJobQueue.offer(Utils.toJSON(m)); } else { if (log.isDebugEnabled()) { log.debug("bypassed overseer for message : {}", Utils.toJSONString(m)); } PerReplicaStates perReplicaStates = PerReplicaStates.fetch(coll.getZNode(), zkClient, coll.getPerReplicaStates()); - PerReplicaStatesOps.flipState(coreNodeName, state, perReplicaStates) + PerReplicaStatesOps.flipState(replicaName, state, perReplicaStates) .persist(coll.getZNode(), zkClient); } } finally { @@ -1640,10 +1640,10 @@ public void unregister(String coreName, CoreDescriptor cd) throws Exception { } public void unregister(String coreName, CoreDescriptor cd, boolean removeCoreFromZk) throws Exception { - final String coreNodeName = cd.getCloudDescriptor().getCoreNodeName(); + final String replicaName = cd.getCloudDescriptor().getReplicaName(); final String collection = cd.getCloudDescriptor().getCollectionName(); getCollectionTerms(collection).remove(cd.getCloudDescriptor().getShardId(), cd); - replicasMetTragicEvent.remove(collection+":"+coreNodeName); + replicasMetTragicEvent.remove(collection+":"+replicaName); if (Strings.isNullOrEmpty(collection)) { log.error("No collection was specified."); @@ -1651,10 +1651,10 @@ public void unregister(String coreName, CoreDescriptor cd, boolean removeCoreFro return; } final DocCollection docCollection = zkStateReader.getClusterState().getCollectionOrNull(collection); - Replica replica = (docCollection == null) ? null : docCollection.getReplica(coreNodeName); + Replica replica = (docCollection == null) ? null : docCollection.getReplica(replicaName); if (replica == null || replica.getType() != Type.PULL) { - ElectionContext context = electionContexts.remove(new ContextKey(collection, coreNodeName)); + ElectionContext context = electionContexts.remove(new ContextKey(collection, replicaName)); if (context != null) { context.cancelElection(); @@ -1666,7 +1666,7 @@ public void unregister(String coreName, CoreDescriptor cd, boolean removeCoreFro OverseerAction.DELETECORE.toLower(), ZkStateReader.CORE_NAME_PROP, coreName, ZkStateReader.NODE_NAME_PROP, getNodeName(), ZkStateReader.COLLECTION_PROP, cloudDescriptor.getCollectionName(), - ZkStateReader.CORE_NODE_NAME_PROP, coreNodeName); + ZkStateReader.CORE_NODE_NAME_PROP, replicaName); overseerJobQueue.offer(Utils.toJSON(m)); } } @@ -1683,18 +1683,18 @@ public ZkStateReader getZkStateReader() { } private void doGetShardIdAndNodeNameProcess(CoreDescriptor cd) { - final String coreNodeName = cd.getCloudDescriptor().getCoreNodeName(); + final String replicaName = cd.getCloudDescriptor().getReplicaName(); - if (coreNodeName != null) { + if (replicaName != null) { waitForShardId(cd); } else { - // if no explicit coreNodeName, we want to match by base url and core name - waitForCoreNodeName(cd); + // if no explicit replicaName, we want to match by base url and core name + waitForReplica(cd); waitForShardId(cd); } } - private void waitForCoreNodeName(CoreDescriptor descriptor) { + private void waitForReplica(CoreDescriptor descriptor) { int retryCount = 320; log.debug("look for our core node name"); while (retryCount-- > 0) { @@ -1714,7 +1714,7 @@ private void waitForCoreNodeName(CoreDescriptor descriptor) { if (msgNodeName.equals(nodeName) && core.equals(msgCore)) { descriptor.getCloudDescriptor() - .setCoreNodeName(replica.getName()); + .setReplicaName(replica.getName()); getCoreContainer().getCoresLocator().persist(getCoreContainer(), descriptor); return; } @@ -1751,20 +1751,24 @@ private void waitForShardId(CoreDescriptor cd) { "Could not get shard id for core: " + cd.getName()); } - - public String getCoreNodeName(CoreDescriptor descriptor) { - String coreNodeName = descriptor.getCloudDescriptor().getCoreNodeName(); - if (coreNodeName == null && !genericCoreNodeNames) { + public String getReplicaName(CoreDescriptor descriptor) { + String replicaName = descriptor.getCloudDescriptor().getReplicaName(); + if (replicaName == null && !genericReplicaNames) { // it's the default return getNodeName() + "_" + descriptor.getName(); } + return replicaName; + } - return coreNodeName; + + @Deprecated + public String getCoreNodeName(CoreDescriptor descriptor) { + return getReplicaName(descriptor); } public void preRegister(CoreDescriptor cd, boolean publishState) { - String coreNodeName = getCoreNodeName(cd); + String replicaName = getReplicaName(cd); // before becoming available, make sure we are not live and active // this also gets us our assigned shard id if it was not specified @@ -1774,8 +1778,8 @@ public void preRegister(CoreDescriptor cd, boolean publishState) { CloudDescriptor cloudDesc = cd.getCloudDescriptor(); // make sure the node name is set on the descriptor - if (cloudDesc.getCoreNodeName() == null) { - cloudDesc.setCoreNodeName(coreNodeName); + if (cloudDesc.getReplicaName() == null) { + cloudDesc.setReplicaName(replicaName); } // publishState == false on startup @@ -1823,11 +1827,11 @@ private boolean isPublishAsDownOnStartup(CloudDescriptor cloudDesc) { private void checkStateInZk(CoreDescriptor cd) throws InterruptedException, NotInClusterStateException { CloudDescriptor cloudDesc = cd.getCloudDescriptor(); - String nodeName = cloudDesc.getCoreNodeName(); + String nodeName = cloudDesc.getReplicaName(); if (nodeName == null) { - throw new SolrException(ErrorCode.SERVER_ERROR, "No coreNodeName for " + cd); + throw new SolrException(ErrorCode.SERVER_ERROR, "No replicaName for " + cd); } - final String coreNodeName = nodeName; + final String replicaName = nodeName; if (cloudDesc.getShardId() == null) { throw new SolrException(ErrorCode.SERVER_ERROR, "No shard id for " + cd); @@ -1845,9 +1849,9 @@ private void checkStateInZk(CoreDescriptor cd) throws InterruptedException, NotI errorMessage.set("Invalid shard: " + cloudDesc.getShardId()); return false; } - Replica replica = slice.getReplica(coreNodeName); + Replica replica = slice.getReplica(replicaName); if (replica == null) { - errorMessage.set("coreNodeName " + coreNodeName + " does not exist in shard " + cloudDesc.getShardId() + + errorMessage.set("replicaName " + replicaName + " does not exist in shard " + cloudDesc.getShardId() + ", ignore the exception if the replica was deleted"); return false; } @@ -1856,7 +1860,7 @@ private void checkStateInZk(CoreDescriptor cd) throws InterruptedException, NotI } catch (TimeoutException e) { String error = errorMessage.get(); if (error == null) - error = "coreNodeName " + coreNodeName + " does not exist in shard " + cloudDesc.getShardId() + + error = "replicaName " + replicaName + " does not exist in shard " + cloudDesc.getShardId() + ", ignore the exception if the replica was deleted"; throw new NotInClusterStateException(ErrorCode.SERVER_ERROR, error); } @@ -2636,7 +2640,7 @@ public NotInClusterStateException(ErrorCode code, String msg) { } } - public boolean checkIfCoreNodeNameAlreadyExists(CoreDescriptor dcore) { + public boolean checkIfReplicaNameAlreadyExists(CoreDescriptor dcore) { DocCollection collection = zkStateReader.getClusterState().getCollectionOrNull(dcore.getCollectionName()); if (collection != null) { Collection slices = collection.getSlices(); diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkShardTerms.java b/solr/core/src/java/org/apache/solr/cloud/ZkShardTerms.java index 6b4799f21b89..a55ed256dc23 100644 --- a/solr/core/src/java/org/apache/solr/cloud/ZkShardTerms.java +++ b/solr/core/src/java/org/apache/solr/cloud/ZkShardTerms.java @@ -110,7 +110,7 @@ public ZkShardTerms(String collection, String shard, SolrZkClient zkClient) { * Ensure that terms are higher than some replica's terms. If the current leader is attempting to give up * leadership and included in replicasNeedingRecovery, then other replicas that are in sync will have higher * terms, while the leader will stay where it is. - * @param leader coreNodeName of leader + * @param leader replicaName of leader * @param replicasNeedingRecovery set of replicas in which their terms should be lower than leader's term */ public void ensureTermsIsHigher(String leader, Set replicasNeedingRecovery) { @@ -123,29 +123,29 @@ public ShardTerms getShardTerms() { } /** * Can this replica become leader? - * @param coreNodeName of the replica + * @param replicaName of the replica * @return true if this replica can become leader, false if otherwise */ - public boolean canBecomeLeader(String coreNodeName) { - return terms.get().canBecomeLeader(coreNodeName); + public boolean canBecomeLeader(String replicaName) { + return terms.get().canBecomeLeader(replicaName); } /** * Should leader skip sending updates to this replica? - * @param coreNodeName of the replica + * @param replicaName of the replica * @return true if this replica has term equals to leader's term, false if otherwise */ - public boolean skipSendingUpdatesTo(String coreNodeName) { - return !terms.get().haveHighestTermValue(coreNodeName); + public boolean skipSendingUpdatesTo(String replicaName) { + return !terms.get().haveHighestTermValue(replicaName); } /** * Did this replica registered its term? This is a sign to check f - * @param coreNodeName of the replica + * @param replicaName of the replica * @return true if this replica registered its term, false if otherwise */ - public boolean registered(String coreNodeName) { - return terms.get().getTerm(coreNodeName) != null; + public boolean registered(String replicaName) { + return terms.get().getTerm(replicaName) != null; } public void close() { @@ -172,7 +172,7 @@ void addListener(CoreTermWatcher listener) { } /** - * Remove the coreNodeName from terms map and also remove any expired listeners + * Remove the replicaName from terms map and also remove any expired listeners * @return Return true if this object should not be reused */ boolean removeTerm(CoreDescriptor cd) { @@ -182,14 +182,14 @@ boolean removeTerm(CoreDescriptor cd) { listeners.removeIf(coreTermWatcher -> !coreTermWatcher.onTermChanged(terms.get())); numListeners = listeners.size(); } - return removeTerm(cd.getCloudDescriptor().getCoreNodeName()) || numListeners == 0; + return removeTerm(cd.getCloudDescriptor().getReplicaName()) || numListeners == 0; } // package private for testing, only used by tests // return true if this object should not be reused - boolean removeTerm(String coreNodeName) { + boolean removeTerm(String replicaName) { ShardTerms newTerms; - while ( (newTerms = terms.get().removeTerm(coreNodeName)) != null) { + while ( (newTerms = terms.get().removeTerm(replicaName)) != null) { try { if (saveTerms(newTerms, "removeTerm")) return false; } catch (KeeperException.NoNodeException e) { @@ -202,41 +202,41 @@ boolean removeTerm(String coreNodeName) { /** * Register a replica's term (term value will be 0). * If a term is already associate with this replica do nothing - * @param coreNodeName of the replica + * @param replicaName of the replica */ - void registerTerm(String coreNodeName) { - mutate(terms -> terms.registerTerm(coreNodeName)); + void registerTerm(String replicaName) { + mutate(terms -> terms.registerTerm(replicaName)); } /** * Set a replica's term equals to leader's term, and remove recovering flag of a replica. * This call should only be used by {@link org.apache.solr.common.params.CollectionParams.CollectionAction#FORCELEADER} - * @param coreNodeName of the replica + * @param replicaName of the replica */ - public void setTermEqualsToLeader(String coreNodeName) { - mutate(terms -> terms.setTermEqualsToLeader(coreNodeName)); + public void setTermEqualsToLeader(String replicaName) { + mutate(terms -> terms.setTermEqualsToLeader(replicaName)); } /** * Set a replica's term to 0. If the term does not exist, create it. - * @param coreNodeName of the replica + * @param replicaName of the replica */ - public void setTermToZero(String coreNodeName) { - mutate(terms -> terms.setTermToZero(coreNodeName)); + public void setTermToZero(String replicaName) { + mutate(terms -> terms.setTermToZero(replicaName)); } /** - * Mark {@code coreNodeName} as recovering + * Mark {@code replicaName} as recovering */ - public void startRecovering(String coreNodeName) { - mutate(terms -> terms.startRecovering(coreNodeName)); + public void startRecovering(String replicaName) { + mutate(terms -> terms.startRecovering(replicaName)); } /** - * Mark {@code coreNodeName} as finished recovering + * Mark {@code replicaName} as finished recovering */ - public void doneRecovering(String coreNodeName) { - mutate(terms -> terms.doneRecovering(coreNodeName)); + public void doneRecovering(String replicaName) { + mutate(terms -> terms.doneRecovering(replicaName)); } public boolean isRecovering(String name) { @@ -269,8 +269,8 @@ public long getHighestTerm() { return terms.get().getMaxTerm(); } - public long getTerm(String coreNodeName) { - Long term = terms.get().getTerm(coreNodeName); + public long getTerm(String replicaName) { + Long term = terms.get().getTerm(replicaName); return term == null? -1 : term; } diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/AddReplicaCmd.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/AddReplicaCmd.java index c3f50047696b..82bfe695b4ca 100644 --- a/solr/core/src/java/org/apache/solr/cloud/api/collections/AddReplicaCmd.java +++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/AddReplicaCmd.java @@ -54,10 +54,7 @@ import org.apache.solr.common.cloud.Slice; import org.apache.solr.common.cloud.ZkNodeProps; import org.apache.solr.common.cloud.ZkStateReader; -import org.apache.solr.common.params.CollectionAdminParams; -import org.apache.solr.common.params.CoreAdminParams; -import org.apache.solr.common.params.ModifiableSolrParams; -import org.apache.solr.common.params.ShardParams; +import org.apache.solr.common.params.*; import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.Utils; import org.apache.solr.core.CoreContainer; @@ -135,7 +132,7 @@ List addReplica(ClusterState clusterState, ZkNodeProps message, @Su if (node != null) { throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Cannot create " + totalReplicas + " replicas if 'name' parameter is specified"); } - if (message.getStr(CoreAdminParams.CORE_NODE_NAME) != null) { + if (message.getStr(CommonParams.REPLICA_NAME) != null) { throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Cannot create " + totalReplicas + " replicas if 'coreNodeName' parameter is specified"); } } @@ -160,7 +157,7 @@ List addReplica(ClusterState clusterState, ZkNodeProps message, @Su Runnable runnable = () -> { shardRequestTracker.processResponses(results, shardHandler, true, "ADDREPLICA failed to create replica"); for (CreateReplica replica : createReplicas) { - ocmh.waitForCoreNodeName(collectionName, replica.node, replica.coreName); + ocmh.waitForReplica(collectionName, replica.node, replica.coreName); } if (onComplete != null) onComplete.run(); }; @@ -209,8 +206,8 @@ private ModifiableSolrParams getReplicaParams(ClusterState clusterState, ZkNodeP ZkStateReader.STATE_PROP, Replica.State.DOWN.toString(), ZkStateReader.NODE_NAME_PROP, createReplica.node, ZkStateReader.REPLICA_TYPE, createReplica.replicaType.name()); - if (createReplica.coreNodeName != null) { - props = props.plus(ZkStateReader.CORE_NODE_NAME_PROP, createReplica.coreNodeName); + if (createReplica.replicaName != null) { + props = props.plus(ZkStateReader.CORE_NODE_NAME_PROP, createReplica.replicaName); } try { ocmh.overseer.offerStateUpdate(Utils.toJSON(props)); @@ -218,7 +215,7 @@ private ModifiableSolrParams getReplicaParams(ClusterState clusterState, ZkNodeP throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Exception updating Overseer state queue", e); } } - params.set(CoreAdminParams.CORE_NODE_NAME, + params.set(CommonParams.REPLICA_NAME, ocmh.waitToSeeReplicasInState(collectionName, Collections.singletonList(createReplica.coreName)).get(createReplica.coreName).getName()); String configName = zkStateReader.readConfigName(collectionName); @@ -253,8 +250,8 @@ private ModifiableSolrParams getReplicaParams(ClusterState clusterState, ZkNodeP if (instanceDir != null) { params.set(CoreAdminParams.INSTANCE_DIR, instanceDir); } - if (createReplica.coreNodeName != null) { - params.set(CoreAdminParams.CORE_NODE_NAME, createReplica.coreNodeName); + if (createReplica.replicaName != null) { + params.set(CoreAdminParams.CORE_NODE_NAME, createReplica.replicaName); } ocmh.addPropertyParams(message, params); @@ -269,7 +266,7 @@ public static CreateReplica assignReplicaDetails(SolrCloudManager cloudManager, String node = replicaPosition.node; String shard = message.getStr(SHARD_ID_PROP); String coreName = message.getStr(CoreAdminParams.NAME); - String coreNodeName = message.getStr(CoreAdminParams.CORE_NODE_NAME); + String replicaName = message.getStr(CoreAdminParams.CORE_NODE_NAME); Replica.Type replicaType = replicaPosition.type; if (StringUtils.isBlank(coreName)) { @@ -296,7 +293,7 @@ public static CreateReplica assignReplicaDetails(SolrCloudManager cloudManager, } } log.info("Returning CreateReplica command."); - return new CreateReplica(collection, shard, node, replicaType, coreName, coreNodeName); + return new CreateReplica(collection, shard, node, replicaType, coreName, replicaName); } public static List buildReplicaPositions(SolrCloudManager cloudManager, ClusterState clusterState, @@ -361,15 +358,15 @@ public static class CreateReplica { public final String node; public final Replica.Type replicaType; public String coreName; - public String coreNodeName; + public String replicaName; - CreateReplica(String collectionName, String sliceName, String node, Replica.Type replicaType, String coreName, String coreNodeName) { + CreateReplica(String collectionName, String sliceName, String node, Replica.Type replicaType, String coreName, String replicaName) { this.collectionName = collectionName; this.sliceName = sliceName; this.node = node; this.replicaType = replicaType; this.coreName = coreName; - this.coreNodeName = coreNodeName; + this.replicaName = replicaName; } } diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/Assign.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/Assign.java index c2f09ac1ef66..ea9ca6e1c044 100644 --- a/solr/core/src/java/org/apache/solr/cloud/api/collections/Assign.java +++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/Assign.java @@ -115,16 +115,16 @@ public static int incAndGetId(DistribStateManager stateManager, String collectio } } - public static String assignCoreNodeName(DistribStateManager stateManager, DocCollection collection) { + public static String assignReplicaName(DistribStateManager stateManager, DocCollection collection) { // for backward compatibility; int defaultValue = defaultCounterValue(collection, false); - String coreNodeName = "core_node" + incAndGetId(stateManager, collection.getName(), defaultValue); - while (collection.getReplica(coreNodeName) != null) { - // there is wee chance that, the new coreNodeName id not totally unique, + String replicaName = "core_node" + incAndGetId(stateManager, collection.getName(), defaultValue); + while (collection.getReplica(replicaName) != null) { + // there is wee chance that, the new replicaName is not totally unique, // but this will be guaranteed unique for new collections - coreNodeName = "core_node" + incAndGetId(stateManager, collection.getName(), defaultValue); + replicaName = "core_node" + incAndGetId(stateManager, collection.getName(), defaultValue); } - return coreNodeName; + return replicaName; } /** diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/LeaderRecoveryWatcher.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/LeaderRecoveryWatcher.java index a80fdc0a3d05..1f3fbc3a0218 100644 --- a/solr/core/src/java/org/apache/solr/cloud/api/collections/LeaderRecoveryWatcher.java +++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/LeaderRecoveryWatcher.java @@ -40,7 +40,7 @@ public class LeaderRecoveryWatcher implements CollectionStateWatcher { * * @param collectionId collection name * @param shardId shard id - * @param replicaId source replica name (coreNodeName) + * @param replicaId source replica name * @param targetCore specific target core name - if null then any active replica will do * @param latch countdown when recovered */ diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/MigrateCmd.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/MigrateCmd.java index 2b094b277035..919b7b9ac66f 100644 --- a/solr/core/src/java/org/apache/solr/cloud/api/collections/MigrateCmd.java +++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/MigrateCmd.java @@ -251,7 +251,7 @@ private void migrateKey(ClusterState clusterState, DocCollection sourceCollectio Replica tempSourceLeader = zkStateReader.getLeaderRetry(tempSourceCollectionName, tempSourceSlice.getName(), 120000); String tempCollectionReplica1 = tempSourceLeader.getCoreName(); - String coreNodeName = ocmh.waitForCoreNodeName(tempSourceCollectionName, + String replicaName = ocmh.waitForReplica(tempSourceCollectionName, sourceLeader.getNodeName(), tempCollectionReplica1); // wait for the replicas to be seen as active on temp source leader if (log.isInfoEnabled()) { @@ -260,7 +260,7 @@ private void migrateKey(ClusterState clusterState, DocCollection sourceCollectio CoreAdminRequest.WaitForState cmd = new CoreAdminRequest.WaitForState(); cmd.setCoreName(tempCollectionReplica1); cmd.setNodeName(sourceLeader.getNodeName()); - cmd.setCoreNodeName(coreNodeName); + cmd.setReplicaName(replicaName); cmd.setState(Replica.State.ACTIVE); cmd.setCheckLive(true); cmd.setOnlyIfLeader(true); @@ -319,7 +319,7 @@ private void migrateKey(ClusterState clusterState, DocCollection sourceCollectio syncRequestTracker.processResponses(results, shardHandler, true, "MIGRATE failed to create replica of " + "temporary collection in target leader node."); } - coreNodeName = ocmh.waitForCoreNodeName(tempSourceCollectionName, + replicaName = ocmh.waitForReplica(tempSourceCollectionName, targetLeader.getNodeName(), tempCollectionReplica2); // wait for the replicas to be seen as active on temp source leader if (log.isInfoEnabled()) { @@ -328,7 +328,7 @@ private void migrateKey(ClusterState clusterState, DocCollection sourceCollectio cmd = new CoreAdminRequest.WaitForState(); cmd.setCoreName(tempSourceLeader.getStr("core")); cmd.setNodeName(targetLeader.getNodeName()); - cmd.setCoreNodeName(coreNodeName); + cmd.setCoreNodeName(replicaName); cmd.setState(Replica.State.ACTIVE); cmd.setCheckLive(true); cmd.setOnlyIfLeader(true); diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/OverseerCollectionMessageHandler.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/OverseerCollectionMessageHandler.java index e321de193ffc..59490558fbe2 100644 --- a/solr/core/src/java/org/apache/solr/cloud/api/collections/OverseerCollectionMessageHandler.java +++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/OverseerCollectionMessageHandler.java @@ -486,7 +486,7 @@ static UpdateResponse softCommit(String url) throws SolrServerException, IOExcep } } - String waitForCoreNodeName(String collectionName, String msgNodeName, String msgCore) { + String waitForReplica(String collectionName, String msgNodeName, String msgCore) { int retryCount = 320; while (retryCount-- > 0) { final DocCollection docCollection = zkStateReader.getClusterState().getCollectionOrNull(collectionName); @@ -511,7 +511,7 @@ String waitForCoreNodeName(String collectionName, String msgNodeName, String msg Thread.currentThread().interrupt(); } } - throw new SolrException(ErrorCode.SERVER_ERROR, "Could not find coreNodeName"); + throw new SolrException(ErrorCode.SERVER_ERROR, "Could not find replicaName"); } ClusterState waitForNewShard(String collectionName, String sliceName) throws KeeperException, InterruptedException { diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/RestoreCmd.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/RestoreCmd.java index 03cb47a6252d..f6c43b7ac8b9 100644 --- a/solr/core/src/java/org/apache/solr/cloud/api/collections/RestoreCmd.java +++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/RestoreCmd.java @@ -327,17 +327,17 @@ public void call(ClusterState state, ZkNodeProps message, NamedList results) thr for (Slice s : restoreCollection.getSlices()) { for (Replica r : s.getReplicas()) { String nodeName = r.getNodeName(); - String coreNodeName = r.getCoreName(); + String replicaName = r.getCoreName(); Replica.State stateRep = r.getState(); if (log.isDebugEnabled()) { - log.debug("Calling REQUESTAPPLYUPDATES on: nodeName={}, coreNodeName={}, state={}", nodeName, coreNodeName, + log.debug("Calling REQUESTAPPLYUPDATES on: nodeName={}, replicaName={}, state={}", nodeName, replicaName, stateRep.name()); } ModifiableSolrParams params = new ModifiableSolrParams(); params.set(CoreAdminParams.ACTION, CoreAdminParams.CoreAdminAction.REQUESTAPPLYUPDATES.toString()); - params.set(CoreAdminParams.NAME, coreNodeName); + params.set(CoreAdminParams.NAME, replicaName); shardRequestTracker.sendShardRequest(nodeName, params, shardHandler); } diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/SplitShardCmd.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/SplitShardCmd.java index ff9df3b825c6..760912337740 100644 --- a/solr/core/src/java/org/apache/solr/cloud/api/collections/SplitShardCmd.java +++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/SplitShardCmd.java @@ -330,11 +330,11 @@ public boolean split(ClusterState clusterState, ZkNodeProps message, NamedList slices = collection != null ? collection.getSlices() : null; if (slices != null) { for (Slice slice : slices) { diff --git a/solr/core/src/java/org/apache/solr/cloud/overseer/ReplicaMutator.java b/solr/core/src/java/org/apache/solr/cloud/overseer/ReplicaMutator.java index 32e27c76b533..c1cbddbb22df 100644 --- a/solr/core/src/java/org/apache/solr/cloud/overseer/ReplicaMutator.java +++ b/solr/core/src/java/org/apache/solr/cloud/overseer/ReplicaMutator.java @@ -259,38 +259,38 @@ protected ZkWriteCommand updateState(final ClusterState prevState, ZkNodeProps m private ZkWriteCommand updateState(final ClusterState prevState, ZkNodeProps message, String collectionName, Integer numShards, boolean collectionExists) { String sliceName = message.getStr(ZkStateReader.SHARD_ID_PROP); - String coreNodeName = message.getStr(ZkStateReader.CORE_NODE_NAME_PROP); + String replicaName = message.getStr(ZkStateReader.CORE_NODE_NAME_PROP); boolean forceSetState = message.getBool(ZkStateReader.FORCE_SET_STATE_PROP, true); DocCollection collection = prevState.getCollectionOrNull(collectionName); - if (!forceSetState && !CloudUtil.replicaExists(prevState, collectionName, sliceName, coreNodeName)) { + if (!forceSetState && !CloudUtil.replicaExists(prevState, collectionName, sliceName, replicaName)) { log.info("Failed to update state because the replica does not exist, {}", message); return ZkStateWriter.NO_OP; } boolean persistCollectionState = collection != null && collection.isPerReplicaState(); - if (coreNodeName == null) { - coreNodeName = ClusterStateMutator.getAssignedCoreNodeName(collection, + if (replicaName == null) { + replicaName = ClusterStateMutator.getAssignedReplicaName(collection, message.getStr(ZkStateReader.NODE_NAME_PROP), message.getStr(ZkStateReader.CORE_NAME_PROP)); - if (coreNodeName != null) { - log.debug("node={} is already registered", coreNodeName); + if (replicaName != null) { + log.debug("node={} is already registered", replicaName); } else { if (!forceSetState) { log.info("Failed to update state because the replica does not exist, {}", message); return ZkStateWriter.NO_OP; } persistCollectionState = true; - // if coreNodeName is null, auto assign one - coreNodeName = Assign.assignCoreNodeName(stateManager, collection); + // if replicaName is null, auto assign one + replicaName = Assign.assignReplicaName(stateManager, collection); } message.getProperties().put(ZkStateReader.CORE_NODE_NAME_PROP, - coreNodeName); + replicaName); } // use the provided non null shardId if (sliceName == null) { //get shardId from ClusterState - sliceName = ClusterStateMutator.getAssignedId(collection, coreNodeName); + sliceName = ClusterStateMutator.getAssignedId(collection, replicaName); if (sliceName != null) { log.debug("shard={} is already registered", sliceName); } @@ -312,7 +312,7 @@ private ZkWriteCommand updateState(final ClusterState prevState, ZkNodeProps mes Map replicaProps = new LinkedHashMap<>(message.getProperties()); if (slice != null) { - Replica oldReplica = slice.getReplica(coreNodeName); + Replica oldReplica = slice.getReplica(replicaName); if (oldReplica != null) { if (oldReplica.containsKey(ZkStateReader.LEADER_PROP)) { replicaProps.put(ZkStateReader.LEADER_PROP, oldReplica.get(ZkStateReader.LEADER_PROP)); @@ -352,7 +352,7 @@ private ZkWriteCommand updateState(final ClusterState prevState, ZkNodeProps mes String shardParent = (String) replicaProps.remove(ZkStateReader.SHARD_PARENT_PROP); - Replica replica = new Replica(coreNodeName, replicaProps, collectionName, sliceName); + Replica replica = new Replica(replicaName, replicaProps, collectionName, sliceName); log.debug("Will update state for replica: {}", replica); @@ -360,7 +360,7 @@ private ZkWriteCommand updateState(final ClusterState prevState, ZkNodeProps mes Map replicas; if (slice != null) { - collection = checkAndCompleteShardSplit(prevState, collection, coreNodeName, sliceName, replica); + collection = checkAndCompleteShardSplit(prevState, collection, replicaName, sliceName, replica); // get the current slice again because it may have been updated due to checkAndCompleteShardSplit method slice = collection.getSlice(sliceName); sliceProps = slice.getProperties(); @@ -385,18 +385,18 @@ private ZkWriteCommand updateState(final ClusterState prevState, ZkNodeProps mes } } - private DocCollection checkAndCompleteShardSplit(ClusterState prevState, DocCollection collection, String coreNodeName, String sliceName, Replica replica) { + private DocCollection checkAndCompleteShardSplit(ClusterState prevState, DocCollection collection, String replicaName, String sliceName, Replica replica) { Slice slice = collection.getSlice(sliceName); Map sliceProps = slice.getProperties(); if (slice.getState() == Slice.State.RECOVERY) { log.info("Shard: {} is in recovery state", sliceName); // is this replica active? if (replica.getState() == Replica.State.ACTIVE) { - log.info("Shard: {} is in recovery state and coreNodeName: {} is active", sliceName, coreNodeName); + log.info("Shard: {} is in recovery state and replicaName: {} is active", sliceName, replicaName); // are all other replicas also active? boolean allActive = true; for (Map.Entry entry : slice.getReplicasMap().entrySet()) { - if (coreNodeName.equals(entry.getKey())) continue; + if (replicaName.equals(entry.getKey())) continue; if (entry.getValue().getState() != Replica.State.ACTIVE) { allActive = false; break; diff --git a/solr/core/src/java/org/apache/solr/cloud/overseer/SliceMutator.java b/solr/core/src/java/org/apache/solr/cloud/overseer/SliceMutator.java index 2594ee4b8865..f8ecd69fec9c 100644 --- a/solr/core/src/java/org/apache/solr/cloud/overseer/SliceMutator.java +++ b/solr/core/src/java/org/apache/solr/cloud/overseer/SliceMutator.java @@ -83,13 +83,13 @@ public ZkWriteCommand addReplica(ClusterState clusterState, ZkNodeProps message) log.error("Invalid Collection/Slice {}/{} ", coll, slice); return ZkStateWriter.NO_OP; } - String coreNodeName; + String replicaName; if (message.getStr(ZkStateReader.CORE_NODE_NAME_PROP) != null) { - coreNodeName = message.getStr(ZkStateReader.CORE_NODE_NAME_PROP); + replicaName = message.getStr(ZkStateReader.CORE_NODE_NAME_PROP); } else { - coreNodeName = Assign.assignCoreNodeName(stateManager, collection); + replicaName = Assign.assignReplicaName(stateManager, collection); } - Replica replica = new Replica(coreNodeName, + Replica replica = new Replica(replicaName, makeMap( ZkStateReader.CORE_NAME_PROP, message.getStr(ZkStateReader.CORE_NAME_PROP), ZkStateReader.STATE_PROP, message.getStr(ZkStateReader.STATE_PROP), @@ -287,10 +287,10 @@ public ZkWriteCommand removeRoutingRule(final ClusterState clusterState, ZkNodeP return ZkStateWriter.NO_OP; } - public static DocCollection updateReplica(DocCollection collection, final Slice slice, String coreNodeName, final Replica replica) { + public static DocCollection updateReplica(DocCollection collection, final Slice slice, String replicaName, final Replica replica) { Map replicasCopy = slice.getReplicasCopy(); if (replica == null) { - replicasCopy.remove(coreNodeName); + replicasCopy.remove(replicaName); } else { replicasCopy.put(replica.getName(), replica); } diff --git a/solr/core/src/java/org/apache/solr/core/CloudConfig.java b/solr/core/src/java/org/apache/solr/core/CloudConfig.java index c8efbbb04614..3af488873a65 100644 --- a/solr/core/src/java/org/apache/solr/core/CloudConfig.java +++ b/solr/core/src/java/org/apache/solr/core/CloudConfig.java @@ -109,7 +109,7 @@ public int getLeaderConflictResolveWait() { return leaderConflictResolveWait; } - public boolean getGenericCoreNodeNames() { + public boolean getGenericReplicaNames() { return useGenericCoreNames; } diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java b/solr/core/src/java/org/apache/solr/core/CoreContainer.java index d8a6a33ed43f..94650d6c56a7 100644 --- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java +++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java @@ -1306,10 +1306,10 @@ public SolrCore create(String coreName, Path instancePath, Map p boolean preExisitingZkEntry = false; try { if (getZkController() != null) { - if (cd.getCloudDescriptor().getCoreNodeName() == null) { + if (cd.getCloudDescriptor().getReplicaName() == null) { throw new SolrException(ErrorCode.SERVER_ERROR, "coreNodeName missing " + parameters.toString()); } - preExisitingZkEntry = getZkController().checkIfCoreNodeNameAlreadyExists(cd); + preExisitingZkEntry = getZkController().checkIfReplicaNameAlreadyExists(cd); } // Much of the logic in core handling pre-supposes that the core.properties file already exists, so create it @@ -1527,7 +1527,7 @@ private SolrCore processCoreCreateException(SolrException original, CoreDescript log.info("Found active leader, will attempt to create fresh core and recover."); resetIndexDirectory(dcore, coreConfig); // the index of this core is emptied, its term should be set to 0 - getZkController().getShardTerms(desc.getCollectionName(), desc.getShardId()).setTermToZero(desc.getCoreNodeName()); + getZkController().getShardTerms(desc.getCollectionName(), desc.getShardId()).setTermToZero(desc.getReplicaName()); return new SolrCore(this, dcore, coreConfig); } } catch (SolrException se) { @@ -1739,7 +1739,7 @@ public void reload(String name, UUID coreId) { if (docCollection != null) { - Replica replica = docCollection.getReplica(cd.getCloudDescriptor().getCoreNodeName()); + Replica replica = docCollection.getReplica(cd.getCloudDescriptor().getReplicaName()); assert replica != null; if (replica.getType() == Replica.Type.TLOG) { // TODO: needed here? getZkController().stopReplicationFromLeader(core.getName()); diff --git a/solr/core/src/java/org/apache/solr/core/CoreDescriptor.java b/solr/core/src/java/org/apache/solr/core/CoreDescriptor.java index 033f2590bd4a..e09b919fe62e 100644 --- a/solr/core/src/java/org/apache/solr/core/CoreDescriptor.java +++ b/solr/core/src/java/org/apache/solr/core/CoreDescriptor.java @@ -39,6 +39,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.apache.solr.common.params.CommonParams.REPLICA_NAME; + /** * Metadata about a {@link SolrCore}. * It's mostly loaded from a file on disk at the very beginning of loading a core. @@ -61,7 +63,8 @@ public class CoreDescriptor { public static final String CORE_PROPERTIES = "properties"; public static final String CORE_LOADONSTARTUP = "loadOnStartup"; public static final String CORE_TRANSIENT = "transient"; - public static final String CORE_NODE_NAME = "coreNodeName"; + @Deprecated + public static final String CORE_NODE_NAME = REPLICA_NAME; public static final String CORE_CONFIGSET = "configSet"; public static final String CORE_CONFIGSET_PROPERTIES = "configSetProperties"; public static final String SOLR_CORE_PROP_PREFIX = "solr.core."; @@ -120,7 +123,7 @@ public Properties getPersistableUserProperties() { CORE_SHARD, CORE_COLLECTION, CORE_ROLES, - CORE_NODE_NAME, + REPLICA_NAME, CloudDescriptor.NUM_SHARDS ); diff --git a/solr/core/src/java/org/apache/solr/core/HdfsDirectoryFactory.java b/solr/core/src/java/org/apache/solr/core/HdfsDirectoryFactory.java index 6b776177d47a..688f1cedff90 100644 --- a/solr/core/src/java/org/apache/solr/core/HdfsDirectoryFactory.java +++ b/solr/core/src/java/org/apache/solr/core/HdfsDirectoryFactory.java @@ -413,7 +413,7 @@ public String getDataHome(CoreDescriptor cd) throws IOException { path = URLEncoder.encode(cd.getCloudDescriptor().getCollectionName(), "UTF-8") + "/" - + URLEncoder.encode(cd.getCloudDescriptor().getCoreNodeName(), + + URLEncoder.encode(cd.getCloudDescriptor().getReplicaName(), "UTF-8"); } else { path = cd.getName(); diff --git a/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java b/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java index 66d195c0a122..f9af65128dd6 100644 --- a/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java +++ b/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java @@ -372,7 +372,7 @@ IndexFetchResult fetchLatestIndex(boolean forceReplication, boolean forceCoreRel assert !solrCore.isClosed(): "Replication should be stopped before closing the core"; Replica replica = getLeaderReplica(); CloudDescriptor cd = solrCore.getCoreDescriptor().getCloudDescriptor(); - if (cd.getCoreNodeName().equals(replica.getName())) { + if (cd.getReplicaName().equals(replica.getName())) { return IndexFetchResult.EXPECTING_NON_LEADER; } if (replica.getState() != Replica.State.ACTIVE) { diff --git a/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java index 0ef3ebbd999d..96e78cef5159 100644 --- a/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java +++ b/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java @@ -35,10 +35,7 @@ import org.apache.solr.common.SolrException; import org.apache.solr.common.SolrException.ErrorCode; import org.apache.solr.common.cloud.ZkStateReader; -import org.apache.solr.common.params.CommonAdminParams; -import org.apache.solr.common.params.CoreAdminParams; -import org.apache.solr.common.params.ModifiableSolrParams; -import org.apache.solr.common.params.SolrParams; +import org.apache.solr.common.params.*; import org.apache.solr.common.util.ExecutorUtil; import org.apache.solr.common.util.NamedList; import org.apache.solr.core.CoreContainer; @@ -57,6 +54,7 @@ import org.slf4j.LoggerFactory; import org.slf4j.MDC; +import static org.apache.solr.common.params.CommonParams.REPLICA_NAME; import static org.apache.solr.common.params.CoreAdminParams.ACTION; import static org.apache.solr.common.params.CoreAdminParams.CoreAdminAction.STATUS; import static org.apache.solr.security.PermissionNameProvider.Name.CORE_EDIT_PERM; @@ -233,7 +231,7 @@ protected void handleCustomAction(SolrQueryRequest req, SolrQueryResponse rsp) { .put(CoreAdminParams.SHARD, CoreDescriptor.CORE_SHARD) .put(CoreAdminParams.COLLECTION, CoreDescriptor.CORE_COLLECTION) .put(CoreAdminParams.ROLES, CoreDescriptor.CORE_ROLES) - .put(CoreAdminParams.CORE_NODE_NAME, CoreDescriptor.CORE_NODE_NAME) + .put(REPLICA_NAME, REPLICA_NAME) .put(ZkStateReader.NUM_SHARDS_PROP, CloudDescriptor.NUM_SHARDS) .put(CoreAdminParams.REPLICA_TYPE, CloudDescriptor.REPLICA_TYPE) .build(); diff --git a/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminOperation.java b/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminOperation.java index 4f09c8513da6..fc5e6a90295f 100644 --- a/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminOperation.java +++ b/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminOperation.java @@ -338,7 +338,7 @@ static NamedList getCoreStatus(CoreContainer cores, String cname, boolea SimpleOrderedMap cloudInfo = new SimpleOrderedMap<>(); cloudInfo.add(COLLECTION, core.getCoreDescriptor().getCloudDescriptor().getCollectionName()); cloudInfo.add(SHARD, core.getCoreDescriptor().getCloudDescriptor().getShardId()); - cloudInfo.add(REPLICA, core.getCoreDescriptor().getCloudDescriptor().getCoreNodeName()); + cloudInfo.add(REPLICA, core.getCoreDescriptor().getCloudDescriptor().getReplicaName()); cloudInfo.add(REPLICA_TYPE, core.getCoreDescriptor().getCloudDescriptor().getReplicaType().name()); info.add("cloud", cloudInfo); } diff --git a/solr/core/src/java/org/apache/solr/handler/admin/PrepRecoveryOp.java b/solr/core/src/java/org/apache/solr/handler/admin/PrepRecoveryOp.java index 15be7463369b..106fd9e0aab2 100644 --- a/solr/core/src/java/org/apache/solr/handler/admin/PrepRecoveryOp.java +++ b/solr/core/src/java/org/apache/solr/handler/admin/PrepRecoveryOp.java @@ -39,6 +39,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.apache.solr.common.params.CommonParams.REPLICA_NAME; + class PrepRecoveryOp implements CoreAdminHandler.CoreAdminOp { private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @@ -52,7 +54,7 @@ public void execute(CallInfo it) throws Exception { String cname = params.get(CoreAdminParams.CORE, ""); String nodeName = params.get("nodeName"); - String coreNodeName = params.get("coreNodeName"); + String replicaName = params.get(REPLICA_NAME); Replica.State waitForState = Replica.State.getState(params.get(ZkStateReader.STATE_PROP)); Boolean checkLive = params.getBool("checkLive"); Boolean onlyIfLeader = params.getBool("onlyIfLeader"); @@ -62,8 +64,8 @@ public void execute(CallInfo it) throws Exception { // wait long enough for the leader conflict to work itself out plus a little extra int conflictWaitMs = coreContainer.getZkController().getLeaderConflictResolveWait(); log.info( - "Going to wait for coreNodeName: {}, state: {}, checkLive: {}, onlyIfLeader: {}, onlyIfLeaderActive: {}", - coreNodeName, waitForState, checkLive, onlyIfLeader, onlyIfLeaderActive); + "Going to wait for replicaName: {}, state: {}, checkLive: {}, onlyIfLeader: {}, onlyIfLeaderActive: {}", + replicaName, waitForState, checkLive, onlyIfLeader, onlyIfLeaderActive); String collectionName; CloudDescriptor cloudDescriptor; @@ -94,7 +96,7 @@ public void execute(CallInfo it) throws Exception { boolean live = false; Slice slice = c.getSlice(cloudDescriptor.getShardId()); if (slice != null) { - final Replica replica = slice.getReplicasMap().get(coreNodeName); + final Replica replica = slice.getReplicasMap().get(replicaName); if (replica != null) { state = replica.getState(); live = n.contains(nodeName); @@ -117,8 +119,8 @@ public void execute(CallInfo it) throws Exception { ZkShardTerms shardTerms = coreContainer.getZkController().getShardTerms(collectionName, slice.getName()); // if the replica is waiting for leader to see recovery state, the leader should refresh its terms - if (waitForState == Replica.State.RECOVERING && shardTerms.registered(coreNodeName) - && shardTerms.skipSendingUpdatesTo(coreNodeName)) { + if (waitForState == Replica.State.RECOVERING && shardTerms.registered(replicaName) + && shardTerms.skipSendingUpdatesTo(replicaName)) { // The replica changed it term, then published itself as RECOVERING. // This core already see replica as RECOVERING // so it is guarantees that a live-fetch will be enough for this core to see max term published @@ -134,7 +136,7 @@ public void execute(CallInfo it) throws Exception { ", isLeader? " + cloudDescriptor.isLeader() + ", live=" + live + ", checkLive=" + checkLive + ", currentState=" + state + ", localState=" + localState + ", nodeName=" + nodeName + - ", coreNodeName=" + coreNodeName + ", onlyIfActiveCheckResult=" + onlyIfActiveCheckResult + ", replicaName=" + replicaName + ", onlyIfActiveCheckResult=" + onlyIfActiveCheckResult + ", nodeProps: " + replica); //nowarn } if (!onlyIfActiveCheckResult && replica != null && (state == waitForState || leaderDoesNotNeedRecovery)) { diff --git a/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java b/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java index ad1483726f8d..d44eabb1b0b3 100644 --- a/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java +++ b/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java @@ -126,7 +126,7 @@ public void process(ResponseBuilder rb) throws IOException if (replicaType == Replica.Type.PULL) { throw new SolrException(ErrorCode.BAD_REQUEST, String.format(Locale.ROOT, "%s can't handle realtime get requests. Replicas of type %s do not support these type of requests", - cloudDesc.getCoreNodeName(), + cloudDesc.getReplicaName(), Replica.Type.PULL)); } // non-leader TLOG replicas should not respond to distrib /get requests, but internal requests are OK diff --git a/solr/core/src/java/org/apache/solr/logging/MDCLoggingContext.java b/solr/core/src/java/org/apache/solr/logging/MDCLoggingContext.java index 492735be6e7a..677d8c6b902c 100644 --- a/solr/core/src/java/org/apache/solr/logging/MDCLoggingContext.java +++ b/solr/core/src/java/org/apache/solr/logging/MDCLoggingContext.java @@ -138,7 +138,7 @@ public static void setCoreDescriptor(CoreContainer coreContainer, CoreDescriptor if (ccd != null) { setCollection(ccd.getCollectionName()); setShard(ccd.getShardId()); - setReplica(ccd.getCoreNodeName()); + setReplica(ccd.getReplicaName()); } } } diff --git a/solr/core/src/java/org/apache/solr/metrics/SolrCoreMetricManager.java b/solr/core/src/java/org/apache/solr/metrics/SolrCoreMetricManager.java index f05889c88031..39b460a7f8b3 100644 --- a/solr/core/src/java/org/apache/solr/metrics/SolrCoreMetricManager.java +++ b/solr/core/src/java/org/apache/solr/metrics/SolrCoreMetricManager.java @@ -63,11 +63,11 @@ private void initCloudMode() { cloudMode = true; collectionName = core.getCoreDescriptor().getCollectionName(); shardName = cd.getShardId(); - //replicaName = cd.getCoreNodeName(); + //replicaName = cd.getReplicaName(); String coreName = core.getName(); replicaName = Utils.parseMetricsReplicaName(collectionName, coreName); if (replicaName == null) { - replicaName = cd.getCoreNodeName(); + replicaName = cd.getReplicaName(); } } } diff --git a/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrShardReporter.java b/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrShardReporter.java index 8791160e9663..734258f821fe 100644 --- a/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrShardReporter.java +++ b/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrShardReporter.java @@ -136,8 +136,8 @@ public void init(PluginInfo pluginInfo, SolrCore core) { log.warn("period={}, not starting shard reporter ", period); return; } - // our id is coreNodeName - String id = core.getCoreDescriptor().getCloudDescriptor().getCoreNodeName(); + // our id is replicaName + String id = core.getCoreDescriptor().getCloudDescriptor().getReplicaName(); // target registry is the leaderRegistryName String groupId = core.getCoreMetricManager().getLeaderRegistryName(); if (groupId == null) { diff --git a/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java b/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java index ddabd2523635..72a06ddcc36b 100644 --- a/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java +++ b/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java @@ -222,14 +222,14 @@ boolean persistManagedSchemaToZooKeeper(boolean createOnly) { * Block up to a specified maximum time until we see agreement on the schema * version in ZooKeeper across all replicas for a collection. */ - public static void waitForSchemaZkVersionAgreement(String collection, String localCoreNodeName, + public static void waitForSchemaZkVersionAgreement(String collection, String localReplicaName, int schemaZkVersion, ZkController zkController, int maxWaitSecs) { RTimer timer = new RTimer(); // get a list of active replica cores to query for the schema zk version (skipping this core of course) List concurrentTasks = new ArrayList<>(); - for (String coreUrl : getActiveReplicaCoreUrls(zkController, collection, localCoreNodeName)) + for (String coreUrl : getActiveReplicaCoreUrls(zkController, collection, localReplicaName)) concurrentTasks.add(new GetZkSchemaVersionCallable(coreUrl, schemaZkVersion)); if (concurrentTasks.isEmpty()) return; // nothing to wait for ... @@ -278,7 +278,7 @@ public static void waitForSchemaZkVersionAgreement(String collection, String loc } catch (InterruptedException ie) { log.warn("Core {} was interrupted waiting for schema version {} to propagate to {} replicas for collection {}" - , localCoreNodeName, schemaZkVersion, concurrentTasks.size(), collection); + , localReplicaName, schemaZkVersion, concurrentTasks.size(), collection); Thread.currentThread().interrupt(); } finally { if (!parallelExecutor.isShutdown()) @@ -291,7 +291,7 @@ public static void waitForSchemaZkVersionAgreement(String collection, String loc } } - protected static List getActiveReplicaCoreUrls(ZkController zkController, String collection, String localCoreNodeName) { + protected static List getActiveReplicaCoreUrls(ZkController zkController, String collection, String localReplicaName) { List activeReplicaCoreUrls = new ArrayList<>(); ZkStateReader zkStateReader = zkController.getZkStateReader(); ClusterState clusterState = zkStateReader.getClusterState(); @@ -304,7 +304,7 @@ protected static List getActiveReplicaCoreUrls(ZkController zkController if (replicasMap != null) { for (Map.Entry entry : replicasMap.entrySet()) { Replica replica = entry.getValue(); - if (!localCoreNodeName.equals(replica.getName()) && + if (!localReplicaName.equals(replica.getName()) && replica.getState() == Replica.State.ACTIVE && liveNodes.contains(replica.getNodeName())) { ZkCoreNodeProps replicaCoreProps = new ZkCoreNodeProps(replica); diff --git a/solr/core/src/java/org/apache/solr/schema/SchemaManager.java b/solr/core/src/java/org/apache/solr/schema/SchemaManager.java index fe2db9a62eb8..c0f6d3c8583e 100644 --- a/solr/core/src/java/org/apache/solr/schema/SchemaManager.java +++ b/solr/core/src/java/org/apache/solr/schema/SchemaManager.java @@ -172,7 +172,7 @@ private void waitForOtherReplicasToUpdate(TimeOut timeOut, int latestVersion) { throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Not enough time left to update replicas. However, the schema is updated already."); } - ManagedIndexSchema.waitForSchemaZkVersionAgreement(collection, cd.getCloudDescriptor().getCoreNodeName(), + ManagedIndexSchema.waitForSchemaZkVersionAgreement(collection, cd.getCloudDescriptor().getReplicaName(), latestVersion, core.getCoreContainer().getZkController(), (int) timeOut.timeLeft(TimeUnit.SECONDS)); } } diff --git a/solr/core/src/java/org/apache/solr/update/processor/DistributedZkUpdateProcessor.java b/solr/core/src/java/org/apache/solr/update/processor/DistributedZkUpdateProcessor.java index aa7c61e58626..88cb404a554b 100644 --- a/solr/core/src/java/org/apache/solr/update/processor/DistributedZkUpdateProcessor.java +++ b/solr/core/src/java/org/apache/solr/update/processor/DistributedZkUpdateProcessor.java @@ -79,7 +79,7 @@ public class DistributedZkUpdateProcessor extends DistributedUpdateProcessor { private final ZkController zkController; private final SolrCmdDistributor cmdDistrib; protected List nodes; - private Set skippedCoreNodeNames; + private Set skippedReplicaNames; private final String collection; private boolean readOnlyCollection = false; @@ -168,7 +168,7 @@ public void processCommit(CommitUpdateCommand cmd) throws IOException { Thread.interrupted(); throw new SolrException(SolrException.ErrorCode.SERVICE_UNAVAILABLE, "Exception finding leader for shard " + cloudDesc.getShardId(), e); } - isLeader = leaderReplica.getName().equals(cloudDesc.getCoreNodeName()); + isLeader = leaderReplica.getName().equals(cloudDesc.getReplicaName()); nodes = getCollectionUrls(collection, EnumSet.of(Replica.Type.TLOG,Replica.Type.NRT), true); if (nodes == null) { @@ -405,9 +405,9 @@ protected void doDeleteByQuery(DeleteUpdateCommand cmd) throws IOException { // Am I the leader for this slice? ZkCoreNodeProps coreLeaderProps = new ZkCoreNodeProps(leader); - String leaderCoreNodeName = leader.getName(); - String coreNodeName = cloudDesc.getCoreNodeName(); - isLeader = coreNodeName.equals(leaderCoreNodeName); + String leaderReplicaName = leader.getName(); + String replicaName = cloudDesc.getReplicaName(); + isLeader = replicaName.equals(leaderReplicaName); if (isLeader) { // don't forward to ourself @@ -516,7 +516,7 @@ private List setupRequestForDBQ() { try { Replica leaderReplica = zkController.getZkStateReader().getLeaderRetry(collection, shardId); - isLeader = leaderReplica.getName().equals(cloudDesc.getCoreNodeName()); + isLeader = leaderReplica.getName().equals(cloudDesc.getReplicaName()); // TODO: what if we are no longer the leader? @@ -628,7 +628,7 @@ protected List setupRequest(String id, SolrInputDocumen // Not equivalent to getLeaderProps, which retries to find a leader. // Replica leader = slice.getLeader(); Replica leaderReplica = zkController.getZkStateReader().getLeaderRetry(collection, shardId); - isLeader = leaderReplica.getName().equals(cloudDesc.getCoreNodeName()); + isLeader = leaderReplica.getName().equals(cloudDesc.getReplicaName()); if (!isLeader) { isSubShardLeader = amISubShardLeader(coll, slice, id, doc); @@ -652,11 +652,11 @@ protected List setupRequest(String id, SolrInputDocumen // that means I want to forward onto my replicas... // so get the replicas... forwardToLeader = false; - String leaderCoreNodeName = leaderReplica.getName(); + String leaderReplicaName = leaderReplica.getName(); List replicas = clusterState.getCollection(collection) .getSlice(shardId) .getReplicas(EnumSet.of(Replica.Type.NRT, Replica.Type.TLOG)); - replicas.removeIf((replica) -> replica.getName().equals(leaderCoreNodeName)); + replicas.removeIf((replica) -> replica.getName().equals(leaderReplicaName)); if (replicas.isEmpty()) { return null; } @@ -671,21 +671,21 @@ protected List setupRequest(String id, SolrInputDocumen } List nodes = new ArrayList<>(replicas.size()); - skippedCoreNodeNames = new HashSet<>(); + skippedReplicaNames = new HashSet<>(); ZkShardTerms zkShardTerms = zkController.getShardTerms(collection, shardId); for (Replica replica: replicas) { - String coreNodeName = replica.getName(); + String replicaName = replica.getName(); if (skipList != null && skipListSet.contains(replica.getCoreUrl())) { if (log.isInfoEnabled()) { log.info("check url:{} against:{} result:true", replica.getCoreUrl(), skipListSet); } - } else if(zkShardTerms.registered(coreNodeName) && zkShardTerms.skipSendingUpdatesTo(coreNodeName)) { + } else if(zkShardTerms.registered(replicaName) && zkShardTerms.skipSendingUpdatesTo(replicaName)) { if (log.isDebugEnabled()) { log.debug("skip url:{} cause its term is less than leader", replica.getCoreUrl()); } - skippedCoreNodeNames.add(replica.getName()); + skippedReplicaNames.add(replica.getName()); } else if (!clusterState.getLiveNodes().contains(replica.getNodeName()) || replica.getState() == Replica.State.DOWN) { - skippedCoreNodeNames.add(replica.getName()); + skippedReplicaNames.add(replica.getName()); } else { nodes.add(new SolrCmdDistributor.StdNode(new ZkCoreNodeProps(replica), collection, shardId, maxRetriesToFollowers)); } @@ -790,7 +790,7 @@ protected boolean amISubShardLeader(DocCollection coll, Slice parentSlice, Strin final Slice.State state = mySlice.getState(); if (state == Slice.State.CONSTRUCTION || state == Slice.State.RECOVERY) { Replica myLeader = zkController.getZkStateReader().getLeaderRetry(collection, myShardId); - boolean amILeader = myLeader.getName().equals(cloudDesc.getCoreNodeName()); + boolean amILeader = myLeader.getName().equals(cloudDesc.getReplicaName()); if (amILeader) { // Does the document belong to my hash range as well? DocRouter.Range myRange = mySlice.getRange(); @@ -808,11 +808,11 @@ protected boolean amISubShardLeader(DocCollection coll, Slice parentSlice, Strin } protected List getReplicaNodesForLeader(String shardId, Replica leaderReplica) { - String leaderCoreNodeName = leaderReplica.getName(); + String leaderReplicaName = leaderReplica.getName(); List replicas = clusterState.getCollection(collection) .getSlice(shardId) .getReplicas(EnumSet.of(Replica.Type.NRT, Replica.Type.TLOG)); - replicas.removeIf((replica) -> replica.getName().equals(leaderCoreNodeName)); + replicas.removeIf((replica) -> replica.getName().equals(leaderReplicaName)); if (replicas.isEmpty()) { return null; } @@ -827,22 +827,22 @@ protected List getReplicaNodesForLeader(String shardId, } List nodes = new ArrayList<>(replicas.size()); - skippedCoreNodeNames = new HashSet<>(); + skippedReplicaNames = new HashSet<>(); ZkShardTerms zkShardTerms = zkController.getShardTerms(collection, shardId); for (Replica replica : replicas) { - String coreNodeName = replica.getName(); + String replicaName = replica.getName(); if (skipList != null && skipListSet.contains(replica.getCoreUrl())) { if (log.isInfoEnabled()) { log.info("check url:{} against:{} result:true", replica.getCoreUrl(), skipListSet); } - } else if (zkShardTerms.registered(coreNodeName) && zkShardTerms.skipSendingUpdatesTo(coreNodeName)) { + } else if (zkShardTerms.registered(replicaName) && zkShardTerms.skipSendingUpdatesTo(replicaName)) { if (log.isDebugEnabled()) { log.debug("skip url:{} cause its term is less than leader", replica.getCoreUrl()); } - skippedCoreNodeNames.add(replica.getName()); + skippedReplicaNames.add(replica.getName()); } else if (!clusterState.getLiveNodes().contains(replica.getNodeName()) || replica.getState() == Replica.State.DOWN) { - skippedCoreNodeNames.add(replica.getName()); + skippedReplicaNames.add(replica.getName()); } else { nodes.add(new SolrCmdDistributor.StdNode(new ZkCoreNodeProps(replica), collection, shardId)); } @@ -1046,8 +1046,8 @@ protected void doDistribFinish() { boolean shouldUpdateTerms = isLeader && isIndexChanged; if (shouldUpdateTerms) { ZkShardTerms zkShardTerms = zkController.getShardTerms(cloudDesc.getCollectionName(), cloudDesc.getShardId()); - if (skippedCoreNodeNames != null) { - zkShardTerms.ensureTermsIsHigher(cloudDesc.getCoreNodeName(), skippedCoreNodeNames); + if (skippedReplicaNames != null) { + zkShardTerms.ensureTermsIsHigher(cloudDesc.getReplicaName(), skippedReplicaNames); } zkController.getShardTerms(collection, cloudDesc.getShardId()).ensureHighestTermsAreNotZero(); } @@ -1096,7 +1096,7 @@ protected void doDistribFinish() { if ("LeaderChanged".equals(cause)) { // let's just fail this request and let the client retry? or just call processAdd again? log.error("On {}, replica {} now thinks it is the leader! Failing the request to let the client retry!" - , cloudDesc.getCoreNodeName(), replicaUrl, error.e); + , cloudDesc.getReplicaName(), replicaUrl, error.e); errorsForClient.add(error); continue; } @@ -1110,24 +1110,24 @@ protected void doDistribFinish() { shardId = stdNode.getShardId(); // before we go setting other replicas to down, make sure we're still the leader! - String leaderCoreNodeName = null; + String leaderReplicaName = null; Exception getLeaderExc = null; Replica leaderProps = null; try { leaderProps = zkController.getZkStateReader().getLeader(collection, shardId); if (leaderProps != null) { - leaderCoreNodeName = leaderProps.getName(); + leaderReplicaName = leaderProps.getName(); } } catch (Exception exc) { getLeaderExc = exc; } - if (leaderCoreNodeName == null) { + if (leaderReplicaName == null) { log.warn("Failed to determine if {} is still the leader for collection={} shardId={} before putting {} into leader-initiated recovery", - cloudDesc.getCoreNodeName(), collection, shardId, replicaUrl, getLeaderExc); + cloudDesc.getReplicaName(), collection, shardId, replicaUrl, getLeaderExc); } List myReplicas = zkController.getZkStateReader().getReplicaProps(collection, - cloudDesc.getShardId(), cloudDesc.getCoreNodeName()); + cloudDesc.getShardId(), cloudDesc.getReplicaName()); boolean foundErrorNodeInReplicaList = false; if (myReplicas != null) { for (ZkCoreNodeProps replicaProp : myReplicas) { @@ -1138,16 +1138,16 @@ protected void doDistribFinish() { } } - if (leaderCoreNodeName != null && cloudDesc.getCoreNodeName().equals(leaderCoreNodeName) // we are still same leader + if (leaderReplicaName != null && cloudDesc.getCoreNodeName().equals(leaderReplicaName) // we are still same leader && foundErrorNodeInReplicaList // we found an error for one of replicas && !stdNode.getNodeProps().getCoreUrl().equals(leaderProps.getCoreUrl())) { // we do not want to put ourself into LIR try { - String coreNodeName = ((Replica) stdNode.getNodeProps().getNodeProps()).getName(); + String replicaName = ((Replica) stdNode.getNodeProps().getNodeProps()).getName(); // if false, then the node is probably not "live" anymore // and we do not need to send a recovery message Throwable rootCause = SolrException.getRootCause(error.e); - log.error("Setting up to try to start recovery on replica {} with url {} by increasing leader term", coreNodeName, replicaUrl, rootCause); - replicasShouldBeInLowerTerms.add(coreNodeName); + log.error("Setting up to try to start recovery on replica {} with url {} by increasing leader term", replicaName, replicaUrl, rootCause); + replicasShouldBeInLowerTerms.add(replicaName); } catch (Exception exc) { Throwable setLirZnodeFailedCause = SolrException.getRootCause(exc); log.error("Leader failed to set replica {} state to DOWN due to: {}" @@ -1157,7 +1157,7 @@ protected void doDistribFinish() { // not the leader anymore maybe or the error'd node is not my replica? if (!foundErrorNodeInReplicaList) { log.warn("Core {} belonging to {} {}, does not have error'd node {} as a replica. No request recovery command will be sent!" - , cloudDesc.getCoreNodeName(), collection, cloudDesc.getShardId(), stdNode.getNodeProps().getCoreUrl()); + , cloudDesc.getReplicaName(), collection, cloudDesc.getShardId(), stdNode.getNodeProps().getCoreUrl()); if (!shardId.equals(cloudDesc.getShardId())) { // some replicas on other shard did not receive the updates (ex: during splitshard), // exception must be notified to clients @@ -1165,14 +1165,14 @@ protected void doDistribFinish() { } } else { log.warn("Core {} is no longer the leader for {} {} or we tried to put ourself into LIR, no request recovery command will be sent!" - , cloudDesc.getCoreNodeName(), collection, shardId); + , cloudDesc.getReplicaName(), collection, shardId); } } } } if (!replicasShouldBeInLowerTerms.isEmpty()) { zkController.getShardTerms(cloudDesc.getCollectionName(), cloudDesc.getShardId()) - .ensureTermsIsHigher(cloudDesc.getCoreNodeName(), replicasShouldBeInLowerTerms); + .ensureTermsIsHigher(cloudDesc.getReplicaName(), replicasShouldBeInLowerTerms); } handleReplicationFactor(); if (0 < errorsForClient.size()) { diff --git a/solr/core/src/java/org/apache/solr/update/processor/DocExpirationUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/DocExpirationUpdateProcessorFactory.java index 90edc57081a4..e7c69eb3c6c0 100644 --- a/solr/core/src/java/org/apache/solr/update/processor/DocExpirationUpdateProcessorFactory.java +++ b/solr/core/src/java/org/apache/solr/update/processor/DocExpirationUpdateProcessorFactory.java @@ -492,9 +492,9 @@ private boolean iAmInChargeOfPeriodicDeletes() { return false; } String leaderInCharge = firstSliceLeader.getName(); - String myCoreNodeName = desc.getCoreNodeName(); + String myReplicaName = desc.getReplicaName(); - boolean inChargeOfDeletesRightNow = leaderInCharge.equals(myCoreNodeName); + boolean inChargeOfDeletesRightNow = leaderInCharge.equals(myReplicaName); if (previouslyInChargeOfDeletes && ! inChargeOfDeletesRightNow) { // don't spam the logs constantly, just log when we know that we're not the guy diff --git a/solr/core/src/java/org/apache/solr/util/SolrLogLayout.java b/solr/core/src/java/org/apache/solr/util/SolrLogLayout.java index 0280eee45337..f60bb05ee050 100644 --- a/solr/core/src/java/org/apache/solr/util/SolrLogLayout.java +++ b/solr/core/src/java/org/apache/solr/util/SolrLogLayout.java @@ -241,7 +241,7 @@ public String _format(LogEvent event) { private Map getReplicaProps(ZkController zkController, SolrCore core) { final String collectionName = core.getCoreDescriptor().getCloudDescriptor().getCollectionName(); DocCollection collection = zkController.getClusterState().getCollectionOrNull(collectionName); - Replica replica = collection.getReplica(zkController.getCoreNodeName(core.getCoreDescriptor())); + Replica replica = collection.getReplica(zkController.getReplicaName(core.getCoreDescriptor())); if (replica != null) { return replica.getProperties(); } diff --git a/solr/core/src/test/org/apache/solr/cloud/AssignBackwardCompatibilityTest.java b/solr/core/src/test/org/apache/solr/cloud/AssignBackwardCompatibilityTest.java index 37062e639272..5480eff72d8e 100644 --- a/solr/core/src/test/org/apache/solr/cloud/AssignBackwardCompatibilityTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/AssignBackwardCompatibilityTest.java @@ -58,7 +58,7 @@ public static void setupCluster() throws Exception { @Test public void test() throws IOException, SolrServerException, KeeperException, InterruptedException { Set coreNames = new HashSet<>(); - Set coreNodeNames = new HashSet<>(); + Set replicaNames = new HashSet<>(); int numOperations = random().nextInt(15) + 15; int numLiveReplicas = 4; @@ -97,9 +97,9 @@ public void test() throws IOException, SolrServerException, KeeperException, Int Replica newReplica = getCollectionState(COLLECTION).getReplicas().stream() .filter(r -> r.getCoreName().equals(coreName)) .findAny().get(); - String coreNodeName = newReplica.getName(); - assertFalse("Core node name is not unique", coreNodeNames.contains(coreName)); - coreNodeNames.add(coreNodeName); + String replicaName = newReplica.getName(); + assertFalse("Core node name is not unique", replicaNames.contains(coreName)); + replicaNames.add(replicaName); } } } diff --git a/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java b/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java index 227e50e14aa6..a7d4c1de534b 100644 --- a/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java @@ -1167,7 +1167,7 @@ private void createSolrCore(final String collection, if (random().nextBoolean()) { // sometimes we use an explicit core node name - createCmd.setCoreNodeName("anode" + nodeCounter.incrementAndGet()); + createCmd.setReplicaName("anode" + nodeCounter.incrementAndGet()); } if (shardId == null) { diff --git a/solr/core/src/test/org/apache/solr/cloud/DeleteInactiveReplicaTest.java b/solr/core/src/test/org/apache/solr/cloud/DeleteInactiveReplicaTest.java index 325c5fbf486d..667ecfe0949a 100644 --- a/solr/core/src/test/org/apache/solr/cloud/DeleteInactiveReplicaTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/DeleteInactiveReplicaTest.java @@ -92,7 +92,7 @@ public void deleteInactiveReplicaTest() throws Exception { timeOut.waitFor("Expected data dir and instance dir of " + replica.getName() + " is deleted", () -> !Files.exists(replicaCd.getInstanceDir()) && !FileUtils.fileExists(replicaCd.getDataDir())); - // Check that we can't create a core with no coreNodeName + // Check that we can't create a core with no replicaName try (SolrClient queryClient = getHttpSolrClient(jetty.getBaseUrl().toString())) { Exception e = expectThrows(Exception.class, () -> { CoreAdminRequest.Create createRequest = new CoreAdminRequest.Create(); @@ -101,7 +101,7 @@ public void deleteInactiveReplicaTest() throws Exception { createRequest.setShardId("shard2"); queryClient.request(createRequest); }); - assertTrue("Unexpected error message: " + e.getMessage(), e.getMessage().contains("coreNodeName missing")); + assertTrue("Unexpected error message: " + e.getMessage(), e.getMessage().contains("replicaName missing")); } } diff --git a/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java b/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java index e7215177bf4e..c47a480e19e9 100644 --- a/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java @@ -293,7 +293,7 @@ public void raceConditionOnDeleteAndRegisterReplica() throws Exception { AtomicInteger times = new AtomicInteger(0); ZkContainer.testing_beforeRegisterInZk = cd -> { if (cd.getCloudDescriptor() == null) return false; - if (replica1.getName().equals(cd.getCloudDescriptor().getCoreNodeName()) + if (replica1.getName().equals(cd.getCloudDescriptor().getReplicaName()) && collectionName.equals(cd.getCloudDescriptor().getCollectionName())) { if (times.incrementAndGet() > 1) { return false; diff --git a/solr/core/src/test/org/apache/solr/cloud/DistribDocExpirationUpdateProcessorTest.java b/solr/core/src/test/org/apache/solr/cloud/DistribDocExpirationUpdateProcessorTest.java index 027af1177cbc..0bd5efdf9c3d 100644 --- a/solr/core/src/test/org/apache/solr/cloud/DistribDocExpirationUpdateProcessorTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/DistribDocExpirationUpdateProcessorTest.java @@ -269,7 +269,7 @@ private void runTest() throws Exception { } /** - * returns a map whose key is the coreNodeName and whose value is data about that core needed for the test + * returns a map whose key is the replicaName and whose value is data about that core needed for the test */ private Map getTestDataForAllReplicas() throws IOException, SolrServerException { Map results = new HashMap<>(); diff --git a/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java b/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java index 081ed5213816..559712b060f9 100644 --- a/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java @@ -412,7 +412,7 @@ protected void testLeaderZkSessionLoss() throws Exception { // cause leader migration by expiring the current leader's zk session chaosMonkey.expireSession(leaderJetty); - String expectedNewLeaderCoreNodeName = notLeaders.get(0).getName(); + String expectedNewLeaderReplicaName = notLeaders.get(0).getName(); long timeout = System.nanoTime() + TimeUnit.NANOSECONDS.convert(60, TimeUnit.SECONDS); while (System.nanoTime() < timeout) { String currentLeaderName = null; @@ -422,7 +422,7 @@ protected void testLeaderZkSessionLoss() throws Exception { currentLeaderName = currentLeader.getName(); } catch (Exception exc) {} - if (expectedNewLeaderCoreNodeName.equals(currentLeaderName)) + if (expectedNewLeaderReplicaName.equals(currentLeaderName)) break; // new leader was elected after zk session expiration Thread.sleep(500); @@ -430,7 +430,7 @@ protected void testLeaderZkSessionLoss() throws Exception { Replica currentLeader = cloudClient.getZkStateReader().getLeaderRetry(testCollectionName, "shard1"); - assertEquals(expectedNewLeaderCoreNodeName, currentLeader.getName()); + assertEquals(expectedNewLeaderReplicaName, currentLeader.getName()); // TODO: This test logic seems to be timing dependent and fails on Jenkins // need to come up with a better approach diff --git a/solr/core/src/test/org/apache/solr/cloud/LeaderElectionContextKeyTest.java b/solr/core/src/test/org/apache/solr/cloud/LeaderElectionContextKeyTest.java index ee74f680ee60..3f55aa11d7a3 100644 --- a/solr/core/src/test/org/apache/solr/cloud/LeaderElectionContextKeyTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/LeaderElectionContextKeyTest.java @@ -49,7 +49,7 @@ public static void setupCluster() throws Exception { for (int i = 1; i <= 2; i++) { // Create two collections with same order of requests, no parallel - // therefore Assign.buildCoreNodeName will create same coreNodeName + // therefore Assign.buildReplicaName will create same coreNodeName CollectionAdminRequest .createCollection("testCollection"+i, "config", 2, 1) .setCreateNodeSet("") diff --git a/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java b/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java index 294f7c2a2187..97925bd1f3e7 100644 --- a/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java @@ -89,9 +89,9 @@ class TestLeaderElectionContext extends ShardLeaderElectionContextBase { private long runLeaderDelay = 0; public TestLeaderElectionContext(LeaderElector leaderElector, - String shardId, String collection, String coreNodeName, ZkNodeProps props, + String shardId, String collection, String replicaName, ZkNodeProps props, ZkController zkController, long runLeaderDelay) { - super (leaderElector, shardId, collection, coreNodeName, props, zkController); + super (leaderElector, shardId, collection, replicaName, props, zkController); this.runLeaderDelay = runLeaderDelay; } diff --git a/solr/core/src/test/org/apache/solr/cloud/LeaderFailureAfterFreshStartTest.java b/solr/core/src/test/org/apache/solr/cloud/LeaderFailureAfterFreshStartTest.java index 8cb40ddfbbfd..a2c7e106bf18 100644 --- a/solr/core/src/test/org/apache/solr/cloud/LeaderFailureAfterFreshStartTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/LeaderFailureAfterFreshStartTest.java @@ -106,9 +106,9 @@ public void test() throws Exception { CloudJettyRunner initialLeaderJetty = shardToLeaderJetty.get("shard1"); List otherJetties = getOtherAvailableJetties(initialLeaderJetty); - log.info("Leader node_name: {}, url: {}", initialLeaderJetty.coreNodeName, initialLeaderJetty.url); + log.info("Leader node_name: {}, url: {}", initialLeaderJetty.replicaName, initialLeaderJetty.url); for (CloudJettyRunner cloudJettyRunner : otherJetties) { - log.info("Nonleader node_name: {}, url: {}", cloudJettyRunner.coreNodeName, cloudJettyRunner.url); + log.info("Nonleader node_name: {}, url: {}", cloudJettyRunner.replicaName, cloudJettyRunner.url); } CloudJettyRunner secondNode = otherJetties.get(0); @@ -212,7 +212,7 @@ private void waitTillNodesActive() throws Exception { boolean allActive = true; Collection nodesDownNames = nodesDown.stream() - .map(n -> n.coreNodeName) + .map(n -> n.replicaName) .collect(Collectors.toList()); Collection replicasToCheck = null; diff --git a/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java b/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java index 16326177b73d..c57caa4b2a1a 100644 --- a/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java @@ -192,7 +192,7 @@ public void createCollection(String collection, int numShards) throws Exception q.offer(Utils.toJSON(m)); } - public String publishState(String collection, String coreName, String coreNodeName, String shard, Replica.State stateName, int numShards, boolean startElection, Overseer overseer) + public String publishState(String collection, String coreName, String replicaName, String shard, Replica.State stateName, int numShards, boolean startElection, Overseer overseer) throws Exception { if (stateName == null) { ElectionContext ec = electionContext.remove(coreName); @@ -202,7 +202,7 @@ public String publishState(String collection, String coreName, String coreNodeNa ZkNodeProps m = new ZkNodeProps(Overseer.QUEUE_OPERATION, OverseerAction.DELETECORE.toLower(), ZkStateReader.NODE_NAME_PROP, nodeName, ZkStateReader.CORE_NAME_PROP, coreName, - ZkStateReader.CORE_NODE_NAME_PROP, coreNodeName, + ZkStateReader.CORE_NODE_NAME_PROP, replicaName, ZkStateReader.COLLECTION_PROP, collection); ZkDistributedQueue q = overseer.getStateUpdateQueue(); q.offer(Utils.toJSON(m)); @@ -212,7 +212,7 @@ public String publishState(String collection, String coreName, String coreNodeNa ZkStateReader.STATE_PROP, stateName.toString(), ZkStateReader.NODE_NAME_PROP, nodeName, ZkStateReader.CORE_NAME_PROP, coreName, - ZkStateReader.CORE_NODE_NAME_PROP, coreNodeName, + ZkStateReader.CORE_NODE_NAME_PROP, replicaName, ZkStateReader.COLLECTION_PROP, collection, ZkStateReader.SHARD_ID_PROP, shard, ZkStateReader.NUM_SHARDS_PROP, Integer.toString(numShards)); @@ -222,8 +222,8 @@ public String publishState(String collection, String coreName, String coreNodeNa if (startElection && collection.length() > 0) { zkStateReader.waitForState(collection, 45000, TimeUnit.MILLISECONDS, - (liveNodes, collectionState) -> getShardId(collectionState, coreNodeName) != null); - String shardId = getShardId(collection, coreNodeName); + (liveNodes, collectionState) -> getShardId(collectionState, replicaName) != null); + String shardId = getShardId(collection, replicaName); if (shardId != null) { ElectionContext prevContext = electionContext.get(coreName); if (prevContext != null) { @@ -238,7 +238,7 @@ public String publishState(String collection, String coreName, String coreNodeNa ZkStateReader.CORE_NAME_PROP, coreName, ZkStateReader.SHARD_ID_PROP, shardId, ZkStateReader.COLLECTION_PROP, collection, - ZkStateReader.CORE_NODE_NAME_PROP, coreNodeName); + ZkStateReader.CORE_NODE_NAME_PROP, replicaName); LeaderElector elector = new LeaderElector(zkClient); ShardLeaderElectionContextBase ctx = new ShardLeaderElectionContextBase( elector, shardId, collection, nodeName + coreName, props, @@ -252,19 +252,19 @@ public String publishState(String collection, String coreName, String coreNodeNa return null; } - private String getShardId(String collection, String coreNodeName) { + private String getShardId(String collection, String replicaName) { DocCollection dc = zkStateReader.getClusterState().getCollectionOrNull(collection); - return getShardId(dc, coreNodeName); + return getShardId(dc, replicaName); } - private String getShardId(DocCollection collection, String coreNodeName) { + private String getShardId(DocCollection collection, String replicaName) { if (collection == null) return null; Map slices = collection.getSlicesMap(); if (slices != null) { for (Slice slice : slices.values()) { for (Replica replica : slice.getReplicas()) { String cnn = replica.getName(); - if (coreNodeName.equals(cnn)) { + if (replicaName.equals(cnn)) { return slice.getName(); } } diff --git a/solr/core/src/test/org/apache/solr/cloud/PeerSyncReplicationTest.java b/solr/core/src/test/org/apache/solr/cloud/PeerSyncReplicationTest.java index c20e3eb127a8..0155de25aeca 100644 --- a/solr/core/src/test/org/apache/solr/cloud/PeerSyncReplicationTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/PeerSyncReplicationTest.java @@ -345,7 +345,7 @@ private void waitTillNodesActive() throws Exception { Collection nodesDownNames = nodesDown.stream() - .map(n -> n.coreNodeName) + .map(n -> n.replicaName) .collect(Collectors.toList()); Collection replicasToCheck = diff --git a/solr/core/src/test/org/apache/solr/cloud/TestCloudSearcherWarming.java b/solr/core/src/test/org/apache/solr/cloud/TestCloudSearcherWarming.java index 247313e5bb4b..5a4511006e6b 100644 --- a/solr/core/src/test/org/apache/solr/cloud/TestCloudSearcherWarming.java +++ b/solr/core/src/test/org/apache/solr/cloud/TestCloudSearcherWarming.java @@ -52,7 +52,7 @@ */ @LogLevel("org.apache.solr.cloud.overseer.*=DEBUG,org.apache.solr.cloud.Overseer=DEBUG,org.apache.solr.cloud.ZkController=DEBUG") public class TestCloudSearcherWarming extends SolrCloudTestCase { - public static final AtomicReference coreNodeNameRef = new AtomicReference<>(null), + public static final AtomicReference replicaNameRef = new AtomicReference<>(null), coreNameRef = new AtomicReference<>(null); private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); private static final AtomicInteger sleepTime = new AtomicInteger(-1); @@ -72,7 +72,7 @@ public void setUp() throws Exception { @Override public void tearDown() throws Exception { coreNameRef.set(null); - coreNodeNameRef.set(null); + replicaNameRef.set(null); sleepTime.set(-1); if (null != cluster) { @@ -112,8 +112,8 @@ public void testRepFactor1LeaderStartup() throws Exception { solrClient.commit(); AtomicInteger expectedDocs = new AtomicInteger(1); - AtomicReference failingCoreNodeName = new AtomicReference<>(); - CollectionStateWatcher stateWatcher = createActiveReplicaSearcherWatcher(expectedDocs, failingCoreNodeName); + AtomicReference failingReplicaName = new AtomicReference<>(); + CollectionStateWatcher stateWatcher = createActiveReplicaSearcherWatcher(expectedDocs, failingReplicaName); JettySolrRunner runner = cluster.getJettySolrRunner(0); runner.stop(); @@ -130,7 +130,7 @@ public void testRepFactor1LeaderStartup() throws Exception { cluster.waitForAllNodes(30); cluster.getSolrClient().getZkStateReader().registerCollectionStateWatcher(collectionName, stateWatcher); cluster.waitForActiveCollection(collectionName, 1, 1); - assertNull("No replica should have been active without registering a searcher, found: " + failingCoreNodeName.get(), failingCoreNodeName.get()); + assertNull("No replica should have been active without registering a searcher, found: " + failingReplicaName.get(), failingReplicaName.get()); cluster.getSolrClient().getZkStateReader().removeCollectionStateWatcher(collectionName, stateWatcher); } @@ -160,18 +160,18 @@ public void testPeersyncFailureReplicationSuccess() throws Exception { solrClient.commit(); AtomicInteger expectedDocs = new AtomicInteger(1); - AtomicReference failingCoreNodeName = new AtomicReference<>(); + AtomicReference failingReplicaName = new AtomicReference<>(); QueryResponse response = solrClient.query(new SolrQuery("*:*")); assertEquals(1, response.getResults().getNumFound()); // reset coreNameRef.set(null); - coreNodeNameRef.set(null); - failingCoreNodeName.set(null); + replicaNameRef.set(null); + failingReplicaName.set(null); sleepTime.set(5000); - CollectionStateWatcher stateWatcher = createActiveReplicaSearcherWatcher(expectedDocs, failingCoreNodeName); + CollectionStateWatcher stateWatcher = createActiveReplicaSearcherWatcher(expectedDocs, failingReplicaName); cluster.getSolrClient().getZkStateReader().registerCollectionStateWatcher(collectionName, stateWatcher); JettySolrRunner newNode = cluster.startJettySolrRunner(); @@ -181,7 +181,7 @@ public void testPeersyncFailureReplicationSuccess() throws Exception { .process(solrClient); waitForState("The collection should have 1 shard and 2 replica", collectionName, clusterShape(1, 2)); - assertNull("No replica should have been active without registering a searcher, found: " + failingCoreNodeName.get(), failingCoreNodeName.get()); + assertNull("No replica should have been active without registering a searcher, found: " + failingReplicaName.get(), failingReplicaName.get()); // stop the old node log.info("Stopping old node 1"); @@ -206,8 +206,8 @@ public void testPeersyncFailureReplicationSuccess() throws Exception { // reset coreNameRef.set(null); - coreNodeNameRef.set(null); - failingCoreNodeName.set(null); + replicaNameRef.set(null); + failingReplicaName.set(null); sleepTime.set(5000); // inject wrong signature output @@ -218,7 +218,7 @@ public void testPeersyncFailureReplicationSuccess() throws Exception { waitForState("", collectionName, clusterShape(1, 2)); // invoke statewatcher explicitly to avoid race condition where the assert happens before the state watcher is invoked by ZkStateReader cluster.getSolrClient().getZkStateReader().registerCollectionStateWatcher(collectionName, stateWatcher); - assertNull("No replica should have been active without registering a searcher, found: " + failingCoreNodeName.get(), failingCoreNodeName.get()); + assertNull("No replica should have been active without registering a searcher, found: " + failingReplicaName.get(), failingReplicaName.get()); oldNodeName.set(cluster.getJettySolrRunner(1).getNodeName()); assertSame(oldNode, cluster.stopJettySolrRunner(1)); // old node is now at 1 @@ -228,8 +228,8 @@ public void testPeersyncFailureReplicationSuccess() throws Exception { // reset coreNameRef.set(null); - coreNodeNameRef.set(null); - failingCoreNodeName.set(null); + replicaNameRef.set(null); + failingReplicaName.set(null); sleepTime.set(14000); // has to be higher than the twice the recovery wait pause between attempts plus some margin // inject failure @@ -240,23 +240,23 @@ public void testPeersyncFailureReplicationSuccess() throws Exception { waitForState("", collectionName, clusterShape(1, 2)); // invoke statewatcher explicitly to avoid race condition where the assert happens before the state watcher is invoked by ZkStateReader cluster.getSolrClient().getZkStateReader().registerCollectionStateWatcher(collectionName, stateWatcher); - assertNull("No replica should have been active without registering a searcher, found: " + failingCoreNodeName.get(), failingCoreNodeName.get()); + assertNull("No replica should have been active without registering a searcher, found: " + failingReplicaName.get(), failingReplicaName.get()); cluster.getSolrClient().getZkStateReader().removeCollectionStateWatcher(collectionName, stateWatcher); } - private CollectionStateWatcher createActiveReplicaSearcherWatcher(AtomicInteger expectedDocs, AtomicReference failingCoreNodeName) { + private CollectionStateWatcher createActiveReplicaSearcherWatcher(AtomicInteger expectedDocs, AtomicReference failingReplicaName) { return new CollectionStateWatcher() { @Override public boolean onStateChanged(Set liveNodes, DocCollection collectionState) { try { - String coreNodeName = coreNodeNameRef.get(); + String replicaName = replicaNameRef.get(); String coreName = coreNameRef.get(); - if (coreNodeName == null || coreName == null) return false; - Replica replica = collectionState.getReplica(coreNodeName); + if (replicaName == null || coreName == null) return false; + Replica replica = collectionState.getReplica(replicaName); if (replica == null) return false; log.info("Collection state: {}", collectionState); if (replica.isActive(liveNodes)) { - log.info("Active replica: {}", coreNodeName); + log.info("Active replica: {}", replicaName); for (int i = 0; i < cluster.getJettySolrRunners().size(); i++) { JettySolrRunner jettySolrRunner = cluster.getJettySolrRunner(i); if (log.isInfoEnabled()) { @@ -277,7 +277,7 @@ public boolean onStateChanged(Set liveNodes, DocCollection collectionSta if (registeredSearcher != null) { log.error("registered searcher not null, maxdocs = {}", registeredSearcher.get().maxDoc()); if (registeredSearcher.get().maxDoc() != expectedDocs.get()) { - failingCoreNodeName.set(coreNodeName); + failingReplicaName.set(replicaName); registeredSearcher.decref(); return false; } else { @@ -295,7 +295,7 @@ public boolean onStateChanged(Set liveNodes, DocCollection collectionSta log.error("newest searcher was also null!"); } // no registered searcher but replica is active! - failingCoreNodeName.set(coreNodeName); + failingReplicaName.set(replicaName); } } } @@ -328,7 +328,7 @@ public void postSoftCommit() { @Override public void newSearcher(SolrIndexSearcher newSearcher, SolrIndexSearcher currentSearcher) { if (sleepTime.get() > 0) { - TestCloudSearcherWarming.coreNodeNameRef.set(newSearcher.getCore().getCoreDescriptor().getCloudDescriptor().getCoreNodeName()); + TestCloudSearcherWarming.replicaNameRef.set(newSearcher.getCore().getCoreDescriptor().getCloudDescriptor().getCoreNodeName()); TestCloudSearcherWarming.coreNameRef.set(newSearcher.getCore().getName()); if (log.isInfoEnabled()) { log.info("Sleeping for {} on newSearcher: {}, currentSearcher: {} belonging to (newest) core: {}, id: {}" diff --git a/solr/core/src/test/org/apache/solr/cloud/TestTlogReplica.java b/solr/core/src/test/org/apache/solr/cloud/TestTlogReplica.java index 8ffff31cc14f..5230c8bc1153 100644 --- a/solr/core/src/test/org/apache/solr/cloud/TestTlogReplica.java +++ b/solr/core/src/test/org/apache/solr/cloud/TestTlogReplica.java @@ -957,7 +957,7 @@ private List getSolrCore(boolean isLeader) { for (SolrCore solrCore : solrRunner.getCoreContainer().getCores()) { CloudDescriptor cloudDescriptor = solrCore.getCoreDescriptor().getCloudDescriptor(); Slice slice = docCollection.getSlice(cloudDescriptor.getShardId()); - Replica replica = docCollection.getReplica(cloudDescriptor.getCoreNodeName()); + Replica replica = docCollection.getReplica(cloudDescriptor.getReplicaName()); if (slice.getLeader().equals(replica) && isLeader) { rs.add(solrCore); } else if (!slice.getLeader().equals(replica) && !isLeader) { @@ -992,7 +992,7 @@ private List getSolrRunner(boolean isLeader) { for (SolrCore solrCore : solrRunner.getCoreContainer().getCores()) { CloudDescriptor cloudDescriptor = solrCore.getCoreDescriptor().getCloudDescriptor(); Slice slice = docCollection.getSlice(cloudDescriptor.getShardId()); - Replica replica = docCollection.getReplica(cloudDescriptor.getCoreNodeName()); + Replica replica = docCollection.getReplica(cloudDescriptor.getReplicaName()); if (slice.getLeader() == replica && isLeader) { rs.add(solrRunner); } else if (slice.getLeader() != replica && !isLeader) { diff --git a/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java b/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java index 8018e782f60f..18be7150748a 100644 --- a/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java @@ -247,7 +247,7 @@ public void testPublishAndWaitForDownStates() throws Exception { /* This test asserts that if zkController.publishAndWaitForDownStates uses only core name to check if all local - cores are down then the method will return immediately but if it uses coreNodeName (as it does after SOLR-6665 then + cores are down then the method will return immediately but if it uses replicaName (as it does after SOLR-6665 then the method will timeout). We setup the cluster state in such a way that two replicas with same core name exist on non-existent nodes and core container also has a dummy core that has the same core name. The publishAndWaitForDownStates before SOLR-6665 @@ -270,9 +270,9 @@ cores are down then the method will return immediately but if it uses coreNodeNa @Override public List getCoreDescriptors() { CoreDescriptor descriptor = new CoreDescriptor(collectionName, TEST_PATH(), Collections.emptyMap(), new Properties(), zkControllerRef.get()); - // non-existent coreNodeName, this will cause zkController.publishAndWaitForDownStates to wait indefinitely - // when using coreNodeName but usage of core name alone will return immediately - descriptor.getCloudDescriptor().setCoreNodeName("core_node0"); + // non-existent replicaName, this will cause zkController.publishAndWaitForDownStates to wait indefinitely + // when using replicaName but usage of core name alone will return immediately + descriptor.getCloudDescriptor().setReplicaName("core_node0"); return Collections.singletonList(descriptor); } }; diff --git a/solr/core/src/test/org/apache/solr/core/CoreSorterTest.java b/solr/core/src/test/org/apache/solr/core/CoreSorterTest.java index fd7b5c4f56e5..9bc5af45277e 100644 --- a/solr/core/src/test/org/apache/solr/core/CoreSorterTest.java +++ b/solr/core/src/test/org/apache/solr/core/CoreSorterTest.java @@ -34,6 +34,7 @@ import org.apache.solr.common.cloud.DocRouter; import org.apache.solr.common.cloud.Replica; import org.apache.solr.common.cloud.Slice; +import org.apache.solr.common.params.CommonParams; import org.apache.solr.core.CoreSorter.CountsForEachShard; import org.junit.Test; @@ -187,7 +188,7 @@ private CoreDescriptor newCoreDescriptor(Replica r) { Map props = map( CoreDescriptor.CORE_SHARD, r.getShard(), CoreDescriptor.CORE_COLLECTION, r.getCollection(), - CoreDescriptor.CORE_NODE_NAME, r.getNodeName() + CommonParams.REPLICA_NAME, r.getNodeName() ); return new CoreDescriptor(r.getCoreName(), TEST_PATH(), props , null, mock(ZkController.class)); } diff --git a/solr/core/src/test/org/apache/solr/handler/admin/HealthCheckHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/admin/HealthCheckHandlerTest.java index 25b66939f2f9..2bcb214a8261 100644 --- a/solr/core/src/test/org/apache/solr/handler/admin/HealthCheckHandlerTest.java +++ b/solr/core/src/test/org/apache/solr/handler/admin/HealthCheckHandlerTest.java @@ -229,7 +229,7 @@ private CloudDescriptor mockCD(String collection, String name, String shardId, b Properties props = new Properties(); props.put(CoreDescriptor.CORE_SHARD, shardId); props.put(CoreDescriptor.CORE_COLLECTION, collection); - props.put(CoreDescriptor.CORE_NODE_NAME, name); + props.put(CommonParams.REPLICA_NAME, name); CloudDescriptor cd = new CloudDescriptor(null, name, props); cd.setHasRegistered(registered); cd.setLastPublished(state); diff --git a/solr/core/src/test/org/apache/solr/metrics/reporters/solr/SolrShardReporterTest.java b/solr/core/src/test/org/apache/solr/metrics/reporters/solr/SolrShardReporterTest.java index 3d8669acf0e3..60d765073b3d 100644 --- a/solr/core/src/test/org/apache/solr/metrics/reporters/solr/SolrShardReporterTest.java +++ b/solr/core/src/test/org/apache/solr/metrics/reporters/solr/SolrShardReporterTest.java @@ -85,7 +85,7 @@ public void test() throws Exception { DocCollection docCollection = state.getCollection(cloudDesc.getCollectionName()); String replicaName = Utils.parseMetricsReplicaName(cloudDesc.getCollectionName(), coreName); if (replicaName == null) { - replicaName = cloudDesc.getCoreNodeName(); + replicaName = cloudDesc.getReplicaName(); } String registryName = SolrCoreMetricManager.createRegistryName(true, cloudDesc.getCollectionName(), cloudDesc.getShardId(), replicaName, null); diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/ShardTerms.java b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/ShardTerms.java index cd6ead0be2e2..adb08224168f 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/ShardTerms.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/ShardTerms.java @@ -58,31 +58,31 @@ public ShardTerms(Map values, int version) { } /** - * Can {@code coreNodeName} become leader? - * @param coreNodeName of the replica - * @return true if {@code coreNodeName} can become leader, false if otherwise + * Can {@code replicaName} become leader? + * @param replicaName of the replica + * @return true if {@code replicaName} can become leader, false if otherwise */ - public boolean canBecomeLeader(String coreNodeName) { - return haveHighestTermValue(coreNodeName) && !values.containsKey(recoveringTerm(coreNodeName)); + public boolean canBecomeLeader(String replicaName) { + return haveHighestTermValue(replicaName) && !values.containsKey(recoveringTerm(replicaName)); } /** - * Is {@code coreNodeName}'s term highest? - * @param coreNodeName of the replica - * @return true if term of {@code coreNodeName} is highest + * Is {@code replicaName}'s term highest? + * @param replicaName of the replica + * @return true if term of {@code replicaName} is highest */ - public boolean haveHighestTermValue(String coreNodeName) { + public boolean haveHighestTermValue(String replicaName) { if (values.isEmpty()) return true; - return values.getOrDefault(coreNodeName, 0L) == maxTerm; + return values.getOrDefault(replicaName, 0L) == maxTerm; } - public Long getTerm(String coreNodeName) { - return values.get(coreNodeName); + public Long getTerm(String replicaName) { + return values.get(replicaName); } /** * Return a new {@link ShardTerms} in which term of {@code leader} is higher than {@code replicasNeedingRecovery} - * @param leader coreNodeName of leader + * @param leader replicaName of leader * @param replicasNeedingRecovery set of replicas in which their terms should be lower than leader's term * @return null if term of {@code leader} is already higher than {@code replicasNeedingRecovery} */ @@ -137,61 +137,61 @@ public ShardTerms ensureHighestTermsAreNotZero() { } /** - * Return a new {@link ShardTerms} in which terms for the {@code coreNodeName} are removed - * @param coreNodeName of the replica - * @return null if term of {@code coreNodeName} is already not exist + * Return a new {@link ShardTerms} in which terms for the {@code replicaName} are removed + * @param replicaName of the replica + * @return null if term of {@code replicaName} is already not exist */ - public ShardTerms removeTerm(String coreNodeName) { - if (!values.containsKey(recoveringTerm(coreNodeName)) && !values.containsKey(coreNodeName)) { + public ShardTerms removeTerm(String replicaName) { + if (!values.containsKey(recoveringTerm(replicaName)) && !values.containsKey(replicaName)) { return null; } HashMap newValues = new HashMap<>(values); - newValues.remove(coreNodeName); - newValues.remove(recoveringTerm(coreNodeName)); + newValues.remove(replicaName); + newValues.remove(recoveringTerm(replicaName)); return new ShardTerms(newValues, version); } /** - * Return a new {@link ShardTerms} in which the associate term of {@code coreNodeName} is not null - * @param coreNodeName of the replica - * @return null if term of {@code coreNodeName} is already exist + * Return a new {@link ShardTerms} in which the associate term of {@code replicaName} is not null + * @param replicaName of the replica + * @return null if term of {@code replicaName} is already exist */ - public ShardTerms registerTerm(String coreNodeName) { - if (values.containsKey(coreNodeName)) return null; + public ShardTerms registerTerm(String replicaName) { + if (values.containsKey(replicaName)) return null; HashMap newValues = new HashMap<>(values); - newValues.put(coreNodeName, 0L); + newValues.put(replicaName, 0L); return new ShardTerms(newValues, version); } /** - * Return a new {@link ShardTerms} in which the associate term of {@code coreNodeName} is equal to zero, + * Return a new {@link ShardTerms} in which the associate term of {@code replicaName} is equal to zero, * creating it if it does not previously exist. - * @param coreNodeName of the replica - * @return null if the term of {@code coreNodeName} already exists and is zero + * @param replicaName of the replica + * @return null if the term of {@code replicaName} already exists and is zero */ - public ShardTerms setTermToZero(String coreNodeName) { - if (values.getOrDefault(coreNodeName, -1L) == 0) { + public ShardTerms setTermToZero(String replicaName) { + if (values.getOrDefault(replicaName, -1L) == 0) { return null; } HashMap newValues = new HashMap<>(values); - newValues.put(coreNodeName, 0L); + newValues.put(replicaName, 0L); return new ShardTerms(newValues, version); } /** - * Return a new {@link ShardTerms} in which the term of {@code coreNodeName} is max - * @param coreNodeName of the replica - * @return null if term of {@code coreNodeName} is already maximum + * Return a new {@link ShardTerms} in which the term of {@code replicaName} is max + * @param replicaName of the replica + * @return null if term of {@code replicaName} is already maximum */ - public ShardTerms setTermEqualsToLeader(String coreNodeName) { - if (values.get(coreNodeName) == maxTerm) return null; + public ShardTerms setTermEqualsToLeader(String replicaName) { + if (values.get(replicaName) == maxTerm) return null; HashMap newValues = new HashMap<>(values); - newValues.put(coreNodeName, maxTerm); - newValues.remove(recoveringTerm(coreNodeName)); + newValues.put(replicaName, maxTerm); + newValues.remove(recoveringTerm(replicaName)); return new ShardTerms(newValues, version); } @@ -200,41 +200,41 @@ public long getMaxTerm() { } /** - * Mark {@code coreNodeName} as recovering - * @param coreNodeName of the replica - * @return null if {@code coreNodeName} is already marked as doing recovering + * Mark {@code replicaName} as recovering + * @param replicaName of the replica + * @return null if {@code replicaName} is already marked as doing recovering */ - public ShardTerms startRecovering(String coreNodeName) { - if (values.get(coreNodeName) == maxTerm) + public ShardTerms startRecovering(String replicaName) { + if (values.get(replicaName) == maxTerm) return null; HashMap newValues = new HashMap<>(values); - if (!newValues.containsKey(recoveringTerm(coreNodeName))) { - long currentTerm = newValues.getOrDefault(coreNodeName, 0L); + if (!newValues.containsKey(recoveringTerm(replicaName))) { + long currentTerm = newValues.getOrDefault(replicaName, 0L); // by keeping old term, we will have more information in leader election - newValues.put(recoveringTerm(coreNodeName), currentTerm); + newValues.put(recoveringTerm(replicaName), currentTerm); } - newValues.put(coreNodeName, maxTerm); + newValues.put(replicaName, maxTerm); return new ShardTerms(newValues, version); } /** - * Mark {@code coreNodeName} as finished recovering - * @param coreNodeName of the replica - * @return null if term of {@code coreNodeName} is already finished doing recovering + * Mark {@code replicaName} as finished recovering + * @param replicaName of the replica + * @return null if term of {@code replicaName} is already finished doing recovering */ - public ShardTerms doneRecovering(String coreNodeName) { - if (!values.containsKey(recoveringTerm(coreNodeName))) { + public ShardTerms doneRecovering(String replicaName) { + if (!values.containsKey(recoveringTerm(replicaName))) { return null; } HashMap newValues = new HashMap<>(values); - newValues.remove(recoveringTerm(coreNodeName)); + newValues.remove(recoveringTerm(replicaName)); return new ShardTerms(newValues, version); } - public static String recoveringTerm(String coreNodeName) { - return coreNodeName + RECOVERING_TERM_SUFFIX; + public static String recoveringTerm(String replicaName) { + return replicaName + RECOVERING_TERM_SUFFIX; } @Override diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/request/CoreAdminRequest.java b/solr/solrj/src/java/org/apache/solr/client/solrj/request/CoreAdminRequest.java index 9e571b7bb07b..2a94be26e87e 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/request/CoreAdminRequest.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/request/CoreAdminRequest.java @@ -27,6 +27,7 @@ import org.apache.solr.client.solrj.util.SolrIdentifierValidator; import org.apache.solr.common.cloud.Replica; import org.apache.solr.common.cloud.ZkStateReader; +import org.apache.solr.common.params.CommonParams; import org.apache.solr.common.params.CoreAdminParams; import org.apache.solr.common.params.CoreAdminParams.CoreAdminAction; import org.apache.solr.common.params.ModifiableSolrParams; @@ -62,7 +63,7 @@ public static class Create extends CoreAdminRequest { private Integer numShards; private String shardId; private String roles; - private String coreNodeName; + private String replicaName; private Boolean loadOnStartup; private Boolean isTransient; private String collectionConfigName; @@ -83,7 +84,9 @@ public void setConfigSet(String configSet) { public void setNumShards(int numShards) {this.numShards = numShards;} public void setShardId(String shardId) {this.shardId = shardId;} public void setRoles(String roles) {this.roles = roles;} - public void setCoreNodeName(String coreNodeName) {this.coreNodeName = coreNodeName;} + public void setReplicaName(String replicaName) {this.replicaName = replicaName;} + @Deprecated + public void setCoreNodeName(String coreNodeName) {this.replicaName = coreNodeName;} public void setIsTransient(Boolean isTransient) { this.isTransient = isTransient; } public void setIsLoadOnStartup(Boolean loadOnStartup) { this.loadOnStartup = loadOnStartup;} public void setCollectionConfigName(String name) { this.collectionConfigName = name;} @@ -99,7 +102,9 @@ public String getConfigSet() { public String getCollection() { return collection; } public String getShardId() { return shardId; } public String getRoles() { return roles; } - public String getCoreNodeName() { return coreNodeName; } + @Deprecated + public String getCoreNodeName() { return replicaName; } + public String getReplicaName() { return replicaName; } public Boolean getIsLoadOnStartup() { return loadOnStartup; } public Boolean getIsTransient() { return isTransient; } public String getCollectionConfigName() { return collectionConfigName;} @@ -156,8 +161,8 @@ public SolrParams getParams() { if (roles != null) { params.set( CoreAdminParams.ROLES, roles); } - if (coreNodeName != null) { - params.set( CoreAdminParams.CORE_NODE_NAME, coreNodeName); + if (replicaName != null) { + params.set(CommonParams.REPLICA_NAME, replicaName); } if (isTransient != null) { @@ -196,11 +201,22 @@ public void setNodeName(String nodeName) { public String getNodeName() { return nodeName; } - + + @Deprecated public String getCoreNodeName() { return coreNodeName; } + @Deprecated + public String getReplicaName() { + return coreNodeName; + } + + public void setReplicaName(String replicaName) { + this.coreNodeName = replicaName; + } + + @Deprecated public void setCoreNodeName(String coreNodeName) { this.coreNodeName = coreNodeName; } diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterStateUtil.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterStateUtil.java index 9ce80906dfff..eec2529e2488 100644 --- a/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterStateUtil.java +++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterStateUtil.java @@ -105,14 +105,14 @@ public static boolean waitForAllActiveAndLiveReplicas(ZkStateReader zkStateReade } /** - * Wait to see an entry in the ClusterState with a specific coreNodeName and + * Wait to see an entry in the ClusterState with a specific replicaName and * baseUrl. * * @param zkStateReader * to use for ClusterState * @param collection * to look in - * @param coreNodeName + * @param replicaName * to wait for * @param baseUrl * to wait for @@ -121,14 +121,14 @@ public static boolean waitForAllActiveAndLiveReplicas(ZkStateReader zkStateReade * @return false if timed out */ public static boolean waitToSeeLiveReplica(ZkStateReader zkStateReader, - String collection, String coreNodeName, String baseUrl, + String collection, String replicaName, String baseUrl, int timeoutInMs) { long timeout = System.nanoTime() + TimeUnit.NANOSECONDS.convert(timeoutInMs, TimeUnit.MILLISECONDS); while (System.nanoTime() < timeout) { log.debug("waiting to see replica just created live collection={} replica={} baseUrl={}", - collection, coreNodeName, baseUrl); + collection, replicaName, baseUrl); ClusterState clusterState = zkStateReader.getClusterState(); if (clusterState != null) { DocCollection docCollection = clusterState.getCollection(collection); @@ -140,9 +140,9 @@ public static boolean waitToSeeLiveReplica(ZkStateReader zkStateReader, for (Replica replica : replicas) { // on a live node? boolean live = clusterState.liveNodesContain(replica.getNodeName()); - String rcoreNodeName = replica.getName(); + String rReplicaName = replica.getName(); String rbaseUrl = replica.getBaseUrl(); - if (live && coreNodeName.equals(rcoreNodeName) + if (live && replicaName.equals(rReplicaName) && baseUrl.equals(rbaseUrl)) { // found it return true; diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/DocCollection.java b/solr/solrj/src/java/org/apache/solr/common/cloud/DocCollection.java index c79168a306ec..318571cb9de5 100644 --- a/solr/solrj/src/java/org/apache/solr/common/cloud/DocCollection.java +++ b/solr/solrj/src/java/org/apache/solr/common/cloud/DocCollection.java @@ -316,12 +316,12 @@ public void write(JSONWriter jsonWriter) { jsonWriter.write(all); } - public Replica getReplica(String coreNodeName) { + public Replica getReplica(String replicaName) { if (perReplicaState) { - return replicaMap.get(coreNodeName); + return replicaMap.get(replicaName); } for (Slice slice : slices.values()) { - Replica replica = slice.getReplica(coreNodeName); + Replica replica = slice.getReplica(replicaName); if (replica != null) return replica; } return null; diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/Replica.java b/solr/solrj/src/java/org/apache/solr/common/cloud/Replica.java index 2c1c6dfe8c22..0c1d98006a35 100644 --- a/solr/solrj/src/java/org/apache/solr/common/cloud/Replica.java +++ b/solr/solrj/src/java/org/apache/solr/common/cloud/Replica.java @@ -258,7 +258,7 @@ public int hashCode() { return Objects.hash(name); } - /** Also known as coreNodeName. */ + /** Also known as replicaName. */ public String getName() { return name; } diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/Slice.java b/solr/solrj/src/java/org/apache/solr/common/cloud/Slice.java index 23796fbf3326..1976db083eee 100644 --- a/solr/solrj/src/java/org/apache/solr/common/cloud/Slice.java +++ b/solr/solrj/src/java/org/apache/solr/common/cloud/Slice.java @@ -270,7 +270,7 @@ public List getReplicas(EnumSet s) { } /** - * Get the map of coreNodeName to replicas for this slice. + * Get the map of replicaName to replicas for this slice. */ public Map getReplicasMap() { return replicas; diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java index 16b9d72327d9..c222877b619b 100644 --- a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java +++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java @@ -895,24 +895,24 @@ public static String getShardLeadersElectPath(String collection, String shardId) } - public List getReplicaProps(String collection, String shardId, String thisCoreNodeName) { - return getReplicaProps(collection, shardId, thisCoreNodeName, null); + public List getReplicaProps(String collection, String shardId, String thisReplicaName) { + return getReplicaProps(collection, shardId, thisReplicaName, null); } - public List getReplicaProps(String collection, String shardId, String thisCoreNodeName, + public List getReplicaProps(String collection, String shardId, String thisReplicaName, Replica.State mustMatchStateFilter) { - return getReplicaProps(collection, shardId, thisCoreNodeName, mustMatchStateFilter, null); + return getReplicaProps(collection, shardId, thisReplicaName, mustMatchStateFilter, null); } - public List getReplicaProps(String collection, String shardId, String thisCoreNodeName, + public List getReplicaProps(String collection, String shardId, String thisReplicaName, Replica.State mustMatchStateFilter, Replica.State mustNotMatchStateFilter) { //TODO: We don't need all these getReplicaProps method overloading. Also, it's odd that the default is to return replicas of type TLOG and NRT only - return getReplicaProps(collection, shardId, thisCoreNodeName, mustMatchStateFilter, null, EnumSet.of(Replica.Type.TLOG, Replica.Type.NRT)); + return getReplicaProps(collection, shardId, thisReplicaName, mustMatchStateFilter, null, EnumSet.of(Replica.Type.TLOG, Replica.Type.NRT)); } - public List getReplicaProps(String collection, String shardId, String thisCoreNodeName, + public List getReplicaProps(String collection, String shardId, String thisReplicaName, Replica.State mustMatchStateFilter, Replica.State mustNotMatchStateFilter, final EnumSet acceptReplicaType) { - assert thisCoreNodeName != null; + assert thisReplicaName != null; ClusterState clusterState = this.clusterState; if (clusterState == null) { return null; @@ -934,9 +934,9 @@ public List getReplicaProps(String collection, String shardId, for (Entry entry : shardMap.entrySet().stream().filter((e) -> acceptReplicaType.contains(e.getValue().getType())).collect(Collectors.toList())) { ZkCoreNodeProps nodeProps = new ZkCoreNodeProps(entry.getValue()); - String coreNodeName = entry.getValue().getName(); + String replicaName = entry.getValue().getName(); - if (clusterState.liveNodesContain(nodeProps.getNodeName()) && !coreNodeName.equals(thisCoreNodeName)) { + if (clusterState.liveNodesContain(nodeProps.getNodeName()) && !replicaName.equals(thisReplicaName)) { if (mustMatchStateFilter == null || mustMatchStateFilter == Replica.State.getState(nodeProps.getState())) { if (mustNotMatchStateFilter == null || mustNotMatchStateFilter != Replica.State.getState(nodeProps.getState())) { nodes.add(nodeProps); diff --git a/solr/solrj/src/java/org/apache/solr/common/params/CommonParams.java b/solr/solrj/src/java/org/apache/solr/common/params/CommonParams.java index 144622cb9019..a9b14a0ca6c1 100644 --- a/solr/solrj/src/java/org/apache/solr/common/params/CommonParams.java +++ b/solr/solrj/src/java/org/apache/solr/common/params/CommonParams.java @@ -305,5 +305,7 @@ public static EchoParamStyle get( String v ) { String CHILDDOC = "_childDocuments_"; + String REPLICA_NAME = "coreNodeName"; + } diff --git a/solr/solrj/src/java/org/apache/solr/common/params/CoreAdminParams.java b/solr/solrj/src/java/org/apache/solr/common/params/CoreAdminParams.java index 2548e621315b..d698b3938b4c 100644 --- a/solr/solrj/src/java/org/apache/solr/common/params/CoreAdminParams.java +++ b/solr/solrj/src/java/org/apache/solr/common/params/CoreAdminParams.java @@ -91,7 +91,8 @@ public abstract class CoreAdminParams public static final String REQUESTID = "requestid"; - public static final String CORE_NODE_NAME = "coreNodeName"; + @Deprecated + public static final String CORE_NODE_NAME = CommonParams.REPLICA_NAME; /** Prefix for core property name=value pair **/ public final static String PROPERTY_PREFIX = "property."; diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java index df38ff66eceb..d1e8dc16ed46 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java @@ -887,7 +887,7 @@ public void testRetryUpdatesWhenClusterStateIsStale() throws Exception { .process(cluster.getSolrClient()).getStatus()); cluster.waitForActiveCollection(COL, 1, 1); - // determine the coreNodeName of only current replica + // determine the replicaName of only current replica Collection slices = cluster.getSolrClient().getZkStateReader().getClusterState().getCollection(COL).getSlices(); assertEquals(1, slices.size()); // sanity check Slice slice = slices.iterator().next(); diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java index e156607561e2..1d2a59d5e497 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java @@ -880,7 +880,7 @@ public void testRetryUpdatesWhenClusterStateIsStale() throws Exception { .process(cluster.getSolrClient()).getStatus()); cluster.waitForActiveCollection(COL, 1, 1); - // determine the coreNodeName of only current replica + // determine the replicaName of only current replica Collection slices = cluster.getSolrClient().getZkStateReader().getClusterState().getCollection(COL).getSlices(); assertEquals(1, slices.size()); // sanity check Slice slice = slices.iterator().next(); diff --git a/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java b/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java index ee4d89b3e190..44cd3ae41079 100644 --- a/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java +++ b/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java @@ -59,6 +59,7 @@ import org.apache.solr.common.SolrDocument; import org.apache.solr.common.SolrDocumentList; import org.apache.solr.common.SolrInputDocument; +import org.apache.solr.common.params.CommonParams; import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.SolrParams; import org.apache.solr.common.util.ExecutorUtil; @@ -460,7 +461,7 @@ public JettySolrRunner createJetty(File solrHome, String dataDir, String shardLi return createJetty(solrHome, dataDir, shardList, solrConfigOverride, schemaOverride, useExplicitNodeNames); } - public JettySolrRunner createJetty(File solrHome, String dataDir, String shardList, String solrConfigOverride, String schemaOverride, boolean explicitCoreNodeName) throws Exception { + public JettySolrRunner createJetty(File solrHome, String dataDir, String shardList, String solrConfigOverride, String schemaOverride, boolean explicitReplicaName) throws Exception { Properties props = new Properties(); if (solrConfigOverride != null) @@ -472,8 +473,8 @@ public JettySolrRunner createJetty(File solrHome, String dataDir, String shardLi if (dataDir != null) { props.setProperty("solr.data.dir", dataDir); } - if (explicitCoreNodeName) { - props.setProperty("coreNodeName", Integer.toString(nodeCnt.incrementAndGet())); + if (explicitReplicaName) { + props.setProperty(CommonParams.REPLICA_NAME, Integer.toString(nodeCnt.incrementAndGet())); } props.setProperty("coreRootDirectory", solrHome.toPath().resolve("cores").toString()); diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java index 1a5bf9836d1b..fda85870dea3 100644 --- a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java +++ b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java @@ -254,13 +254,13 @@ static void waitForNewLeader(CloudSolrClient cloudClient, String shardName, Repl }); } - public static void verifyReplicaStatus(ZkStateReader reader, String collection, String shard, String coreNodeName, + public static void verifyReplicaStatus(ZkStateReader reader, String collection, String shard, String replicaName, Replica.State expectedState) throws InterruptedException, TimeoutException { - log.info("verifyReplicaStatus ({}) shard={} coreNodeName={}", collection, shard, coreNodeName); + log.info("verifyReplicaStatus ({}) shard={} replicaName={}", collection, shard, replicaName); reader.waitForState(collection, 15000, TimeUnit.MILLISECONDS, (collectionState) -> collectionState != null && collectionState.getSlice(shard) != null - && collectionState.getSlice(shard).getReplicasMap().get(coreNodeName) != null - && collectionState.getSlice(shard).getReplicasMap().get(coreNodeName).getState() == expectedState); + && collectionState.getSlice(shard).getReplicasMap().get(replicaName) != null + && collectionState.getSlice(shard).getReplicasMap().get(replicaName).getState() == expectedState); } protected static void assertAllActive(String collection, ZkStateReader zkStateReader) diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java index 662e73ccdd90..8f2523328d37 100644 --- a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java +++ b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java @@ -159,7 +159,7 @@ public void beforeTest() { public static class CloudJettyRunner { public JettySolrRunner jetty; public String nodeName; - public String coreNodeName; + public String replicaName; public String url; public CloudSolrServerClient client; public ZkNodeProps info; @@ -877,7 +877,7 @@ protected void updateMappingsFromZk(List jettys, List