epugh commented on code in PR #4452:
URL: https://github.com/apache/solr/pull/4452#discussion_r3269690172
##########
solr/core/src/java/org/apache/solr/handler/admin/api/ListActiveTasks.java:
##########
@@ -0,0 +1,82 @@
+package org.apache.solr.handler.admin.api;
+
+import jakarta.inject.Inject;
+import org.apache.solr.api.JerseyResource;
+import org.apache.solr.client.api.endpoint.ListActiveTasksApi;
+import org.apache.solr.client.api.model.ListActiveTaskResponse;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.jersey.PermissionName;
+import org.apache.solr.request.SolrQueryRequest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.lang.invoke.MethodHandles;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import static org.apache.solr.security.PermissionNameProvider.Name.READ_PERM;
+
+public class ListActiveTasks extends JerseyResource implements
ListActiveTasksApi {
+
+ private static final Logger log =
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ private final SolrQueryRequest solrQueryRequest;
+
+ @Inject
+ public ListActiveTasks(
+ SolrQueryRequest solrQueryRequest) {
+ this.solrQueryRequest = solrQueryRequest;
+ }
+
+
+
+ @Override
+ @PermissionName(READ_PERM)
+ public ListActiveTaskResponse listActiveTasks(String taskUUID) throws
Exception {
+
+ final ListActiveTaskResponse response =
instantiateJerseyResponse(ListActiveTaskResponse.class);
+ CoreContainer coreContainer = solrQueryRequest.getCoreContainer();
+
+ if (coreContainer.isZooKeeperAware()) {
+ if (log.isDebugEnabled()) {
+ log.debug("solr cloud");
+ }
+ handleSolrCloudMode(response, taskUUID);
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("standalone solr");
+ }
+ handleStandAloneMode(response, taskUUID);
+ }
+
+ log.debug("something random");
+
+ return response;
+
+ }
+
+ private void handleStandAloneMode(ListActiveTaskResponse response, String
taskUUID) {
Review Comment:
One thing we are trying to do is move the V1 API logic into the V2 code
base, and have the V1 call the V2 version, this way, as these apis evolve, we
know that v1 and v2 stay in sync till we get rid of V1. I believe that
ideally we would want `ActiveTasksListComponent` to delegate to the same code
as this V2 api. Now, maybe it's so simple that both can just call core
`getCancellableQueryTracker().getActiveQueriesGenerated`. In other V2 apis,
you can see the code live in the V2 and then V1 calls it...
##########
solr/api/src/java/org/apache/solr/client/api/model/ListActiveTaskResponse.java:
##########
@@ -0,0 +1,9 @@
+package org.apache.solr.client.api.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.Map;
+
+public class ListActiveTaskResponse extends SolrJerseyResponse {
+ @JsonProperty
+ public Map<String, String> taskList;
Review Comment:
We are trying to move to more strongly typed responses so taht we don't have
`Map` everywhere. Go ahead and specify out the return properties!
##########
solr/core/src/java/org/apache/solr/handler/admin/api/ListActiveTasks.java:
##########
@@ -0,0 +1,82 @@
+package org.apache.solr.handler.admin.api;
+
+import jakarta.inject.Inject;
+import org.apache.solr.api.JerseyResource;
+import org.apache.solr.client.api.endpoint.ListActiveTasksApi;
+import org.apache.solr.client.api.model.ListActiveTaskResponse;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.jersey.PermissionName;
+import org.apache.solr.request.SolrQueryRequest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.lang.invoke.MethodHandles;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import static org.apache.solr.security.PermissionNameProvider.Name.READ_PERM;
+
+public class ListActiveTasks extends JerseyResource implements
ListActiveTasksApi {
+
+ private static final Logger log =
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ private final SolrQueryRequest solrQueryRequest;
+
+ @Inject
+ public ListActiveTasks(
+ SolrQueryRequest solrQueryRequest) {
+ this.solrQueryRequest = solrQueryRequest;
+ }
+
+
+
+ @Override
+ @PermissionName(READ_PERM)
+ public ListActiveTaskResponse listActiveTasks(String taskUUID) throws
Exception {
+
+ final ListActiveTaskResponse response =
instantiateJerseyResponse(ListActiveTaskResponse.class);
+ CoreContainer coreContainer = solrQueryRequest.getCoreContainer();
+
+ if (coreContainer.isZooKeeperAware()) {
+ if (log.isDebugEnabled()) {
+ log.debug("solr cloud");
+ }
+ handleSolrCloudMode(response, taskUUID);
+ } else {
Review Comment:
not quite sure I see the differences in the two paths yet?
##########
solr/api/src/java/org/apache/solr/client/api/endpoint/ListActiveTasksApi.java:
##########
@@ -0,0 +1,21 @@
+package org.apache.solr.client.api.endpoint;
+
+import io.swagger.v3.oas.annotations.Operation;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.QueryParam;
+import org.apache.solr.client.api.model.ListActiveTaskResponse;
+import org.apache.solr.client.api.util.StoreApiParameters;
+
+import static org.apache.solr.client.api.util.Constants.INDEX_PATH_PREFIX;
+
+@Path(INDEX_PATH_PREFIX + "/tasks/listjalaz")
+public interface ListActiveTasksApi {
+ @GET
+ @StoreApiParameters
+ @Operation(
+ summary = "Lists all the currently running tasks or status of any
taskUUID being passed as queryParam",
Review Comment:
So, I think we would revamp this api... if you look at the desired api,
ListActiveTasks would just list all tasks. If you wanted a specfific task,
then it would be a idfferent end point with a `/taskUUID`.
--
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]