ijioio opened a new pull request, #931: URL: https://github.com/apache/solr/pull/931
https://issues.apache.org/jira/browse/SOLR-16282 # Description At the moment implementing custom actions for `CoreAdminHandler` implies subsclassing of the `CoreAdminHandler` and overridng `handleCustomAction` method. This has numerous problems. First, it seems a bit too much for the simple concept of implementing custom actions and quite quirky (out of the way Solr usually do things). The second thing is, current custom actions implementation is just a block of code to be called, so it is not integrated into the standard actions workflow and doesn't use async facility. # Solution Add support for pluggable custom actions. No need to subclass `CoreAdminHandler` at all. Just implement `CoreAdminOp` interface and defined actions within `solr.xml`. Example: `com.ijioio.solr.FooAction` ```java public class FooAction implements CoreAdminOp { @Override public void execute(CallInfo it) throws Exception { NamedList<Object> details = new SimpleOrderedMap<>(); details.add("startTime", Instant.now().toString()); // do some stuff details.add("status", "success"); details.add("endTime", Instant.now().toString()); it.rsp.addResponse(details); } } ``` `solr.xml` ```xml ... <coreAdminHandlerActions> <str name="foo">org.apache.solr.handler.admin.FooAction</str> <str name="bar">org.apache.solr.handler.admin.BarAction</str> </coreAdminHandlerActions> ... ``` Not it possible to call these action by sending requests. ### Sync reaquest Request: `http://localhost:8983/solr/admin/cores?action=foo` Response: ```json { "responseHeader": { "status": 0, "QTime": 8023 }, "response": { "startTime": "2022-07-05T03:35:57.365294500Z", "status": "success", "endTime": "2022-07-05T03:35:57.365547900Z" } } ``` ### Async request Request: `http://localhost:8983/solr/admin/cores?action=foo&async=1000` Response: ```json { "responseHeader": { "status": 0, "QTime": 4020 } } ``` Request: `http://localhost:8983/solr/admin/cores?action=requeststatus&requestid=1000` Response: ```json { "responseHeader": { "status": 0, "QTime": 2308 }, "STATUS": "completed", "msg": "TaskId: 1000 webapp=null path=/admin/cores params={async=1000&action=foo} status=0 QTime=4020", "response": { "startTime": "2022-07-05T03:36:21.910596800Z", "status": "success", "endTime": "2022-07-05T03:36:21.910596800Z" } } ``` # Checklist Please review the following and check all that apply: - [*] I have reviewed the guidelines for [How to Contribute](https://wiki.apache.org/solr/HowToContribute) and my code conforms to the standards described there to the best of my ability. - [*] I have created a Jira issue and added the issue ID to my pull request title. - [*] I have given Solr maintainers [access](https://help.github.com/en/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork) to contribute to my PR branch. (optional but recommended) - [*] I have developed this patch against the `main` branch. - [ ] I have run `./gradlew check`. - [ ] I have added tests for my changes. - [ ] I have added documentation for the [Reference Guide](https://github.com/apache/solr/tree/main/solr/solr-ref-guide) -- 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: issues-unsubscr...@solr.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For additional commands, e-mail: issues-h...@solr.apache.org