gerlowskija commented on code in PR #1144:
URL: https://github.com/apache/solr/pull/1144#discussion_r1036084453
##########
solr/core/src/java/org/apache/solr/handler/admin/ZookeeperInfoHandler.java:
##########
@@ -116,22 +114,22 @@ public Name getPermissionName(AuthorizationContext
request) {
}
/** Enumeration of ways to filter collections on the graph panel. */
- static enum FilterType {
+ public static enum FilterType {
none,
name,
status
}
/** Holds state of a single page of collections requested from the cloud
panel. */
Review Comment:
[0] This is unrelated to your PR, but the way this is tightly coupled to
Solr's Admin UI is a real shame.
##########
solr/core/src/java/org/apache/solr/handler/admin/ZookeeperInfoHandler.java:
##########
@@ -358,96 +357,45 @@ public void command() {
@Override
@SuppressWarnings({"unchecked"})
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp)
throws Exception {
+ final ZookeeperAPI zookeeperAPI = new ZookeeperAPI(cores, req, rsp);
final SolrParams params = req.getParams();
- Map<String, String> map = new HashMap<>(1);
- map.put(WT, "raw");
- map.put(OMIT_HEADER, "true");
- req.setParams(SolrParams.wrapDefaults(new MapSolrParams(map), params));
- synchronized (this) {
- if (pagingSupport == null) {
- pagingSupport = new PagedCollectionSupport();
- ZkController zkController = cores.getZkController();
- if (zkController != null) {
- // get notified when the ZK session expires (so we can clear the
cached collections and
- // rebuild)
- zkController.addOnReconnectListener(pagingSupport);
- }
- }
- }
-
- String path = params.get(PATH);
-
- if (params.get("addr") != null) {
- throw new SolrException(ErrorCode.BAD_REQUEST, "Illegal parameter
\"addr\"");
- }
-
- String detailS = params.get(PARAM_DETAIL);
- boolean detail = detailS != null && detailS.equals("true");
-
- String dumpS = params.get("dump");
- boolean dump = dumpS != null && dumpS.equals("true");
-
- int start = params.getInt("start", 0); // Note start ignored if rows not
specified
- int rows = params.getInt("rows", -1);
-
- String filterType = params.get("filterType");
- if (filterType != null) {
- filterType = filterType.trim().toLowerCase(Locale.ROOT);
- if (filterType.length() == 0) filterType = null;
+ if (params.get(PATH) == null) {
+ V2ApiUtils.squashIntoNamedList(rsp.getValues(), zookeeperAPI.getFiles());
+ } else {
+ V2ApiUtils.squashIntoNamedList(rsp.getValues(), zookeeperAPI.getFile());
}
- FilterType type = (filterType != null) ? FilterType.valueOf(filterType) :
FilterType.none;
+ }
- String filter = (type != FilterType.none) ? params.get("filter") : null;
- if (filter != null) {
- filter = filter.trim();
- if (filter.length() == 0) filter = null;
- }
+ @Override
+ public Boolean registerV2() {
+ return true;
+ }
- ZKPrinter printer = new ZKPrinter(cores.getZkController());
- printer.detail = detail;
- printer.dump = dump;
- boolean isGraphView = "graph".equals(params.get("view"));
- // There is no znode /clusterstate.json (removed in Solr 9), but we do as
if there's one and
- // return collection listing. Need to change services.js if cleaning up
here, collection list is
- // used from Admin UI Cloud - Graph
- boolean paginateCollections = (isGraphView &&
"/clusterstate.json".equals(path));
- printer.page = paginateCollections ? new PageOfCollections(start, rows,
type, filter) : null;
- printer.pagingSupport = pagingSupport;
-
- try {
- if (paginateCollections) {
- // List collections and allow pagination, but no specific znode info
like when looking at a
- // normal ZK path
- printer.printPaginatedCollections();
- } else {
- printer.print(path);
- }
- } finally {
- printer.close();
- }
- rsp.getValues().add(RawResponseWriter.CONTENT, printer);
+ @Override
+ public Collection<Class<? extends JerseyResource>> getJerseyResources() {
+ return List.of(ZookeeperAPI.class);
}
//
--------------------------------------------------------------------------------------
//
//
--------------------------------------------------------------------------------------
- static class ZKPrinter implements ContentStream {
+ public static class ZKPrinter implements ContentStream {
static boolean FULLPATH_DEFAULT = false;
boolean indent = true;
boolean fullpath = FULLPATH_DEFAULT;
- boolean detail = false;
- boolean dump = false;
+ public boolean detail = false;
Review Comment:
[-0] I wonder about all the visibility changes in the nested-classes in this
PR. As I read this diff, they're not really used in this Handler any more
since the logic has (rightly) all moved into the API class...could we avoid the
visibility escalation by moving the classes out of here and into the one place
they're actually used (i.e. `ZooKeeperAPI`)?
Alternatively, we could avoid making the internal fields public and instead
add getters/setters for those fields. Though that may not be worth the
effort....
##########
solr/core/src/java/org/apache/solr/handler/admin/ZookeeperStatusHandler.java:
##########
@@ -75,27 +76,18 @@ public Category getCategory() {
@Override
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp)
throws Exception {
- NamedList<Object> values = rsp.getValues();
- if (cores.isZooKeeperAware()) {
- String zkHost = cores.getZkController().getZkServerAddress();
- ZkDynamicConfig dynConfig = null;
- try {
- SolrZkClient zkClient = cores.getZkController().getZkClient();
- dynConfig = ZkDynamicConfig.parseLines(zkClient.getConfig());
- } catch (SolrException e) {
- if (!(e.getCause() instanceof KeeperException)) {
- throw e;
- }
- if (log.isWarnEnabled()) {
- log.warn("{} - Continuing with static connection string",
e.toString());
- }
- }
- values.add("zkStatus", getZkStatus(zkHost, dynConfig));
- } else {
- throw new SolrException(
- SolrException.ErrorCode.BAD_REQUEST,
- "The Zookeeper status API is only available in Cloud mode");
- }
+ final ZookeeperAPI zookeeperAPI = new ZookeeperAPI(cores, req, rsp);
+ V2ApiUtils.squashIntoNamedList(rsp.getValues(), zookeeperAPI.getStatus());
+ }
+
+ @Override
+ public Boolean registerV2() {
+ return true;
+ }
+
+ @Override
+ public Collection<Class<? extends JerseyResource>> getJerseyResources() {
+ return List.of(ZookeeperAPI.class);
Review Comment:
[Q] Hmm, `ZookeeperAPI` gets associated with (and registered by) both
ZooKeeperInfoHandler and ZooKeeperStatusHandler...I wonder how Jersey handles
that double-registration. Just leaving this as a reminder to myself to debug
this a bit.
##########
solr/core/src/java/org/apache/solr/handler/admin/api/ZookeeperAPI.java:
##########
@@ -0,0 +1,285 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.handler.admin.api;
+
+import static
org.apache.solr.client.solrj.impl.BinaryResponseParser.BINARY_CONTENT_TYPE_V2;
+import static org.apache.solr.common.params.CommonParams.OMIT_HEADER;
+import static org.apache.solr.common.params.CommonParams.PATH;
+import static org.apache.solr.common.params.CommonParams.WT;
+import static
org.apache.solr.security.PermissionNameProvider.Name.ZK_READ_PERM;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.v3.oas.annotations.Operation;
+import java.lang.invoke.MethodHandles;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import org.apache.solr.api.JerseyResource;
+import org.apache.solr.cloud.ZkController;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.SolrException.ErrorCode;
+import org.apache.solr.common.cloud.SolrZkClient;
+import org.apache.solr.common.cloud.ZkDynamicConfig;
+import org.apache.solr.common.params.SolrParams;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.handler.admin.ZookeeperInfoHandler.FilterType;
+import org.apache.solr.handler.admin.ZookeeperInfoHandler.PageOfCollections;
+import
org.apache.solr.handler.admin.ZookeeperInfoHandler.PagedCollectionSupport;
+import org.apache.solr.handler.admin.ZookeeperInfoHandler.ZKPrinter;
+import org.apache.solr.handler.admin.ZookeeperStatusHandler;
+import org.apache.solr.jersey.PermissionName;
+import org.apache.solr.jersey.SolrJerseyResponse;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.zookeeper.KeeperException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Path("/cluster/zookeeper/")
+public class ZookeeperAPI extends JerseyResource {
+
+ private static final Logger log =
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ private final CoreContainer coreContainer;
+ private final SolrQueryRequest solrQueryRequest;
+ private final SolrQueryResponse solrQueryResponse;
+ private PagedCollectionSupport pagingSupport;
+
+ @Inject
+ public ZookeeperAPI(
+ CoreContainer coreContainer,
+ SolrQueryRequest solrQueryRequest,
+ SolrQueryResponse solrQueryResponse) {
+ this.coreContainer = coreContainer;
+ this.solrQueryRequest = solrQueryRequest;
+ this.solrQueryResponse = solrQueryResponse;
+ }
+
+ @GET
+ @Path("/files")
+ @Produces({"application/json", "application/xml", BINARY_CONTENT_TYPE_V2})
+ @Operation(
+ summary = "List Zookeeper files.",
+ tags = {"zookeeperFiles"})
+ @PermissionName(ZK_READ_PERM)
+ public ZookeeperFilesResponse getFiles() throws Exception {
+ final ZookeeperFilesResponse response =
instantiateJerseyResponse(ZookeeperFilesResponse.class);
+ final SolrParams params = solrQueryRequest.getParams();
+ Map<String, String> map = new HashMap<>(1);
+ map.put(WT, "raw");
+ map.put(OMIT_HEADER, "true");
+ // solrQueryRequest.setParams(SolrParams.wrapDefaults(new
MapSolrParams(map), params));
+ synchronized (this) {
+ if (pagingSupport == null) {
+ pagingSupport = new PagedCollectionSupport();
+ ZkController zkController = coreContainer.getZkController();
+ if (zkController != null) {
+ // get notified when the ZK session expires (so we can clear the
cached collections and
+ // rebuild)
+ zkController.addOnReconnectListener(pagingSupport);
+ }
+ }
+ }
+
+ String path = params.get(PATH);
Review Comment:
[-1] Fetching parameters off of the `SolrQueryRequest` gets the job done,
but it doesn't make use of the strong-typing or clear enumeration of
inputs/outputs that's one of the big draws of using JAX-RS for our APIs.
i.e. It makes it hard to tell what the APIs inputs are from the method
signature alone. Any OpenAPI spec we generate for this API won't know about
the stuff we get off of SolrQueryRequest, etc.
I'd rather we put any inputs that this API requires up in the method
signature (and modify the v1 code to pass those in when it calls
`ZooKeeperAPI.getFile`
##########
solr/core/src/java/org/apache/solr/handler/admin/api/ZookeeperAPI.java:
##########
@@ -0,0 +1,285 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.handler.admin.api;
+
+import static
org.apache.solr.client.solrj.impl.BinaryResponseParser.BINARY_CONTENT_TYPE_V2;
+import static org.apache.solr.common.params.CommonParams.OMIT_HEADER;
+import static org.apache.solr.common.params.CommonParams.PATH;
+import static org.apache.solr.common.params.CommonParams.WT;
+import static
org.apache.solr.security.PermissionNameProvider.Name.ZK_READ_PERM;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.v3.oas.annotations.Operation;
+import java.lang.invoke.MethodHandles;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import org.apache.solr.api.JerseyResource;
+import org.apache.solr.cloud.ZkController;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.SolrException.ErrorCode;
+import org.apache.solr.common.cloud.SolrZkClient;
+import org.apache.solr.common.cloud.ZkDynamicConfig;
+import org.apache.solr.common.params.SolrParams;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.handler.admin.ZookeeperInfoHandler.FilterType;
+import org.apache.solr.handler.admin.ZookeeperInfoHandler.PageOfCollections;
+import
org.apache.solr.handler.admin.ZookeeperInfoHandler.PagedCollectionSupport;
+import org.apache.solr.handler.admin.ZookeeperInfoHandler.ZKPrinter;
+import org.apache.solr.handler.admin.ZookeeperStatusHandler;
+import org.apache.solr.jersey.PermissionName;
+import org.apache.solr.jersey.SolrJerseyResponse;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.zookeeper.KeeperException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Path("/cluster/zookeeper/")
+public class ZookeeperAPI extends JerseyResource {
+
+ private static final Logger log =
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ private final CoreContainer coreContainer;
+ private final SolrQueryRequest solrQueryRequest;
+ private final SolrQueryResponse solrQueryResponse;
+ private PagedCollectionSupport pagingSupport;
+
+ @Inject
+ public ZookeeperAPI(
+ CoreContainer coreContainer,
+ SolrQueryRequest solrQueryRequest,
+ SolrQueryResponse solrQueryResponse) {
+ this.coreContainer = coreContainer;
+ this.solrQueryRequest = solrQueryRequest;
+ this.solrQueryResponse = solrQueryResponse;
+ }
+
+ @GET
+ @Path("/files")
+ @Produces({"application/json", "application/xml", BINARY_CONTENT_TYPE_V2})
+ @Operation(
+ summary = "List Zookeeper files.",
+ tags = {"zookeeperFiles"})
+ @PermissionName(ZK_READ_PERM)
+ public ZookeeperFilesResponse getFiles() throws Exception {
+ final ZookeeperFilesResponse response =
instantiateJerseyResponse(ZookeeperFilesResponse.class);
+ final SolrParams params = solrQueryRequest.getParams();
+ Map<String, String> map = new HashMap<>(1);
+ map.put(WT, "raw");
+ map.put(OMIT_HEADER, "true");
+ // solrQueryRequest.setParams(SolrParams.wrapDefaults(new
MapSolrParams(map), params));
+ synchronized (this) {
+ if (pagingSupport == null) {
+ pagingSupport = new PagedCollectionSupport();
+ ZkController zkController = coreContainer.getZkController();
+ if (zkController != null) {
+ // get notified when the ZK session expires (so we can clear the
cached collections and
+ // rebuild)
+ zkController.addOnReconnectListener(pagingSupport);
+ }
+ }
+ }
+
+ String path = params.get(PATH);
+
+ if (params.get("addr") != null) {
+ throw new SolrException(ErrorCode.BAD_REQUEST, "Illegal parameter
\"addr\"");
+ }
+
+ boolean detail = false;
+
+ String dumpS = params.get("dump");
+ boolean dump = dumpS != null && dumpS.equals("true");
+
+ int start = params.getInt("start", 0); // Note start ignored if rows not
specified
+ int rows = params.getInt("rows", -1);
+
+ String filterType = params.get("filterType");
+ if (filterType != null) {
+ filterType = filterType.trim().toLowerCase(Locale.ROOT);
+ if (filterType.length() == 0) filterType = null;
+ }
+ FilterType type = (filterType != null) ? FilterType.valueOf(filterType) :
FilterType.none;
+
+ String filter = (type != FilterType.none) ? params.get("filter") : null;
+ if (filter != null) {
+ filter = filter.trim();
+ if (filter.length() == 0) filter = null;
+ }
+
+ ZKPrinter printer = new ZKPrinter(coreContainer.getZkController());
+ printer.detail = detail;
+ printer.dump = dump;
+ boolean isGraphView = "graph".equals(params.get("view"));
+ // There is no znode /clusterstate.json (removed in Solr 9), but we do as
if there's one and
+ // return collection listing. Need to change services.js if cleaning up
here, collection list is
+ // used from Admin UI Cloud - Graph
+ boolean paginateCollections = (isGraphView &&
"/clusterstate.json".equals(path));
+ printer.page = paginateCollections ? new PageOfCollections(start, rows,
type, filter) : null;
+ printer.pagingSupport = pagingSupport;
+
+ try {
+ if (paginateCollections) {
+ // List collections and allow pagination, but no specific znode info
like when looking at a
+ // normal ZK path
+ response.zookeeperFiles = printer.printPaginatedCollections();
+ } else {
+ response.zookeeperFiles = printer.print(path);
+ }
+ } finally {
+ printer.close();
+ }
+ return response;
+ }
+
+ @GET
+ @Path("/files/{path}")
+ @Produces({"application/json", "application/xml", BINARY_CONTENT_TYPE_V2})
+ @Operation(
+ summary = "List Zookeeper file.",
+ tags = {"zookeeperFile"})
+ @PermissionName(ZK_READ_PERM)
+ public ZookeeperFileResponse getFile() throws Exception {
+ final ZookeeperFileResponse response =
instantiateJerseyResponse(ZookeeperFileResponse.class);
+ final SolrParams params = solrQueryRequest.getParams();
+ Map<String, String> map = new HashMap<>(1);
+ map.put(WT, "raw");
+ map.put(OMIT_HEADER, "true");
Review Comment:
[0] Some of this code is common to `getFiles`, `getFile`, and `getStatus`
and should maybe be in a shared private method?
##########
solr/core/src/java/org/apache/solr/handler/admin/api/ZookeeperAPI.java:
##########
@@ -0,0 +1,285 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.handler.admin.api;
+
+import static
org.apache.solr.client.solrj.impl.BinaryResponseParser.BINARY_CONTENT_TYPE_V2;
+import static org.apache.solr.common.params.CommonParams.OMIT_HEADER;
+import static org.apache.solr.common.params.CommonParams.PATH;
+import static org.apache.solr.common.params.CommonParams.WT;
+import static
org.apache.solr.security.PermissionNameProvider.Name.ZK_READ_PERM;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.v3.oas.annotations.Operation;
+import java.lang.invoke.MethodHandles;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import org.apache.solr.api.JerseyResource;
+import org.apache.solr.cloud.ZkController;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.SolrException.ErrorCode;
+import org.apache.solr.common.cloud.SolrZkClient;
+import org.apache.solr.common.cloud.ZkDynamicConfig;
+import org.apache.solr.common.params.SolrParams;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.handler.admin.ZookeeperInfoHandler.FilterType;
+import org.apache.solr.handler.admin.ZookeeperInfoHandler.PageOfCollections;
+import
org.apache.solr.handler.admin.ZookeeperInfoHandler.PagedCollectionSupport;
+import org.apache.solr.handler.admin.ZookeeperInfoHandler.ZKPrinter;
+import org.apache.solr.handler.admin.ZookeeperStatusHandler;
+import org.apache.solr.jersey.PermissionName;
+import org.apache.solr.jersey.SolrJerseyResponse;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.zookeeper.KeeperException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Path("/cluster/zookeeper/")
+public class ZookeeperAPI extends JerseyResource {
+
+ private static final Logger log =
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ private final CoreContainer coreContainer;
+ private final SolrQueryRequest solrQueryRequest;
+ private final SolrQueryResponse solrQueryResponse;
+ private PagedCollectionSupport pagingSupport;
+
+ @Inject
+ public ZookeeperAPI(
+ CoreContainer coreContainer,
+ SolrQueryRequest solrQueryRequest,
+ SolrQueryResponse solrQueryResponse) {
+ this.coreContainer = coreContainer;
+ this.solrQueryRequest = solrQueryRequest;
+ this.solrQueryResponse = solrQueryResponse;
+ }
+
+ @GET
+ @Path("/files")
+ @Produces({"application/json", "application/xml", BINARY_CONTENT_TYPE_V2})
+ @Operation(
+ summary = "List Zookeeper files.",
+ tags = {"zookeeperFiles"})
+ @PermissionName(ZK_READ_PERM)
+ public ZookeeperFilesResponse getFiles() throws Exception {
+ final ZookeeperFilesResponse response =
instantiateJerseyResponse(ZookeeperFilesResponse.class);
+ final SolrParams params = solrQueryRequest.getParams();
+ Map<String, String> map = new HashMap<>(1);
+ map.put(WT, "raw");
+ map.put(OMIT_HEADER, "true");
+ // solrQueryRequest.setParams(SolrParams.wrapDefaults(new
MapSolrParams(map), params));
+ synchronized (this) {
+ if (pagingSupport == null) {
+ pagingSupport = new PagedCollectionSupport();
+ ZkController zkController = coreContainer.getZkController();
+ if (zkController != null) {
+ // get notified when the ZK session expires (so we can clear the
cached collections and
+ // rebuild)
+ zkController.addOnReconnectListener(pagingSupport);
+ }
+ }
+ }
+
+ String path = params.get(PATH);
+
+ if (params.get("addr") != null) {
+ throw new SolrException(ErrorCode.BAD_REQUEST, "Illegal parameter
\"addr\"");
+ }
+
+ boolean detail = false;
+
+ String dumpS = params.get("dump");
+ boolean dump = dumpS != null && dumpS.equals("true");
+
+ int start = params.getInt("start", 0); // Note start ignored if rows not
specified
+ int rows = params.getInt("rows", -1);
+
+ String filterType = params.get("filterType");
+ if (filterType != null) {
+ filterType = filterType.trim().toLowerCase(Locale.ROOT);
+ if (filterType.length() == 0) filterType = null;
+ }
+ FilterType type = (filterType != null) ? FilterType.valueOf(filterType) :
FilterType.none;
+
+ String filter = (type != FilterType.none) ? params.get("filter") : null;
+ if (filter != null) {
+ filter = filter.trim();
+ if (filter.length() == 0) filter = null;
+ }
+
+ ZKPrinter printer = new ZKPrinter(coreContainer.getZkController());
+ printer.detail = detail;
+ printer.dump = dump;
+ boolean isGraphView = "graph".equals(params.get("view"));
+ // There is no znode /clusterstate.json (removed in Solr 9), but we do as
if there's one and
+ // return collection listing. Need to change services.js if cleaning up
here, collection list is
+ // used from Admin UI Cloud - Graph
+ boolean paginateCollections = (isGraphView &&
"/clusterstate.json".equals(path));
+ printer.page = paginateCollections ? new PageOfCollections(start, rows,
type, filter) : null;
+ printer.pagingSupport = pagingSupport;
+
+ try {
+ if (paginateCollections) {
+ // List collections and allow pagination, but no specific znode info
like when looking at a
+ // normal ZK path
+ response.zookeeperFiles = printer.printPaginatedCollections();
+ } else {
+ response.zookeeperFiles = printer.print(path);
+ }
+ } finally {
+ printer.close();
+ }
+ return response;
+ }
+
+ @GET
+ @Path("/files/{path}")
+ @Produces({"application/json", "application/xml", BINARY_CONTENT_TYPE_V2})
+ @Operation(
+ summary = "List Zookeeper file.",
Review Comment:
[0] Looks like a copy/paste mistake from the API above? I'd expect the
summary here to be something about fetching a specific single ZK file.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]