-
Notifications
You must be signed in to change notification settings - Fork 842
SOLR-18248 : Migration of Tasks V2 APIs to JAX-RS Constructs #4452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jaykay12
wants to merge
63
commits into
apache:main
Choose a base branch
from
jaykay12:SOLR-18248-list-tasks
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
63 commits
Select commit
Hold shift + click to select a range
acccb16
initial changes
jaykay12 e426014
testing
jaykay12 7b15791
working api
jaykay12 02c14b9
working setup
jaykay12 177d2c6
cleanup
jaykay12 95ace8d
cleanup
jaykay12 7dc167a
logging
jaykay12 1a32bb1
minor
jaykay12 6b6f536
Merge branch 'main' into SOLR-18248-list-tasks
jaykay12 d746e21
response model for 2nd API
jaykay12 df5c428
verifies for solr cloud
jaykay12 354d0f5
changes related to pojo & duplicate code removal
jaykay12 1cad09d
removed older interfaces
jaykay12 579925d
removing debug
jaykay12 eb1cd97
done
jaykay12 4e10720
self review
jaykay12 eb9b51b
added cl
jaykay12 adc7006
tidying done
jaykay12 996b45b
added apache license
jaykay12 f6cb8f7
tests
jaykay12 97e5afa
added 1 test
jaykay12 3d72214
added license
jaykay12 68eec35
test corrections
jaykay12 87204e2
minor tidy
jaykay12 930312b
test to check actual active/inactive
jaykay12 ba79375
Merge branch 'main' into SOLR-18248-list-tasks
jaykay12 199cb24
comments addressal
jaykay12 24ca810
comments addressed
jaykay12 c583c38
tidying it up
jaykay12 bb0f0f1
comments addressed
jaykay12 d0ddec6
tidy up
jaykay12 0905202
update
jaykay12 d08d788
minor
jaykay12 1b0b81d
Remove "breadcrumb" pointer, we only do it in one other place.
epugh 200afba
checking
jaykay12 cd97aa6
Merge branch 'main' into SOLR-18248-list-tasks
jaykay12 d161485
this works
jaykay12 12e0a9c
commenting the remaining code & related tests for now
jaykay12 8132972
Fix the path structure, nesting didn't work.
epugh dc5db45
Merge branch 'SOLR-18248-list-tasks' of https://github.com/jaykay12/s…
epugh 02ecda9
Merge branch 'main' into SOLR-18248-list-tasks
jaykay12 a8beb53
Merge branch 'main' into SOLR-18248-list-tasks
jaykay12 6c3ed49
removed commented code
jaykay12 1a6c5e3
pr ready again
jaykay12 4b16add
tidy up
jaykay12 96ad4f4
added license
jaykay12 6133beb
tidy forced
jaykay12 5d0d2ce
Merge branch 'main' into SOLR-18248-list-tasks
jaykay12 c85327f
fixed response format v1-list api
jaykay12 e128b41
changes in response of v1 api
jaykay12 1b67fe2
Test that demonstrates cross shard task status visibility works on main.
epugh 4ba15e4
Merge branch 'SOLR-18248-list-tasks' of https://github.com/jaykay12/s…
epugh 1675c4f
Merge branch 'main' into SOLR-18248-list-tasks
jaykay12 f0896f8
Merge branch 'SOLR-18248-list-tasks' of github.com:jaykay12/solr into…
jaykay12 2286146
Merge branch 'main' into SOLR-18248-list-tasks
jaykay12 eacf2f6
Merge branch 'main' into SOLR-18248-list-tasks
jaykay12 a87890f
changes
jaykay12 feffde3
Merge branch 'main' into SOLR-18248-list-tasks
jaykay12 06363ad
Merge branch 'main' into SOLR-18248-list-tasks
jaykay12 6922c3e
changes
jaykay12 1ae020e
tidying up
jaykay12 9efe214
Merge branch 'main' into SOLR-18248-list-tasks
jaykay12 ce41531
Merge branch 'main' into SOLR-18248-list-tasks
jaykay12 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| title: Migrated ListTasks API & TaskStatus API from homegrown @EndPoint to JAX-RS | ||
| type: added | ||
| authors: | ||
| - name: Jalaz Kumar | ||
| - name: Eric Pugh | ||
| links: | ||
| - name: SOLR-18248 | ||
| url: https://issues.apache.org/jira/browse/SOLR-18248 |
47 changes: 47 additions & 0 deletions
47
solr/api/src/java/org/apache/solr/client/api/endpoint/TasksApi.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| /* | ||
| * 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.api.endpoint; | ||
|
|
||
| import static org.apache.solr.client.api.util.Constants.INDEX_PATH_PREFIX; | ||
|
|
||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import jakarta.ws.rs.GET; | ||
| import jakarta.ws.rs.Path; | ||
| import jakarta.ws.rs.PathParam; | ||
| import org.apache.solr.client.api.model.ListActiveTaskResponse; | ||
| import org.apache.solr.client.api.model.TaskStatusResponse; | ||
| import org.apache.solr.client.api.util.StoreApiParameters; | ||
|
|
||
| @Path(INDEX_PATH_PREFIX + "/tasks") | ||
| public interface TasksApi { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice! |
||
|
|
||
| @GET | ||
| @StoreApiParameters | ||
| @Operation( | ||
| summary = "Lists all the active tasks", | ||
| tags = {"tasks"}) | ||
| ListActiveTaskResponse listAllActiveTasks() throws Exception; | ||
|
|
||
| @GET | ||
| @Path("/{taskID}") | ||
| @StoreApiParameters | ||
| @Operation( | ||
| summary = "Status of a specific task", | ||
| tags = {"tasks"}) | ||
| TaskStatusResponse getTaskStatus(@PathParam("taskID") String taskID) throws Exception; | ||
| } | ||
33 changes: 33 additions & 0 deletions
33
solr/api/src/java/org/apache/solr/client/api/model/ActiveTaskDetails.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /* | ||
| * 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.api.model; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
|
||
| public class ActiveTaskDetails { | ||
|
|
||
| public ActiveTaskDetails() {} | ||
|
|
||
| public ActiveTaskDetails(String taskID, String taskQuery) { | ||
| this.taskID = taskID; | ||
| this.taskQuery = taskQuery; | ||
| } | ||
|
|
||
| @JsonProperty public String taskID; | ||
| @JsonProperty public String taskQuery; | ||
| } |
25 changes: 25 additions & 0 deletions
25
solr/api/src/java/org/apache/solr/client/api/model/ListActiveTaskResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /* | ||
| * 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.api.model; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import java.util.List; | ||
|
|
||
| public class ListActiveTaskResponse extends SolrJerseyResponse { | ||
| @JsonProperty public List<ActiveTaskDetails> taskList; | ||
| } |
40 changes: 40 additions & 0 deletions
40
solr/api/src/java/org/apache/solr/client/api/model/TaskStatusResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| /* | ||
| * 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.api.model; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
|
||
| public class TaskStatusResponse extends SolrJerseyResponse { | ||
|
|
||
| public enum TaskStatus { | ||
| ACTIVE("active"), | ||
| INACTIVE("inactive"); | ||
|
|
||
| private final String value; | ||
|
|
||
| TaskStatus(String value) { | ||
| this.value = value; | ||
| } | ||
|
|
||
| public String getValue() { | ||
| return this.value; | ||
| } | ||
| } | ||
|
|
||
| @JsonProperty public TaskStatus taskStatus; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
solr/core/src/java/org/apache/solr/handler/admin/api/ActiveTask.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| /* | ||
| * 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.security.PermissionNameProvider.Name.READ_PERM; | ||
|
|
||
| import jakarta.inject.Inject; | ||
| import java.util.ArrayList; | ||
| import java.util.Iterator; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import org.apache.solr.api.JerseyResource; | ||
| import org.apache.solr.client.api.endpoint.TasksApi; | ||
| import org.apache.solr.client.api.model.ActiveTaskDetails; | ||
| import org.apache.solr.client.api.model.ListActiveTaskResponse; | ||
| import org.apache.solr.client.api.model.TaskStatusResponse; | ||
| import org.apache.solr.handler.component.ActiveTaskQuerySupport; | ||
| import org.apache.solr.jersey.PermissionName; | ||
| import org.apache.solr.request.SolrQueryRequest; | ||
|
|
||
| public class ActiveTask extends JerseyResource implements TasksApi { | ||
|
|
||
| private final SolrQueryRequest solrQueryRequest; | ||
|
|
||
| @Inject | ||
| public ActiveTask(SolrQueryRequest solrQueryRequest) { | ||
| this.solrQueryRequest = solrQueryRequest; | ||
| } | ||
|
|
||
| @Override | ||
| @PermissionName(READ_PERM) | ||
| public ListActiveTaskResponse listAllActiveTasks() throws Exception { | ||
| final ListActiveTaskResponse response = instantiateJerseyResponse(ListActiveTaskResponse.class); | ||
| response.taskList = ActiveTaskQuerySupport.listActiveTasks(solrQueryRequest); | ||
| return response; | ||
| } | ||
|
|
||
| @Override | ||
| @PermissionName(READ_PERM) | ||
| public TaskStatusResponse getTaskStatus(String taskID) throws Exception { | ||
| final TaskStatusResponse response = instantiateJerseyResponse(TaskStatusResponse.class); | ||
|
|
||
| boolean isTaskActive = ActiveTaskQuerySupport.isTaskActive(solrQueryRequest, taskID); | ||
|
|
||
| response.taskStatus = | ||
| (isTaskActive) | ||
| ? TaskStatusResponse.TaskStatus.ACTIVE | ||
| : TaskStatusResponse.TaskStatus.INACTIVE; | ||
|
|
||
| return response; | ||
| } | ||
|
|
||
| public static List<ActiveTaskDetails> getActiveTasksOnThisShard( | ||
| SolrQueryRequest solrQueryRequest) { | ||
| Iterator<Map.Entry<String, String>> iterator = | ||
| solrQueryRequest.getCore().getCancellableQueryTracker().getActiveQueriesGenerated(); | ||
|
|
||
| List<ActiveTaskDetails> activeTaskDetails = new ArrayList<>(); | ||
| while (iterator.hasNext()) { | ||
| Map.Entry<String, String> entry = iterator.next(); | ||
| activeTaskDetails.add(new ActiveTaskDetails(entry.getKey(), entry.getValue())); | ||
| } | ||
|
|
||
| return activeTaskDetails; | ||
| } | ||
|
|
||
| public static boolean isTaskActiveOnThisShard(SolrQueryRequest solrQueryRequest, String taskId) { | ||
| return solrQueryRequest.getCore().getCancellableQueryTracker().isQueryIdActive(taskId); | ||
| } | ||
| } |
48 changes: 0 additions & 48 deletions
48
solr/core/src/java/org/apache/solr/handler/admin/api/ListActiveTasksAPI.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am expecting a
DELETE /tasks/{taskId}for cancelling a running task. Or... we need a PATCH that does the cancelPATCH /tasks/{taskId}/cancelThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, in this PR scope, #4452 (comment) took only 2 out of 3 API related to Tasks.
Cancel Running task API migration will be a follow-up, independent PR of itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Smart!