You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ge...@apache.org on 2022/10/20 18:44:58 UTC
[solr] branch main updated: SOLR-16459: Remove 'invoke' /admin/cores command (#1085)
This is an automated email from the ASF dual-hosted git repository.
gerlowskija pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/main by this push:
new a088a91e961 SOLR-16459: Remove 'invoke' /admin/cores command (#1085)
a088a91e961 is described below
commit a088a91e9613d8767f3e741832577686bbaf0abf
Author: Jason Gerlowski <ge...@apache.org>
AuthorDate: Thu Oct 20 14:44:52 2022 -0400
SOLR-16459: Remove 'invoke' /admin/cores command (#1085)
Previously added in support of a feature that has since been deprecated
and removed, this internal API can be ripped out without fear of
backcompat violation.
---
.../solr/handler/admin/CoreAdminHandler.java | 6 --
.../solr/handler/admin/CoreAdminOperation.java | 2 -
.../org/apache/solr/handler/admin/InvokeOp.java | 57 -------------------
.../solr/handler/admin/api/InvokeClassAPI.java | 65 ----------------------
.../solr/handler/admin/CoreAdminOperationTest.java | 19 -------
.../handler/admin/api/V2NodeAPIMappingTest.java | 20 -------
.../solrj/request/beans/InvokeClassPayload.java | 28 ----------
.../apache/solr/common/params/CoreAdminParams.java | 1 -
8 files changed, 198 deletions(-)
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
index 0b44aa85b9d..767943a4589 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
@@ -55,7 +55,6 @@ import org.apache.solr.core.CoreDescriptor;
import org.apache.solr.handler.RequestHandlerBase;
import org.apache.solr.handler.admin.api.AllCoresStatusAPI;
import org.apache.solr.handler.admin.api.CreateCoreAPI;
-import org.apache.solr.handler.admin.api.InvokeClassAPI;
import org.apache.solr.handler.admin.api.MergeIndexesAPI;
import org.apache.solr.handler.admin.api.OverseerOperationAPI;
import org.apache.solr.handler.admin.api.PrepareCoreRecoveryAPI;
@@ -459,7 +458,6 @@ public class CoreAdminHandler extends RequestHandlerBase implements PermissionNa
apis.addAll(AnnotatedApi.getApis(new AllCoresStatusAPI(this)));
apis.addAll(AnnotatedApi.getApis(new SingleCoreStatusAPI(this)));
apis.addAll(AnnotatedApi.getApis(new CreateCoreAPI(this)));
- apis.addAll(AnnotatedApi.getApis(new InvokeClassAPI(this)));
apis.addAll(AnnotatedApi.getApis(new RejoinLeaderElectionAPI(this)));
apis.addAll(AnnotatedApi.getApis(new OverseerOperationAPI(this)));
apis.addAll(AnnotatedApi.getApis(new ReloadCoreAPI(this)));
@@ -483,10 +481,6 @@ public class CoreAdminHandler extends RequestHandlerBase implements PermissionNa
for (CoreAdminOperation op : CoreAdminOperation.values())
opMap.put(op.action.toString().toLowerCase(Locale.ROOT), op);
}
- /** used by the INVOKE action of core admin handler */
- public interface Invocable {
- Map<String, Object> invoke(SolrQueryRequest req);
- }
public interface CoreAdminOp {
/**
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminOperation.java b/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminOperation.java
index fea8f9124f9..75dfa9f137a 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminOperation.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminOperation.java
@@ -22,7 +22,6 @@ import static org.apache.solr.common.params.CoreAdminParams.CoreAdminAction.BACK
import static org.apache.solr.common.params.CoreAdminParams.CoreAdminAction.CREATE;
import static org.apache.solr.common.params.CoreAdminParams.CoreAdminAction.CREATESNAPSHOT;
import static org.apache.solr.common.params.CoreAdminParams.CoreAdminAction.DELETESNAPSHOT;
-import static org.apache.solr.common.params.CoreAdminParams.CoreAdminAction.INVOKE;
import static org.apache.solr.common.params.CoreAdminParams.CoreAdminAction.LISTSNAPSHOTS;
import static org.apache.solr.common.params.CoreAdminParams.CoreAdminAction.MERGEINDEXES;
import static org.apache.solr.common.params.CoreAdminParams.CoreAdminAction.OVERSEEROP;
@@ -268,7 +267,6 @@ public enum CoreAdminOperation implements CoreAdminOp {
"zkController is null in CoreAdminHandler.handleRequestInternal:REJOINLEADERELECTION. No action taken.");
}
}),
- INVOKE_OP(INVOKE, new InvokeOp()),
BACKUPCORE_OP(BACKUPCORE, new BackupCoreOp()),
RESTORECORE_OP(RESTORECORE, new RestoreCoreOp()),
CREATESNAPSHOT_OP(CREATESNAPSHOT, new CreateSnapshotOp()),
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/InvokeOp.java b/solr/core/src/java/org/apache/solr/handler/admin/InvokeOp.java
deleted file mode 100644
index 85201016dc4..00000000000
--- a/solr/core/src/java/org/apache/solr/handler/admin/InvokeOp.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.admin;
-
-import java.lang.invoke.MethodHandles;
-import java.util.Map;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.core.CoreContainer;
-import org.apache.solr.core.SolrResourceLoader;
-import org.apache.solr.request.SolrQueryRequest;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-class InvokeOp implements CoreAdminHandler.CoreAdminOp {
- private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
-
- static Map<String, Object> invokeAClass(SolrQueryRequest req, String c) {
- SolrResourceLoader loader = null;
- if (req.getCore() != null) loader = req.getCore().getResourceLoader();
- else if (req.getContext().get(CoreContainer.class.getName()) != null) {
- CoreContainer cc = (CoreContainer) req.getContext().get(CoreContainer.class.getName());
- loader = cc.getResourceLoader();
- }
-
- CoreAdminHandler.Invocable invokable = loader.newInstance(c, CoreAdminHandler.Invocable.class);
- Map<String, Object> result = invokable.invoke(req);
- log.info("Invocable_invoked {}", result);
- return result;
- }
-
- @Override
- public void execute(CoreAdminHandler.CallInfo it) throws Exception {
- String[] klas = it.req.getParams().getParams("class");
- if (klas == null || klas.length == 0) {
- throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "class is a required param");
- }
- for (String c : klas) {
- Map<String, Object> result = invokeAClass(it.req, c);
- it.rsp.add(c, result);
- }
- }
-}
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/api/InvokeClassAPI.java b/solr/core/src/java/org/apache/solr/handler/admin/api/InvokeClassAPI.java
deleted file mode 100644
index d652cbf07d5..00000000000
--- a/solr/core/src/java/org/apache/solr/handler/admin/api/InvokeClassAPI.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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.admin.api;
-
-import static org.apache.solr.client.solrj.SolrRequest.METHOD.POST;
-import static org.apache.solr.common.params.CoreAdminParams.ACTION;
-import static org.apache.solr.common.params.CoreAdminParams.CoreAdminAction.INVOKE;
-import static org.apache.solr.security.PermissionNameProvider.Name.CORE_EDIT_PERM;
-
-import java.util.Locale;
-import org.apache.solr.api.Command;
-import org.apache.solr.api.EndPoint;
-import org.apache.solr.api.PayloadObj;
-import org.apache.solr.client.solrj.request.beans.InvokeClassPayload;
-import org.apache.solr.common.params.ModifiableSolrParams;
-import org.apache.solr.handler.admin.CoreAdminHandler;
-
-/**
- * V2 API for triggering "invocable" classes.
- *
- * <p>This API (POST /v2/node {'invoke': {...}}) is analogous to the v1 /admin/cores?action=INVOKE
- * command.
- */
-@EndPoint(
- path = {"/node"},
- method = POST,
- permission = CORE_EDIT_PERM)
-public class InvokeClassAPI {
- public static final String INVOKE_CMD = "invoke";
-
- private final CoreAdminHandler coreAdminHandler;
-
- public InvokeClassAPI(CoreAdminHandler coreAdminHandler) {
- this.coreAdminHandler = coreAdminHandler;
- }
-
- @Command(name = INVOKE_CMD)
- public void invokeClasses(PayloadObj<InvokeClassPayload> payload) throws Exception {
- final InvokeClassPayload v2Body = payload.get();
- final ModifiableSolrParams v1Params =
- new ModifiableSolrParams(payload.getRequest().getParams());
- v1Params.add(ACTION, INVOKE.name().toLowerCase(Locale.ROOT));
- for (String clazzStr : v2Body.classes) {
- v1Params.add("class", clazzStr);
- }
-
- payload.getRequest().setParams(v1Params);
- coreAdminHandler.handleRequestBody(payload.getRequest(), payload.getResponse());
- }
-}
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminOperationTest.java b/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminOperationTest.java
index 384b78c9487..476c685f116 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminOperationTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminOperationTest.java
@@ -359,25 +359,6 @@ public class CoreAdminOperationTest extends SolrTestCaseJ4 {
assertSolrExceptionWithCode(ex, ErrorCode.SERVER_ERROR.code);
}
- @Test
- public void testInvokeUnexpectedFailuresResultIn500Exception() {
- final Throwable cause = new NullPointerException();
- whenUnexpectedErrorOccursDuringCoreAdminOp(cause);
-
- Exception ex =
- expectThrows(Exception.class, () -> CoreAdminOperation.INVOKE_OP.execute(callInfo));
- assertSolrExceptionWithCodeAndCause(ex, ErrorCode.SERVER_ERROR.code, cause);
- }
-
- @Test
- public void testInvokeMissingClassParamResultsIn400SolrException() {
- whenCoreAdminOpHasParams(Maps.newHashMap());
-
- Exception ex =
- expectThrows(Exception.class, () -> CoreAdminOperation.INVOKE_OP.execute(callInfo));
- assertSolrExceptionWithCode(ex, ErrorCode.BAD_REQUEST.code);
- }
-
@Test
public void testBackupUnexpectedFailuresResultIn500Exception() {
final Throwable cause = new NullPointerException();
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/api/V2NodeAPIMappingTest.java b/solr/core/src/test/org/apache/solr/handler/admin/api/V2NodeAPIMappingTest.java
index fb133c63297..23e2702e3af 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/api/V2NodeAPIMappingTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/api/V2NodeAPIMappingTest.java
@@ -24,7 +24,6 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.google.common.collect.Maps;
-import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -132,24 +131,6 @@ public class V2NodeAPIMappingTest extends SolrTestCaseJ4 {
assertEquals("true", v1Params.get("rejoinAtHead"));
}
- @Test
- public void testInvokeClassApiAllProperties() throws Exception {
- final SolrParams v1Params =
- captureConvertedCoreV1Params(
- "/node",
- "POST",
- "{"
- + "\"invoke\": {"
- + "\"classes\": [\"someClassName\", \"someOtherClassName\"]"
- + "}}");
-
- assertEquals("invoke", v1Params.get(ACTION));
- assertEquals(2, v1Params.getParams("class").length);
- final List<String> classes = Arrays.asList(v1Params.getParams("class"));
- assertTrue(classes.contains("someClassName"));
- assertTrue(classes.contains("someOtherClassName"));
- }
-
@Test
public void testSystemPropsApiAllProperties() throws Exception {
final ModifiableSolrParams solrParams = new ModifiableSolrParams();
@@ -286,7 +267,6 @@ public class V2NodeAPIMappingTest extends SolrTestCaseJ4 {
ApiBag apiBag, CoreAdminHandler coreHandler, InfoHandler infoHandler) {
apiBag.registerObject(new OverseerOperationAPI(coreHandler));
apiBag.registerObject(new RejoinLeaderElectionAPI(coreHandler));
- apiBag.registerObject(new InvokeClassAPI(coreHandler));
apiBag.registerObject(new NodePropertiesAPI(infoHandler.getPropertiesHandler()));
apiBag.registerObject(new NodeThreadsAPI(infoHandler.getThreadDumpHandler()));
apiBag.registerObject(new NodeLoggingAPI(infoHandler.getLoggingHandler()));
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/request/beans/InvokeClassPayload.java b/solr/solrj/src/java/org/apache/solr/client/solrj/request/beans/InvokeClassPayload.java
deleted file mode 100644
index 5f5eb25d191..00000000000
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/request/beans/InvokeClassPayload.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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.solrj.request.beans;
-
-import java.util.List;
-import org.apache.solr.common.annotation.JsonProperty;
-import org.apache.solr.common.util.ReflectMapWriter;
-
-public class InvokeClassPayload implements ReflectMapWriter {
-
- @JsonProperty(required = true)
- public List<String> classes;
-}
diff --git a/solr/solrj/src/java/org/apache/solr/common/params/CoreAdminParams.java b/solr/solrj/src/java/org/apache/solr/common/params/CoreAdminParams.java
index b019a1effcc..015d276d1cf 100644
--- a/solr/solrj/src/java/org/apache/solr/common/params/CoreAdminParams.java
+++ b/solr/solrj/src/java/org/apache/solr/common/params/CoreAdminParams.java
@@ -173,7 +173,6 @@ public abstract class CoreAdminParams {
REJOINLEADERELECTION,
// internal API used by force shard leader election
FORCEPREPAREFORLEADERSHIP,
- INVOKE,
// Internal APIs to backup and restore a core
BACKUPCORE,
RESTORECORE,