This is an automated email from the ASF dual-hosted git repository.

yuanbo pushed a commit to branch TUBEMQ-421
in repository https://gitbox.apache.org/repos/asf/incubator-tubemq.git


The following commit(s) were added to refs/heads/TUBEMQ-421 by this push:
     new 24757da  [TUBEMQ-490] add consumer group \ black group \ enable 
auth-control \ query consumer group \ query black group (#379)
24757da is described below

commit 24757da0d3c90e572baea4e84ad248e2bebba6d2
Author: EMsnap <[email protected]>
AuthorDate: Wed Jan 6 19:17:02 2021 +0800

    [TUBEMQ-490] add consumer group \ black group \ enable auth-control \ query 
consumer group \ query black group (#379)
---
 .../controller/topic/TopicWebController.java       | 126 ++++++++++++++++++++-
 .../topic/request/BatchAddGroupAuthReq.java        |  30 +++++
 .../topic/request/BatchAddTopicAuthReq.java        |  29 +++++
 .../controller/topic/request/DeleteGroupReq.java   |  28 +++++
 .../controller/topic/request/GroupAuthItem.java    |  28 +++++
 .../controller/topic/request/TopicAuthItem.java    |  26 +++++
 6 files changed, 266 insertions(+), 1 deletion(-)

diff --git 
a/tubemq-manager/src/main/java/org/apache/tubemq/manager/controller/topic/TopicWebController.java
 
b/tubemq-manager/src/main/java/org/apache/tubemq/manager/controller/topic/TopicWebController.java
index 7847ae6..9511c96 100644
--- 
a/tubemq-manager/src/main/java/org/apache/tubemq/manager/controller/topic/TopicWebController.java
+++ 
b/tubemq-manager/src/main/java/org/apache/tubemq/manager/controller/topic/TopicWebController.java
@@ -18,7 +18,10 @@
 
 package org.apache.tubemq.manager.controller.topic;
 
+import static org.apache.tubemq.manager.service.TubeMQHttpConst.SCHEMA;
+import static org.apache.tubemq.manager.utils.MasterUtils.TUBE_REQUEST_PATH;
 import static org.apache.tubemq.manager.utils.MasterUtils.queryMaster;
+import static org.apache.tubemq.manager.utils.MasterUtils.requestMaster;
 
 import com.google.gson.Gson;
 import java.util.Map;
@@ -27,13 +30,17 @@ import org.apache.tubemq.manager.controller.TubeMQResult;
 import org.apache.tubemq.manager.controller.node.request.BatchAddTopicReq;
 import org.apache.tubemq.manager.controller.node.request.CloneOffsetReq;
 import org.apache.tubemq.manager.controller.node.request.CloneTopicReq;
+import org.apache.tubemq.manager.controller.topic.request.BatchAddGroupAuthReq;
+import org.apache.tubemq.manager.controller.topic.request.DeleteGroupReq;
 import org.apache.tubemq.manager.entry.NodeEntry;
 import org.apache.tubemq.manager.repository.NodeRepository;
 import org.apache.tubemq.manager.repository.TopicRepository;
 import org.apache.tubemq.manager.service.NodeService;
 import org.apache.tubemq.manager.service.TopicBackendWorker;
+import org.apache.tubemq.manager.utils.ConvertUtils;
 import org.apache.tubemq.manager.utils.MasterUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -160,13 +167,130 @@ public class TopicWebController {
      * @return
      * @throws Exception
      */
-    @PostMapping("/query/config")
+    @PostMapping("/query/topic-config")
     public @ResponseBody String queryTopicConfig(
         @RequestParam Map<String, String> req) throws Exception {
         String url = masterUtils.getQueryUrl(req);
         return queryMaster(url);
     }
 
+    /**
+     * add group to black list for certain topic
+     * @param req
+     * @return
+     * @throws Exception
+     */
+    @GetMapping("/add/blackGroup")
+    public @ResponseBody TubeMQResult addBlackGroup(
+        @RequestParam Map<String, String> req) throws Exception {
+        String url = masterUtils.getQueryUrl(req);
+        return requestMaster(url);
+    }
+
+    /**
+     * delete group to black list for certain topic
+     * @param req
+     * @return
+     * @throws Exception
+     */
+    @GetMapping("/delete/blackGroup")
+    public @ResponseBody TubeMQResult deleteBlackGroup(
+        @RequestParam Map<String, String> req) throws Exception {
+        String url = masterUtils.getQueryUrl(req);
+        return requestMaster(url);
+    }
+
+    /**
+     * query the black list for certain topic
+     * @param req
+     * @return
+     * @throws Exception
+     */
+    @GetMapping("/query/blackGroup")
+    public @ResponseBody String queryBlackGroup(
+        @RequestParam Map<String, String> req) throws Exception {
+        String url = masterUtils.getQueryUrl(req);
+        return queryMaster(url);
+    }
+
+    /**
+     * batch add consumer group for certain topic
+     * @param req
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/add/group")
+    public @ResponseBody TubeMQResult addConsumer(
+        @RequestBody BatchAddGroupAuthReq req) throws Exception {
+        NodeEntry nodeEntry =
+            
nodeRepository.findNodeEntryByClusterIdIsAndMasterIsTrue(req.getClusterId());
+        if (nodeEntry == null) {
+            return TubeMQResult.getErrorResult("no such cluster");
+        }
+        String url = SCHEMA + nodeEntry.getIp() + ":" + nodeEntry.getWebPort()
+            + "/" + TUBE_REQUEST_PATH + "?" + 
ConvertUtils.convertReqToQueryStr(req);
+        return requestMaster(url);
+    }
+
+
+    /**
+     * delete consumer group for certain topic
+     * @param req
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/delete/group")
+    public @ResponseBody TubeMQResult deleteConsumer(
+        @RequestBody DeleteGroupReq req) throws Exception {
+        NodeEntry nodeEntry =
+            
nodeRepository.findNodeEntryByClusterIdIsAndMasterIsTrue(req.getClusterId());
+        if (nodeEntry == null) {
+            return TubeMQResult.getErrorResult("no such cluster");
+        }
+        String url = SCHEMA + nodeEntry.getIp() + ":" + nodeEntry.getWebPort()
+            + "/" + TUBE_REQUEST_PATH + "?" + 
ConvertUtils.convertReqToQueryStr(req);
+        return requestMaster(url);
+    }
+
+    /**
+     * enable auth control for topics
+     * @param req
+     * @return
+     * @throws Exception
+     */
+    @GetMapping("/enable/auth-control")
+    public @ResponseBody TubeMQResult enableAuthControl(
+        @RequestParam Map<String, String> req) throws Exception {
+        String url = masterUtils.getQueryUrl(req);
+        return requestMaster(url);
+    }
+
+    /**
+     * disable auth control for topics
+     * @param req
+     * @return
+     * @throws Exception
+     */
+    @GetMapping("/disable/auth-control")
+    public @ResponseBody TubeMQResult disableAuthControl(
+        @RequestParam Map<String, String> req) throws Exception {
+        String url = masterUtils.getQueryUrl(req);
+        return requestMaster(url);
+    }
+
+    /**
+     * query the consumer group for certain topic
+     * @param req
+     * @return
+     * @throws Exception
+     */
+    @GetMapping("/query/group")
+    public @ResponseBody String queryConsumer(
+        @RequestParam Map<String, String> req) throws Exception {
+        String url = masterUtils.getQueryUrl(req);
+        return queryMaster(url);
+    }
+
 
     /**
      * clone offset from one group to another
diff --git 
a/tubemq-manager/src/main/java/org/apache/tubemq/manager/controller/topic/request/BatchAddGroupAuthReq.java
 
b/tubemq-manager/src/main/java/org/apache/tubemq/manager/controller/topic/request/BatchAddGroupAuthReq.java
new file mode 100644
index 0000000..081cfe3
--- /dev/null
+++ 
b/tubemq-manager/src/main/java/org/apache/tubemq/manager/controller/topic/request/BatchAddGroupAuthReq.java
@@ -0,0 +1,30 @@
+/*
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.tubemq.manager.controller.topic.request;
+
+import java.util.List;
+import lombok.Data;
+import org.apache.tubemq.manager.controller.node.request.BaseReq;
+
+@Data
+public class BatchAddGroupAuthReq extends BaseReq {
+    public String confModAuthToken;
+    public List<GroupAuthItem> groupNameJsonSet;
+    public String createUser;
+}
diff --git 
a/tubemq-manager/src/main/java/org/apache/tubemq/manager/controller/topic/request/BatchAddTopicAuthReq.java
 
b/tubemq-manager/src/main/java/org/apache/tubemq/manager/controller/topic/request/BatchAddTopicAuthReq.java
new file mode 100644
index 0000000..3df3734
--- /dev/null
+++ 
b/tubemq-manager/src/main/java/org/apache/tubemq/manager/controller/topic/request/BatchAddTopicAuthReq.java
@@ -0,0 +1,29 @@
+/*
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.tubemq.manager.controller.topic.request;
+
+import java.util.List;
+import lombok.Data;
+import org.apache.tubemq.manager.controller.node.request.BaseReq;
+
+@Data
+public class BatchAddTopicAuthReq extends BaseReq {
+    public String confModAuthToken;
+    public List<TopicAuthItem> topicJsonSet;
+    public String createUser;
+}
diff --git 
a/tubemq-manager/src/main/java/org/apache/tubemq/manager/controller/topic/request/DeleteGroupReq.java
 
b/tubemq-manager/src/main/java/org/apache/tubemq/manager/controller/topic/request/DeleteGroupReq.java
new file mode 100644
index 0000000..a9d9505
--- /dev/null
+++ 
b/tubemq-manager/src/main/java/org/apache/tubemq/manager/controller/topic/request/DeleteGroupReq.java
@@ -0,0 +1,28 @@
+/*
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.tubemq.manager.controller.topic.request;
+
+import lombok.Data;
+import org.apache.tubemq.manager.controller.node.request.BaseReq;
+
+@Data
+public class DeleteGroupReq extends BaseReq {
+    public String confModAuthToken;
+    public String topicName;
+    public String groupName;
+}
diff --git 
a/tubemq-manager/src/main/java/org/apache/tubemq/manager/controller/topic/request/GroupAuthItem.java
 
b/tubemq-manager/src/main/java/org/apache/tubemq/manager/controller/topic/request/GroupAuthItem.java
new file mode 100644
index 0000000..d830ca7
--- /dev/null
+++ 
b/tubemq-manager/src/main/java/org/apache/tubemq/manager/controller/topic/request/GroupAuthItem.java
@@ -0,0 +1,28 @@
+/*
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.tubemq.manager.controller.topic.request;
+
+import lombok.Data;
+import org.apache.tubemq.manager.controller.node.request.BaseReq;
+
+@Data
+public class GroupAuthItem extends BaseReq {
+    public String topicName;
+    public String groupName;
+}
diff --git 
a/tubemq-manager/src/main/java/org/apache/tubemq/manager/controller/topic/request/TopicAuthItem.java
 
b/tubemq-manager/src/main/java/org/apache/tubemq/manager/controller/topic/request/TopicAuthItem.java
new file mode 100644
index 0000000..501c19f
--- /dev/null
+++ 
b/tubemq-manager/src/main/java/org/apache/tubemq/manager/controller/topic/request/TopicAuthItem.java
@@ -0,0 +1,26 @@
+/*
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.tubemq.manager.controller.topic.request;
+
+import lombok.Data;
+
+@Data
+public class TopicAuthItem {
+    public String topicName;
+}

Reply via email to