You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2020/04/14 13:32:30 UTC
[GitHub] [lucene-solr] noblepaul opened a new pull request #1432: SOLR-14404
CoreContainer level custom requesthandlers
noblepaul opened a new pull request #1432: SOLR-14404 CoreContainer level custom requesthandlers
URL: https://github.com/apache/lucene-solr/pull/1432
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] madrob commented on a change in pull request #1432:
SOLR-14404 CoreContainer level custom requesthandlers
Posted by GitBox <gi...@apache.org>.
madrob commented on a change in pull request #1432: SOLR-14404 CoreContainer level custom requesthandlers
URL: https://github.com/apache/lucene-solr/pull/1432#discussion_r409693320
##########
File path: solr/core/src/test/org/apache/solr/handler/TestContainerPlugin.java
##########
@@ -0,0 +1,250 @@
+/*
+ * 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 java.io.IOException;
+import java.util.List;
+import java.util.concurrent.Callable;
+
+import com.google.common.collect.ImmutableMap;
+import org.apache.solr.api.Command;
+import org.apache.solr.api.EndPoint;
+import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.impl.BaseHttpSolrClient;
+import org.apache.solr.client.solrj.request.V2Request;
+import org.apache.solr.client.solrj.request.beans.Package;
+import org.apache.solr.client.solrj.request.beans.PluginMeta;
+import org.apache.solr.client.solrj.response.V2Response;
+import org.apache.solr.cloud.MiniSolrCloudCluster;
+import org.apache.solr.cloud.SolrCloudTestCase;
+import org.apache.solr.common.NavigableObject;
+import org.apache.solr.common.util.Utils;
+import org.apache.solr.filestore.PackageStoreAPI;
+import org.apache.solr.filestore.TestDistribPackageStore;
+import org.apache.solr.pkg.TestPackages;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.security.PermissionNameProvider;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static java.util.Collections.singletonMap;
+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.filestore.TestDistribPackageStore.readFile;
+import static org.apache.solr.filestore.TestDistribPackageStore.uploadKey;
+import static org.hamcrest.CoreMatchers.containsString;
+
+public class TestContainerPlugin extends SolrCloudTestCase {
+
+ @Before
+ public void setup() {
+ System.setProperty("enable.packages", "true");
+ }
+
+ @After
+ public void teardown() {
+ System.clearProperty("enable.packages");
+ }
+
+ @Test
+ public void testApi() throws Exception {
+ MiniSolrCloudCluster cluster =
+ configureCluster(4)
+ .withJettyConfig(jetty -> jetty.enableV2(true))
+ .configure();
+ String errPath = "/error/details[0]/errorMessages[0]";
+ try {
+ PluginMeta plugin = new PluginMeta();
+ plugin.name = "testplugin";
+ plugin.klass = C2.class.getName();
+ V2Request req = new V2Request.Builder("/cluster/plugin")
+ .forceV2(true)
+ .withMethod(POST)
+ .withPayload(singletonMap("add", plugin))
+ .build();
+ expectError(req, cluster.getSolrClient(), errPath, "Must have a no-arg constructor or CoreContainer constructor and it must not be a non static inner class");
+
+ plugin.klass = C1.class.getName();
+ expectError(req, cluster.getSolrClient(), errPath, "Invalid class, no @EndPoint annotation");
+
+ plugin.klass = C3.class.getName();
+ req.process(cluster.getSolrClient());
+
+ V2Response rsp = new V2Request.Builder("/cluster/plugin")
+ .forceV2(true)
+ .withMethod(GET)
+ .build()
+ .process(cluster.getSolrClient());
+ assertEquals(C3.class.getName(), rsp._getStr("/plugin/testplugin/class", null));
+
+ TestDistribPackageStore.assertResponseValues(10,
+ () -> new V2Request.Builder("/plugin/my/plugin")
+ .forceV2(true)
+ .withMethod(GET)
+ .build().process(cluster.getSolrClient()),
+ ImmutableMap.of("/testkey", "testval"));
+
+ new V2Request.Builder("/cluster/plugin")
+ .withMethod(POST)
+ .forceV2(true)
+ .withPayload("{remove : testplugin}")
+ .build()
+ .process(cluster.getSolrClient());
+
+ rsp = new V2Request.Builder("/cluster/plugin")
+ .forceV2(true)
+ .withMethod(GET)
+ .build()
+ .process(cluster.getSolrClient());
+ assertEquals(null, rsp._get("/plugin/testplugin/class", null));
+
+ } finally {
+ cluster.shutdown();
+ }
+ }
+ @Test
+ public void testApiFromPackage() throws Exception {
Review comment:
this is a fairly long test and was somewhat hard to follow, can we break it up into smaller pieces?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] madrob commented on a change in pull request #1432:
SOLR-14404 CoreContainer level custom requesthandlers
Posted by GitBox <gi...@apache.org>.
madrob commented on a change in pull request #1432: SOLR-14404 CoreContainer level custom requesthandlers
URL: https://github.com/apache/lucene-solr/pull/1432#discussion_r409690893
##########
File path: solr/core/src/test/org/apache/solr/handler/admin/TestApiFramework.java
##########
@@ -199,6 +200,25 @@ public void testPayload() {
}
+ public void testApiWrapper() {
+ Class<ApiWithConstructor> klas = ApiWithConstructor.class;
Review comment:
unclear what this test is testing
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] madrob commented on a change in pull request #1432:
SOLR-14404 CoreContainer level custom requesthandlers
Posted by GitBox <gi...@apache.org>.
madrob commented on a change in pull request #1432: SOLR-14404 CoreContainer level custom requesthandlers
URL: https://github.com/apache/lucene-solr/pull/1432#discussion_r409676264
##########
File path: solr/core/src/java/org/apache/solr/api/ApiBag.java
##########
@@ -134,6 +142,14 @@ static void registerIntrospect(List<String> l, PathTrie<Api> registry, Map<Strin
registry.insert(copy, substitutes, introspect);
}
+ public Api unregister(SolrRequest.METHOD method, String path) {
Review comment:
Should this be synchronized to match `register`?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] madrob commented on a change in pull request #1432:
SOLR-14404 CoreContainer level custom requesthandlers
Posted by GitBox <gi...@apache.org>.
madrob commented on a change in pull request #1432: SOLR-14404 CoreContainer level custom requesthandlers
URL: https://github.com/apache/lucene-solr/pull/1432#discussion_r409691926
##########
File path: solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpSolrClient.java
##########
@@ -62,6 +63,9 @@ public static RemoteExecutionException create(String host, NamedList errResponse
if (errObj != null) {
Number code = (Number) getObjectByPath(errObj, true, Collections.singletonList("code"));
String msg = (String) getObjectByPath(errObj, true, Collections.singletonList("msg"));
+ if(msg == null) msg = "";
Review comment:
There's already a null check later, what kinds of messages do we get here that are useful and don't leak too much internals?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] madrob commented on a change in pull request #1432:
SOLR-14404 CoreContainer level custom requesthandlers
Posted by GitBox <gi...@apache.org>.
madrob commented on a change in pull request #1432: SOLR-14404 CoreContainer level custom requesthandlers
URL: https://github.com/apache/lucene-solr/pull/1432#discussion_r409685318
##########
File path: solr/core/src/test-files/runtimecode/sig.txt
##########
@@ -69,6 +69,14 @@ openssl dgst -sha1 -sign ../cryptokeys/priv_key512.pem expressible.jar.bin | ope
ZOT11arAiPmPZYOHzqodiNnxO9pRyRozWZEBX8XGjU1/HJptFnZK+DI7eXnUtbNaMcbXE2Ze8hh4M/eGyhY8BQ==
+openssl dgst -sha1 -sign priv_key512.pem containerplugin.v.1.jar.bin | openssl enc -base64 | sed 's/+/%2B/g' | tr -d \\n | sed
Review comment:
Does this need to be `../cryptokeys/priv_key512.pem`?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] madrob commented on a change in pull request #1432:
SOLR-14404 CoreContainer level custom requesthandlers
Posted by GitBox <gi...@apache.org>.
madrob commented on a change in pull request #1432: SOLR-14404 CoreContainer level custom requesthandlers
URL: https://github.com/apache/lucene-solr/pull/1432#discussion_r409688568
##########
File path: solr/core/src/test/org/apache/solr/handler/TestContainerPlugin.java
##########
@@ -0,0 +1,250 @@
+/*
+ * 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 java.io.IOException;
+import java.util.List;
+import java.util.concurrent.Callable;
+
+import com.google.common.collect.ImmutableMap;
+import org.apache.solr.api.Command;
+import org.apache.solr.api.EndPoint;
+import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.impl.BaseHttpSolrClient;
+import org.apache.solr.client.solrj.request.V2Request;
+import org.apache.solr.client.solrj.request.beans.Package;
+import org.apache.solr.client.solrj.request.beans.PluginMeta;
+import org.apache.solr.client.solrj.response.V2Response;
+import org.apache.solr.cloud.MiniSolrCloudCluster;
+import org.apache.solr.cloud.SolrCloudTestCase;
+import org.apache.solr.common.NavigableObject;
+import org.apache.solr.common.util.Utils;
+import org.apache.solr.filestore.PackageStoreAPI;
+import org.apache.solr.filestore.TestDistribPackageStore;
+import org.apache.solr.pkg.TestPackages;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.security.PermissionNameProvider;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static java.util.Collections.singletonMap;
+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.filestore.TestDistribPackageStore.readFile;
+import static org.apache.solr.filestore.TestDistribPackageStore.uploadKey;
+import static org.hamcrest.CoreMatchers.containsString;
+
+public class TestContainerPlugin extends SolrCloudTestCase {
+
+ @Before
+ public void setup() {
+ System.setProperty("enable.packages", "true");
+ }
+
+ @After
+ public void teardown() {
+ System.clearProperty("enable.packages");
+ }
+
+ @Test
+ public void testApi() throws Exception {
+ MiniSolrCloudCluster cluster =
+ configureCluster(4)
+ .withJettyConfig(jetty -> jetty.enableV2(true))
+ .configure();
+ String errPath = "/error/details[0]/errorMessages[0]";
+ try {
+ PluginMeta plugin = new PluginMeta();
+ plugin.name = "testplugin";
+ plugin.klass = C2.class.getName();
+ V2Request req = new V2Request.Builder("/cluster/plugin")
+ .forceV2(true)
+ .withMethod(POST)
+ .withPayload(singletonMap("add", plugin))
+ .build();
+ expectError(req, cluster.getSolrClient(), errPath, "Must have a no-arg constructor or CoreContainer constructor and it must not be a non static inner class");
+
+ plugin.klass = C1.class.getName();
+ expectError(req, cluster.getSolrClient(), errPath, "Invalid class, no @EndPoint annotation");
+
+ plugin.klass = C3.class.getName();
+ req.process(cluster.getSolrClient());
+
+ V2Response rsp = new V2Request.Builder("/cluster/plugin")
+ .forceV2(true)
+ .withMethod(GET)
+ .build()
+ .process(cluster.getSolrClient());
+ assertEquals(C3.class.getName(), rsp._getStr("/plugin/testplugin/class", null));
+
+ TestDistribPackageStore.assertResponseValues(10,
+ () -> new V2Request.Builder("/plugin/my/plugin")
+ .forceV2(true)
+ .withMethod(GET)
+ .build().process(cluster.getSolrClient()),
+ ImmutableMap.of("/testkey", "testval"));
+
+ new V2Request.Builder("/cluster/plugin")
+ .withMethod(POST)
+ .forceV2(true)
+ .withPayload("{remove : testplugin}")
+ .build()
+ .process(cluster.getSolrClient());
+
+ rsp = new V2Request.Builder("/cluster/plugin")
+ .forceV2(true)
+ .withMethod(GET)
+ .build()
+ .process(cluster.getSolrClient());
+ assertEquals(null, rsp._get("/plugin/testplugin/class", null));
+
+ } finally {
+ cluster.shutdown();
+ }
+ }
+ @Test
+ public void testApiFromPackage() throws Exception {
+ MiniSolrCloudCluster cluster =
+ configureCluster(4)
+ .withJettyConfig(jetty -> jetty.enableV2(true))
+ .configure();
+ String FILE1 = "/myplugin/v1.jar";
+ String FILE2 = "/myplugin/v2.jar";
+
+ String errPath = "/error/details[0]/errorMessages[0]";
+ try {
+ byte[] derFile = readFile("cryptokeys/pub_key512.der");
+ uploadKey(derFile, PackageStoreAPI.KEYS_DIR+"/pub_key512.der", cluster);
+ TestPackages.postFileAndWait(cluster, "runtimecode/containerplugin.v.1.jar.bin", FILE1,
+ "pmrmWCDafdNpYle2rueAGnU2J6NYlcAey9mkZYbqh+5RdYo2Ln+llLF9voyRj+DDivK9GV1XdtKvD9rgCxlD7Q==");
+ TestPackages.postFileAndWait(cluster, "runtimecode/containerplugin.v.2.jar.bin", FILE2,
+ "StR3DmqaUSL7qjDOeVEiCqE+ouiZAkW99fsL48F9oWG047o7NGgwwZ36iGgzDC3S2tPaFjRAd9Zg4UK7OZLQzg==");
+
+ Package.AddVersion add = new Package.AddVersion();
+ add.version = "1.0";
+ add.pkg = "mypkg";
+ add.files = List.of(FILE1);
+ V2Request addPkgVersionReq = new V2Request.Builder("/cluster/package")
+ .forceV2(true)
+ .withMethod(POST)
+ .withPayload(singletonMap("add", add))
+ .build();
+ addPkgVersionReq.process(cluster.getSolrClient());
+
+ TestDistribPackageStore.assertResponseValues(10,
+ () -> new V2Request.Builder("/cluster/package").
+ withMethod(GET)
+ .build().process(cluster.getSolrClient()),
+ Utils.makeMap(
+ ":result:packages:mypkg[0]:version", "1.0",
+ ":result:packages:mypkg[0]:files[0]", FILE1
+ ));
+
+ PluginMeta plugin = new PluginMeta();
+ plugin.name = "myplugin";
+ plugin.klass = "mypkg:org.apache.solr.handler.MyPlugin";
+ plugin.version = add.version;
+ V2Request req1 = new V2Request.Builder("/cluster/plugin")
+ .forceV2(true)
+ .withMethod(POST)
+ .withPayload(singletonMap("add", plugin))
+ .build();
+ req1.process(cluster.getSolrClient());
+ TestDistribPackageStore.assertResponseValues(10,
+ () -> new V2Request.Builder("/cluster/plugin").
+ withMethod(GET)
+ .build().process(cluster.getSolrClient()),
+ ImmutableMap.of(
+ "/plugin/myplugin/class", plugin.klass,
+ "/plugin/myplugin/version", plugin.version
+ ));
+ Callable<NavigableObject> invokePlugin = () -> new V2Request.Builder("/plugin/my/path")
+ .forceV2(true)
+ .withMethod(GET)
+ .build().process(cluster.getSolrClient());
+ TestDistribPackageStore.assertResponseValues(10,
+ invokePlugin,
+ ImmutableMap.of("/myplugin.version", "1.0"));
+
+ add.version = "2.0";
+ add.files = List.of(FILE2);
+ addPkgVersionReq.process(cluster.getSolrClient());
+
+ plugin.version = add.version;
+ new V2Request.Builder("/cluster/plugin")
+ .forceV2(true)
+ .withMethod(POST)
+ .withPayload(singletonMap("update", plugin))
+ .build()
+ .process(cluster.getSolrClient());
+
+ TestDistribPackageStore.assertResponseValues(10,
+ () -> new V2Request.Builder("/cluster/plugin").
+ withMethod(GET)
+ .build().process(cluster.getSolrClient()),
+ ImmutableMap.of(
+ "/plugin/myplugin/class", plugin.klass,
+ "/plugin/myplugin/version", "2.0"
+ ));
+ TestDistribPackageStore.assertResponseValues(10,
+ invokePlugin,
+ ImmutableMap.of("/myplugin.version", "2.0"));
+ } finally {
+ cluster.shutdown();
+ }
+ }
+
+ public static class C1 {
+
+ }
+
+ @EndPoint(
+ method = GET,
+ path = "/plugin/my/plugin",
+ permission = PermissionNameProvider.Name.COLL_READ_PERM)
+ public class C2 {
+
+
+ }
+
+ @EndPoint(
+ method = GET,
+ path = "/plugin/my/plugin",
+ permission = PermissionNameProvider.Name.COLL_READ_PERM)
+ public static class C3 {
+ @Command
+ public void read(SolrQueryRequest req, SolrQueryResponse rsp) {
+ rsp.add("testkey", "testval");
+ }
+
+ }
+
+
+ private void expectError(V2Request req, SolrClient client, String errPath, String expectErrorMsg) throws IOException, SolrServerException {
+ try {
Review comment:
use `expectThrows` here.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] madrob commented on a change in pull request #1432:
SOLR-14404 CoreContainer level custom requesthandlers
Posted by GitBox <gi...@apache.org>.
madrob commented on a change in pull request #1432: SOLR-14404 CoreContainer level custom requesthandlers
URL: https://github.com/apache/lucene-solr/pull/1432#discussion_r409689441
##########
File path: solr/core/src/test/org/apache/solr/handler/TestContainerPlugin.java
##########
@@ -0,0 +1,250 @@
+/*
+ * 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 java.io.IOException;
+import java.util.List;
+import java.util.concurrent.Callable;
+
+import com.google.common.collect.ImmutableMap;
+import org.apache.solr.api.Command;
+import org.apache.solr.api.EndPoint;
+import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.impl.BaseHttpSolrClient;
+import org.apache.solr.client.solrj.request.V2Request;
+import org.apache.solr.client.solrj.request.beans.Package;
+import org.apache.solr.client.solrj.request.beans.PluginMeta;
+import org.apache.solr.client.solrj.response.V2Response;
+import org.apache.solr.cloud.MiniSolrCloudCluster;
+import org.apache.solr.cloud.SolrCloudTestCase;
+import org.apache.solr.common.NavigableObject;
+import org.apache.solr.common.util.Utils;
+import org.apache.solr.filestore.PackageStoreAPI;
+import org.apache.solr.filestore.TestDistribPackageStore;
+import org.apache.solr.pkg.TestPackages;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.security.PermissionNameProvider;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static java.util.Collections.singletonMap;
+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.filestore.TestDistribPackageStore.readFile;
+import static org.apache.solr.filestore.TestDistribPackageStore.uploadKey;
+import static org.hamcrest.CoreMatchers.containsString;
+
+public class TestContainerPlugin extends SolrCloudTestCase {
+
+ @Before
+ public void setup() {
+ System.setProperty("enable.packages", "true");
+ }
+
+ @After
+ public void teardown() {
+ System.clearProperty("enable.packages");
+ }
+
+ @Test
+ public void testApi() throws Exception {
+ MiniSolrCloudCluster cluster =
Review comment:
cluster setup and teardown can go in Before/After methods
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] madrob commented on a change in pull request #1432:
SOLR-14404 CoreContainer level custom requesthandlers
Posted by GitBox <gi...@apache.org>.
madrob commented on a change in pull request #1432: SOLR-14404 CoreContainer level custom requesthandlers
URL: https://github.com/apache/lucene-solr/pull/1432#discussion_r409694609
##########
File path: solr/core/src/java/org/apache/solr/core/CoreContainer.java
##########
@@ -648,8 +655,8 @@ public void load() {
pkiAuthenticationPlugin.initializeMetrics(solrMetricsContext, "/authentication/pki");
TracerConfigurator.loadTracer(loader, cfg.getTracerConfiguratorPluginInfo(), getZkController().getZkStateReader());
packageLoader = new PackageLoader(this);
- containerHandlers.getApiBag().register(new AnnotatedApi(packageLoader.getPackageAPI().editAPI), Collections.EMPTY_MAP);
- containerHandlers.getApiBag().register(new AnnotatedApi(packageLoader.getPackageAPI().readAPI), Collections.EMPTY_MAP);
+ containerHandlers.getApiBag().registerObject(packageLoader.getPackageAPI().editAPI);
Review comment:
There's a minor inconsistency here between edit/read and write/read, maybe we can standardize on one?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] madrob commented on a change in pull request #1432:
SOLR-14404 CoreContainer level custom requesthandlers
Posted by GitBox <gi...@apache.org>.
madrob commented on a change in pull request #1432: SOLR-14404 CoreContainer level custom requesthandlers
URL: https://github.com/apache/lucene-solr/pull/1432#discussion_r409687566
##########
File path: solr/core/src/test-files/runtimecode/MyPlugin.java
##########
@@ -0,0 +1,43 @@
+/*
+ * 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.Command;
+import org.apache.solr.api.EndPoint;
+import org.apache.solr.client.solrj.SolrRequest.METHOD;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.security.PermissionNameProvider;
+
+@EndPoint(path = "/plugin/my/path",
+ method = METHOD.GET,
+ permission = PermissionNameProvider.Name.CONFIG_READ_PERM)
+public class MyPlugin {
Review comment:
I assume this is used to generate containerplugin.v.1.jar.bin and v.2? Should we have two source files for those? Can we do this some other way, besides checking in binaries to the repo?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] madrob commented on a change in pull request #1432:
SOLR-14404 CoreContainer level custom requesthandlers
Posted by GitBox <gi...@apache.org>.
madrob commented on a change in pull request #1432: SOLR-14404 CoreContainer level custom requesthandlers
URL: https://github.com/apache/lucene-solr/pull/1432#discussion_r409684159
##########
File path: solr/core/src/java/org/apache/solr/pkg/PackageListeners.java
##########
@@ -63,13 +63,13 @@ public synchronized void removeListener(Listener listener) {
}
synchronized void packagesUpdated(List<PackageLoader.Package> pkgs) {
- MDCLoggingContext.setCore(core);
Review comment:
Why do we need this check? setCore already handles nulls.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] madrob commented on a change in pull request #1432:
SOLR-14404 CoreContainer level custom requesthandlers
Posted by GitBox <gi...@apache.org>.
madrob commented on a change in pull request #1432: SOLR-14404 CoreContainer level custom requesthandlers
URL: https://github.com/apache/lucene-solr/pull/1432#discussion_r409680029
##########
File path: solr/core/src/java/org/apache/solr/handler/admin/ContainerPluginsApi.java
##########
@@ -0,0 +1,178 @@
+/*
+ * 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.io.IOException;
+import java.lang.invoke.MethodHandles;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.function.Supplier;
+
+import org.apache.solr.api.AnnotatedApi;
+import org.apache.solr.api.Command;
+import org.apache.solr.api.CustomContainerPlugins;
+import org.apache.solr.api.EndPoint;
+import org.apache.solr.api.PayloadObj;
+import org.apache.solr.client.solrj.SolrRequest.METHOD;
+import org.apache.solr.client.solrj.request.beans.PluginMeta;
+import org.apache.solr.common.cloud.SolrZkClient;
+import org.apache.solr.common.cloud.ZkStateReader;
+import org.apache.solr.common.util.Utils;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.security.PermissionNameProvider;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.data.Stat;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.apache.lucene.util.IOUtils.closeWhileHandlingException;
+
+
+public class ContainerPluginsApi {
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ public static final String PLUGIN = "plugin";
+ private final Supplier<SolrZkClient> zkClientSupplier;
+ private final CoreContainer coreContainer;
+ public final Read readAPI = new Read();
+ public final Edit editAPI = new Edit();
+
+ public ContainerPluginsApi(CoreContainer coreContainer) {
+ this.zkClientSupplier = coreContainer.zkClientSupplier;
+ this.coreContainer = coreContainer;
+ }
+
+ @EndPoint(method = METHOD.GET,
+ path = "/cluster/plugin",
+ permission = PermissionNameProvider.Name.COLL_READ_PERM)
+ public class Read {
+
+ @Command
+ public void list(SolrQueryRequest req, SolrQueryResponse rsp) throws IOException {
+ rsp.add(PLUGIN, plugins(zkClientSupplier));
+ }
+ }
+
+ @EndPoint(method = METHOD.POST,
+ path = "/cluster/plugin",
+ permission = PermissionNameProvider.Name.COLL_EDIT_PERM)
+ public class Edit {
+
+ @Command(name = "add")
+ public void add(SolrQueryRequest req, SolrQueryResponse rsp, PayloadObj<PluginMeta> payload) throws IOException {
+ PluginMeta info = payload.get();
+ validateConfig(payload, info);
+ if(payload.hasError()) return;
+ persistPlugins(map -> {
+ if (map.containsKey(info.name)) {
+ payload.addError(info.name + " already exists");
+ return null;
+ }
+ map.put(info.name, info);
+ return map;
+ });
+ }
+
+ @Command(name = "remove")
+ public void remove(SolrQueryRequest req, SolrQueryResponse rsp, PayloadObj<String> payload) throws IOException {
Review comment:
Should this be METHOD.DELETE instead of a post?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org