You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by no...@apache.org on 2020/09/24 02:53:10 UTC
[lucene-solr] branch branch_8x updated (a2dcba0 -> 7eb2961)
This is an automated email from the ASF dual-hosted git repository.
noble pushed a change to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git.
from a2dcba0 SOLR-14890: Refactor code to use annotations for configset API
new 1f26043 SOLR-14894: Use annotations to implement V2 collection APIs
new 7eb2961 SOLR-14894: ASL header
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../java/org/apache/solr/core/CoreContainer.java | 2 +
.../java/org/apache/solr/handler/ClusterAPI.java | 3 ++
.../org/apache/solr/handler/CollectionsAPI.java | 63 ++++++++++++++++++++++
.../solr/handler/admin/TestApiFramework.java | 41 ++++++++++----
.../solr/handler/admin/TestCollectionAPIs.java | 2 +
.../client/solrj/request/CollectionApiMapping.java | 10 ----
.../solrj/src/resources/apispec/cluster.nodes.json | 12 -----
.../apispec/collections.collection.delete.json | 13 -----
solr/solrj/src/resources/apispec/collections.json | 13 -----
9 files changed, 102 insertions(+), 57 deletions(-)
create mode 100644 solr/core/src/java/org/apache/solr/handler/CollectionsAPI.java
delete mode 100644 solr/solrj/src/resources/apispec/cluster.nodes.json
delete mode 100644 solr/solrj/src/resources/apispec/collections.collection.delete.json
delete mode 100644 solr/solrj/src/resources/apispec/collections.json
[lucene-solr] 01/02: SOLR-14894: Use annotations to implement V2
collection APIs
Posted by no...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
noble pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
commit 1f26043c1c2465f1e4dfcc61e7026dfe5b8b452c
Author: noblepaul <no...@gmail.com>
AuthorDate: Thu Sep 24 12:37:12 2020 +1000
SOLR-14894: Use annotations to implement V2 collection APIs
---
.../java/org/apache/solr/core/CoreContainer.java | 2 +
.../java/org/apache/solr/handler/ClusterAPI.java | 3 ++
.../org/apache/solr/handler/CollectionsAPI.java | 46 ++++++++++++++++++++++
.../solr/handler/admin/TestApiFramework.java | 41 ++++++++++++++-----
.../solr/handler/admin/TestCollectionAPIs.java | 2 +
.../client/solrj/request/CollectionApiMapping.java | 10 -----
.../solrj/src/resources/apispec/cluster.nodes.json | 12 ------
.../apispec/collections.collection.delete.json | 13 ------
solr/solrj/src/resources/apispec/collections.json | 13 ------
9 files changed, 85 insertions(+), 57 deletions(-)
diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
index 1db1543..c53ed26 100644
--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java
+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
@@ -89,6 +89,7 @@ import org.apache.solr.core.backup.repository.BackupRepository;
import org.apache.solr.core.backup.repository.BackupRepositoryFactory;
import org.apache.solr.filestore.PackageStoreAPI;
import org.apache.solr.handler.ClusterAPI;
+import org.apache.solr.handler.CollectionsAPI;
import org.apache.solr.handler.RequestHandlerBase;
import org.apache.solr.handler.SnapShooter;
import org.apache.solr.handler.admin.AutoscalingHistoryHandler;
@@ -725,6 +726,7 @@ public class CoreContainer {
createHandler(ZK_PATH, ZookeeperInfoHandler.class.getName(), ZookeeperInfoHandler.class);
createHandler(ZK_STATUS_PATH, ZookeeperStatusHandler.class.getName(), ZookeeperStatusHandler.class);
collectionsHandler = createHandler(COLLECTIONS_HANDLER_PATH, cfg.getCollectionsHandlerClass(), CollectionsHandler.class);
+ containerHandlers.getApiBag().registerObject(new CollectionsAPI(collectionsHandler));
configSetsHandler = createHandler(CONFIGSETS_HANDLER_PATH, cfg.getConfigSetsHandlerClass(), ConfigSetsHandler.class);
ClusterAPI clusterAPI = new ClusterAPI(collectionsHandler, configSetsHandler);
containerHandlers.getApiBag().registerObject(clusterAPI);
diff --git a/solr/core/src/java/org/apache/solr/handler/ClusterAPI.java b/solr/core/src/java/org/apache/solr/handler/ClusterAPI.java
index 0a90ae2..ca16ede 100644
--- a/solr/core/src/java/org/apache/solr/handler/ClusterAPI.java
+++ b/solr/core/src/java/org/apache/solr/handler/ClusterAPI.java
@@ -54,6 +54,9 @@ import static org.apache.solr.security.PermissionNameProvider.Name.COLL_READ_PER
import static org.apache.solr.security.PermissionNameProvider.Name.CONFIG_EDIT_PERM;
import static org.apache.solr.security.PermissionNameProvider.Name.CONFIG_READ_PERM;
+/** All V2 APIs that have a prefix of /api/cluster/
+ *
+ */
public class ClusterAPI {
private final CollectionsHandler collectionsHandler;
private final ConfigSetsHandler configSetsHandler;
diff --git a/solr/core/src/java/org/apache/solr/handler/CollectionsAPI.java b/solr/core/src/java/org/apache/solr/handler/CollectionsAPI.java
new file mode 100644
index 0000000..61ceffa
--- /dev/null
+++ b/solr/core/src/java/org/apache/solr/handler/CollectionsAPI.java
@@ -0,0 +1,46 @@
+package org.apache.solr.handler;
+
+import org.apache.solr.api.EndPoint;
+import org.apache.solr.common.cloud.ZkStateReader;
+import org.apache.solr.common.params.CollectionParams.CollectionAction;
+import org.apache.solr.handler.admin.CollectionsHandler;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+
+import static org.apache.solr.client.solrj.SolrRequest.METHOD.DELETE;
+import static org.apache.solr.client.solrj.SolrRequest.METHOD.GET;
+import static org.apache.solr.common.params.CommonParams.NAME;
+import static org.apache.solr.security.PermissionNameProvider.Name.COLL_EDIT_PERM;
+import static org.apache.solr.security.PermissionNameProvider.Name.COLL_READ_PERM;
+
+/**
+ * All V2 APIs for collection management
+ *
+ */
+public class CollectionsAPI {
+
+ private final CollectionsHandler collectionsHandler;
+
+ public CollectionsAPI(CollectionsHandler collectionsHandler) {
+ this.collectionsHandler = collectionsHandler;
+ }
+
+ @EndPoint(
+ path = {"/c", "/collections"},
+ method = GET,
+ permission = COLL_READ_PERM)
+ public void getCollections(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
+ CollectionsHandler.CollectionOperation.LIST_OP.execute(req, rsp, collectionsHandler);
+ }
+
+ @EndPoint(path = {"/c/{collection}", "/collections/{collection}"},
+ method = DELETE,
+ permission = COLL_EDIT_PERM)
+ public void deleteCollection(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
+ req = ClusterAPI.wrapParams(req, "action",
+ CollectionAction.DELETE.toString(),
+ NAME, req.getPathTemplateValues().get(ZkStateReader.COLLECTION_PROP));
+ collectionsHandler.handleRequestBody(req, rsp);
+ }
+
+}
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/TestApiFramework.java b/solr/core/src/test/org/apache/solr/handler/admin/TestApiFramework.java
index 55ce63b..bfa9eae 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/TestApiFramework.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/TestApiFramework.java
@@ -17,17 +17,41 @@
package org.apache.solr.handler.admin;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
import org.apache.solr.SolrTestCaseJ4;
-import org.apache.solr.api.*;
+import org.apache.solr.api.Api;
+import org.apache.solr.api.ApiBag;
+import org.apache.solr.api.Command;
+import org.apache.solr.api.EndPoint;
+import org.apache.solr.api.PayloadObj;
+import org.apache.solr.api.V2HttpCall;
import org.apache.solr.api.V2HttpCall.CompositeApi;
import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.common.annotation.JsonProperty;
import org.apache.solr.common.params.MapSolrParams;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.SolrParams;
-import org.apache.solr.common.util.*;
+import org.apache.solr.common.util.CommandOperation;
+import org.apache.solr.common.util.ContentStream;
+import org.apache.solr.common.util.ContentStreamBase;
+import org.apache.solr.common.util.JsonSchemaValidator;
+import org.apache.solr.common.util.PathTrie;
+import org.apache.solr.common.util.ReflectMapWriter;
+import org.apache.solr.common.util.StrUtils;
+import org.apache.solr.common.util.Utils;
+import org.apache.solr.common.util.ValidatingJsonMap;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.PluginBag;
+import org.apache.solr.handler.CollectionsAPI;
import org.apache.solr.handler.PingRequestHandler;
import org.apache.solr.handler.SchemaHandler;
import org.apache.solr.handler.SolrConfigHandler;
@@ -38,16 +62,13 @@ import org.apache.solr.request.SolrRequestHandler;
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.security.PermissionNameProvider;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.*;
-
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.solr.api.ApiBag.EMPTY_SPEC;
import static org.apache.solr.client.solrj.SolrRequest.METHOD.GET;
import static org.apache.solr.client.solrj.SolrRequest.METHOD.POST;
-import static org.apache.solr.common.params.CommonParams.*;
+import static org.apache.solr.common.params.CommonParams.COLLECTIONS_HANDLER_PATH;
+import static org.apache.solr.common.params.CommonParams.CONFIGSETS_HANDLER_PATH;
+import static org.apache.solr.common.params.CommonParams.CORES_HANDLER_PATH;
import static org.apache.solr.common.util.ValidatingJsonMap.NOT_NULL;
public class TestApiFramework extends SolrTestCaseJ4 {
@@ -57,7 +78,9 @@ public class TestApiFramework extends SolrTestCaseJ4 {
Map<String, Object> out = new HashMap<>();
CoreContainer mockCC = TestCoreAdminApis.getCoreContainerMock(calls, out);
PluginBag<SolrRequestHandler> containerHandlers = new PluginBag<>(SolrRequestHandler.class, null, false);
- containerHandlers.put(COLLECTIONS_HANDLER_PATH, new TestCollectionAPIs.MockCollectionsHandler());
+ TestCollectionAPIs.MockCollectionsHandler collectionsHandler = new TestCollectionAPIs.MockCollectionsHandler();
+ containerHandlers.put(COLLECTIONS_HANDLER_PATH, collectionsHandler);
+ containerHandlers.getApiBag().registerObject(new CollectionsAPI(collectionsHandler));
containerHandlers.put(CORES_HANDLER_PATH, new CoreAdminHandler(mockCC));
containerHandlers.put(CONFIGSETS_HANDLER_PATH, new ConfigSetsHandler(mockCC));
out.put("getRequestHandlers", containerHandlers);
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/TestCollectionAPIs.java b/solr/core/src/test/org/apache/solr/handler/admin/TestCollectionAPIs.java
index d32097f..0518c77 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/TestCollectionAPIs.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/TestCollectionAPIs.java
@@ -41,6 +41,7 @@ import org.apache.solr.common.util.Pair;
import org.apache.solr.common.util.Utils;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.handler.ClusterAPI;
+import org.apache.solr.handler.CollectionsAPI;
import org.apache.solr.request.LocalSolrQueryRequest;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.SolrQueryResponse;
@@ -83,6 +84,7 @@ public class TestCollectionAPIs extends SolrTestCaseJ4 {
ApiBag apiBag;
try (MockCollectionsHandler collectionsHandler = new MockCollectionsHandler()) {
apiBag = new ApiBag(false);
+ apiBag.registerObject(new CollectionsAPI(collectionsHandler));
Collection<Api> apis = collectionsHandler.getApis();
for (Api api : apis) apiBag.register(api, Collections.emptyMap());
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionApiMapping.java b/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionApiMapping.java
index 91227e0..9b106ab 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionApiMapping.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionApiMapping.java
@@ -38,7 +38,6 @@ import static org.apache.solr.client.solrj.SolrRequest.METHOD.DELETE;
import static org.apache.solr.client.solrj.SolrRequest.METHOD.GET;
import static org.apache.solr.client.solrj.SolrRequest.METHOD.POST;
import static org.apache.solr.client.solrj.request.CollectionApiMapping.EndPoint.CLUSTER_ALIASES;
-import static org.apache.solr.client.solrj.request.CollectionApiMapping.EndPoint.COLLECTIONS;
import static org.apache.solr.client.solrj.request.CollectionApiMapping.EndPoint.COLLECTIONS_COMMANDS;
import static org.apache.solr.client.solrj.request.CollectionApiMapping.EndPoint.COLLECTION_STATE;
import static org.apache.solr.client.solrj.request.CollectionApiMapping.EndPoint.PER_COLLECTION;
@@ -56,7 +55,6 @@ import static org.apache.solr.common.params.CommonParams.NAME;
public class CollectionApiMapping {
public enum Meta implements CommandMeta {
- GET_COLLECTIONS(COLLECTIONS, GET, LIST),
GET_A_COLLECTION(COLLECTION_STATE, GET, CLUSTERSTATUS),
LIST_ALIASES(CLUSTER_ALIASES, GET, LISTALIASES),
CREATE_COLLECTION(COLLECTIONS_COMMANDS,
@@ -70,12 +68,6 @@ public class CollectionApiMapping {
),
Utils.makeMap("property.", "properties.")),
- DELETE_COLL(EndPoint.PER_COLLECTION_DELETE,
- DELETE,
- CollectionAction.DELETE,
- CollectionAction.DELETE.toLower(),
- Utils.makeMap(NAME, "collection")),
-
RELOAD_COLL(PER_COLLECTION,
POST,
RELOAD,
@@ -313,10 +305,8 @@ public class CollectionApiMapping {
public enum EndPoint implements V2EndPoint {
CLUSTER_ALIASES("cluster.aliases"),
COLLECTIONS_COMMANDS("collections.Commands"),
- COLLECTIONS("collections"),
COLLECTION_STATE("collections.collection"),
PER_COLLECTION("collections.collection.Commands"),
- PER_COLLECTION_DELETE("collections.collection.delete"),
PER_COLLECTION_SHARDS_COMMANDS("collections.collection.shards.Commands"),
PER_COLLECTION_PER_SHARD_COMMANDS("collections.collection.shards.shard.Commands"),
PER_COLLECTION_PER_SHARD_DELETE("collections.collection.shards.shard.delete"),
diff --git a/solr/solrj/src/resources/apispec/cluster.nodes.json b/solr/solrj/src/resources/apispec/cluster.nodes.json
deleted file mode 100644
index 0dd474d..0000000
--- a/solr/solrj/src/resources/apispec/cluster.nodes.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "documentation": "https://lucene.apache.org/solr/guide/cluster-node-management.html",
- "description": "Provides general information about the available nodes of the cluster.",
- "methods": [
- "GET"
- ],
- "url": {
- "paths": [
- "/cluster/nodes"
- ]
- }
-}
diff --git a/solr/solrj/src/resources/apispec/collections.collection.delete.json b/solr/solrj/src/resources/apispec/collections.collection.delete.json
deleted file mode 100644
index 2e38c0f..0000000
--- a/solr/solrj/src/resources/apispec/collections.collection.delete.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "documentation": "https://lucene.apache.org/solr/guide/collection-management.html#delete",
- "description": "Deletes a collection.",
- "methods": [
- "DELETE"
- ],
- "url": {
- "paths": [
- "/collections/{collection}",
- "/c/{collection}"
- ]
- }
-}
diff --git a/solr/solrj/src/resources/apispec/collections.json b/solr/solrj/src/resources/apispec/collections.json
deleted file mode 100644
index 10b91ab..0000000
--- a/solr/solrj/src/resources/apispec/collections.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "documentation": "https://lucene.apache.org/solr/guide/collection-management.html#list",
- "description": "List all available collections and their properties.",
- "methods": [
- "GET"
- ],
- "url": {
- "paths": [
- "/collections",
- "/c"
- ]
- }
-}
[lucene-solr] 02/02: SOLR-14894: ASL header
Posted by no...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
noble pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
commit 7eb2961590fa555d063f425bd8d47ea34bbfd17b
Author: noblepaul <no...@gmail.com>
AuthorDate: Thu Sep 24 12:40:05 2020 +1000
SOLR-14894: ASL header
---
.../java/org/apache/solr/handler/CollectionsAPI.java | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/solr/core/src/java/org/apache/solr/handler/CollectionsAPI.java b/solr/core/src/java/org/apache/solr/handler/CollectionsAPI.java
index 61ceffa..e02e5f2 100644
--- a/solr/core/src/java/org/apache/solr/handler/CollectionsAPI.java
+++ b/solr/core/src/java/org/apache/solr/handler/CollectionsAPI.java
@@ -1,3 +1,20 @@
+/*
+ * 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.handler;
import org.apache.solr.api.EndPoint;