You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2021/03/08 09:31:13 UTC

[GitHub] [lucene-solr] muse-dev[bot] commented on a change in pull request #2403: SOLR-15164: Implement Task Management Interface

muse-dev[bot] commented on a change in pull request #2403:
URL: https://github.com/apache/lucene-solr/pull/2403#discussion_r589280471



##########
File path: solr/core/src/java/org/apache/solr/handler/component/ActiveTasksListHandler.java
##########
@@ -0,0 +1,106 @@
+/*
+ * 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.component;
+
+import org.apache.solr.api.Api;
+import org.apache.solr.api.ApiBag;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.request.SolrRequestHandler;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.security.AuthorizationContext;
+import org.apache.solr.security.PermissionNameProvider;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.apache.solr.common.params.CommonParams.TASK_CHECK_UUID;
+
+/**
+ * Handles request for listing all active cancellable tasks
+ */
+public class ActiveTasksListHandler extends TaskManagementHandler {
+    // This can be a parent level member but we keep it here to allow future handlers to have
+    // a custom list of components
+    private List<SearchComponent> components;
+
+    @Override
+    public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
+        Map<String, String> extraParams = null;
+        ResponseBuilder rb = buildResponseBuilder(req, rsp, getComponentsList());
+
+        String taskStatusCheckUUID = req.getParams().get(TASK_CHECK_UUID, null);
+
+        if (taskStatusCheckUUID != null) {
+            if (rb.isDistrib) {
+                extraParams = new HashMap<>();
+
+                extraParams.put(TASK_CHECK_UUID, taskStatusCheckUUID);
+            }
+
+            rb.setTaskStatusCheckUUID(taskStatusCheckUUID);
+        }
+
+        // Let this be visible to handleResponses in the handling component
+        rb.setTaskListRequest(true);
+
+        processRequest(req, rb, extraParams);
+    }
+
+    @Override
+    public String getDescription() {
+        return "activetaskslist";
+    }
+
+    @Override
+    public Category getCategory() {
+        return Category.ADMIN;
+    }
+
+    @Override
+    public PermissionNameProvider.Name getPermissionName(AuthorizationContext ctx) {
+        return PermissionNameProvider.Name.READ_PERM;
+    }
+
+    @Override
+    public SolrRequestHandler getSubHandler(String path) {

Review comment:
       *:*  param being equated to Strings using equals
   (at-me [in a reply](https://docs.muse.dev/docs/talk-to-muse/) with `help` or `ignore`)

##########
File path: solr/core/src/java/org/apache/solr/handler/component/QueryCancellationHandler.java
##########
@@ -0,0 +1,108 @@
+/*
+ * 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.component;
+
+import org.apache.solr.api.Api;
+import org.apache.solr.api.ApiBag;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.request.SolrRequestHandler;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.security.AuthorizationContext;
+import org.apache.solr.security.PermissionNameProvider;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.apache.solr.common.params.CommonParams.QUERY_UUID;
+
+/**
+ * Handles requests for query cancellation for cancellable queries
+ */
+public class QueryCancellationHandler extends TaskManagementHandler {
+    // This can be a parent level member but we keep it here to allow future handlers to have
+    // a custom list of components
+    private List<SearchComponent> components;
+
+    @Override
+    public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
+        ResponseBuilder rb = buildResponseBuilder(req, rsp, getComponentsList());
+        Map<String, String> extraParams = null;
+
+        rb.setCancellation(true);
+
+        String cancellationUUID = req.getParams().get(QUERY_UUID, null);
+
+        if (cancellationUUID == null) {
+            throw new IllegalArgumentException("Query cancellation was requested but no query UUID for cancellation was given");
+        }
+
+        if (rb.isDistrib) {
+            extraParams = new HashMap<>();
+
+            extraParams.put(QUERY_UUID, cancellationUUID);
+        }
+
+        // Let this be visible to handleResponses in the handling component
+        rb.setCancellationUUID(cancellationUUID);
+
+        processRequest(req, rb, extraParams);
+    }
+
+    @Override
+    public String getDescription() {
+        return "Cancel queries";
+    }
+
+    @Override
+    public Category getCategory() {
+        return Category.ADMIN;
+    }
+
+    @Override
+    public PermissionNameProvider.Name getPermissionName(AuthorizationContext ctx) {
+        return PermissionNameProvider.Name.READ_PERM;
+    }
+
+    @Override
+    public SolrRequestHandler getSubHandler(String path) {

Review comment:
       *:*  param being equated to Strings using equals
   (at-me [in a reply](https://docs.muse.dev/docs/talk-to-muse/) with `help` or `ignore`)




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org