You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/06/29 08:42:06 UTC

[GitHub] [inlong] kipshi opened a new pull request, #4813: [INLONG-4811][Manager] Add delete MQ task in DeleteGroupWorkflowDefinition and DeleteStreamW…

kipshi opened a new pull request, #4813:
URL: https://github.com/apache/inlong/pull/4813

   …orkflowDefinition
   
   ### Prepare a Pull Request
   *(Change the title refer to the following example)*
   
   - Title Example: [INLONG-XYZ][Component] Title of the pull request
   
   *(The following *XYZ* should be replaced by the actual [GitHub Issue](https://github.com/apache/inlong/issues) number)*
   
   - Fixes #4811 
   
   ### Motivation
   
   ### Modifications
   
   ### Verifying this change
   
   As see in topic
   
   *(Please pick either of the following options)*
   
   - [ ] This change is a trivial rework/code cleanup without any test coverage.
   
   - [ ] This change is already covered by existing tests, such as:
     *(please describe tests)*
   
   - [ ] This change added tests and can be verified as follows:
   
     *(example:)*
     - *Added integration tests for end-to-end deployment with large payloads (10MB)*
     - *Extended integration test for recovery after broker failure*
   
   ### Documentation
   
     - Does this pull request introduce a new feature? (yes / no)
     - If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
     - If a feature is not applicable for documentation, explain why?
     - If a feature is not documented yet in this PR, please create a follow-up issue for adding the documentation
   


-- 
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: commits-unsubscribe@inlong.apache.org

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


[GitHub] [inlong] healchow merged pull request #4813: [INLONG-4811][Manager] Add delete MQ task in group and stream workflow definition

Posted by GitBox <gi...@apache.org>.
healchow merged PR #4813:
URL: https://github.com/apache/inlong/pull/4813


-- 
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: commits-unsubscribe@inlong.apache.org

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


[GitHub] [inlong] healchow commented on a diff in pull request #4813: [INLONG-4811][Manager] Add delete MQ task in group and stream workflow definition

Posted by GitBox <gi...@apache.org>.
healchow commented on code in PR #4813:
URL: https://github.com/apache/inlong/pull/4813#discussion_r909481250


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/mq/DeletePulsarResourceTaskListener.java:
##########
@@ -0,0 +1,104 @@
+/*
+ * 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.inlong.manager.service.mq;
+
+import lombok.extern.slf4j.Slf4j;
+import org.apache.inlong.manager.common.enums.ClusterType;
+import org.apache.inlong.manager.common.exceptions.WorkflowListenerException;
+import org.apache.inlong.manager.common.pojo.cluster.InlongClusterInfo;
+import org.apache.inlong.manager.common.pojo.cluster.pulsar.PulsarClusterInfo;
+import org.apache.inlong.manager.common.pojo.group.InlongGroupInfo;
+import org.apache.inlong.manager.common.pojo.group.pulsar.InlongPulsarInfo;
+import org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm;
+import org.apache.inlong.manager.common.util.Preconditions;
+import org.apache.inlong.manager.service.cluster.InlongClusterService;
+import org.apache.inlong.manager.service.group.InlongGroupService;
+import org.apache.inlong.manager.service.mq.util.PulsarOperator;
+import org.apache.inlong.manager.service.mq.util.PulsarUtils;
+import org.apache.inlong.manager.workflow.WorkflowContext;
+import org.apache.inlong.manager.workflow.event.ListenerResult;
+import org.apache.inlong.manager.workflow.event.task.QueueOperateListener;
+import org.apache.inlong.manager.workflow.event.task.TaskEvent;
+import org.apache.pulsar.client.admin.PulsarAdmin;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * Delete Pulsar tenant, namespace and topic after group is operated to delete
+ */
+@Slf4j
+@Component
+public class DeletePulsarResourceTaskListener implements QueueOperateListener {
+
+    @Autowired
+    private InlongGroupService groupService;
+    @Autowired
+    private InlongClusterService clusterService;
+    @Autowired
+    private PulsarOperator pulsarOperator;
+
+    @Override
+    public TaskEvent event() {
+        return TaskEvent.COMPLETE;
+    }
+
+    @Override
+    public ListenerResult listen(WorkflowContext context) throws Exception {
+        GroupResourceProcessForm form = (GroupResourceProcessForm) context.getProcessForm();
+        String groupId = form.getInlongGroupId();
+        log.info("begin to delete pulsar resource for groupId={}", groupId);
+        InlongGroupInfo groupInfo = groupService.get(groupId);
+        if (groupInfo == null) {
+            throw new WorkflowListenerException("inlong group or pulsar cluster not found for groupId=" + groupId);
+        }
+        try {
+            InlongPulsarInfo pulsarInfo = (InlongPulsarInfo) groupInfo;
+            InlongClusterInfo clusterInfo = clusterService.getOne(groupInfo.getInlongClusterTag(), null,
+                    ClusterType.CLS_PULSAR);
+            deletePulsarProcess(pulsarInfo, (PulsarClusterInfo) clusterInfo);
+        } catch (Exception e) {
+            log.error("delete pulsar resource error for groupId={}", groupId, e);
+            throw new WorkflowListenerException("delete pulsar resource error for groupId=" + groupId);
+        }
+
+        log.info("success to delete pulsar resource for groupId={}", groupId);
+        return ListenerResult.success();
+    }
+
+    /**
+     * Delete Pulsar namespace forcefully
+     */
+    private void deletePulsarProcess(InlongPulsarInfo pulsarInfo, PulsarClusterInfo pulsarCluster) throws Exception {
+        String groupId = pulsarInfo.getInlongGroupId();
+        log.info("begin to delete pulsar resource for groupId={} in cluster={}", groupId, pulsarCluster);
+
+        String namespace = pulsarInfo.getMqResource();
+        Preconditions.checkNotNull(namespace, "pulsar namespace cannot be empty for groupId=" + groupId);
+        try (PulsarAdmin pulsarAdmin = PulsarUtils.getPulsarAdmin(pulsarCluster)) {
+            String tenant = pulsarCluster.getTenant();
+            // create pulsar namespace
+            pulsarOperator.forceDeleteNamespace(pulsarAdmin, tenant, namespace);

Review Comment:
   The namespace may be used by another user, delete namespace is a dangerous operation.



-- 
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: commits-unsubscribe@inlong.apache.org

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


[GitHub] [inlong] kipshi commented on a diff in pull request #4813: [INLONG-4811][Manager] Add delete MQ task in group and stream workflow definition

Posted by GitBox <gi...@apache.org>.
kipshi commented on code in PR #4813:
URL: https://github.com/apache/inlong/pull/4813#discussion_r909515445


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/mq/DeletePulsarResourceTaskListener.java:
##########
@@ -0,0 +1,104 @@
+/*
+ * 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.inlong.manager.service.mq;
+
+import lombok.extern.slf4j.Slf4j;
+import org.apache.inlong.manager.common.enums.ClusterType;
+import org.apache.inlong.manager.common.exceptions.WorkflowListenerException;
+import org.apache.inlong.manager.common.pojo.cluster.InlongClusterInfo;
+import org.apache.inlong.manager.common.pojo.cluster.pulsar.PulsarClusterInfo;
+import org.apache.inlong.manager.common.pojo.group.InlongGroupInfo;
+import org.apache.inlong.manager.common.pojo.group.pulsar.InlongPulsarInfo;
+import org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm;
+import org.apache.inlong.manager.common.util.Preconditions;
+import org.apache.inlong.manager.service.cluster.InlongClusterService;
+import org.apache.inlong.manager.service.group.InlongGroupService;
+import org.apache.inlong.manager.service.mq.util.PulsarOperator;
+import org.apache.inlong.manager.service.mq.util.PulsarUtils;
+import org.apache.inlong.manager.workflow.WorkflowContext;
+import org.apache.inlong.manager.workflow.event.ListenerResult;
+import org.apache.inlong.manager.workflow.event.task.QueueOperateListener;
+import org.apache.inlong.manager.workflow.event.task.TaskEvent;
+import org.apache.pulsar.client.admin.PulsarAdmin;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * Delete Pulsar tenant, namespace and topic after group is operated to delete
+ */
+@Slf4j
+@Component
+public class DeletePulsarResourceTaskListener implements QueueOperateListener {
+
+    @Autowired
+    private InlongGroupService groupService;
+    @Autowired
+    private InlongClusterService clusterService;
+    @Autowired
+    private PulsarOperator pulsarOperator;
+
+    @Override
+    public TaskEvent event() {
+        return TaskEvent.COMPLETE;
+    }
+
+    @Override
+    public ListenerResult listen(WorkflowContext context) throws Exception {
+        GroupResourceProcessForm form = (GroupResourceProcessForm) context.getProcessForm();
+        String groupId = form.getInlongGroupId();
+        log.info("begin to delete pulsar resource for groupId={}", groupId);
+        InlongGroupInfo groupInfo = groupService.get(groupId);
+        if (groupInfo == null) {
+            throw new WorkflowListenerException("inlong group or pulsar cluster not found for groupId=" + groupId);
+        }
+        try {
+            InlongPulsarInfo pulsarInfo = (InlongPulsarInfo) groupInfo;
+            InlongClusterInfo clusterInfo = clusterService.getOne(groupInfo.getInlongClusterTag(), null,
+                    ClusterType.CLS_PULSAR);
+            deletePulsarProcess(pulsarInfo, (PulsarClusterInfo) clusterInfo);
+        } catch (Exception e) {
+            log.error("delete pulsar resource error for groupId={}", groupId, e);
+            throw new WorkflowListenerException("delete pulsar resource error for groupId=" + groupId);
+        }
+
+        log.info("success to delete pulsar resource for groupId={}", groupId);
+        return ListenerResult.success();
+    }
+
+    /**
+     * Delete Pulsar namespace forcefully
+     */
+    private void deletePulsarProcess(InlongPulsarInfo pulsarInfo, PulsarClusterInfo pulsarCluster) throws Exception {
+        String groupId = pulsarInfo.getInlongGroupId();
+        log.info("begin to delete pulsar resource for groupId={} in cluster={}", groupId, pulsarCluster);
+
+        String namespace = pulsarInfo.getMqResource();
+        Preconditions.checkNotNull(namespace, "pulsar namespace cannot be empty for groupId=" + groupId);
+        try (PulsarAdmin pulsarAdmin = PulsarUtils.getPulsarAdmin(pulsarCluster)) {
+            String tenant = pulsarCluster.getTenant();
+            // create pulsar namespace
+            pulsarOperator.forceDeleteNamespace(pulsarAdmin, tenant, namespace);

Review Comment:
   ok



-- 
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: commits-unsubscribe@inlong.apache.org

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