Skip to content

Commit

Permalink
SOLR-16825: Migrate v2 definitions to 'api' module, pt 5 (#1974)
Browse files Browse the repository at this point in the history
This commit covers the collection-prop, core-snapshot, migrate-replicas,
reload-core, and restore-core APIs.

Extracting annotated interfaces for these APIs includes them in the SolrRequest-
generation we now do in SolrJ
  • Loading branch information
gerlowskija committed Oct 6, 2023
1 parent 8740b07 commit 16d57e9
Show file tree
Hide file tree
Showing 31 changed files with 687 additions and 352 deletions.
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 javax.ws.rs.DELETE;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import org.apache.solr.client.api.model.SolrJerseyResponse;
import org.apache.solr.client.api.model.UpdateCollectionPropertyRequestBody;

/** V2 API definitions for modifying collection-level properties. */
@Path("/collections/{collName}/properties/{propName}")
public interface CollectionPropertyApi {
@PUT
@Operation(
summary = "Create or update a collection property",
tags = {"collection-properties"})
SolrJerseyResponse createOrUpdateCollectionProperty(
@PathParam("collName") String collName,
@PathParam("propName") String propName,
UpdateCollectionPropertyRequestBody requestBody)
throws Exception;

@DELETE
@Operation(
summary = "Delete the specified collection property from the collection",
tags = {"collection-properties"})
SolrJerseyResponse deleteCollectionProperty(
@PathParam("collName") String collName, @PathParam("propName") String propName)
throws Exception;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* 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 javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;
import org.apache.solr.client.api.model.CreateCoreSnapshotResponse;
import org.apache.solr.client.api.model.DeleteSnapshotResponse;
import org.apache.solr.client.api.model.ListCoreSnapshotsResponse;

/** V2 API definitions for Creating, Listing, and Deleting Core Snapshots. */
@Path("/cores/{coreName}/snapshots")
public interface CoreSnapshotApi {
@POST
@Path("/{snapshotName}")
@Operation(
summary = "Create a new snapshot of the specified core.",
tags = {"core-snapshots"})
CreateCoreSnapshotResponse createSnapshot(
@Parameter(description = "The name of the core to snapshot.", required = true)
@PathParam("coreName")
String coreName,
@Parameter(description = "The name to associate with the core snapshot.", required = true)
@PathParam("snapshotName")
String snapshotName,
@Parameter(description = "The id to associate with the async task.") @QueryParam("async")
String taskId)
throws Exception;

@GET
@Operation(
summary = "List existing snapshots for the specified core.",
tags = {"core-snapshots"})
ListCoreSnapshotsResponse listSnapshots(
@Parameter(
description = "The name of the core for which to retrieve snapshots.",
required = true)
@PathParam("coreName")
String coreName)
throws Exception;

@DELETE
@Path("/{snapshotName}")
@Operation(
summary = "Delete a single snapshot from the specified core.",
tags = {"core-snapshots"})
DeleteSnapshotResponse deleteSnapshot(
@Parameter(
description = "The name of the core for which to delete a snapshot.",
required = true)
@PathParam("coreName")
String coreName,
@Parameter(description = "The name of the core snapshot to delete.", required = true)
@PathParam("snapshotName")
String snapshotName,
@Parameter(description = "The id to associate with the async task.") @QueryParam("async")
String taskId)
throws Exception;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* 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.parameters.RequestBody;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import org.apache.solr.client.api.model.MigrateReplicasRequestBody;
import org.apache.solr.client.api.model.SolrJerseyResponse;

/** V2 API definition for migrating replicas from a set of nodes to another set of nodes. */
@Path("cluster/replicas/migrate")
public interface MigrateReplicasApi {
@POST
@Operation(
summary = "Migrate Replicas from a given set of nodes.",
tags = {"cluster"})
SolrJerseyResponse migrateReplicas(
@RequestBody(description = "Contains user provided parameters", required = true)
MigrateReplicasRequestBody requestBody)
throws Exception;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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.media.Schema;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import org.apache.solr.client.api.model.ReloadCoreRequestBody;
import org.apache.solr.client.api.model.SolrJerseyResponse;

/** V2 API definition for reloading an individual core. */
@Path("/cores/{coreName}/reload")
public interface ReloadCoreApi {

@POST
@Operation(
summary = "Reload the specified core.",
tags = {"cores"})
SolrJerseyResponse reloadCore(
@Parameter(description = "The name of the core to reload.", required = true)
@PathParam("coreName")
String coreName,
@Schema(description = "Additional parameters for reloading the core") @RequestBody
ReloadCoreRequestBody reloadCoreRequestBody)
throws Exception;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* 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 javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import org.apache.solr.client.api.model.RestoreCoreRequestBody;
import org.apache.solr.client.api.model.SolrJerseyResponse;

/** V2 API definition for restoring a previously taken backup to a core */
@Path("/cores/{coreName}/restore")
public interface RestoreCoreApi {

@POST
@Operation(
summary = "Restore a previously-taken backup to the specified core",
tags = {"cores"})
SolrJerseyResponse restoreCore(
@Parameter(description = "The name of the core to be restored") @PathParam("coreName")
String coreName,
RestoreCoreRequestBody requestBody)
throws Exception;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

public class Constants {

// TODO Most of these constants are also defined in various constant files in 'solrj' - we should
// move those into the 'api' module and eliminate this file.

private Constants() {
/* Private ctor prevents instantiation */
}
Expand Down Expand Up @@ -51,4 +54,8 @@ private Constants() {

/** The name of the config set to be used for a collection */
public static final String COLL_CONF = "collection.configName";

public static final String SNAPSHOT_GENERATION_NUM = "generation";

public static final String SNAPSHOT_NAME = "snapshotName";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* 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 static org.apache.solr.client.api.model.Constants.SNAPSHOT_NAME;

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

public class CreateCoreSnapshotResponse extends SolrJerseyResponse {
@Schema(description = "The name of the core.")
@JsonProperty
public String core;

@Schema(name = "commitName", description = "The name of the created snapshot.")
@JsonProperty(SNAPSHOT_NAME)
public String commitName;

@Schema(description = "The path to the directory containing the index files.")
@JsonProperty
public String indexDirPath;

@Schema(description = "The generation value for the created snapshot.")
@JsonProperty
public Long generation;

@Schema(description = "The list of index filenames contained within the created snapshot.")
@JsonProperty
public Collection<String> files;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* 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 static org.apache.solr.client.api.model.Constants.SNAPSHOT_NAME;

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

public class DeleteSnapshotResponse extends SolrJerseyResponse {
@Schema(name = "coreName", description = "The name of the core.")
@JsonProperty("core")
public String coreName;

@Schema(name = "commitName", description = "The name of the deleted snapshot.")
@JsonProperty(SNAPSHOT_NAME)
public String commitName;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* 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;

public class ListCoreSnapshotsResponse extends SolrJerseyResponse {
@Schema(description = "The collection of snapshots found for the requested core.")
@JsonProperty
public Map<String, SnapshotInformation> snapshots;
}

0 comments on commit 16d57e9

Please sign in to comment.