Skip to content
Open
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
31 changes: 31 additions & 0 deletions changelog/unreleased/SOLR-18166-remove-linkconfig.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# (DELETE ALL COMMENTS UP HERE AFTER FILLING THIS IN

# See https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc

# If the change is minor, don't bother adding a changelog entry.
# For `other` type entries, the threshold to bother with a changelog entry should be even higher.

# title:
# * The audience is end-users and administrators, not committers.
# * Be short and focused on the user impact. Multiple sentences is fine!
# * For technical/geeky details, prefer the commit message instead of changelog.
# * Reference JIRA issues like `SOLR-12345`, or if no JIRA but have a GitHub PR then `PR#12345`.

# type:
# `added` for new features/improvements, opt-in by the user typically documented in the ref guide
# `changed` for improvements; not opt-in
# `fixed` for improvements that are deemed to have fixed buggy behavior
# `deprecated` for marking things deprecated
# `removed` for code removed
# `dependency_update` for updates to dependencies
# `other` for anything else, like large/significant refactorings, build changes,
# test infrastructure, or documentation.
# Most such changes are too small/minor to bother with a changelog entry.

title: Remove outmoded and misleading 'bin/solr zk linkconfig' tool.
type: removed
authors:
- name: Jason Gerlowski
links:
- name: SOLR-18166
url: https://issues.apache.org/jira/browse/SOLR-18166
87 changes: 0 additions & 87 deletions solr/core/src/java/org/apache/solr/cli/LinkConfigTool.java

This file was deleted.

4 changes: 1 addition & 3 deletions solr/core/src/java/org/apache/solr/cli/SolrCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ public static void main(String[] args) throws Exception {
// select the version tool to be run
args = new String[] {"version"};
}
if (Arrays.asList(
"upconfig", "downconfig", "cp", "rm", "mv", "ls", "mkroot", "linkconfig", "updateacls")
if (Arrays.asList("upconfig", "downconfig", "cp", "rm", "mv", "ls", "mkroot", "updateacls")
.contains(args[0])) {
// remap our arguments to invoke the zk short tool help
args = new String[] {"zk-tool-help", "--print-zk-subcommand-usage", args[0]};
Expand Down Expand Up @@ -194,7 +193,6 @@ private static Tool newTool(String toolType, ToolRuntime runtime) throws Excepti
else if ("ls".equals(toolType)) return new ZkLsTool(runtime);
else if ("cluster".equals(toolType)) return new ClusterTool(runtime);
else if ("updateacls".equals(toolType)) return new UpdateACLTool(runtime);
else if ("linkconfig".equals(toolType)) return new LinkConfigTool(runtime);
else if ("mkroot".equals(toolType)) return new ZkMkrootTool(runtime);
else if ("assert".equals(toolType)) return new AssertTool(runtime);
else if ("auth".equals(toolType)) return new AuthTool(runtime);
Expand Down
1 change: 0 additions & 1 deletion solr/core/src/java/org/apache/solr/cli/ZkToolHelp.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ public void runImpl(CommandLine cli) throws Exception {
print(new ConfigSetUploadTool(runtime).getUsage());
print(new ConfigSetDownloadTool(runtime).getUsage());
print(new ZkMkrootTool(runtime).getUsage());
print(new LinkConfigTool(runtime).getUsage());
print(new UpdateACLTool(runtime).getUsage());
print("");
print(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import java.util.Optional;
import java.util.Set;
import org.apache.solr.client.solrj.cloud.SolrCloudManager;
import org.apache.solr.client.solrj.impl.ZkClientClusterStateProvider;
import org.apache.solr.cloud.overseer.ClusterStateMutator;
import org.apache.solr.cloud.overseer.CollectionMutator;
import org.apache.solr.cloud.overseer.NodeMutator;
Expand Down Expand Up @@ -573,26 +572,20 @@ private void doStateDotJsonCasUpdate(ClusterState updatedState)
* enough... (we have to deal anyway with failures of conditional updates so trying to use non
* fresh data is ok, a second attempt will be made)
*/
@SuppressWarnings("unchecked")
private ClusterState fetchStateForCollection() throws KeeperException, InterruptedException {
String collectionStatePath = DocCollection.getCollectionPath(updater.getCollectionName());
Stat stat = new Stat();
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.
// TODO in Solr 10 remove that factory method

ClusterState clusterState;
clusterState =
ZkClientClusterStateProvider.createFromJsonSupportingLegacyConfigName(
stat.getVersion(),
data,
Set.of(),
updater.getCollectionName(),
zkStateReader.getZkClient(),
Instant.ofEpochMilli(stat.getCtime()));

return clusterState;
Map<String, Object> stateMap = (Map<String, Object>) Utils.fromJSON(data);

return ClusterState.createFromCollectionMap(
stat.getVersion(),
stateMap,
Set.of(),
Instant.ofEpochMilli(stat.getCtime()),
PerReplicaStatesOps.getZkClientPrsSupplier(
zkStateReader.getZkClient(), collectionStatePath));
}
}

Expand Down
40 changes: 0 additions & 40 deletions solr/core/src/java/org/apache/solr/cloud/ZkController.java
Original file line number Diff line number Diff line change
Expand Up @@ -2378,46 +2378,6 @@ private ZkCoreNodeProps waitForLeaderToSeeDownState(
return leaderProps;
}

public static void linkConfSet(SolrZkClient zkClient, String collection, String confSetName)
throws KeeperException, InterruptedException {
String path = ZkStateReader.COLLECTIONS_ZKNODE + "/" + collection;
log.debug("Load collection config from:{}", path);
byte[] data;
try {
data = zkClient.getData(path, null, null);
} catch (NoNodeException e) {
// if there is no node, we will try and create it
// first try to make in case we are pre-configuring
ZkNodeProps props = new ZkNodeProps(CONFIGNAME_PROP, confSetName);
try {

zkClient.makePath(path, Utils.toJSON(props), CreateMode.PERSISTENT, null, true);
} catch (KeeperException e2) {
// it's okay if the node already exists
if (e2.code() != KeeperException.Code.NODEEXISTS) {
throw e;
}
// if we fail creating, setdata
// TODO: we should consider using version
zkClient.setData(path, Utils.toJSON(props));
}
return;
}
// we found existing data, let's update it
ZkNodeProps props = null;
if (data != null) {
props = ZkNodeProps.load(data);
Map<String, Object> newProps = new HashMap<>(props.getProperties());
newProps.put(CONFIGNAME_PROP, confSetName);
props = new ZkNodeProps(newProps);
} else {
props = new ZkNodeProps(CONFIGNAME_PROP, confSetName);
}

// TODO: we should consider using version
zkClient.setData(path, Utils.toJSON(props));
}

public ZkDistributedQueue getOverseerJobQueue() {
if (distributedClusterStateUpdater.isDistributedStateUpdate()) {
throw new IllegalStateException(
Expand Down
24 changes: 1 addition & 23 deletions solr/core/src/test/org/apache/solr/cli/ZkSubcommandsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
import org.apache.solr.common.cloud.DigestZkCredentialsProvider;
import org.apache.solr.common.cloud.SolrZkClient;
import org.apache.solr.common.cloud.VMParamsZkCredentialsInjector;
import org.apache.solr.common.cloud.ZkNodeProps;
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.util.ZLibCompressor;
import org.apache.solr.core.ConfigSetService;
import org.apache.solr.util.ExternalPaths;
Expand Down Expand Up @@ -303,7 +301,7 @@ public void testLs() throws Exception {
}

@Test
public void testUpConfigLinkConfigClearZk() throws Exception {
public void testUpConfigDownConfigClearZk() throws Exception {
Path tmpDir = createTempDir();

// test upconfig
Expand Down Expand Up @@ -333,26 +331,6 @@ public void testUpConfigLinkConfigClearZk() throws Exception {
"Verify that all local files are uploaded to ZK", filesStream.count(), zkFiles.size());
}

// test linkconfig
args =
new String[] {
"linkconfig",
"--conf-name",
confsetname,
"-c",
"collection1",
"-z",
zkServer.getZkAddress()
};

assertEquals(0, CLITestHelper.runTool(args, LinkConfigTool.class));

ZkNodeProps collectionProps =
ZkNodeProps.load(
zkClient.getData(ZkStateReader.COLLECTIONS_ZKNODE + "/collection1", null, null));
assertTrue(collectionProps.containsKey("configName"));
assertEquals(confsetname, collectionProps.getStr("configName"));

// test down config
Path destDir =
FilterPath.unwrap(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.time.Instant;
import java.util.Collection;
import java.util.List;
import java.util.Map;
Expand All @@ -28,16 +27,10 @@
import org.apache.solr.common.AlreadyClosedException;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.cloud.ClusterState;
import org.apache.solr.common.cloud.DocCollection;
import org.apache.solr.common.cloud.PerReplicaStatesOps;
import org.apache.solr.common.cloud.SolrZkClient;
import org.apache.solr.common.cloud.ZkNodeProps;
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.cloud.ZooKeeperException;
import org.apache.solr.common.util.EnvUtils;
import org.apache.solr.common.util.Utils;
import org.apache.zookeeper.KeeperException;
import org.noggit.JSONWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -85,62 +78,6 @@ public ZkClientClusterStateProvider(String zkHost) {
this.canUseZkACLs = true;
}

/**
* Create a ClusterState from Json. This method supports legacy configName location
*
* @param bytes a byte array of a Json representation of a mapping from collection name to the
* Json representation of a {@link DocCollection} as written by {@link
* ClusterState#write(JSONWriter)}. It can represent one or more collections.
* @param liveNodes list of live nodes
* @param coll collection name
* @param zkClient ZK client
* @param createTime creation time of the data/bytes
* @return the ClusterState
*/
@SuppressWarnings({"unchecked"})
@Deprecated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yay! finally

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes!

public static ClusterState createFromJsonSupportingLegacyConfigName(
int version,
byte[] bytes,
Set<String> liveNodes,
String coll,
SolrZkClient zkClient,
Instant createTime) {
if (bytes == null || bytes.length == 0) {
return new ClusterState(liveNodes, Map.of());
}
Map<String, Object> stateMap = (Map<String, Object>) Utils.fromJSON(bytes);
Map<String, Object> props = (Map<String, Object>) stateMap.get(coll);
if (props != null) {
if (!props.containsKey(ZkStateReader.CONFIGNAME_PROP)) {
try {
// read configName from collections/collection node
String path = ZkStateReader.COLLECTIONS_ZKNODE + "/" + coll;
byte[] data = zkClient.getData(path, null, null);
if (data != null && data.length > 0) {
ZkNodeProps configProp = ZkNodeProps.load(data);
String configName = configProp.getStr(ZkStateReader.CONFIGNAME_PROP);
if (configName != null) {
props.put(ZkStateReader.CONFIGNAME_PROP, configName);
stateMap.put(coll, props);
} else {
log.warn("configName is null, not found on {}", path);
}
}
} catch (KeeperException | InterruptedException e) {
// do nothing
}
}
}
return ClusterState.createFromCollectionMap(
version,
stateMap,
liveNodes,
createTime,
PerReplicaStatesOps.getZkClientPrsSupplier(
zkClient, DocCollection.getCollectionPath(coll)));
}

@Override
public ClusterState.CollectionRef getState(String collection) {
ClusterState clusterState = getZkStateReader().getClusterState();
Expand Down
Loading
Loading