Skip to content
7 changes: 7 additions & 0 deletions changelog/unreleased/migrate-splitcoreapi-to-jaxrs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
title: Migrate SplitCore and SplitShard to JAX-RS. SplitCore and SplitShard now have OpenAPI and SolrJ support.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[0] Drop the JAX-RS bit - users don't care about that IMO. What I'd focus on is the new auto-generated SolrJ classes that client users will have access to.

type: changed
authors:
- name: Eric Pugh
links:
- name: PR#4179
url: https://github.com/apache/solr/pull/4179
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.solr.client.api.endpoint;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import org.apache.solr.client.api.model.SolrJerseyResponse;
import org.apache.solr.client.api.model.SplitCoreRequestBody;

/**
* V2 API definition for splitting a Solr core.
*
* <p>The new API (POST /api/cores/{coreName}/split) is equivalent to the v1
* /admin/cores?action=split command.
*/
@Path("/cores/{coreName}/split")
public interface SplitCoreApi {
@POST
@Operation(
summary = "Splits a core index into two or more indexes.",
tags = {"cores"})
SolrJerseyResponse splitCore(
@Parameter(description = "The name of the core to split.", required = true)
@PathParam("coreName")
String coreName,
@RequestBody(description = "Additional properties for the split operation.")
SplitCoreRequestBody requestBody)
throws Exception;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.solr.client.api.endpoint;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import org.apache.solr.client.api.model.SolrJerseyResponse;
import org.apache.solr.client.api.model.SplitShardRequestBody;

/**
* V2 API definition for splitting an existing shard into multiple pieces.
*
* <p>The new API (POST /api/collections/{collectionName}/shards/split) is equivalent to the v1
* /admin/collections?action=SPLITSHARD command.
*/
@Path("/collections/{collectionName}/shards/split")
public interface SplitShardApi {
@POST
@Operation(
summary = "Splits a shard in an existing collection into two or more shards.",
tags = {"shards"})
SolrJerseyResponse splitShard(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[-1] SolrJerseyResponse is a very minimal POJO that pretty much just includes the responseHeader section. If you look at our actual split-shard implementation it can include a good bit more than that. Today's split-shard response can optionally include timing information about stages of the split, etc.

So we probably need a split-shard specific response POJO

@Parameter(description = "The name of the collection containing the shard.", required = true)
@PathParam("collectionName")
String collectionName,
@RequestBody(description = "Additional properties for the shard split operation.")
SplitShardRequestBody requestBody)
throws Exception;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.solr.client.api.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.List;

/**
* Request body for splitting a Solr core via {@link
* org.apache.solr.client.api.endpoint.SplitCoreApi}
*/
public class SplitCoreRequestBody {
@Schema(description = "Multi-valued, file system paths to write the split pieces to.")
@JsonProperty
public List<String> path;

@Schema(description = "Multi-valued, names of the cores to split the index into.")
@JsonProperty
public List<String> targetCore;

@Schema(description = "A route key to be used for splitting the index.")
@JsonProperty
public String splitKey;

@Schema(description = "The method to use for splitting the index (e.g. 'rewrite' or 'link').")
@JsonProperty
public String splitMethod;

@Schema(description = "When true, returns the range recommendations for splitting the index.")
@JsonProperty
public Boolean getRanges;

@Schema(description = "Comma-separated hash ranges to split the index into (e.g. 'a-b,c-d').")
@JsonProperty
public String ranges;

@Schema(description = "Request ID to track this action which will be processed asynchronously.")
@JsonProperty
public String async;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.solr.client.api.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.Map;

/**
* Request body for splitting a shard via {@link org.apache.solr.client.api.endpoint.SplitShardApi}
*/
public class SplitShardRequestBody {
@Schema(description = "The name of the shard to be split.")
@JsonProperty
public String shard;

@Schema(description = "Comma-separated hash ranges to split the shard into (e.g. 'a-b,c-d').")
@JsonProperty
public String ranges;

@Schema(description = "A route key to be used for splitting the index.")
@JsonProperty
public String splitKey;

@Schema(description = "The number of sub-shards to create from the shard.")
@JsonProperty
public Integer numSubShards;

@Schema(description = "A fuzzy factor for the split (e.g. '0.2').")
@JsonProperty
public String splitFuzz;

@Schema(description = "When true, timing information is included in the response.")
@JsonProperty
public Boolean timing;

@Schema(description = "When true, split ranges are determined based on prefix distribution.")
@JsonProperty
public Boolean splitByPrefix;

@Schema(description = "When true, aliases are followed to find the actual collection name.")
@JsonProperty
public Boolean followAliases;

@Schema(description = "The method to use for splitting the index (e.g. 'rewrite' or 'link').")
@JsonProperty
public String splitMethod;

@Schema(description = "Core properties to set on the sub-shards.")
@JsonProperty
public Map<String, Object> coreProperties;

@Schema(description = "Request ID to track this action which will be processed asynchronously.")
@JsonProperty
public String async;

@Deprecated(since = "9.10")
@Schema(description = "Deprecated. When true, waits for the final state before returning.")
@JsonProperty
public Boolean waitForFinalState;
}
Original file line number Diff line number Diff line change
Expand Up @@ -1373,13 +1373,13 @@ public Collection<Class<? extends JerseyResource>> getJerseyResources() {
ListCollectionSnapshots.class,
CreateCollectionSnapshot.class,
DeleteCollectionSnapshot.class,
ClusterProperty.class);
ClusterProperty.class,
SplitShardAPI.class);
}

@Override
public Collection<Api> getApis() {
final List<Api> apis = new ArrayList<>();
apis.addAll(AnnotatedApi.getApis(new SplitShardAPI(this)));
apis.addAll(AnnotatedApi.getApis(new MigrateDocsAPI(this)));
apis.addAll(AnnotatedApi.getApis(new ModifyCollectionAPI(this)));
apis.addAll(AnnotatedApi.getApis(new MoveReplicaAPI(this)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ public Collection<Api> getApis() {
final List<Api> apis = new ArrayList<>();
apis.addAll(AnnotatedApi.getApis(new RejoinLeaderElectionAPI(this)));
apis.addAll(AnnotatedApi.getApis(new OverseerOperationAPI(this)));
apis.addAll(AnnotatedApi.getApis(new SplitCoreAPI(this)));
// Internal APIs
apis.addAll(AnnotatedApi.getApis(new RequestCoreRecoveryAPI(this)));
apis.addAll(AnnotatedApi.getApis(new PrepareCoreRecoveryAPI(this)));
Expand All @@ -339,6 +338,7 @@ public Collection<Class<? extends JerseyResource>> getJerseyResources() {
SwapCores.class,
RenameCore.class,
MergeIndexes.class,
SplitCoreAPI.class,
GetNodeCommandStatus.class);
}

Expand Down
Loading