public TSStatus operateMultiplePipes(final OperateMultiplePipesPlanV2 plan) {
    acquireWriteLock();
    try {
      if (plan.getSubPlans() == null || plan.getSubPlans().isEmpty()) {
        return new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode());
      }

      TSStatus status = new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode());
      // We use sub-status to record the status of each subPlan
      status.setSubStatus(new ArrayList<>());

      for (final ConfigPhysicalPlan subPlan : plan.getSubPlans()) {
        try {
          if (subPlan instanceof CreatePipePlanV2) {
            createPipe((CreatePipePlanV2) subPlan);
          } else if (subPlan instanceof AlterPipePlanV2) {
            alterPipe((AlterPipePlanV2) subPlan);
          } else if (subPlan instanceof SetPipeStatusPlanV2) {
            setPipeStatus((SetPipeStatusPlanV2) subPlan);
          } else if (subPlan instanceof DropPipePlanV2) {
            dropPipe((DropPipePlanV2) subPlan);
          } else {
            throw new PipeException(
                String.format("Unsupported subPlan type: %s", subPlan.getClass().getName()));
          }
          status.getSubStatus().add(new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode()));
        } catch (final Exception e) {
          // If one of the subPlan fails, we stop operating the rest of the pipes
          LOGGER.error("Failed to operate pipe", e);
          status.setCode(TSStatusCode.PIPE_ERROR.getStatusCode());
          status.getSubStatus().add(new TSStatus(TSStatusCode.PIPE_ERROR.getStatusCode()));
          break;
        }
      }

      // If all the subPlans are successful, we return the success status and clear sub-status.
      // Otherwise, we return the error status with sub-status to record the failing index.
      if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
        status.setSubStatus(null);
      }
      return status;
    } finally {
      releaseWriteLock();
    }
  }
Caller should ensure that the method is called in the lock {@link #acquireWriteLock}.
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/pipe/PipeTaskInfo.java