Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions changelog/unreleased/SOLR-16116-remove-retryOnConnLoss.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
title: Remove parameter retryOnConnLoss everywhere from the codebase. This parameter
was already fully ignored since the move to Curator.
type: removed
authors:
- name: Pierre Salagnac
links:
- name: SOLR-16116
url: https://issues.apache.org/jira/browse/SOLR-16116
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public Map<String, Object> plugins() throws IOException {
try {
Map<String, Object> clusterPropsJson =
(Map<String, Object>)
Utils.fromJSON(zkClient.getData(ZkStateReader.CLUSTER_PROPS, null, new Stat(), true));
Utils.fromJSON(zkClient.getData(ZkStateReader.CLUSTER_PROPS, null, new Stat()));
return Map.copyOf(
(Map<String, Object>)
clusterPropsJson.computeIfAbsent(
Expand Down
8 changes: 4 additions & 4 deletions solr/core/src/java/org/apache/solr/cli/AuthTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ private void handleBasicAuth(CommandLine cli) throws Exception {
if (!updateIncludeFileOnly) {
echoIfVerbose("Uploading following security.json: " + securityJson);
try (SolrZkClient zkClient = CLIUtils.getSolrZkClient(cli, zkHost)) {
zkClient.setData("/security.json", securityJson.getBytes(StandardCharsets.UTF_8), true);
zkClient.setData("/security.json", securityJson.getBytes(StandardCharsets.UTF_8));
}
}

Expand Down Expand Up @@ -309,8 +309,8 @@ private void handleBasicAuth(CommandLine cli) throws Exception {

private void checkSecurityJsonExists(SolrZkClient zkClient)
throws KeeperException, InterruptedException {
if (zkClient.exists("/security.json", true)) {
byte[] oldSecurityBytes = zkClient.getData("/security.json", null, null, true);
if (zkClient.exists("/security.json")) {
byte[] oldSecurityBytes = zkClient.getData("/security.json", null, null);
if (!"{}".equals(new String(oldSecurityBytes, StandardCharsets.UTF_8).trim())) {
CLIO.out(
"Security is already enabled. You can disable it with 'bin/solr auth disable'. Existing security.json: \n"
Expand All @@ -332,7 +332,7 @@ private void clearSecurityJson(CommandLine cli, boolean updateIncludeFileOnly) t
echoIfVerbose("Uploading following security.json: {}");

try (SolrZkClient zkClient = CLIUtils.getSolrZkClient(cli, zkHost)) {
zkClient.setData("/security.json", "{}".getBytes(StandardCharsets.UTF_8), true);
zkClient.setData("/security.json", "{}".getBytes(StandardCharsets.UTF_8));
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions solr/core/src/java/org/apache/solr/cli/CreateTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,7 @@ protected void createCollection(CloudSolrClient cloudSolrClient, CommandLine cli
boolean configExistsInZk =
confName != null
&& !confName.trim().isEmpty()
&& ZkStateReader.from(cloudSolrClient)
.getZkClient()
.exists("/configs/" + confName, true);
&& ZkStateReader.from(cloudSolrClient).getZkClient().exists("/configs/" + confName);

if (configExistsInZk) {
echo("Re-using existing configuration directory " + confName);
Expand Down
2 changes: 1 addition & 1 deletion solr/core/src/java/org/apache/solr/cli/ZkMkrootTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void runImpl(CommandLine cli) throws Exception {
echoIfVerbose("\nConnecting to ZooKeeper at " + zkHost + " ...");

echo("Creating ZooKeeper path " + znode + " on ZooKeeper at " + zkHost);
zkClient.makePath(znode, failOnExists, true);
zkClient.makePath(znode, failOnExists);
} catch (Exception e) {
log.error("Could not complete mkroot operation for reason: ", e);
throw (e);
Expand Down
2 changes: 1 addition & 1 deletion solr/core/src/java/org/apache/solr/cli/ZkRmTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void runImpl(CommandLine cli) throws Exception {
}
echoIfVerbose("\nConnecting to ZooKeeper at " + zkHost + " ...");
try (SolrZkClient zkClient = CLIUtils.getSolrZkClient(cli, zkHost)) {
if (!recursive && zkClient.getChildren(znode, null, true).size() != 0) {
if (!recursive && zkClient.getChildren(znode, null).size() != 0) {
throw new SolrServerException(
"ZooKeeper node " + znode + " has children and recursive has NOT been specified.");
}
Expand Down
4 changes: 2 additions & 2 deletions solr/core/src/java/org/apache/solr/cloud/CloudUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ public static String unifiedResourcePath(SolrResourceLoader loader) {
public static Map<String, byte[]> getTrustedKeys(SolrZkClient zk, String dir) {
Map<String, byte[]> result = new HashMap<>();
try {
List<String> children = zk.getChildren("/keys/" + dir, null, true);
List<String> children = zk.getChildren("/keys/" + dir, null);
for (String key : children) {
if (key.endsWith(".der"))
result.put(key, zk.getData("/keys/" + dir + "/" + key, null, null, true));
result.put(key, zk.getData("/keys/" + dir + "/" + key, null, null));
}
} catch (KeeperException.NoNodeException e) {
log.info("Error fetching key names");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,8 @@ enum State {
this.rootNodePath = rootNodePath;

try {
if (!zkClient.exists(rootNodePath, true)) {
zkClient.makePath(rootNodePath, new byte[0], CreateMode.PERSISTENT, true);
if (!zkClient.exists(rootNodePath)) {
zkClient.makePath(rootNodePath, new byte[0], CreateMode.PERSISTENT);
}
} catch (KeeperException.NodeExistsException nee) {
// Some other thread (on this or another JVM) beat us to create the node, that's ok, the
Expand All @@ -341,27 +341,25 @@ void createNewInFlightTask(String asyncId) throws KeeperException, InterruptedEx
zkClient.create(
getPath(asyncId),
State.SUBMITTED.shorthand.getBytes(StandardCharsets.UTF_8),
CreateMode.EPHEMERAL,
true);
CreateMode.EPHEMERAL);
}

void setTaskRunning(String asyncId) throws KeeperException, InterruptedException {
zkClient.setData(
getPath(asyncId), State.RUNNING.shorthand.getBytes(StandardCharsets.UTF_8), true);
zkClient.setData(getPath(asyncId), State.RUNNING.shorthand.getBytes(StandardCharsets.UTF_8));
}

void deleteInFlightTask(String asyncId) throws KeeperException, InterruptedException {
zkClient.delete(getPath(asyncId), -1, true);
zkClient.delete(getPath(asyncId), -1);
}

State getInFlightState(String asyncId) throws KeeperException, InterruptedException {
if (!zkClient.exists(getPath(asyncId), true)) {
if (!zkClient.exists(getPath(asyncId))) {
return State.NOT_FOUND;
}

final byte[] bytes;
try {
bytes = zkClient.getData(getPath(asyncId), null, null, true);
bytes = zkClient.getData(getPath(asyncId), null, null);
} catch (KeeperException.NoNodeException nne) {
// Unlikely race, but not impossible...
if (log.isInfoEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ private void doStateDotJsonCasUpdate(ClusterState updatedState)
if (updater.isCollectionCreation()) {
// The state.json file does not exist yet (more precisely it is assumed not to exist)
log.debug("going to create collection {}", jsonPath);
zkStateReader.getZkClient().create(jsonPath, stateJson, CreateMode.PERSISTENT, true);
zkStateReader.getZkClient().create(jsonPath, stateJson, CreateMode.PERSISTENT);
} else {
// We're updating an existing state.json
if (log.isDebugEnabled()) {
Expand All @@ -561,9 +561,7 @@ private void doStateDotJsonCasUpdate(ClusterState updatedState)
jsonPath,
collection.getZNodeVersion());
}
zkStateReader
.getZkClient()
.setData(jsonPath, stateJson, collection.getZNodeVersion(), true);
zkStateReader.getZkClient().setData(jsonPath, stateJson, collection.getZNodeVersion());
}
}
}
Expand All @@ -577,7 +575,7 @@ private void doStateDotJsonCasUpdate(ClusterState updatedState)
private ClusterState fetchStateForCollection() throws KeeperException, InterruptedException {
String collectionStatePath = DocCollection.getCollectionPath(updater.getCollectionName());
Stat stat = new Stat();
byte[] data = zkStateReader.getZkClient().getData(collectionStatePath, null, stat, true);
byte[] data = zkStateReader.getZkClient().getData(collectionStatePath, null, stat);

// This factory method can detect a missing configName and supply it by reading it from the
// old ZK location.
Expand Down Expand Up @@ -890,7 +888,7 @@ public static void executeNodeDownStateUpdate(String nodeName, ZkStateReader zkS

try {
final List<String> collectionNames =
zkStateReader.getZkClient().getChildren(COLLECTIONS_ZKNODE, null, true);
zkStateReader.getZkClient().getChildren(COLLECTIONS_ZKNODE, null);

// Collections are totally independent of each other. Multiple threads could share the load
// here (need a ZK connection for each though).
Expand Down
20 changes: 9 additions & 11 deletions solr/core/src/java/org/apache/solr/cloud/DistributedMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ private void assertKeyFormat(String trackingId) {

public void put(String trackingId, byte[] data) throws KeeperException, InterruptedException {
assertKeyFormat(trackingId);
zookeeper.makePath(
dir + "/" + PREFIX + trackingId, data, CreateMode.PERSISTENT, null, false, true);
zookeeper.makePath(dir + "/" + PREFIX + trackingId, data, CreateMode.PERSISTENT, null, false);
}

/**
Expand All @@ -81,25 +80,24 @@ public boolean putIfAbsent(String trackingId, byte[] data)
throws KeeperException, InterruptedException {
assertKeyFormat(trackingId);
try {
zookeeper.makePath(
dir + "/" + PREFIX + trackingId, data, CreateMode.PERSISTENT, null, true, true);
zookeeper.makePath(dir + "/" + PREFIX + trackingId, data, CreateMode.PERSISTENT, null, true);
return true;
} catch (NodeExistsException e) {
return false;
}
}

public byte[] get(String trackingId) throws KeeperException, InterruptedException {
return zookeeper.getData(dir + "/" + PREFIX + trackingId, null, null, true);
return zookeeper.getData(dir + "/" + PREFIX + trackingId, null, null);
}

public boolean contains(String trackingId) throws KeeperException, InterruptedException {
return zookeeper.exists(dir + "/" + PREFIX + trackingId, true);
return zookeeper.exists(dir + "/" + PREFIX + trackingId);
}

public int size() throws KeeperException, InterruptedException {
Stat stat = new Stat();
zookeeper.getData(dir, null, stat, true);
zookeeper.getData(dir, null, stat);
return stat.getNumChildren();
}

Expand All @@ -110,7 +108,7 @@ public int size() throws KeeperException, InterruptedException {
public boolean remove(String trackingId) throws KeeperException, InterruptedException {
final var path = dir + "/" + PREFIX + trackingId;
try {
zookeeper.delete(path, -1, true);
zookeeper.delete(path, -1);
} catch (KeeperException.NoNodeException e) {
return false;
} catch (KeeperException.NotEmptyException hack) {
Expand All @@ -123,15 +121,15 @@ public boolean remove(String trackingId) throws KeeperException, InterruptedExce

/** Helper method to clear all child nodes for a parent node. */
public void clear() throws KeeperException, InterruptedException {
List<String> childNames = zookeeper.getChildren(dir, null, true);
List<String> childNames = zookeeper.getChildren(dir, null);
for (String childName : childNames) {
zookeeper.delete(dir + "/" + childName, -1, true);
zookeeper.delete(dir + "/" + childName, -1);
}
}

/** Returns the keys of all the elements in the map */
public Collection<String> keys() throws KeeperException, InterruptedException {
List<String> childs = zookeeper.getChildren(dir, null, true);
List<String> childs = zookeeper.getChildren(dir, null);
final List<String> ids = new ArrayList<>(childs.size());
childs.stream().forEach((child) -> ids.add(child.substring(PREFIX.length())));
return ids;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void cancelElection() throws InterruptedException, KeeperException {
if (leaderSeqPath != null) {
try {
log.debug("Canceling election {}", leaderSeqPath);
zkClient.delete(leaderSeqPath, -1, true);
zkClient.delete(leaderSeqPath, -1);
} catch (NoNodeException e) {
// fine
log.debug("cancelElection did not find election node to remove {}", leaderSeqPath);
Expand Down
23 changes: 8 additions & 15 deletions solr/core/src/java/org/apache/solr/cloud/LeaderElector.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private void checkIfIamLeader(final ElectionContext context, boolean replacement
context.checkIfIamLeaderFired();
// get all other numbers...
final String holdElectionPath = context.electionPath + ELECTION_NODE;
List<String> seqs = zkClient.getChildren(holdElectionPath, null, true);
List<String> seqs = zkClient.getChildren(holdElectionPath, null);
sortSeqs(seqs);

String leaderSeqNodeName =
Expand All @@ -114,7 +114,7 @@ private void checkIfIamLeader(final ElectionContext context, boolean replacement
try {
String toDelete = holdElectionPath + "/" + elec;
log.warn("Deleting duplicate registration: {}", toDelete);
zkClient.delete(toDelete, -1, true);
zkClient.delete(toDelete, -1);
} catch (KeeperException.NoNodeException e) {
// ignore
}
Expand Down Expand Up @@ -148,8 +148,7 @@ private void checkIfIamLeader(final ElectionContext context, boolean replacement
watcher =
new ElectionWatcher(
context.leaderSeqPath, watchedNode, getSeq(context.leaderSeqPath), context),
null,
true);
null);
log.debug("Watching path {} to know if I could be the leader", watchedNode);
} catch (KeeperException.SessionExpiredException e) {
throw e;
Expand Down Expand Up @@ -240,10 +239,7 @@ public int joinElection(ElectionContext context, boolean replacement, boolean jo
if (nodes.size() < 2) {
leaderSeqPath =
zkClient.create(
shardsElectZkPath + "/" + id + "-n_",
null,
CreateMode.EPHEMERAL_SEQUENTIAL,
false);
shardsElectZkPath + "/" + id + "-n_", null, CreateMode.EPHEMERAL_SEQUENTIAL);
} else {
String firstInLine = nodes.get(1);
log.debug("The current head: {}", firstInLine);
Expand All @@ -252,23 +248,20 @@ public int joinElection(ElectionContext context, boolean replacement, boolean jo
throw new IllegalStateException("Could not find regex match in:" + firstInLine);
}
leaderSeqPath = shardsElectZkPath + "/" + id + "-n_" + m.group(1);
zkClient.create(leaderSeqPath, null, CreateMode.EPHEMERAL, false);
zkClient.create(leaderSeqPath, null, CreateMode.EPHEMERAL);
}
} else {
leaderSeqPath =
zkClient.create(
shardsElectZkPath + "/" + id + "-n_",
null,
CreateMode.EPHEMERAL_SEQUENTIAL,
false);
shardsElectZkPath + "/" + id + "-n_", null, CreateMode.EPHEMERAL_SEQUENTIAL);
}

log.debug("Joined leadership election with path: {}", leaderSeqPath);
context.leaderSeqPath = leaderSeqPath;
cont = false;
} catch (ConnectionLossException e) {
// we don't know if we made our node or not...
List<String> entries = zkClient.getChildren(shardsElectZkPath, null, true);
List<String> entries = zkClient.getChildren(shardsElectZkPath, null);

boolean foundId = false;
for (String entry : entries) {
Expand Down Expand Up @@ -336,7 +329,7 @@ public void process(WatchedEvent event) {
if (canceled) {
log.debug("This watcher is not active anymore {}", myNode);
try {
zkClient.delete(myNode, -1, true);
zkClient.delete(myNode, -1);
} catch (KeeperException.NoNodeException nne) {
// expected . don't do anything
} catch (Exception e) {
Expand Down
8 changes: 4 additions & 4 deletions solr/core/src/java/org/apache/solr/cloud/Overseer.java
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ private void checkIfIamStillLeader() {
final String path = OVERSEER_ELECT + "/leader";
byte[] data;
try {
data = zkClient.getData(path, null, stat, true);
data = zkClient.getData(path, null, stat);
} catch (IllegalStateException | KeeperException.NoNodeException e) {
return;
} catch (Exception e) {
Expand All @@ -480,7 +480,7 @@ private void checkIfIamStillLeader() {
log.warn(
"I (id={}) am exiting, but I'm still the leader",
overseerCollectionConfigSetProcessor.getId());
zkClient.delete(path, stat.getVersion(), true);
zkClient.delete(path, stat.getVersion());
} catch (KeeperException.BadVersionException e) {
// no problem ignore it some other Overseer has already taken over
} catch (Exception e) {
Expand Down Expand Up @@ -602,7 +602,7 @@ private LeaderStatus amILeader() {
String propsId = null;
try {
ZkNodeProps props =
ZkNodeProps.load(zkClient.getData(OVERSEER_ELECT + "/leader", null, null, true));
ZkNodeProps.load(zkClient.getData(OVERSEER_ELECT + "/leader", null, null));
propsId = props.getStr(ID);
if (myId.equals(propsId)) {
return LeaderStatus.YES;
Expand Down Expand Up @@ -1027,7 +1027,7 @@ OverseerTaskQueue getConfigSetQueue(final SolrZkClient zkClient, Stats zkStats)

private void createOverseerNode(final SolrZkClient zkClient) {
try {
zkClient.create("/overseer", new byte[0], CreateMode.PERSISTENT, true);
zkClient.create("/overseer", new byte[0], CreateMode.PERSISTENT);
} catch (KeeperException.NodeExistsException e) {
// ok
} catch (InterruptedException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void runLeaderProcess(boolean weAreReplacement, int pauseBeforeStartMs)
final String id = leaderSeqPath.substring(leaderSeqPath.lastIndexOf('/') + 1);
ZkNodeProps myProps = new ZkNodeProps(ID, id);

zkClient.makePath(leaderPath, Utils.toJSON(myProps), CreateMode.EPHEMERAL, true);
zkClient.makePath(leaderPath, Utils.toJSON(myProps), CreateMode.EPHEMERAL);
if (pauseBeforeStartMs > 0) {
try {
Thread.sleep(pauseBeforeStartMs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ public OverseerNodePrioritizer(
public synchronized void prioritizeOverseerNodes(String overseerId) throws Exception {
SolrZkClient zk = zkStateReader.getZkClient();
List<String> overseerDesignates = new ArrayList<>();
if (zk.exists(ZkStateReader.ROLES, true)) {
Map<?, ?> m =
(Map<?, ?>) Utils.fromJSON(zk.getData(ZkStateReader.ROLES, null, new Stat(), true));
if (zk.exists(ZkStateReader.ROLES)) {
Map<?, ?> m = (Map<?, ?>) Utils.fromJSON(zk.getData(ZkStateReader.ROLES, null, new Stat()));
@SuppressWarnings("unchecked")
List<String> l = (List<String>) m.get("overseer");
if (l != null) {
Expand Down
Loading