You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ro...@apache.org on 2022/05/23 17:38:19 UTC

[iotdb] 05/18: /confignode.thrift

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

rong pushed a commit to branch iotdb-3227
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit dfb73e801a271c0a05ffd529334f2f95df18622a
Author: Steve Yurong Su <ro...@apache.org>
AuthorDate: Thu May 19 11:46:57 2022 +0800

    /confignode.thrift
---
 .../plan/execution/config/CreateFunctionTask.java  | 49 ++++++++++++++++++++++
 .../src/main/thrift/confignode.thrift              | 11 +++++
 2 files changed, 60 insertions(+)

diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/CreateFunctionTask.java b/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/CreateFunctionTask.java
index 62cfc5f965..663f533729 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/CreateFunctionTask.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/CreateFunctionTask.java
@@ -22,12 +22,19 @@ package org.apache.iotdb.db.mpp.plan.execution.config;
 import org.apache.iotdb.commons.client.IClientManager;
 import org.apache.iotdb.commons.consensus.PartitionRegionId;
 import org.apache.iotdb.db.client.ConfigNodeClient;
+import org.apache.iotdb.db.conf.IoTDBConfig;
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.mpp.plan.statement.metadata.CreateFunctionStatement;
 
 import com.google.common.util.concurrent.ListenableFuture;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class CreateFunctionTask implements IConfigTask {
 
+  private static final Logger LOGGER = LoggerFactory.getLogger(CreateFunctionTask.class);
+  private static final IoTDBConfig CONFIG = IoTDBDescriptor.getInstance().getConfig();
+
   private final CreateFunctionStatement createFunctionStatement;
 
   public CreateFunctionTask(CreateFunctionStatement createFunctionStatement) {
@@ -39,5 +46,47 @@ public class CreateFunctionTask implements IConfigTask {
       IClientManager<PartitionRegionId, ConfigNodeClient> clientManager)
       throws InterruptedException {
     return null;
+    //    SettableFuture<ConfigTaskResult> future = SettableFuture.create();
+    //    if (CONFIG.isClusterMode()) {
+    //      TDeleteStorageGroupsReq req =
+    //          new TDeleteStorageGroupsReq(deleteStorageGroupStatement.getPrefixPath());
+    //      try (ConfigNodeClient client =
+    // clientManager.borrowClient(ConfigNodeInfo.partitionRegionId)) {
+    //        TSStatus tsStatus = client.deleteStorageGroups(req);
+    //        if (TSStatusCode.SUCCESS_STATUS.getStatusCode() != tsStatus.getCode()) {
+    //          LOGGER.error(
+    //              "Failed to execute delete storage group {} in config node, status is {}.",
+    //              deleteStorageGroupStatement.getPrefixPath(),
+    //              tsStatus);
+    //          future.setException(new StatementExecutionException(tsStatus));
+    //        } else {
+    //          future.set(new ConfigTaskResult(TSStatusCode.SUCCESS_STATUS));
+    //        }
+    //      } catch (TException | IOException e) {
+    //        LOGGER.error("Failed to connect to config node.");
+    //        future.setException(e);
+    //      }
+    //    } else {
+    //      try {
+    //        List<PartialPath> deletePathList =
+    //            deleteStorageGroupStatement.getPrefixPath().stream()
+    //                .map(
+    //                    path -> {
+    //                      try {
+    //                        return new PartialPath(path);
+    //                      } catch (IllegalPathException e) {
+    //                        return null;
+    //                      }
+    //                    })
+    //                .collect(Collectors.toList());
+    //        LocalConfigNode.getInstance().deleteStorageGroups(deletePathList);
+    //      } catch (MetadataException e) {
+    //        future.setException(e);
+    //      }
+    //      future.set(new ConfigTaskResult(TSStatusCode.SUCCESS_STATUS));
+    //    }
+    //    // If the action is executed successfully, return the Future.
+    //    // If your operation is async, you can return the corresponding future directly.
+    //    return future;
   }
 }
diff --git a/thrift-confignode/src/main/thrift/confignode.thrift b/thrift-confignode/src/main/thrift/confignode.thrift
index f102e2aa3a..af0e8fada9 100644
--- a/thrift-confignode/src/main/thrift/confignode.thrift
+++ b/thrift-confignode/src/main/thrift/confignode.thrift
@@ -174,6 +174,13 @@ struct TConfigNodeRegisterResp {
   3: optional list<common.TConfigNodeLocation> configNodeList
 }
 
+// UDF
+struct TCreateFuctionReq {
+  1: required string udfName
+  2: required string className
+  3: required list<string> uris
+}
+
 service ConfigIService {
 
   /* DataNode */
@@ -229,4 +236,8 @@ service ConfigIService {
   TConfigNodeRegisterResp registerConfigNode(TConfigNodeRegisterReq req)
 
   common.TSStatus applyConfigNode(common.TConfigNodeLocation configNodeLocation)
+
+  /* UDF */
+
+  common.TSStatus createFunction(TCreateFuctionReq req)
 }
\ No newline at end of file