VGalaxies commented on code in PR #12969:
URL: https://github.com/apache/iotdb/pull/12969#discussion_r1689551066


##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/IManager.java:
##########
@@ -629,13 +632,13 @@ TDataPartitionTableResp getOrCreateDataPartition(
   TSStatus stopPipe(String pipeName);
 
   /**
-   * Drop Pipe.
+   * Drop Pipe function with IF Exists semantics.

Review Comment:
   ```suggestion
      * Drop Pipe function with If Exists semantics.
   ```



##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/pipe/AbstractOperatePipeProcedureV2.java:
##########
@@ -224,7 +224,7 @@ protected Flow executeFromState(ConfigNodeProcedureEnv env, 
OperatePipeTaskState
     try {
       switch (state) {
         case VALIDATE_TASK:
-          if (executeFromValidateTask(env)) {
+          if (!executeFromValidateTask(env)) {

Review Comment:
   The corresponding comment in AbstractOperatePipeProcedureV2 should also be 
modified.



##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/pipe/plugin/CreatePipePluginProcedure.java:
##########
@@ -125,14 +128,18 @@ private Flow executeFromLock(ConfigNodeProcedureEnv env) {
         env.getConfigManager().getPipeManager().getPipePluginCoordinator();
 
     pipePluginCoordinator.lock();
-
+    boolean notExists = true;
     try {
-      pipePluginCoordinator
-          .getPipePluginInfo()
-          .validateBeforeCreatingPipePlugin(
-              pipePluginMeta.getPluginName(),
-              pipePluginMeta.getJarName(),
-              pipePluginMeta.getJarMD5());
+      // If the result is ture, the Procedure will continue; if it is false, 
the Procedure will exit

Review Comment:
   ```suggestion
         // If the result is ture, the procedure will continue; if it is false, 
the procedure will exit
   ```



##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/subscription/SubscriptionCoordinator.java:
##########
@@ -149,11 +151,23 @@ public TSStatus createTopic(TCreateTopicReq req) {
     return status;
   }
 
-  public TSStatus dropTopic(String topicName) {
-    final TSStatus status = 
configManager.getProcedureManager().dropTopic(topicName);
+  public TSStatus dropTopic(TDropTopicReq req) {
+    final boolean isTopicExistedBeforeDrop = 
subscriptionInfo.isTopicExisted(req.getTopicName());
+    final TSStatus status = 
configManager.getProcedureManager().dropTopic(req.getTopicName());
     if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
-      LOGGER.warn("Failed to drop topic {}. Result status: {}.", topicName, 
status);
+      LOGGER.warn("Failed to drop topic {}. Result status: {}.", 
req.getTopicName(), status);
     }
+
+    if (!isTopicExistedBeforeDrop && req.isIfExistsCondition()) {
+      // If the IF EXISTS condition is not set and the topic does not exist 
before the delete
+      // operation,return an error status indicating that the topic does not 
exist.
+      return RpcUtils.getStatus(
+          TSStatusCode.TOPIC_NOT_EXIST_ERROR,
+          String.format(
+              "Failed to drop Topic %s. Failures: %s does not exist.",

Review Comment:
   ```suggestion
                 "Failed to drop topic %s. Failures: %s does not exist.",
   ```



##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/subscription/SubscriptionCoordinator.java:
##########
@@ -149,11 +151,23 @@ public TSStatus createTopic(TCreateTopicReq req) {
     return status;
   }
 
-  public TSStatus dropTopic(String topicName) {
-    final TSStatus status = 
configManager.getProcedureManager().dropTopic(topicName);
+  public TSStatus dropTopic(TDropTopicReq req) {
+    final boolean isTopicExistedBeforeDrop = 
subscriptionInfo.isTopicExisted(req.getTopicName());
+    final TSStatus status = 
configManager.getProcedureManager().dropTopic(req.getTopicName());
     if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
-      LOGGER.warn("Failed to drop topic {}. Result status: {}.", topicName, 
status);
+      LOGGER.warn("Failed to drop topic {}. Result status: {}.", 
req.getTopicName(), status);
     }
+
+    if (!isTopicExistedBeforeDrop && req.isIfExistsCondition()) {
+      // If the IF EXISTS condition is not set and the topic does not exist 
before the delete
+      // operation,return an error status indicating that the topic does not 
exist.

Review Comment:
   ```suggestion
         // operation, return an error status indicating that the topic does 
not exist.
   ```



##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/coordinator/task/PipeTaskCoordinator.java:
##########
@@ -160,18 +161,24 @@ public TSStatus stopPipe(String pipeName) {
   }
 
   /** Caller should ensure that the method is called in the lock {@link 
#lock()}. */
-  public TSStatus dropPipe(String pipeName) {
-    final boolean isPipeExistedBeforeDrop = 
pipeTaskInfo.isPipeExisted(pipeName);
-    final TSStatus status = 
configManager.getProcedureManager().dropPipe(pipeName);
+  public TSStatus dropPipe(TDropPipeReq req) {
+    final boolean isPipeExistedBeforeDrop = 
pipeTaskInfo.isPipeExisted(req.getPipeName());
+    final TSStatus status = 
configManager.getProcedureManager().dropPipe(req.getPipeName());
     if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
-      LOGGER.warn("Failed to drop pipe {}. Result status: {}.", pipeName, 
status);
+      LOGGER.warn("Failed to drop pipe {}. Result status: {}.", 
req.getPipeName(), status);
     }
-    return isPipeExistedBeforeDrop
-        ? status
-        : RpcUtils.getStatus(
-            TSStatusCode.PIPE_NOT_EXIST_ERROR,
-            String.format(
-                "Failed to drop pipe %s. Failures: %s does not exist.", 
pipeName, pipeName));
+
+    if (!isPipeExistedBeforeDrop && !req.isIfExistsCondition()) {
+      // If the IF EXISTS condition is not set and the pipe does not exist 
before the delete
+      // operation,return an error status indicating that the pipe does not 
exist.

Review Comment:
   ```suggestion
         // operation, return an error status indicating that the pipe does not 
exist.
   ```



##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/pipe/plugin/DropPipePluginProcedure.java:
##########
@@ -128,6 +134,17 @@ private Flow executeFromLock(ConfigNodeProcedureEnv env) {
       return Flow.NO_MORE_STATE;
     }
 
+    // If the plugin does not exist and the IFExists condition is met, the 
process ends.

Review Comment:
   ```suggestion
       // If the plugin does not exist and the If Exists condition is met, the 
process ends.
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to