diff --git a/changelog/unreleased/SOLR-18417-deprecate-pingrequesthandler.yml b/changelog/unreleased/SOLR-18417-deprecate-pingrequesthandler.yml new file mode 100644 index 000000000000..fb82ab8f6d1f --- /dev/null +++ b/changelog/unreleased/SOLR-18417-deprecate-pingrequesthandler.yml @@ -0,0 +1,7 @@ +type: deprecated +title: Deprecate PingRequestHandler (the "/admin/ping" endpoint), SolrPing, SolrPingResponse, and SolrClient.ping()/ping(String). +authors: + - name: Jason Gerlowski +links: + - name: SOLR-18417 + url: https://issues.apache.org/jira/browse/SOLR-18417 diff --git a/changelog/unreleased/SOLR-18417-remove-pingrequesthandler.yml b/changelog/unreleased/SOLR-18417-remove-pingrequesthandler.yml new file mode 100644 index 000000000000..ad7f8392629f --- /dev/null +++ b/changelog/unreleased/SOLR-18417-remove-pingrequesthandler.yml @@ -0,0 +1,7 @@ +type: removed +title: `PingRequestHandler` (the "/admin/ping" endpoint), `SolrPing`, `SolrPingResponse`, and `SolrClient.ping()` have been removed. Users looking for a healthcheck API can use `/api/node/health` (v2) or `/solr/admin/info/health` (v1) instead. SolrJ users looking to replace "ping" functionality can either use `QueryRequest` for true query submission, or `HealthCheckRequest` for making a node-level healthcheck request. +authors: + - name: Jason Gerlowski +links: + - name: SOLR-18417 + url: https://issues.apache.org/jira/browse/SOLR-18417 diff --git a/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java b/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java index 64b288ab6add..69fc4ca5f987 100644 --- a/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java +++ b/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java @@ -35,6 +35,7 @@ import org.apache.solr.client.solrj.jetty.HttpJettySolrClient; import org.apache.solr.client.solrj.request.AbstractUpdateRequest; import org.apache.solr.client.solrj.request.CoreAdminRequest.WaitForState; +import org.apache.solr.client.solrj.request.HealthCheckRequest; import org.apache.solr.client.solrj.request.UpdateRequest; import org.apache.solr.common.SolrException; import org.apache.solr.common.SolrException.ErrorCode; @@ -824,7 +825,7 @@ private Replica pingLeader(String ourUrl, CoreDescriptor coreDesc, boolean mayPu try (SolrClient httpSolrClient = recoverySolrClientBuilder(leaderReplica.getBaseUrl(), leaderReplica.getCoreName()) .build()) { - httpSolrClient.ping(); + new HealthCheckRequest().process(httpSolrClient); return leaderReplica; } catch (IOException e) { log.error("Failed to connect leader {} on recovery, try again", leaderReplica.getBaseUrl()); diff --git a/solr/core/src/java/org/apache/solr/handler/PingRequestHandler.java b/solr/core/src/java/org/apache/solr/handler/PingRequestHandler.java deleted file mode 100644 index f7eaa97db78b..000000000000 --- a/solr/core/src/java/org/apache/solr/handler/PingRequestHandler.java +++ /dev/null @@ -1,339 +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; - -import static org.apache.solr.common.params.CommonParams.ACTION; -import static org.apache.solr.common.params.CommonParams.DISABLE; -import static org.apache.solr.common.params.CommonParams.DISTRIB; -import static org.apache.solr.common.params.CommonParams.ENABLE; - -import java.io.IOException; -import java.lang.invoke.MethodHandles; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.time.Instant; -import java.util.Locale; -import org.apache.solr.common.SolrException; -import org.apache.solr.common.params.CommonParams; -import org.apache.solr.common.params.ModifiableSolrParams; -import org.apache.solr.common.params.ShardParams; -import org.apache.solr.common.params.SolrParams; -import org.apache.solr.common.util.NamedList; -import org.apache.solr.core.SolrCore; -import org.apache.solr.request.SolrQueryRequest; -import org.apache.solr.request.SolrRequestHandler; -import org.apache.solr.response.SolrQueryResponse; -import org.apache.solr.security.AuthorizationContext; -import org.apache.solr.util.plugin.SolrCoreAware; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Ping Request Handler for reporting SolrCore health to a Load Balancer. - * - *

This handler is designed to be used as the endpoint for an HTTP Load-Balancer to use when - * checking the "health" or "up status" of a Solr server. - * - *

In its simplest form, the PingRequestHandler should be configured with some defaults - * indicating a request that should be executed. If the request succeeds, then the - * PingRequestHandler will respond back with a simple "OK" status. If the request fails, then the - * PingRequestHandler will respond back with the corresponding HTTP Error code. Clients (such as - * load balancers) can be configured to poll the PingRequestHandler monitoring for these types of - * responses (or for a simple connection failure) to know if there is a problem with the Solr - * server. - * - *

Note in case isShard=true, PingRequestHandler respond back with what the delegated handler - * returns (by default it's /select handler). - * - *

- * <requestHandler name="/admin/ping" class="solr.PingRequestHandler">
- *   <lst name="invariants">
- *     <str name="qt">/search</str><!-- handler to delegate to -->
- *     <str name="q">some test query</str>
- *   </lst>
- * </requestHandler>
- * 
- * - *

A more advanced option available, is to configure the handler with a "healthcheckFile" which - * can be used to enable/disable the PingRequestHandler. - * - *

- * <requestHandler name="/admin/ping" class="solr.PingRequestHandler">
- *   <!-- relative paths are resolved against the data dir -->
- *   <str name="healthcheckFile">server-enabled.txt</str>
- *   <lst name="invariants">
- *     <str name="qt">/search</str><!-- handler to delegate to -->
- *     <str name="q">some test query</str>
- *   </lst>
- * </requestHandler>
- * 
- * - * - * - *

This health check file feature can be used as a way to indicate to some Load Balancers that - * the server should be "removed from rotation" for maintenance, or upgrades, or whatever reason you - * may wish. - * - *

The health check file may be created/deleted by any external system, or the PingRequestHandler - * itself can be used to create/delete the file by specifying an "action" param in a request: - * - *

- * - * @since solr 1.3 - */ -public class PingRequestHandler extends RequestHandlerBase implements SolrCoreAware { - private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - public static final String HEALTHCHECK_FILE_PARAM = "healthcheckFile"; - - @Override - public Name getPermissionName(AuthorizationContext request) { - String action = request.getParams().get(ACTION, "").strip().toLowerCase(Locale.ROOT); - // Modifying the health check file requires more permission than just doing a ping - switch (action) { - case ENABLE: - case DISABLE: - return Name.CONFIG_EDIT_PERM; - default: - return Name.HEALTH_PERM; - } - } - - protected enum ACTIONS { - STATUS, - ENABLE, - DISABLE, - PING - }; - - private String healthFileName = null; - private Path healthcheck = null; - - @Override - public void init(NamedList args) { - super.init(args); - Object tmp = args.get(HEALTHCHECK_FILE_PARAM); - healthFileName = (null == tmp ? null : tmp.toString()); - } - - @Override - public void inform(SolrCore core) { - if (null != healthFileName) { - healthcheck = Path.of(healthFileName); - if (!healthcheck.isAbsolute()) { - healthcheck = Path.of(core.getDataDir(), healthFileName); - healthcheck = healthcheck.toAbsolutePath(); - } - - if (!Files.isWritable(healthcheck.getParent())) { - // this is not fatal, users may not care about enable/disable via - // solr request, file might be touched/deleted by an external system - log.warn( - "Directory for configured healthcheck file is not writable by solr, PingRequestHandler will not be able to control enable/disable: {}", - healthcheck.getParent().toAbsolutePath()); - } - } - } - - /** - * Returns true if the healthcheck flag-file is enabled but does not exist, otherwise (no file - * configured, or file configured and exists) returns false. - */ - public boolean isPingDisabled() { - return (null != healthcheck && !Files.exists(healthcheck)); - } - - @Override - public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception { - - SolrParams params = req.getParams(); - - // in this case, we want to default distrib to false so - // we only ping the single node - Boolean distrib = params.getBool(DISTRIB); - if (distrib == null) { - ModifiableSolrParams mparams = new ModifiableSolrParams(params); - mparams.set(DISTRIB, false); - req.setParams(mparams); - } - - String actionParam = params.get("action"); - ACTIONS action = null; - if (actionParam == null) { - action = ACTIONS.PING; - } else { - try { - action = ACTIONS.valueOf(actionParam.toUpperCase(Locale.ROOT)); - } catch (IllegalArgumentException iae) { - throw new SolrException( - SolrException.ErrorCode.BAD_REQUEST, "Unknown action: " + actionParam); - } - } - switch (action) { - case PING: - if (isPingDisabled()) { - SolrException e = - new SolrException(SolrException.ErrorCode.SERVICE_UNAVAILABLE, "Service disabled"); - rsp.setException(e); - return; - } - handlePing(req, rsp); - break; - case ENABLE: - handleEnable(true); - break; - case DISABLE: - handleEnable(false); - break; - case STATUS: - if (healthcheck == null) { - SolrException e = - new SolrException( - SolrException.ErrorCode.SERVICE_UNAVAILABLE, "healthcheck not configured"); - rsp.setException(e); - } else { - rsp.add("status", isPingDisabled() ? "disabled" : "enabled"); - } - } - } - - protected void handlePing(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception { - - SolrParams params = req.getParams(); - SolrCore core = req.getCore(); - - // Get the RequestHandler - String qt = params.get(CommonParams.QT); // optional; you get the default otherwise - SolrRequestHandler handler = core.getRequestHandler(qt); - if (handler == null) { - throw new SolrException( - SolrException.ErrorCode.BAD_REQUEST, "Unknown RequestHandler (qt): " + qt); - } - - if (handler instanceof PingRequestHandler) { - // In case it's a query for shard, use default handler - if (params.getBool(ShardParams.IS_SHARD, false)) { - handler = core.getRequestHandler(null); - ModifiableSolrParams wparams = new ModifiableSolrParams(params); - wparams.remove(CommonParams.QT); - req.setParams(wparams); - } else { - throw new SolrException( - SolrException.ErrorCode.BAD_REQUEST, - "Cannot execute the PingRequestHandler recursively"); - } - } - - // Execute the ping query and catch any possible exception - Throwable ex = null; - - // In case it's a query for shard, return the result from delegated handler for distributed - // query to merge result - if (params.getBool(ShardParams.IS_SHARD, false)) { - try { - core.execute(handler, req, rsp); - ex = rsp.getException(); - } catch (Exception e) { - ex = e; - } - // Send an error or return - if (ex != null) { - throw new SolrException( - SolrException.ErrorCode.SERVER_ERROR, - "Ping query caused exception: " + ex.getMessage(), - ex); - } - } else { - try { - SolrQueryResponse pingrsp = new SolrQueryResponse(); - core.execute(handler, req, pingrsp); - ex = pingrsp.getException(); - NamedList headers = rsp.getResponseHeader(); - if (headers != null) { - headers.add("zkConnected", pingrsp.getResponseHeader().get("zkConnected")); - } - - } catch (Exception e) { - ex = e; - } - - // Send an error or an 'OK' message (response code will be 200) - if (ex != null) { - throw new SolrException( - SolrException.ErrorCode.SERVER_ERROR, - "Ping query caused exception: " + ex.getMessage(), - ex); - } - - rsp.add("status", "OK"); - } - } - - protected void handleEnable(boolean enable) throws SolrException { - if (healthcheck == null) { - throw new SolrException( - SolrException.ErrorCode.SERVICE_UNAVAILABLE, "No healthcheck file defined."); - } - if (enable) { - try { - // write out when the file was created - Files.write(healthcheck, Instant.now().toString().getBytes(StandardCharsets.UTF_8)); - } catch (IOException e) { - throw new SolrException( - SolrException.ErrorCode.SERVER_ERROR, "Unable to write healthcheck flag file", e); - } - } else { - try { - Files.deleteIfExists(healthcheck); - } catch (Throwable cause) { - throw new SolrException( - SolrException.ErrorCode.NOT_FOUND, - "Did not successfully delete healthcheck file: " + healthcheck.toAbsolutePath(), - cause); - } - } - } - - //////////////////////// SolrInfoMBeans methods ////////////////////// - - @Override - public String getDescription() { - return "Reports application health to a load-balancer"; - } - - @Override - public Boolean registerV2() { - return Boolean.TRUE; - } - - @Override - public Category getCategory() { - return Category.ADMIN; - } -} diff --git a/solr/core/src/java/org/apache/solr/metrics/SolrMetricInfo.java b/solr/core/src/java/org/apache/solr/metrics/SolrMetricInfo.java index d01dd8f8b31d..2d27780ddbf6 100644 --- a/solr/core/src/java/org/apache/solr/metrics/SolrMetricInfo.java +++ b/solr/core/src/java/org/apache/solr/metrics/SolrMetricInfo.java @@ -29,7 +29,7 @@ public final class SolrMetricInfo { * Creates a new instance of {@link SolrMetricInfo}. * * @param category the category of the metric (e.g. `QUERY`) - * @param scope the scope of the metric (e.g. `/admin/ping`) + * @param scope the scope of the metric (e.g. `/admin/segments`) * @param name the name of the metric (e.g. `Requests`) */ public SolrMetricInfo(SolrInfoBean.Category category, String scope, String name) { diff --git a/solr/core/src/resources/ImplicitPlugins.json b/solr/core/src/resources/ImplicitPlugins.json index a9e8dd45ef4c..638cc8577bf9 100644 --- a/solr/core/src/resources/ImplicitPlugins.json +++ b/solr/core/src/resources/ImplicitPlugins.json @@ -57,14 +57,6 @@ "omitHeader": true } }, - "/admin/ping": { - "class": "solr.PingRequestHandler", - "useParams":"_ADMIN_PING", - "invariants": { - "echoParams": "all", - "q": "{!lucene}*:*" - } - }, "/admin/segments": { "class": "solr.SegmentsInfoRequestHandler", "useParams":"_ADMIN_SEGMENTS" diff --git a/solr/core/src/test-files/solr/collection1/conf/solrconfig-sql.xml b/solr/core/src/test-files/solr/collection1/conf/solrconfig-sql.xml index d9efb26fa811..d36eb39cc3bf 100644 --- a/solr/core/src/test-files/solr/collection1/conf/solrconfig-sql.xml +++ b/solr/core/src/test-files/solr/collection1/conf/solrconfig-sql.xml @@ -53,14 +53,4 @@ - - - *:* - - - all - - server-enabled.txt - - diff --git a/solr/core/src/test/org/apache/solr/core/SolrCoreTest.java b/solr/core/src/test/org/apache/solr/core/SolrCoreTest.java index 9fa63f89801f..5a2e6820b3e3 100644 --- a/solr/core/src/test/org/apache/solr/core/SolrCoreTest.java +++ b/solr/core/src/test/org/apache/solr/core/SolrCoreTest.java @@ -97,8 +97,6 @@ public void testImplicitPlugins() { ++ihCount; assertEquals(pathToClassMap.get("/admin/luke"), "solr.LukeRequestHandler"); ++ihCount; - assertEquals(pathToClassMap.get("/admin/ping"), "solr.PingRequestHandler"); - ++ihCount; assertEquals(pathToClassMap.get("/admin/segments"), "solr.SegmentsInfoRequestHandler"); ++ihCount; assertEquals(pathToClassMap.get("/admin/info"), "solr.CoreInfoHandler"); diff --git a/solr/core/src/test/org/apache/solr/core/TestSolrConfigHandler.java b/solr/core/src/test/org/apache/solr/core/TestSolrConfigHandler.java index 4cb5b8889b6e..68d09f0a6666 100644 --- a/solr/core/src/test/org/apache/solr/core/TestSolrConfigHandler.java +++ b/solr/core/src/test/org/apache/solr/core/TestSolrConfigHandler.java @@ -104,7 +104,6 @@ public void testProperty() throws Exception { assertNotNull(confMap._get(asList("config", "requestHandler", "/admin/luke"), null)); assertNotNull(confMap._get(asList("config", "requestHandler", "/admin/info"), null)); assertNotNull(confMap._get(asList("config", "requestHandler", "/admin/file"), null)); - assertNotNull(confMap._get(asList("config", "requestHandler", "/admin/ping"), null)); String payload = "{\n" diff --git a/solr/core/src/test/org/apache/solr/handler/PingRequestHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/PingRequestHandlerTest.java deleted file mode 100644 index 3f151e51efca..000000000000 --- a/solr/core/src/test/org/apache/solr/handler/PingRequestHandlerTest.java +++ /dev/null @@ -1,233 +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; - -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.List; -import org.apache.solr.SolrTestCaseJ4; -import org.apache.solr.client.solrj.impl.CloudSolrClient; -import org.apache.solr.client.solrj.request.CollectionAdminRequest; -import org.apache.solr.client.solrj.request.SolrPing; -import org.apache.solr.client.solrj.response.SolrPingResponse; -import org.apache.solr.cloud.MiniSolrCloudCluster; -import org.apache.solr.cloud.SolrCloudTestCase; -import org.apache.solr.common.SolrException; -import org.apache.solr.common.util.NamedList; -import org.apache.solr.embedded.JettyConfig; -import org.apache.solr.embedded.JettySolrRunner; -import org.apache.solr.request.SolrQueryRequest; -import org.apache.solr.response.SolrQueryResponse; -import org.junit.Before; -import org.junit.BeforeClass; - -public class PingRequestHandlerTest extends SolrTestCaseJ4 { - protected int NUM_SERVERS = 5; - protected int NUM_SHARDS = 2; - protected int REPLICATION_FACTOR = 2; - - private final String fileName = this.getClass().getName() + ".server-enabled"; - private Path healthcheckFile = null; - private PingRequestHandler handler = null; - - @BeforeClass - public static void beforeClass() throws Exception { - initCore("solrconfig.xml", "schema.xml"); - } - - @Before - public void before() throws IOException { - // by default, use relative file in dataDir - healthcheckFile = initAndGetDataDir().resolve(fileName); - String fileNameParam = fileName; - - // sometimes randomly use an absolute File path instead - if (random().nextBoolean()) { - fileNameParam = healthcheckFile.toString(); - } - - if (Files.exists(healthcheckFile)) Files.delete(healthcheckFile); - - handler = new PingRequestHandler(); - NamedList initParams = new NamedList<>(); - initParams.add(PingRequestHandler.HEALTHCHECK_FILE_PARAM, fileNameParam); - handler.init(initParams); - handler.inform(h.getCore()); - } - - public void testPingWithNoHealthCheck() throws Exception { - - // for this test, we don't want any healthcheck file configured at all - handler = new PingRequestHandler(); - handler.init(new NamedList<>()); - handler.inform(h.getCore()); - - SolrQueryResponse rsp = null; - - rsp = makeRequest(handler, req()); - assertEquals("OK", rsp.getValues().get("status")); - - rsp = makeRequest(handler, req("action", "ping")); - assertEquals("OK", rsp.getValues().get("status")); - } - - public void testEnablingServer() throws Exception { - - assertFalse(Files.exists(healthcheckFile)); - - // first make sure that ping responds back that the service is disabled - SolrQueryResponse sqr = makeRequest(handler, req()); - SolrException se = (SolrException) sqr.getException(); - assertEquals( - "Response should have been replaced with a 503 SolrException.", - se.code(), - SolrException.ErrorCode.SERVICE_UNAVAILABLE.code); - - // now enable - - makeRequest(handler, req("action", "enable")); - - assertTrue(Files.exists(healthcheckFile)); - assertNotNull(Files.readString(healthcheckFile, StandardCharsets.UTF_8)); - - // now verify that the handler response with success - - SolrQueryResponse rsp = makeRequest(handler, req()); - assertEquals("OK", rsp.getValues().get("status")); - - // enable when already enabled shouldn't cause any problems - makeRequest(handler, req("action", "enable")); - assertTrue(Files.exists(healthcheckFile)); - } - - public void testDisablingServer() throws Exception { - - assertFalse(Files.exists(healthcheckFile)); - - Files.createFile(healthcheckFile); - - // first make sure that ping responds back that the service is enabled - - SolrQueryResponse rsp = makeRequest(handler, req()); - assertEquals("OK", rsp.getValues().get("status")); - - // now disable - - makeRequest(handler, req("action", "disable")); - - assertFalse(Files.exists(healthcheckFile)); - - // now make sure that ping responds back that the service is disabled - SolrQueryResponse sqr = makeRequest(handler, req()); - SolrException se = (SolrException) sqr.getException(); - assertEquals( - "Response should have been replaced with a 503 SolrException.", - se.code(), - SolrException.ErrorCode.SERVICE_UNAVAILABLE.code); - - // disable when already disabled shouldn't cause any problems - makeRequest(handler, req("action", "disable")); - assertFalse(Files.exists(healthcheckFile)); - } - - public void testGettingStatus() throws Exception { - SolrQueryResponse rsp = null; - - handler.handleEnable(true); - - rsp = makeRequest(handler, req("action", "status")); - assertEquals("enabled", rsp.getValues().get("status")); - - handler.handleEnable(false); - - rsp = makeRequest(handler, req("action", "status")); - assertEquals("disabled", rsp.getValues().get("status")); - } - - public void testBadActionRaisesException() { - SolrException se = - expectThrows(SolrException.class, () -> makeRequest(handler, req("action", "badaction"))); - assertEquals(SolrException.ErrorCode.BAD_REQUEST.code, se.code()); - } - - public void testPingInClusterWithNoHealthCheck() throws Exception { - - MiniSolrCloudCluster miniCluster = - new MiniSolrCloudCluster(NUM_SERVERS, createTempDir(), JettyConfig.builder().build()); - - final CloudSolrClient cloudSolrClient = miniCluster.getSolrClient(); - - try { - assertNotNull(miniCluster.getZkServer()); - List jettys = miniCluster.getJettySolrRunners(); - assertEquals(NUM_SERVERS, jettys.size()); - for (JettySolrRunner jetty : jettys) { - assertTrue(jetty.isRunning()); - } - - // create collection - String collectionName = "testSolrCloudCollection"; - String configName = "solrCloudCollectionConfig"; - miniCluster.uploadConfigSet( - SolrTestCaseJ4.TEST_PATH().resolve("collection1").resolve("conf"), configName); - CollectionAdminRequest.createCollection( - collectionName, configName, NUM_SHARDS, REPLICATION_FACTOR) - .setPerReplicaState(SolrCloudTestCase.isPRS()) - .process(miniCluster.getSolrClient()); - - // Send distributed and non-distributed ping query - SolrPingWithDistrib reqDistrib = new SolrPingWithDistrib(); - reqDistrib.setDistrib(true); - SolrPingResponse rsp = reqDistrib.process(cloudSolrClient, collectionName); - assertEquals(0, rsp.getStatus()); - assertTrue(rsp.getResponseHeader().getBooleanArg(("zkConnected"))); - - SolrPing reqNonDistrib = new SolrPing(); - rsp = reqNonDistrib.process(cloudSolrClient, collectionName); - assertEquals(0, rsp.getStatus()); - assertTrue(rsp.getResponseHeader().getBooleanArg(("zkConnected"))); - - } finally { - miniCluster.shutdown(); - } - } - - /** - * Helper Method: Executes the request against the handler, returns the response, and closes the - * request. - */ - private SolrQueryResponse makeRequest(PingRequestHandler handler, SolrQueryRequest req) - throws Exception { - - SolrQueryResponse rsp = new SolrQueryResponse(); - try { - handler.handleRequestBody(req, rsp); - } finally { - req.close(); - } - return rsp; - } - - static class SolrPingWithDistrib extends SolrPing { - public SolrPing setDistrib(boolean distrib) { - getParams().add("distrib", distrib ? "true" : "false"); - return this; - } - } -} diff --git a/solr/core/src/test/org/apache/solr/handler/TestHttpRequestId.java b/solr/core/src/test/org/apache/solr/handler/TestHttpRequestId.java index ef0f486fa30e..aecffaec0f9b 100644 --- a/solr/core/src/test/org/apache/solr/handler/TestHttpRequestId.java +++ b/solr/core/src/test/org/apache/solr/handler/TestHttpRequestId.java @@ -28,7 +28,7 @@ import org.apache.logging.log4j.core.LogEvent; import org.apache.solr.SolrTestCaseJ4; import org.apache.solr.client.solrj.jetty.HttpJettySolrClient; -import org.apache.solr.client.solrj.request.SolrPing; +import org.apache.solr.client.solrj.request.HealthCheckRequest; import org.apache.solr.common.util.ExecutorUtil; import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.SolrNamedThreadFactory; @@ -106,7 +106,7 @@ private void setupClientAndRun( MDC.put(key, value); cf = client - .requestAsync(new SolrPing(), null) + .requestAsync(new HealthCheckRequest(), null) .whenComplete((nl, e) -> assertEquals(value, MDC.get(key))); } finally { ExecutorUtil.shutdownAndAwaitTermination(commExecutor); 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 101ee2a09b39..de076bcddc5d 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 @@ -60,7 +60,6 @@ import org.apache.solr.common.util.ValidatingJsonMap; import org.apache.solr.core.CoreContainer; import org.apache.solr.core.PluginBag; -import org.apache.solr.handler.PingRequestHandler; import org.apache.solr.handler.SchemaHandler; import org.apache.solr.handler.SolrConfigHandler; import org.apache.solr.request.SolrQueryRequest; @@ -91,7 +90,6 @@ public void testFramework() { new PluginBag<>(SolrRequestHandler.class, null, false); coreHandlers.put("/schema", new SchemaHandler()); coreHandlers.put("/config", new SolrConfigHandler()); - coreHandlers.put("/admin/ping", new PingRequestHandler()); Map parts = new HashMap<>(); String fullPath = "/collections/hello/shards"; diff --git a/solr/solr-ref-guide/modules/configuration-guide/pages/implicit-requesthandlers.adoc b/solr/solr-ref-guide/modules/configuration-guide/pages/implicit-requesthandlers.adoc index 005742a7cec8..8f98b352a9fc 100644 --- a/solr/solr-ref-guide/modules/configuration-guide/pages/implicit-requesthandlers.adoc +++ b/solr/solr-ref-guide/modules/configuration-guide/pages/implicit-requesthandlers.adoc @@ -80,17 +80,6 @@ This handler must have a collection name in the path to the endpoint. |`solr//admin/luke` |{solr-javadocs}/core/org/apache/solr/handler/admin/LukeRequestHandler.html[LukeRequestHandler] |`_ADMIN_LUKE` |=== -Ping:: Health check. -This handler must have a collection name in the path to the endpoint. -+ -*Documentation*: xref:deployment-guide:ping.adoc[] -+ -[cols="3*.",frame=none,grid=cols,options="header"] -|=== -|API Endpoint |Class & Javadocs |Paramset -|`solr//admin/ping` |{solr-javadocs}/core/org/apache/solr/handler/PingRequestHandler.html[PingRequestHandler] |`_ADMIN_PING` -|=== - System Properties:: Return JRE system properties. Secret values are redacted. + diff --git a/solr/solr-ref-guide/modules/configuration-guide/pages/requesthandlers-searchcomponents.adoc b/solr/solr-ref-guide/modules/configuration-guide/pages/requesthandlers-searchcomponents.adoc index 3fb8b2f9e61b..8a197a4a5b57 100644 --- a/solr/solr-ref-guide/modules/configuration-guide/pages/requesthandlers-searchcomponents.adoc +++ b/solr/solr-ref-guide/modules/configuration-guide/pages/requesthandlers-searchcomponents.adoc @@ -19,7 +19,7 @@ After the `` section of `solrconfig.xml`, request handlers and search components are configured. A _request handler_ processes requests coming to Solr. -These might be query requests, index update requests or specialized interactions such as xref:deployment-guide:ping.adoc[]. +These might be queries, index updates, or other admin operations. Not all handlers are defined explicitly in `solrconfig.xml`, many are defined implicitly. See xref:implicit-requesthandlers.adoc[] for details. diff --git a/solr/solr-ref-guide/modules/configuration-guide/pages/v2-api.adoc b/solr/solr-ref-guide/modules/configuration-guide/pages/v2-api.adoc index 844297cdce09..1c7f9cc8a0f0 100644 --- a/solr/solr-ref-guide/modules/configuration-guide/pages/v2-api.adoc +++ b/solr/solr-ref-guide/modules/configuration-guide/pages/v2-api.adoc @@ -129,7 +129,6 @@ Example of introspect for a POST API: `\http://localhost:8983/api/c/gettingstart "/c/gettingstarted/config":["POST", "GET"], "/c/gettingstarted/schema":["POST", "GET"], "/c/gettingstarted/export":["POST", "GET"], - "/c/gettingstarted/admin/ping":["POST", "GET"], "/c/gettingstarted/update":["POST"]} } ---- diff --git a/solr/solr-ref-guide/modules/deployment-guide/deployment-nav.adoc b/solr/solr-ref-guide/modules/deployment-guide/deployment-nav.adoc index 83bb2e286ed6..2794f17a141c 100644 --- a/solr/solr-ref-guide/modules/deployment-guide/deployment-nav.adoc +++ b/solr/solr-ref-guide/modules/deployment-guide/deployment-nav.adoc @@ -57,7 +57,6 @@ * Monitoring Solr ** xref:configuring-logging.adoc[] -** xref:ping.adoc[] ** xref:metrics-reporting.adoc[] ** xref:performance-statistics-reference.adoc[] ** xref:plugins-stats-screen.adoc[] diff --git a/solr/solr-ref-guide/modules/deployment-guide/examples/UsingPingRefGuideExamplesTest.java b/solr/solr-ref-guide/modules/deployment-guide/examples/UsingPingRefGuideExamplesTest.java deleted file mode 100644 index 71e3f7b25866..000000000000 --- a/solr/solr-ref-guide/modules/deployment-guide/examples/UsingPingRefGuideExamplesTest.java +++ /dev/null @@ -1,83 +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. - * - */ - -import org.apache.solr.client.solrj.SolrClient; -import org.apache.solr.client.solrj.request.CollectionAdminRequest; -import org.apache.solr.client.solrj.request.SolrPing; -import org.apache.solr.client.solrj.response.SolrPingResponse; -import org.apache.solr.cloud.SolrCloudTestCase; -import org.apache.solr.util.ExternalPaths; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * Example Ping usage. - * - *

Snippets surrounded by "tag" and "end" comments are extracted and used in the Solr Reference - * Guide. - */ -public class UsingPingRefGuideExamplesTest extends SolrCloudTestCase { - - private static final int NUM_LIVE_NODES = 1; - - @BeforeClass - public static void setUpCluster() throws Exception { - configureCluster(NUM_LIVE_NODES) - .addConfig("conf", ExternalPaths.TECHPRODUCTS_CONFIGSET) - .configure(); - - CollectionAdminRequest.createCollection("techproducts", "conf", 1, 1) - .process(cluster.getSolrClient()); - cluster.waitForActiveCollection("techproducts", 1, 1); - } - - private SolrClient getSolrClient() { - return cluster.getSolrClient(); - } - - @Test - public void solrJExampleWithSolrPing() throws Exception { - - final SolrClient solrClient = getSolrClient(); - String collectionName = "techproducts"; - - // tag::solrj-example-with-solrping[] - SolrPing ping = new SolrPing(); - ping.getParams() - .add("distrib", "true"); // To make it a distributed request against a collection - SolrPingResponse rsp = ping.process(solrClient, collectionName); - String status = (String) rsp.getResponse().get("status"); - // end::solrj-example-with-solrping[] - - assertEquals("OK", status); - } - - @Test - public void solrJExampleWithSolrClient() throws Exception { - - String collectionName = "techproducts"; - - // tag::solrj-example-with-solrclient[] - final SolrClient solrClient = getSolrClient(); - SolrPingResponse pingResponse = solrClient.ping(collectionName); - String status = (String) pingResponse.getResponse().get("status"); - // end::solrj-example-with-solrclient[] - - assertEquals("OK", status); - } -} diff --git a/solr/solr-ref-guide/modules/deployment-guide/images/ping/ping.png b/solr/solr-ref-guide/modules/deployment-guide/images/ping/ping.png deleted file mode 100644 index 055b344546de..000000000000 Binary files a/solr/solr-ref-guide/modules/deployment-guide/images/ping/ping.png and /dev/null differ diff --git a/solr/solr-ref-guide/modules/deployment-guide/pages/ping.adoc b/solr/solr-ref-guide/modules/deployment-guide/pages/ping.adoc deleted file mode 100644 index 169fb97e9ab7..000000000000 --- a/solr/solr-ref-guide/modules/deployment-guide/pages/ping.adoc +++ /dev/null @@ -1,87 +0,0 @@ -= Ping -// 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. - -Choosing Ping under a core name issues a `ping` request to check whether the core is up and responding to requests. - -.Ping Option in Core Dropdown -image::ping/ping.png[image,width=171,height=195] - -The search executed by a Ping is configured with the xref:configuration-guide:request-parameters-api.adoc[]. -See xref:configuration-guide:implicit-requesthandlers.adoc[] for the paramset to use for the `/admin/ping` endpoint. - -The Ping option doesn't open a page, but the status of the request can be seen on the core overview page shown when clicking on a collection name. -The length of time the request has taken is displayed next to the Ping option, in milliseconds. - -== Ping API Examples - -While the UI screen makes it easy to see the ping response time, the underlying ping command can be more useful when executed by remote monitoring tools: - -*Input* - -[source,bash] ----- -http://localhost:8983/solr//admin/ping ----- - -This command will ping the core name for a response. - -*Input* - -[source,bash] ----- -http://localhost:8983/solr//admin/ping?distrib=true&wt=xml ----- - -This command will ping all replicas of the given collection name for a response: - -*Sample Output* - -[source,xml] ----- - - - 0 - 13 - - {!lucene}*:* - false - _text_ - 10 - all - - - OK - ----- - -Both API calls have the same output. -A status=OK indicates that the nodes are responding. - -*SolrJ Example with SolrPing* - -[source,java,indent=0] ----- -include::example$UsingPingRefGuideExamplesTest.java[tag=solrj-example-with-solrping] ----- - -*SolrJ Example with SolrClient* - -[source,java,indent=0] ----- -include::example$UsingPingRefGuideExamplesTest.java[tag=solrj-example-with-solrclient] ----- diff --git a/solr/solr-ref-guide/modules/getting-started/pages/solr-admin-ui.adoc b/solr/solr-ref-guide/modules/getting-started/pages/solr-admin-ui.adoc index 715047bec86f..7d08890c591d 100644 --- a/solr/solr-ref-guide/modules/getting-started/pages/solr-admin-ui.adoc +++ b/solr/solr-ref-guide/modules/getting-started/pages/solr-admin-ui.adoc @@ -179,7 +179,6 @@ Here are sections throughout the Guide describing each screen of the Admin UI: // tag::ui-core-tools[] [cols="1,1",frame=none,grid=none,stripes=none] |=== -| xref:deployment-guide:ping.adoc[]: Ping a named core to determine whether it is active. | xref:deployment-guide:plugins-stats-screen.adoc[]: Statistics for request handlers, search components, plugins, and other installed components. | xref:deployment-guide:user-managed-index-replication.adoc#replication-screen[Replication Screen]: Enable replication for a core and view current replication status. | xref:configuration-guide:index-segments-merging.adoc#segments-info-screen[Segments Info Screen]: Visualization of the underlying Lucene index segments. diff --git a/solr/solrj-jetty/src/test/org/apache/solr/client/solrj/jetty/HttpJettySolrClientTest.java b/solr/solrj-jetty/src/test/org/apache/solr/client/solrj/jetty/HttpJettySolrClientTest.java index 6a3be4726776..878827cf2dea 100644 --- a/solr/solrj-jetty/src/test/org/apache/solr/client/solrj/jetty/HttpJettySolrClientTest.java +++ b/solr/solrj-jetty/src/test/org/apache/solr/client/solrj/jetty/HttpJettySolrClientTest.java @@ -36,10 +36,10 @@ import org.apache.solr.client.solrj.impl.HttpSolrClient; import org.apache.solr.client.solrj.impl.HttpSolrClientTestBase; import org.apache.solr.client.solrj.request.ContentWriterUpdateRequest; +import org.apache.solr.client.solrj.request.HealthCheckRequest; import org.apache.solr.client.solrj.request.JavaBinRequestWriter; import org.apache.solr.client.solrj.request.QueryRequest; import org.apache.solr.client.solrj.request.RequestWriter; -import org.apache.solr.client.solrj.request.SolrPing; import org.apache.solr.client.solrj.request.SolrQuery; import org.apache.solr.client.solrj.request.XMLRequestWriter; import org.apache.solr.client.solrj.response.InputStreamResponseParser; @@ -177,7 +177,9 @@ public void testSolrExceptionWithNullBaseurl() throws IOException, SolrServerExc try { // if client base url is null, request url will be used in exception message client.requestWithBaseUrl( - solrTestRule.getBaseUrl() + DEBUG_SERVLET_PATH, new SolrPing(), DEFAULT_COLLECTION); + solrTestRule.getBaseUrl() + DEBUG_SERVLET_PATH, + new HealthCheckRequest(), + DEFAULT_COLLECTION); fail("Didn't get excepted exception from oversided request"); } catch (SolrException e) { diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/SolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/SolrClient.java index 5d54d12155a1..6d67b742cc7a 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/SolrClient.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/SolrClient.java @@ -26,12 +26,10 @@ import org.apache.solr.client.solrj.SolrRequest.METHOD; import org.apache.solr.client.solrj.beans.DocumentObjectBinder; import org.apache.solr.client.solrj.request.QueryRequest; -import org.apache.solr.client.solrj.request.SolrPing; import org.apache.solr.client.solrj.request.UpdateRequest; import org.apache.solr.client.solrj.response.FastStreamingDocsCallback; import org.apache.solr.client.solrj.response.QueryResponse; import org.apache.solr.client.solrj.response.ResponseParser; -import org.apache.solr.client.solrj.response.SolrPingResponse; import org.apache.solr.client.solrj.response.StreamingJavaBinResponseParser; import org.apache.solr.client.solrj.response.StreamingResponseCallback; import org.apache.solr.client.solrj.response.UpdateResponse; @@ -887,31 +885,6 @@ public UpdateResponse deleteByQuery(String query, int commitWithinMs) return deleteByQuery(null, query, commitWithinMs); } - /** - * Issues a ping request to check if the collection's replicas are alive - * - * @param collection collection to ping - * @return a {@link org.apache.solr.client.solrj.response.SolrPingResponse} containing the - * response from the server - * @throws IOException If there is a low-level I/O error. - * @throws SolrServerException if there is an error on the server - */ - public SolrPingResponse ping(String collection) throws SolrServerException, IOException { - return new SolrPing().process(this, collection); - } - - /** - * Issues a ping request to check if the server is alive - * - * @return a {@link org.apache.solr.client.solrj.response.SolrPingResponse} containing the - * response from the server - * @throws IOException If there is a low-level I/O error. - * @throws SolrServerException if there is an error on the server - */ - public SolrPingResponse ping() throws SolrServerException, IOException { - return new SolrPing().process(this, null); - } - /** * Performs a query to the Solr server * diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/request/SolrPing.java b/solr/solrj/src/java/org/apache/solr/client/solrj/request/SolrPing.java deleted file mode 100644 index 2b9f9824802e..000000000000 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/request/SolrPing.java +++ /dev/null @@ -1,98 +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; - -import org.apache.solr.client.solrj.response.SolrPingResponse; -import org.apache.solr.common.params.CommonParams; -import org.apache.solr.common.params.ModifiableSolrParams; -import org.apache.solr.common.util.NamedList; - -/** - * Verify that there is a working Solr core at the URL of a {@link - * org.apache.solr.client.solrj.SolrClient}. To use this class, the solrconfig.xml for the relevant - * core must include the request handler for /admin/ping. - * - * @since solr 1.3 - */ -public class SolrPing extends CollectionRequiringSolrRequest { - - /** serialVersionUID. */ - private static final long serialVersionUID = 5828246236669090017L; - - /** Request parameters. */ - private final ModifiableSolrParams params; - - /** Create a new SolrPing object. */ - public SolrPing() { - super(METHOD.GET, CommonParams.PING_HANDLER, SolrRequestType.ADMIN); - params = new ModifiableSolrParams(); - } - - @Override - protected SolrPingResponse createResponse(NamedList namedList) { - return new SolrPingResponse(); - } - - @Override - public ModifiableSolrParams getParams() { - return params; - } - - /** - * Remove the action parameter from this request. This will result in the same behavior as {@code - * SolrPing#setActionPing()}. For Solr server version 4.0 and later. - * - * @return this - */ - public SolrPing removeAction() { - params.remove(CommonParams.ACTION); - return this; - } - - /** - * Set the action parameter on this request to enable. This will delete the health-check file for - * the Solr core. For Solr server version 4.0 and later. - * - * @return this - */ - public SolrPing setActionDisable() { - params.set(CommonParams.ACTION, CommonParams.DISABLE); - return this; - } - - /** - * Set the action parameter on this request to enable. This will create the health-check file for - * the Solr core. For Solr server version 4.0 and later. - * - * @return this - */ - public SolrPing setActionEnable() { - params.set(CommonParams.ACTION, CommonParams.ENABLE); - return this; - } - - /** - * Set the action parameter on this request to ping. This is the same as not including the action - * at all. For Solr server version 4.0 and later. - * - * @return this - */ - public SolrPing setActionPing() { - params.set(CommonParams.ACTION, CommonParams.PING); - return this; - } -} diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/response/SolrPingResponse.java b/solr/solrj/src/java/org/apache/solr/client/solrj/response/SolrPingResponse.java deleted file mode 100644 index da124f135943..000000000000 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/response/SolrPingResponse.java +++ /dev/null @@ -1,24 +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.response; - -/** - * @since solr 1.3 - */ -public class SolrPingResponse extends SolrResponseBase { - // nothing special now... -} diff --git a/solr/solrj/src/java/org/apache/solr/common/params/CommonParams.java b/solr/solrj/src/java/org/apache/solr/common/params/CommonParams.java index 3bed47aac571..827f4d7f14d4 100644 --- a/solr/solrj/src/java/org/apache/solr/common/params/CommonParams.java +++ b/solr/solrj/src/java/org/apache/solr/common/params/CommonParams.java @@ -75,21 +75,9 @@ public interface CommonParams { String INDENT = "indent"; // SOLR-4228 start - /** handler value for SolrPing */ - String PING_HANDLER = "/admin/ping"; - - /** "action" parameter for SolrPing */ + /** "action" parameter name, used by several admin/collection-management APIs */ String ACTION = "action"; - /** "disable" value for SolrPing action */ - String DISABLE = "disable"; - - /** "enable" value for SolrPing action */ - String ENABLE = "enable"; - - /** "ping" value for SolrPing action */ - String PING = "ping"; - // SOLR-4228 end /** query and init param for field list */ diff --git a/solr/solrj/src/test-files/solrj/solr/collection1/conf/solrconfig-sql.xml b/solr/solrj/src/test-files/solrj/solr/collection1/conf/solrconfig-sql.xml index 5877db808885..cad80102cf44 100644 --- a/solr/solrj/src/test-files/solrj/solr/collection1/conf/solrconfig-sql.xml +++ b/solr/solrj/src/test-files/solrj/solr/collection1/conf/solrconfig-sql.xml @@ -53,14 +53,4 @@ - - - *:* - - - all - - server-enabled.txt - - diff --git a/solr/solrj/src/test-files/solrj/solr/collection1/conf/solrconfig.xml b/solr/solrj/src/test-files/solrj/solr/collection1/conf/solrconfig.xml index bce00fec07ab..40b0b626b0ec 100644 --- a/solr/solrj/src/test-files/solrj/solr/collection1/conf/solrconfig.xml +++ b/solr/solrj/src/test-files/solrj/solr/collection1/conf/solrconfig.xml @@ -41,14 +41,4 @@ - - - *:* - - - all - - server-enabled.txt - - diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java index b72ea5ba5a69..8c762cd01905 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java @@ -1156,14 +1156,6 @@ public void testStatistics() throws Exception { assertEquals("they have the same distribution", inStockF.getStddev(), inStockT.getStddev()); } - @Test - public void testPingHandler() throws Exception { - SolrClient client = getSolrClient(); - - // should be ok - client.ping(); - } - @Test public void testFaceting() throws Exception { SolrClient client = getSolrClient(); diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java index 94ca36f2b153..341801cb344a 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java @@ -52,7 +52,6 @@ import org.apache.solr.client.solrj.request.V2Request; import org.apache.solr.client.solrj.response.QueryResponse; import org.apache.solr.client.solrj.response.RequestStatusState; -import org.apache.solr.client.solrj.response.SolrPingResponse; import org.apache.solr.client.solrj.response.UpdateResponse; import org.apache.solr.cloud.AbstractFullDistribZkTestBase; import org.apache.solr.cloud.SolrCloudTestCase; @@ -1215,19 +1214,6 @@ private void queryWithPreferReplicaTypes( } } - @Test - public void testPing() throws Exception { - final String testCollection = "ping_test"; - CollectionAdminRequest.createCollection(testCollection, "conf", 2, 1) - .process(cluster.getSolrClient()); - cluster.waitForActiveCollection(testCollection, 2, 2); - final SolrClient clientUnderTest = getRandomClient(); - - final SolrPingResponse response = clientUnderTest.ping(testCollection); - - assertEquals("This should be OK", 0, response.getStatus()); - } - public void testPerReplicaStateCollection() throws Exception { String collection = getSaferTestName(); @@ -1243,7 +1229,7 @@ public void testPerReplicaStateCollection() throws Exception { .process(cluster.getSolrClient()); cluster.waitForActiveCollection(testCollection, 2, 4); final SolrClient clientUnderTest = getRandomClient(); - final SolrPingResponse response = clientUnderTest.ping(testCollection); + final QueryResponse response = clientUnderTest.query(testCollection, new SolrQuery("*:*")); assertEquals("This should be OK", 0, response.getStatus()); DocCollection c = cluster.getZkStateReader().getCollection(testCollection); diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpJdkSolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpJdkSolrClientTest.java index 9f9233f375e8..c18277bed2b0 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpJdkSolrClientTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpJdkSolrClientTest.java @@ -51,7 +51,6 @@ import org.apache.solr.client.solrj.request.json.JsonQueryRequest; import org.apache.solr.client.solrj.response.JavaBinResponseParser; import org.apache.solr.client.solrj.response.ResponseParser; -import org.apache.solr.client.solrj.response.SolrPingResponse; import org.apache.solr.client.solrj.response.XMLResponseParser; import org.apache.solr.common.params.CommonParams; import org.apache.solr.common.params.MapSolrParams; @@ -614,15 +613,6 @@ public void testCookieHandlerSettingHonored() throws Exception { } } - @Test - public void testPing() throws Exception { - try (HttpJdkSolrClient client = builder(solrTestRule.getBaseUrl()).build()) { - SolrPingResponse spr = client.ping("collection1"); - assertEquals(0, spr.getStatus()); - assertNull(spr.getException()); - } - } - @Test public void testMaybeTryHeadRequestHasContentType() throws Exception { DebugServlet.clear(); diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/request/SolrPingTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/request/SolrPingTest.java deleted file mode 100644 index 721a94925390..000000000000 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/request/SolrPingTest.java +++ /dev/null @@ -1,85 +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; - -import java.nio.file.Path; -import org.apache.solr.SolrTestCase; -import org.apache.solr.SolrTestCaseJ4; -import org.apache.solr.client.solrj.response.SolrPingResponse; -import org.apache.solr.common.SolrException; -import org.apache.solr.common.SolrInputDocument; -import org.apache.solr.util.EmbeddedSolrServerTestRule; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -/** Test SolrPing in Solrj */ -public class SolrPingTest extends SolrTestCase { - - @ClassRule - public static final EmbeddedSolrServerTestRule solrTestRule = new EmbeddedSolrServerTestRule(); - - @BeforeClass - public static void beforeClass() throws Exception { - Path solrHome = SolrTestCaseJ4.getFile("solrj/solr"); - solrTestRule.startSolr(solrHome); - - SolrTestCaseJ4.newRandomConfig(); - solrTestRule.newCollection().withConfigSet(solrHome.resolve("collection1")).create(); - } - - @Before - @Override - public void setUp() throws Exception { - super.setUp(); - solrTestRule.clearIndex(); - - SolrInputDocument doc = new SolrInputDocument(); - doc.setField("id", 1); - doc.setField("terms_s", "samsung"); - solrTestRule.getSolrClient().add(doc); - solrTestRule.getSolrClient().commit(true, true); - } - - @Test - public void testEnabledSolrPing() throws Exception { - SolrPing ping = new SolrPing(); - SolrPingResponse rsp = null; - ping.setActionEnable(); - ping.process(solrTestRule.getSolrClient()); - ping.removeAction(); - rsp = ping.process(solrTestRule.getSolrClient()); - assertNotNull(rsp); - } - - @Test(expected = SolrException.class) - public void testDisabledSolrPing() throws Exception { - SolrPing ping = new SolrPing(); - SolrPingResponse rsp = null; - ping.setActionDisable(); - try { - ping.process(solrTestRule.getSolrClient()); - } catch (Exception e) { - throw new Exception("disable action failed!"); - } - ping.setActionPing(); - rsp = ping.process(solrTestRule.getSolrClient()); - // the above line should fail with a 503 SolrException. - assertNotNull(rsp); - } -} diff --git a/solr/solrj/src/test/org/apache/solr/common/cloud/PerReplicaStatesIntegrationTest.java b/solr/solrj/src/test/org/apache/solr/common/cloud/PerReplicaStatesIntegrationTest.java index 009857689d11..51ef301b2e22 100644 --- a/solr/solrj/src/test/org/apache/solr/common/cloud/PerReplicaStatesIntegrationTest.java +++ b/solr/solrj/src/test/org/apache/solr/common/cloud/PerReplicaStatesIntegrationTest.java @@ -27,9 +27,10 @@ import org.apache.lucene.tests.util.LuceneTestCase.Nightly; import org.apache.solr.client.solrj.SolrClient; import org.apache.solr.client.solrj.request.CollectionAdminRequest; +import org.apache.solr.client.solrj.request.SolrQuery; import org.apache.solr.client.solrj.request.V2Request; import org.apache.solr.client.solrj.response.CollectionAdminResponse; -import org.apache.solr.client.solrj.response.SolrPingResponse; +import org.apache.solr.client.solrj.response.QueryResponse; import org.apache.solr.cloud.MiniSolrCloudCluster; import org.apache.solr.cloud.SolrCloudTestCase; import org.apache.solr.common.NavigableObject; @@ -78,7 +79,7 @@ public void testPerReplicaStateCollection() throws Exception { .process(cluster.getSolrClient()); cluster.waitForActiveCollection(testCollection, 2, 4); final SolrClient clientUnderTest = cluster.getSolrClient(); - final SolrPingResponse response = clientUnderTest.ping(testCollection); + final QueryResponse response = clientUnderTest.query(testCollection, new SolrQuery("*:*")); assertEquals("This should be OK", 0, response.getStatus()); DocCollection c = cluster.getZkStateReader().getCollection(testCollection); c.forEachReplica((s, replica) -> assertNotNull(replica.getReplicaState())); diff --git a/solr/webapp/src/test/org/apache/solr/webapp/AdminUiCollectionScreensTest.java b/solr/webapp/src/test/org/apache/solr/webapp/AdminUiCollectionScreensTest.java index f758d46e11b4..274288f5879f 100644 --- a/solr/webapp/src/test/org/apache/solr/webapp/AdminUiCollectionScreensTest.java +++ b/solr/webapp/src/test/org/apache/solr/webapp/AdminUiCollectionScreensTest.java @@ -101,7 +101,6 @@ public void testCoreOverviewShowsStats() { openPage(coreName + "/core-overview", By.id("dashboard")); waitForPageContains("Num Docs"); waitForPageContains(Integer.toString(NUM_DOCS)); - // the ping widget answers 503 when the configset has no healthcheck file - assertNoSevereConsoleErrors("/admin/ping"); + assertNoSevereConsoleErrors(); } } diff --git a/solr/webapp/src/test/org/apache/solr/webapp/AdminUiCoreAdminStandaloneTest.java b/solr/webapp/src/test/org/apache/solr/webapp/AdminUiCoreAdminStandaloneTest.java index 0508fd636e79..f0c3b715cc0a 100644 --- a/solr/webapp/src/test/org/apache/solr/webapp/AdminUiCoreAdminStandaloneTest.java +++ b/solr/webapp/src/test/org/apache/solr/webapp/AdminUiCoreAdminStandaloneTest.java @@ -63,8 +63,7 @@ public void testStandaloneMenus() { openPage("swapa/core-overview", By.id("dashboard")); waitFor(By.cssSelector("#core-menu .query")); waitFor(By.cssSelector("#core-menu .replication")); - // the ping widget answers 503 when the configset has no healthcheck file - assertNoSevereConsoleErrors("/admin/ping"); + assertNoSevereConsoleErrors(); } @Test diff --git a/solr/webapp/src/test/org/apache/solr/webapp/AdminUiSmokeTest.java b/solr/webapp/src/test/org/apache/solr/webapp/AdminUiSmokeTest.java index 5dfc5b2a4517..a20059160181 100644 --- a/solr/webapp/src/test/org/apache/solr/webapp/AdminUiSmokeTest.java +++ b/solr/webapp/src/test/org/apache/solr/webapp/AdminUiSmokeTest.java @@ -91,9 +91,7 @@ public void testCoreScreens() { coreName + "/plugins", By.id("plugins"), coreName + "/segments", By.id("segments")); screens.forEach(this::smoke); - // the ping widget on the overview answers 503 when no healthcheck file is configured, - // as is the case for the _default configset - smoke(coreName + "/core-overview", By.id("dashboard"), "/admin/ping"); + smoke(coreName + "/core-overview", By.id("dashboard")); } private void smoke(String route, By anchor) { diff --git a/solr/webapp/web/index.html b/solr/webapp/web/index.html index 46535d6b7427..2b136be845b0 100644 --- a/solr/webapp/web/index.html +++ b/solr/webapp/web/index.html @@ -250,7 +250,6 @@

Connection recovered...

  • Documents
  • Paramsets
  • Files
  • -
  • Ping ({{pingMS}}ms)
  • Plugins / Stats
  • Query
  • Replication
  • diff --git a/solr/webapp/web/js/angular/app.js b/solr/webapp/web/js/angular/app.js index 27a2f458682f..2af813f9b187 100644 --- a/solr/webapp/web/js/angular/app.js +++ b/solr/webapp/web/js/angular/app.js @@ -510,7 +510,7 @@ solrAdminApp.config([ }; }); -solrAdminApp.controller('MainController', function($scope, $route, $rootScope, $location, $timeout, CoresV2, CollectionsV2, AliasesV2, SystemV2, Ping, Constants, SchemaDesigner, ApiErrorHandler) { +solrAdminApp.controller('MainController', function($scope, $route, $rootScope, $location, $timeout, CoresV2, CollectionsV2, AliasesV2, SystemV2, Constants, SchemaDesigner, ApiErrorHandler) { $rootScope.exceptions={}; @@ -640,14 +640,6 @@ solrAdminApp.controller('MainController', function($scope, $route, $rootScope, $ return selectedColl && selectedColl.type === 'alias' && selectedColl.collections.includes(','); }; - $scope.ping = function() { - Ping.ping({core: $scope.currentCore.name}, function(data) { - $scope.showPing = true; - $scope.pingMS = data.responseHeader.QTime; - }); - // @todo .attr( 'title', '/admin/ping is not configured (' + xhr.status + ': ' + error_thrown + ')' ); - }; - $scope.dumpCloud = function() { $scope.$broadcast("cloud-dump"); } diff --git a/solr/webapp/web/js/angular/controllers/core-overview.js b/solr/webapp/web/js/angular/controllers/core-overview.js index 4c97e6d12b07..5b0f59909426 100644 --- a/solr/webapp/web/js/angular/controllers/core-overview.js +++ b/solr/webapp/web/js/angular/controllers/core-overview.js @@ -16,7 +16,7 @@ */ solrAdminApp.controller('CoreOverviewController', -function($scope, $rootScope, $routeParams, Luke, CoreInfo, Update, Replication, Ping, Constants) { +function($scope, $rootScope, $routeParams, Luke, CoreInfo, Update, Replication, Constants) { $scope.resetMenu("overview", Constants.IS_CORE_PAGE); $scope.refreshIndex = function() { Luke.index({core: $routeParams.core}, @@ -54,40 +54,10 @@ function($scope, $rootScope, $routeParams, Luke, CoreInfo, Update, Replication, ); }; - $scope.refreshPing = function() { - Ping.status({core: $routeParams.core}, function(data) { - if (data.error) { - $scope.healthcheckStatus = false; - if (data.error.code == 503) { - $scope.healthcheckMessage = 'Ping request handler is not configured with a healthcheck file.'; - } - } else { - $scope.healthcheckStatus = data.status == "enabled"; - } - }); - }; - - $scope.toggleHealthcheck = function() { - if ($scope.healthcheckStatus) { - Ping.disable( - {core: $routeParams.core}, - function(data) {$scope.healthcheckStatus = false}, - function(error) {$scope.healthcheckMessage = error} - ); - } else { - Ping.enable( - {core: $routeParams.core}, - function(data) {$scope.healthcheckStatus = true}, - function(error) {$scope.healthcheckMessage = error} - ); - } - }; - $scope.refresh = function() { $scope.refreshIndex(); $scope.refreshReplication(); $scope.refreshInfo(); - $scope.refreshPing(); }; $scope.refresh(); diff --git a/solr/webapp/web/js/angular/services.js b/solr/webapp/web/js/angular/services.js index f75a2f9d3c6c..269e3028ce2a 100644 --- a/solr/webapp/web/js/angular/services.js +++ b/solr/webapp/web/js/angular/services.js @@ -304,15 +304,6 @@ solrAdminServices.factory('Metrics', "field": {params: {"analysis.showmatch": true}} }); }]) -.factory('Ping', - ['$resource', function($resource) { - return $resource(':core/admin/ping', {wt:'json', core: '@core', ts:Date.now(), _:Date.now()}, { - "ping": {}, - "enable": {params:{action:"enable"}, headers: {doNotIntercept: "true"}}, - "disable": {params:{action:"disable"}, headers: {doNotIntercept: "true"}}, - "status": {params:{action:"status"}, headers: {doNotIntercept: "true"} - }}); - }]) .factory('Files', ['$resource', function($resource) { return $resource(':core/admin/file', {'wt':'json', core: '@core', '_':Date.now()}, { diff --git a/solr/webapp/web/partials/core_overview.html b/solr/webapp/web/partials/core_overview.html index a17b5aa0caba..11349b375e6e 100644 --- a/solr/webapp/web/partials/core_overview.html +++ b/solr/webapp/web/partials/core_overview.html @@ -174,28 +174,6 @@

    -
    - -

    Healthcheck

    - -
    -
    {{healthcheckMessage}}
    -
    - -
    -
    - -
    Status:
    -
    - -
    -
    - -
    -
    -
    - -