Skip to content

Commit

Permalink
SOLR-17066: Replace 'data store' term in code and docs (#2201)
Browse files Browse the repository at this point in the history
"Data store" as a term, was introduced a few weeks back as a way to
refer generically to something that could be either a collection or a
core.  As its use expanded though, it turned out to not be very well
liked in practice.

This commit replaces all usage of the term with either "collection" or
"index type", depending on the specific usage.
  • Loading branch information
gerlowskija committed Jan 19, 2024
1 parent 1624b4d commit 9246075
Show file tree
Hide file tree
Showing 42 changed files with 96 additions and 103 deletions.
5 changes: 2 additions & 3 deletions solr/CHANGES.txt
Expand Up @@ -127,9 +127,8 @@ Improvements
* SOLR-17063: Do not retain log param references in LogWatcher (Michael Gibney)

* SOLR-17066: SolrClient builders now allow users to specify a "default" collection or core
using the `withDefaultDataStore` method ("Cloud" client builders retain the more specific
`withDefaultCollection`). Use of the Builder methods is preferable to including the
collection in the base URL accepted by certain client implementations. (Jason Gerlowski)
using the `withDefaultCollection` method. Use of the Builder methods is preferable to including
the collection in the base URL accepted by certain client implementations. (Jason Gerlowski)

* SOLR-15960: Unified use of system properties and environment variables (janhoy)

Expand Down
Expand Up @@ -16,7 +16,7 @@
*/
package org.apache.solr.client.api.endpoint;

import static org.apache.solr.client.api.util.Constants.STORE_PATH_PREFIX;
import static org.apache.solr.client.api.util.Constants.INDEX_PATH_PREFIX;

import io.swagger.v3.oas.annotations.Operation;
import javax.ws.rs.DefaultValue;
Expand All @@ -31,7 +31,7 @@
import org.apache.solr.client.api.model.SchemaZkVersionResponse;
import org.apache.solr.client.api.util.StoreApiParameters;

@Path(STORE_PATH_PREFIX + "/schema")
@Path(INDEX_PATH_PREFIX + "/schema")
public interface GetSchemaApi {

@GET
Expand Down
Expand Up @@ -17,7 +17,7 @@
package org.apache.solr.client.api.endpoint;

import static org.apache.solr.client.api.util.Constants.GENERIC_ENTITY_PROPERTY;
import static org.apache.solr.client.api.util.Constants.STORE_PATH_PREFIX;
import static org.apache.solr.client.api.util.Constants.INDEX_PATH_PREFIX;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
Expand All @@ -42,7 +42,7 @@
* Solr's OAS (and the clients generated from that) an approximate view of the endpoint until its
* inputs and outputs can be understood more fully.
*/
@Path(STORE_PATH_PREFIX + "/select")
@Path(INDEX_PATH_PREFIX + "/select")
public interface SelectApi {
@GET
@StoreApiParameters
Expand Down
Expand Up @@ -16,13 +16,13 @@
*/
package org.apache.solr.client.api.model;

public enum StoreType {
public enum IndexType {
COLLECTION("collections"),
CORE("cores");

private final String pathString;

StoreType(String pathString) {
IndexType(String pathString) {
this.pathString = pathString;
}

Expand Down
Expand Up @@ -22,10 +22,10 @@ private Constants() {
/* Private ctor prevents instantiation */
}

public static final String STORE_TYPE_PATH_PARAMETER = "storeType";
public static final String STORE_NAME_PATH_PARAMETER = "storeName";
public static final String STORE_PATH_PREFIX =
"/{" + STORE_TYPE_PATH_PARAMETER + ":cores|collections}/{" + STORE_NAME_PATH_PARAMETER + "}";
public static final String INDEX_TYPE_PATH_PARAMETER = "indexType";
public static final String INDEX_NAME_PATH_PARAMETER = "indexName";
public static final String INDEX_PATH_PREFIX =
"/{" + INDEX_TYPE_PATH_PARAMETER + ":cores|collections}/{" + INDEX_NAME_PATH_PARAMETER + "}";

public static final String GENERIC_ENTITY_PROPERTY = "genericEntity";

Expand Down
Expand Up @@ -16,8 +16,8 @@
*/
package org.apache.solr.client.api.util;

import static org.apache.solr.client.api.util.Constants.STORE_NAME_PATH_PARAMETER;
import static org.apache.solr.client.api.util.Constants.STORE_TYPE_PATH_PARAMETER;
import static org.apache.solr.client.api.util.Constants.INDEX_NAME_PATH_PARAMETER;
import static org.apache.solr.client.api.util.Constants.INDEX_TYPE_PATH_PARAMETER;

import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
Expand All @@ -26,7 +26,7 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.apache.solr.client.api.model.StoreType;
import org.apache.solr.client.api.model.IndexType;

/**
* Concisely collects the parameters shared by APIs that interact with contents of a specific
Expand All @@ -38,8 +38,8 @@
@Target({ElementType.METHOD, ElementType.TYPE, ElementType.PARAMETER, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@Parameter(
name = STORE_TYPE_PATH_PARAMETER,
name = INDEX_TYPE_PATH_PARAMETER,
in = ParameterIn.PATH,
schema = @Schema(implementation = StoreType.class, enumAsRef = true))
@Parameter(name = STORE_NAME_PATH_PARAMETER, in = ParameterIn.PATH)
schema = @Schema(implementation = IndexType.class, enumAsRef = true))
@Parameter(name = INDEX_NAME_PATH_PARAMETER, in = ParameterIn.PATH)
public @interface StoreApiParameters {}
Expand Up @@ -181,7 +181,7 @@ private HttpSolrClient.Builder recoverySolrClientBuilder(String baseUrl, String
// (even though getRecoveryOnlyHttpClient() already has them set)
final UpdateShardHandlerConfig cfg = cc.getConfig().getUpdateShardHandlerConfig();
return (new HttpSolrClient.Builder(baseUrl)
.withDefaultDataStore(leaderCoreName)
.withDefaultCollection(leaderCoreName)
.withConnectionTimeout(cfg.getDistributedConnectionTimeout(), TimeUnit.MILLISECONDS)
.withSocketTimeout(cfg.getDistributedSocketTimeout(), TimeUnit.MILLISECONDS)
.withHttpClient(cc.getUpdateShardHandler().getRecoveryOnlyHttpClient()));
Expand Down
Expand Up @@ -260,7 +260,7 @@ static UpdateResponse softCommit(String baseUrl, String coreName)

try (SolrClient client =
new HttpSolrClient.Builder(baseUrl)
.withDefaultDataStore(coreName)
.withDefaultCollection(coreName)
.withConnectionTimeout(30000, TimeUnit.MILLISECONDS)
.withSocketTimeout(120000, TimeUnit.MILLISECONDS)
.build()) {
Expand Down
Expand Up @@ -796,7 +796,7 @@ private void killDaemon(String daemonName, Replica daemonReplica) throws Excepti
try (SolrClient solrClient =
new HttpSolrClient.Builder()
.withHttpClient(client)
.withDefaultDataStore(daemonReplica.getCoreName())
.withDefaultCollection(daemonReplica.getCoreName())
.withBaseSolrUrl(daemonReplica.getBaseUrl())
.build()) {
ModifiableSolrParams q = new ModifiableSolrParams();
Expand Down
Expand Up @@ -59,7 +59,7 @@
import org.apache.solr.client.solrj.SolrResponse;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.io.stream.expr.Expressible;
import org.apache.solr.client.solrj.request.DataStoreSolrRequest;
import org.apache.solr.client.solrj.request.CollectionRequiringSolrRequest;
import org.apache.solr.cloud.ZkController;
import org.apache.solr.cloud.ZkSolrResourceLoader;
import org.apache.solr.common.MapSerializable;
Expand Down Expand Up @@ -960,7 +960,7 @@ public Name getPermissionName(AuthorizationContext ctx) {
}
}

private static class PerReplicaCallable extends DataStoreSolrRequest<SolrResponse>
private static class PerReplicaCallable extends CollectionRequiringSolrRequest<SolrResponse>
implements Callable<Boolean> {
Replica replica;
String prop;
Expand Down Expand Up @@ -989,7 +989,7 @@ public Boolean call() throws Exception {
int attempts = 0;
try (HttpSolrClient solr =
new HttpSolrClient.Builder(replica.getBaseUrl())
.withDefaultDataStore(replica.getCoreName())
.withDefaultCollection(replica.getCoreName())
.build()) {
// eventually, this loop will get killed by the ExecutorService's timeout
while (true) {
Expand Down
Expand Up @@ -96,7 +96,7 @@ public CallBack(ShardResponse originalShardResponse, QueryRequest req) {
URLUtil.extractCoreFromCoreUrl(originalShardResponse.getShardAddress());
this.solrClient =
new Builder(shardBaseUrl)
.withDefaultDataStore(shardCoreName)
.withDefaultCollection(shardCoreName)
.withHttpClient(httpClient)
.build();
this.req = req;
Expand Down
Expand Up @@ -44,7 +44,7 @@
import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.SolrResponse;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.request.DataStoreSolrRequest;
import org.apache.solr.client.solrj.request.CollectionRequiringSolrRequest;
import org.apache.solr.cloud.ZkController;
import org.apache.solr.cloud.ZkSolrResourceLoader;
import org.apache.solr.common.SolrException;
Expand Down Expand Up @@ -347,8 +347,8 @@ private static List<Replica> getActiveReplicas(
return activeReplicas;
}

private static class GetZkSchemaVersionCallable extends DataStoreSolrRequest<SolrResponse>
implements Callable<Integer> {
private static class GetZkSchemaVersionCallable
extends CollectionRequiringSolrRequest<SolrResponse> implements Callable<Integer> {

private final ZkController zkController;
private String baseUrl;
Expand All @@ -375,7 +375,7 @@ public SolrParams getParams() {
public Integer call() throws Exception {
int remoteVersion = -1;
try (HttpSolrClient solr =
new HttpSolrClient.Builder(baseUrl).withDefaultDataStore(coreName).build()) {
new HttpSolrClient.Builder(baseUrl).withDefaultCollection(coreName).build()) {
// eventually, this loop will get killed by the ExecutorService's timeout
while (remoteVersion == -1
|| (remoteVersion < expectedZkVersion
Expand Down
Expand Up @@ -85,7 +85,7 @@ public PeerSyncWithLeader(SolrCore core, String leaderUrl, int nUpdates) {
final var coreName = URLUtil.extractCoreFromCoreUrl(leaderUrl);
this.clientToLeader =
new HttpSolrClient.Builder(leaderBaseUrl)
.withDefaultDataStore(coreName)
.withDefaultCollection(coreName)
.withHttpClient(httpClient)
.build();

Expand Down
Expand Up @@ -76,7 +76,7 @@ public synchronized SolrClient getSolrClient(final SolrCmdDistributor.Req req) {
client =
new ErrorReportingConcurrentUpdateSolrClient.Builder(
req.node.getBaseUrl(), httpClient, req, errors)
.withDefaultDataStore(defaultCore)
.withDefaultCollection(defaultCore)
.withQueueSize(100)
.withThreadCount(runnerCount)
.withExecutorService(updateExecutor)
Expand Down
Expand Up @@ -55,7 +55,8 @@ In Solr, one or more <<document,Documents>> grouped together in a single logical
In <<solrclouddef,SolrCloud>> a collection may be divided up into multiple logical shards, which may in turn be distributed across many nodes.
+
Single-node installations and user-managed clusters use instead the concept of a <<core,Core>>.

"Collection" is most frequently used in the SolrCloud context, but as it represents a "logical index", the term may be used to refer to individual cores in a user-managed cluster as well.
+
[[defcommit]]Commit::
To make document changes permanent in the index.
In the case of added documents, they would be searchable after a _commit_.
Expand Down
Expand Up @@ -176,15 +176,15 @@ public void setQueryParams(Set<String> queryParams) {
public abstract SolrParams getParams();

/**
* Determines whether this request should use or ignore any specified data stores (esp. {@link
* Determines whether this request should use or ignore any specified collections (esp. {@link
* SolrClient#defaultCollection})
*
* <p>Many Solr requests target a particular data store (i.e. core or collection). But not all of
* them - many Solr APIs (e.g. security or other admin APIs) are agnostic of data stores entirely.
* This method gives these requests a way to opt out of using {@link SolrClient#defaultCollection}
* or other specified data stores.
* <p>Many Solr requests target a particular core or collection. But not all of them - many Solr
* APIs (e.g. security or other admin APIs) are agnostic of collections entirely. This method
* gives these requests a way to opt out of using {@link SolrClient#defaultCollection} or other
* specified collections.
*/
public boolean requiresDataStore() {
public boolean requiresCollection() {
return false;
}

Expand Down
Expand Up @@ -64,7 +64,7 @@ protected CloudLegacySolrClient(Builder builder) {
super(builder.shardLeadersOnly, builder.parallelUpdates, builder.directUpdatesToLeadersOnly);
this.stateProvider = builder.stateProvider;
this.retryExpiryTimeNano = builder.retryExpiryTimeNano;
this.defaultCollection = builder.defaultDataStore;
this.defaultCollection = builder.defaultCollection;
this.collectionStateCache.timeToLiveMs =
TimeUnit.MILLISECONDS.convert(builder.timeToLiveSeconds, TimeUnit.SECONDS);
this.clientIsInternal = builder.httpClient == null;
Expand Down Expand Up @@ -238,16 +238,6 @@ public Builder canUseZkACLs(boolean canUseZkACLs) {
return this;
}

/**
* Sets a default collection for all collection-based requests.
*
* <p>Identical to {@link #withDefaultDataStore(String)} for this builder
*/
public Builder withDefaultCollection(String defaultCollection) {
this.defaultDataStore = defaultCollection;
return this;
}

/** Provides a {@link HttpClient} for the builder to use when creating clients. */
public Builder withLBHttpSolrClientBuilder(LBHttpSolrClient.Builder lbHttpSolrClientBuilder) {
this.lbClientBuilder = lbHttpSolrClientBuilder;
Expand Down
Expand Up @@ -150,7 +150,7 @@ protected ConcurrentUpdateHttp2SolrClient(Builder builder) {
this.runners = new ArrayDeque<>();
this.streamDeletes = builder.streamDeletes;
this.basePath = builder.baseSolrUrl;
this.defaultCollection = builder.defaultDataStore;
this.defaultCollection = builder.defaultCollection;
this.pollQueueTimeMillis = builder.pollQueueTimeMillis;
this.stallTimeMillis = Integer.getInteger("solr.cloud.client.stallTime", 15000);

Expand Down Expand Up @@ -361,7 +361,7 @@ private void addRunner() {
@Override
public NamedList<Object> request(final SolrRequest<?> request, String collection)
throws SolrServerException, IOException {
if (ClientUtils.shouldApplyDefaultDataStore(collection, request))
if (ClientUtils.shouldApplyDefaultCollection(collection, request))
collection = defaultCollection;
if (!(request instanceof UpdateRequest)) {
request.setBasePath(basePath);
Expand Down Expand Up @@ -701,7 +701,7 @@ public void shutdownNow() {
public static class Builder {
protected Http2SolrClient client;
protected String baseSolrUrl;
protected String defaultDataStore;
protected String defaultCollection;
protected int queueSize = 10;
protected int threadCount;
protected ExecutorService executorService;
Expand Down Expand Up @@ -792,9 +792,9 @@ public Builder neverStreamDeletes() {
return this;
}

/** Sets a default data store for core- or collection-based requests. */
public Builder withDefaultDataStore(String defaultCoreOrCollection) {
this.defaultDataStore = defaultCoreOrCollection;
/** Sets a default for core or collection based requests. */
public Builder withDefaultCollection(String defaultCoreOrCollection) {
this.defaultCollection = defaultCoreOrCollection;
return this;
}

Expand Down
Expand Up @@ -116,7 +116,7 @@ protected ConcurrentUpdateSolrClient(Builder builder) {
this.soTimeout = builder.socketTimeoutMillis;
this.pollQueueTimeMillis = builder.pollQueueTime;
this.stallTimeMillis = Integer.getInteger("solr.cloud.client.stallTime", 15000);
this.defaultCollection = builder.defaultDataStore;
this.defaultCollection = builder.defaultCollection;

// make sure the stall time is larger than the polling time
// to give a chance for the queue to change
Expand Down Expand Up @@ -476,7 +476,7 @@ public void setCollection(String collection) {
@Override
public NamedList<Object> request(final SolrRequest<?> request, String collection)
throws SolrServerException, IOException {
if (ClientUtils.shouldApplyDefaultDataStore(collection, request))
if (ClientUtils.shouldApplyDefaultCollection(collection, request))
collection = defaultCollection;
if (!(request instanceof UpdateRequest)) {
return client.request(request, collection);
Expand Down
Expand Up @@ -191,7 +191,7 @@ protected Http2SolrClient(String serverBaseUrl, Builder builder) {
this.parser = builder.responseParser;
}
updateDefaultMimeTypeForParser();
this.defaultCollection = builder.defaultDataStore;
this.defaultCollection = builder.defaultCollection;
if (builder.requestTimeoutMillis != null) {
this.requestTimeoutMillis = builder.requestTimeoutMillis;
} else {
Expand Down Expand Up @@ -555,7 +555,7 @@ public void onFailure(Response response, Throwable failure) {
@Override
public NamedList<Object> request(SolrRequest<?> solrRequest, String collection)
throws SolrServerException, IOException {
if (ClientUtils.shouldApplyDefaultDataStore(collection, solrRequest))
if (ClientUtils.shouldApplyDefaultCollection(collection, solrRequest))
collection = defaultCollection;
String url = getRequestPath(solrRequest, collection);
Throwable abortCause = null;
Expand Down Expand Up @@ -1072,7 +1072,7 @@ public static class Builder {
private ExecutorService executor;
protected RequestWriter requestWriter;
protected ResponseParser responseParser;
protected String defaultDataStore;
protected String defaultCollection;
private Set<String> urlParamNames;
private CookieStore cookieStore = getDefaultCookieStore();
private String proxyHost;
Expand Down Expand Up @@ -1197,9 +1197,9 @@ public Builder withResponseParser(ResponseParser responseParser) {
return this;
}

/** Sets a default data store for core- or collection-based requests. */
public Builder withDefaultDataStore(String defaultCoreOrCollection) {
this.defaultDataStore = defaultCoreOrCollection;
/** Sets a default for core or collection based requests. */
public Builder withDefaultCollection(String defaultCoreOrCollection) {
this.defaultCollection = defaultCoreOrCollection;
return this;
}

Expand Down
Expand Up @@ -189,7 +189,7 @@ protected HttpSolrClient(Builder builder) {
this.soTimeout = builder.socketTimeoutMillis;
this.useMultiPartPost = builder.useMultiPartPost;
this.urlParamNames = builder.urlParamNames;
this.defaultCollection = builder.defaultDataStore;
this.defaultCollection = builder.defaultCollection;
}

public Set<String> getUrlParamNames() {
Expand Down Expand Up @@ -244,7 +244,7 @@ public NamedList<Object> request(final SolrRequest<?> request, final ResponsePar
public NamedList<Object> request(
final SolrRequest<?> request, final ResponseParser processor, String collection)
throws SolrServerException, IOException {
if (ClientUtils.shouldApplyDefaultDataStore(collection, request))
if (ClientUtils.shouldApplyDefaultCollection(collection, request))
collection = defaultCollection;
HttpRequestBase method = createMethod(request, collection);
setBasicAuthHeader(request, method);
Expand Down

0 comments on commit 9246075

Please sign in to comment.