You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by is...@apache.org on 2020/12/16 13:05:12 UTC
[lucene-solr] branch jira/solr-15052-8x updated: SOLR-15052:
Formatting fixes
This is an automated email from the ASF dual-hosted git repository.
ishan pushed a commit to branch jira/solr-15052-8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/jira/solr-15052-8x by this push:
new bf9aee0 SOLR-15052: Formatting fixes
bf9aee0 is described below
commit bf9aee07386f2617a793ce0853e8709d547d31ab
Author: Ishan Chattopadhyaya <is...@apache.org>
AuthorDate: Wed Dec 16 18:34:13 2020 +0530
SOLR-15052: Formatting fixes
---
.../org/apache/solr/cloud/overseer/ReplicaMutator.java | 2 +-
.../java/org/apache/solr/cloud/overseer/SliceMutator.java | 6 +++---
.../java/org/apache/solr/cloud/overseer/ZkStateWriter.java | 12 ++++++------
.../org/apache/solr/handler/admin/CollectionsHandler.java | 2 +-
.../apache/solr/cloud/api/collections/ShardSplitTest.java | 4 ++--
.../solr/client/solrj/request/CollectionAdminRequest.java | 2 +-
.../java/org/apache/solr/common/cloud/ClusterState.java | 6 +++---
.../java/org/apache/solr/common/cloud/DocCollection.java | 14 +++++++-------
.../org/apache/solr/common/cloud/PerReplicaStates.java | 14 +++++++-------
.../src/java/org/apache/solr/common/cloud/Replica.java | 4 ++--
10 files changed, 33 insertions(+), 33 deletions(-)
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 8df5bd2..b6fc8b0 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
@@ -363,7 +363,7 @@ public class ReplicaMutator {
DocCollection newCollection = CollectionMutator.updateSlice(collectionName, collection, slice);
log.debug("Collection is now: {}", newCollection);
- if(collection != null && collection.isPerReplicaState()) {
+ if (collection != null && collection.isPerReplicaState()) {
PerReplicaStates prs = PerReplicaStates.fetch(collection.getZNode(), zkClient, collection.getPerReplicaStates());
return new ZkWriteCommand(collectionName, newCollection, PerReplicaStates.WriteOps.flipState(replica.getName(), replica.getState(), prs), persistCollectionState);
} else{
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 774aa5b..32465fd 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
@@ -95,7 +95,7 @@ public class SliceMutator {
ZkStateReader.NODE_NAME_PROP, message.getStr(ZkStateReader.NODE_NAME_PROP),
ZkStateReader.REPLICA_TYPE, message.get(ZkStateReader.REPLICA_TYPE)), coll, slice);
- if(collection.isPerReplicaState()) {
+ if (collection.isPerReplicaState()) {
PerReplicaStates prs = PerReplicaStates.fetch(collection.getZNode(), zkClient, collection.getPerReplicaStates());
return new ZkWriteCommand(coll, updateReplica(collection, sl, replica.getName(), replica),
PerReplicaStates.WriteOps.addReplica(replica.getName(), replica.getState(), replica.isLeader(), prs), true);
@@ -129,7 +129,7 @@ public class SliceMutator {
}
- if(coll.isPerReplicaState()) {
+ if (coll.isPerReplicaState()) {
return new ZkWriteCommand(collection, coll.copyWithSlices(newSlices), PerReplicaStates.WriteOps.deleteReplica(cnn, coll.getPerReplicaStates()) , true);
} else {
return new ZkWriteCommand(collection, coll.copyWithSlices(newSlices));
@@ -169,7 +169,7 @@ public class SliceMutator {
Map<String, Object> newSliceProps = slice.shallowCopy();
newSliceProps.put(Slice.REPLICAS, newReplicas);
slice = new Slice(slice.getName(), newReplicas, slice.getProperties(), collectionName);
- if(coll.isPerReplicaState()) {
+ if (coll.isPerReplicaState()) {
PerReplicaStates prs = PerReplicaStates.fetch(coll.getZNode(), zkClient, coll.getPerReplicaStates());
return new ZkWriteCommand(collectionName, CollectionMutator.updateSlice(collectionName, coll, slice),
PerReplicaStates.WriteOps.flipLeader(
diff --git a/solr/core/src/java/org/apache/solr/cloud/overseer/ZkStateWriter.java b/solr/core/src/java/org/apache/solr/cloud/overseer/ZkStateWriter.java
index 5979ddb..b7a4934 100644
--- a/solr/core/src/java/org/apache/solr/cloud/overseer/ZkStateWriter.java
+++ b/solr/core/src/java/org/apache/solr/cloud/overseer/ZkStateWriter.java
@@ -115,7 +115,7 @@ public class ZkStateWriter {
if (isNoOps(cmds)) return prevState;
boolean forceFlush = false;
- if(cmds.size() == 1) {
+ if (cmds.size() == 1) {
//most messages result in only one command. let's deal with it right away
ZkWriteCommand cmd = cmds.get(0);
if (cmd.collection != null && cmd.collection.isPerReplicaState()) {
@@ -131,13 +131,13 @@ public class ZkStateWriter {
try {
return writeUpdate(cmd);
} finally {
- if(callback !=null) callback.onWrite();
+ if (callback !=null) callback.onWrite();
}
}
} else {
//there are more than one commands created as a result of this message
for (ZkWriteCommand cmd : cmds) {
- if(cmd.collection != null && cmd.collection.isPerReplicaState()) {
+ if (cmd.collection != null && cmd.collection.isPerReplicaState()) {
// we don't try to optimize for this case. let's flush out all after this
forceFlush = true;
break;
@@ -233,7 +233,7 @@ public class ZkStateWriter {
ZkWriteCommand cmd = entry.getValue();
DocCollection c = cmd.collection;
- if(cmd.ops != null && cmd.ops.isPreOp()) {
+ if (cmd.ops != null && cmd.ops.isPreOp()) {
PerReplicaStates.persist(cmd.ops, path, reader.getZkClient());
//nocommit
/*PerReplicaStates prs = PerReplicaStates.fetch(ZkStateReader.getCollectionPath(cmd.collection.getName()), reader.getZkClient());
@@ -244,7 +244,7 @@ public class ZkStateWriter {
clusterState = clusterState.copyWith(name,
cmd.collection.copyWith(PerReplicaStates.fetch(cmd.collection.getZNode(), reader.getZkClient(), null)));
}
- if(!cmd.persistCollState) continue;
+ if (!cmd.persistCollState) continue;
if (c == null) {
// let's clean up the state.json of this collection only, the rest should be clean by delete collection cmd
log.debug("going to delete state.json {}", path);
@@ -267,7 +267,7 @@ public class ZkStateWriter {
} else if (c.getStateFormat() == 1) {
isClusterStateModified = true;
}
- if(cmd.ops != null && !cmd.ops.isPreOp()) {
+ if (cmd.ops != null && !cmd.ops.isPreOp()) {
PerReplicaStates.persist(cmd.ops, path, reader.getZkClient());
DocCollection currentCollState = clusterState.getCollection(cmd.name);
if ( currentCollState != null) {
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
index 917d386..91a70cb 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
@@ -1455,7 +1455,7 @@ public class CollectionsHandler extends RequestHandlerBase implements Permission
}
if (!n.contains(replica.getNodeName())
|| !state.equals(Replica.State.ACTIVE.toString())) {
- if(log.isDebugEnabled()) {
+ if (log.isDebugEnabled()) {
log.debug("inactive replica {} , state {}", replica.getName(), replica.getReplicaState());
}
replicaNotAliveCnt++;
diff --git a/solr/core/src/test/org/apache/solr/cloud/api/collections/ShardSplitTest.java b/solr/core/src/test/org/apache/solr/cloud/api/collections/ShardSplitTest.java
index 87e2ef4..60c704c 100644
--- a/solr/core/src/test/org/apache/solr/cloud/api/collections/ShardSplitTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/api/collections/ShardSplitTest.java
@@ -823,7 +823,7 @@ public class ShardSplitTest extends BasicDistributedZkTest {
MAX_SHARDS_PER_NODE, maxShardsPerNode,
OverseerCollectionMessageHandler.NUM_SLICES, numShards,
"router.field", shard_fld);
- if(SolrCloudTestCase.USE_PER_REPLICA_STATE) {
+ if (SolrCloudTestCase.USE_PER_REPLICA_STATE) {
props.put(DocCollection.PER_REPLICA_STATE, Boolean.TRUE);
}
@@ -887,7 +887,7 @@ public class ShardSplitTest extends BasicDistributedZkTest {
REPLICATION_FACTOR, replicationFactor,
MAX_SHARDS_PER_NODE, maxShardsPerNode,
OverseerCollectionMessageHandler.NUM_SLICES, numShards);
- if(SolrCloudTestCase.USE_PER_REPLICA_STATE) {
+ if (SolrCloudTestCase.USE_PER_REPLICA_STATE) {
props.put(DocCollection.PER_REPLICA_STATE, Boolean.TRUE);
}
createCollection(collectionInfos, collectionName,props,client);
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java b/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
index 21ef417..4143563 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
@@ -593,7 +593,7 @@ public abstract class CollectionAdminRequest<T extends CollectionAdminResponse>
if (tlogReplicas != null) {
params.set(ZkStateReader.TLOG_REPLICAS, tlogReplicas);
}
- if(Boolean.TRUE.equals(perReplicaState)) {
+ if (Boolean.TRUE.equals(perReplicaState)) {
params.set(PER_REPLICA_STATE, perReplicaState);
}
if (rule != null) params.set(DocCollection.RULE, rule);
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java
index 65bcc97..5a6a309 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java
@@ -263,8 +263,8 @@ public class ClusterState implements JSONWriter.Writable {
Map<String,Object> props;
Map<String,Slice> slices;
- if("true".equals(String.valueOf(objs.get(DocCollection.PER_REPLICA_STATE)))) {
- log.info("a collection {} has per-replica state" , name);
+ if ("true".equals(String.valueOf(objs.get(DocCollection.PER_REPLICA_STATE)))) {
+ log.info("a collection {} has per-replica state", name); // nocommit should be a debug
//this collection has replica states stored outside
ReplicaStatesProvider rsp = REPLICASTATES_PROVIDER.get();
if (rsp instanceof StatesProvider) ((StatesProvider) rsp).isPerReplicaState = true;
@@ -485,7 +485,7 @@ public class ClusterState implements JSONWriter.Writable {
@Override
public PerReplicaStates getStates() {
- if(perReplicaStates == null) perReplicaStates = replicaStatesSupplier.get();
+ if (perReplicaStates == null) perReplicaStates = replicaStatesSupplier.get();
return perReplicaStates;
}
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 f52b1dd..852a444 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
@@ -134,7 +134,7 @@ public class DocCollection extends ZkNodeProps implements Iterable<Slice> {
}
for (Replica replica : slice.getValue()) {
addNodeNameReplica(replica);
- if(perReplicaState) {
+ if (perReplicaState) {
replicaMap.put(replica.getName(), replica);
}
}
@@ -152,13 +152,13 @@ public class DocCollection extends ZkNodeProps implements Iterable<Slice> {
log.debug("collection :{} going to be updated : per-replica state :{} -> {}",
name,
getChildNodesVersion(), newPerReplicaStates.cversion);
- if(getChildNodesVersion() == newPerReplicaStates.cversion) return this;
+ if (getChildNodesVersion() == newPerReplicaStates.cversion) return this;
Set<String> modifiedReplicas = PerReplicaStates.findModifiedReplicas(newPerReplicaStates, this.perReplicaStates);
- if(modifiedReplicas.isEmpty()) return this; //nothing is modified
+ if (modifiedReplicas.isEmpty()) return this; //nothing is modified
Map<String, Slice> modifiedShards = new HashMap<>(getSlicesMap());
for (String s : modifiedReplicas) {
Replica replica = getReplica(s);
- if(replica != null) {
+ if (replica != null) {
Replica newReplica = replica.copyWith(newPerReplicaStates.get(s));
Slice shard = modifiedShards.get(replica.slice);
modifiedShards.put(replica.slice, shard.copyWith(newReplica));
@@ -302,8 +302,8 @@ public class DocCollection extends ZkNodeProps implements Iterable<Slice> {
}
public boolean isModified(int dataVersion, int childVersion) {
- if(dataVersion > znodeVersion) return true;
- if(childVersion > getChildNodesVersion()) return true;
+ if (dataVersion > znodeVersion) return true;
+ if (childVersion > getChildNodesVersion()) return true;
return false;
}
@@ -360,7 +360,7 @@ public class DocCollection extends ZkNodeProps implements Iterable<Slice> {
}
public Replica getReplica(String coreNodeName) {
- if(perReplicaState) {
+ if (perReplicaState) {
return replicaMap.get(coreNodeName);
}
for (Slice slice : slices.values()) {
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/PerReplicaStates.java b/solr/solrj/src/java/org/apache/solr/common/cloud/PerReplicaStates.java
index 9c3e70a..f69217b 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/PerReplicaStates.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/PerReplicaStates.java
@@ -88,15 +88,15 @@ public class PerReplicaStates implements ReflectMapWriter {
*/
public static Set<String> findModifiedReplicas(PerReplicaStates old, PerReplicaStates fresh) {
Set<String> result = new HashSet<>();
- if(fresh == null) {
+ if (fresh == null) {
old.states.forEachKey(result::add);
return result;
}
old.states.forEachEntry((s, state) -> {
- //the state is modified or missing
- if(!Objects.equals(fresh.get(s) , state)) result.add(s);
+ // the state is modified or missing
+ if (!Objects.equals(fresh.get(s) , state)) result.add(s);
});
- fresh.states.forEachEntry((s, state) -> { if(old.get(s) == null ) result.add(s);
+ fresh.states.forEachEntry((s, state) -> { if (old.get(s) == null ) result.add(s);
});
return result;
}
@@ -410,7 +410,7 @@ public class PerReplicaStates implements ReflectMapWriter {
@Override
protected List<Op> refresh(PerReplicaStates rs) {
List<Op> ops = new ArrayList<>(4);
- if(next != null) {
+ if (next != null) {
State st = rs.get(next);
if (st != null) {
if (!st.isLeader) {
@@ -430,7 +430,7 @@ public class PerReplicaStates implements ReflectMapWriter {
State st = rs.get(r);
if (st == null) continue;//unlikely
if (!Objects.equals(r, next)) {
- if(st.isLeader) {
+ if (st.isLeader) {
//some other replica is the leader now. unset
ops.add(new Op(Op.Type.ADD, new State(st.replica, st.state, Boolean.FALSE, st.version + 1)));
ops.add(new Op(Op.Type.DELETE, st));
@@ -576,7 +576,7 @@ public class PerReplicaStates implements ReflectMapWriter {
int count = 0;
@Override
public void accept(String s, State state) {
- if(count++ > 0) sb.append(", ");
+ if (count++ > 0) sb.append(", ");
sb.append(state.asString);
for (State d : state.getDuplicates()) sb.append(d.asString);
}
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 15ecb12..353edbb 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
@@ -146,7 +146,7 @@ public class Replica extends ZkNodeProps {
ClusterState.getReplicaStatesProvider().get().ifPresent(it -> {
log.debug("A replica {} state fetched from per-replica state", name);
replicaState = it.getStates().get(name);
- if(replicaState!= null) {
+ if (replicaState!= null) {
propMap.put(ZkStateReader.STATE_PROP, replicaState.state.toString().toLowerCase(Locale.ROOT));
if (replicaState.isLeader) propMap.put(Slice.LEADER, "true");
}
@@ -265,7 +265,7 @@ public class Replica extends ZkNodeProps {
}
public boolean isLeader() {
- if(replicaState != null) return replicaState.isLeader;
+ if (replicaState != null) return replicaState.isLeader;
return getStr(Slice.LEADER) != null;
}
@Override