Skip to content
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

;-) Look slike you have some debugging?

Copy link
Copy Markdown
Contributor Author

@jaykay12 jaykay12 May 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, started with firstly wiring this api to give any random response, & now using this to compare my V2 response with the original V2 response, 😄 thus, kept a different api endpoint for now to do response comparision.

will surely update this during self-review before raising for formal review 💯

public interface ListActiveTasksApi {
@GET
@StoreApiParameters
@Operation(
summary = "Lists all the currently running tasks or status of any taskUUID being passed as queryParam",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, have updated this Api class for now, handling the taskUUID as a path param now, it was queryParam in the V1 as well as homegrown v2.

tags = {"tasks"})
ListActiveTaskResponse listActiveTasks(
@QueryParam("taskUUID") String taskUUID) throws Exception;
}
Original file line number Diff line number Diff line change
@@ -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;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, have done so.

}
Original file line number Diff line number Diff line change
@@ -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 {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not quite sure I see the differences in the two paths yet?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea, i am also checking this up.
I have tested this endpoint by running on cloud example which we have in examples, it worked fine. It should work fine for standalone as well, will remove the current conditional branching done once that's verified.

if (log.isDebugEnabled()) {
log.debug("standalone solr");
}
handleStandAloneMode(response, taskUUID);
}

log.debug("something random");

return response;

}

private void handleStandAloneMode(ListActiveTaskResponse response, String taskUUID) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

understood this part, have made suitable changes.

Iterator<Map.Entry<String, String>> iterator = solrQueryRequest.getCore().getCancellableQueryTracker().getActiveQueriesGenerated();

Map<String, String> taskList = new HashMap<>();
while (iterator.hasNext()) {
Map.Entry<String, String> entry = iterator.next();
taskList.put(entry.getKey(), entry.getValue());
}

response.taskList = taskList;
}

private void handleSolrCloudMode(ListActiveTaskResponse response, String taskUUID) {
Iterator<Map.Entry<String, String>> iterator = solrQueryRequest.getCore().getCancellableQueryTracker().getActiveQueriesGenerated();

Map<String, String> taskList = new HashMap<>();
while (iterator.hasNext()) {
Map.Entry<String, String> entry = iterator.next();
taskList.put(entry.getKey(), entry.getValue());
}

response.taskList = taskList;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.apache.solr.api.JerseyResource;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.SolrCore;
import org.apache.solr.handler.RequestHandlerBase;
import org.apache.solr.handler.admin.api.ListActiveTasks;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.security.PermissionNameProvider;
Expand Down Expand Up @@ -132,4 +135,9 @@ public static ResponseBuilder buildResponseBuilder(

return rb;
}

@Override
public Collection<Class<? extends JerseyResource>> getJerseyResources() {
return List.of(ListActiveTasks.class);
}
}
Loading