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

[iotdb] branch deleteStorageGroups created (now 58d5a2f3eb)

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

haonan pushed a change to branch deleteStorageGroups
in repository https://gitbox.apache.org/repos/asf/iotdb.git


      at 58d5a2f3eb [IOTDB-3186] Support DeleteStorageGroups API for new cluster

This branch includes the following new commits:

     new 58d5a2f3eb [IOTDB-3186] Support DeleteStorageGroups API for new cluster

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[iotdb] 01/01: [IOTDB-3186] Support DeleteStorageGroups API for new cluster

Posted by ha...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

haonan pushed a commit to branch deleteStorageGroups
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 58d5a2f3eb1f03a3b14a219f63c8eba240155245
Author: HTHou <hh...@outlook.com>
AuthorDate: Sun May 15 19:26:23 2022 +0800

    [IOTDB-3186] Support DeleteStorageGroups API for new cluster
---
 .../db/mpp/plan/parser/StatementGenerator.java     |  7 +++
 .../thrift/impl/DataNodeTSIServiceImpl.java        | 65 ++++++++++++++++++----
 2 files changed, 60 insertions(+), 12 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/StatementGenerator.java b/server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/StatementGenerator.java
index fdd5f36f91..faeb37ef7b 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/StatementGenerator.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/StatementGenerator.java
@@ -39,6 +39,7 @@ import org.apache.iotdb.db.mpp.plan.statement.crud.QueryStatement;
 import org.apache.iotdb.db.mpp.plan.statement.metadata.CreateAlignedTimeSeriesStatement;
 import org.apache.iotdb.db.mpp.plan.statement.metadata.CreateMultiTimeSeriesStatement;
 import org.apache.iotdb.db.mpp.plan.statement.metadata.CreateTimeSeriesStatement;
+import org.apache.iotdb.db.mpp.plan.statement.metadata.DeleteStorageGroupStatement;
 import org.apache.iotdb.db.mpp.plan.statement.metadata.SetStorageGroupStatement;
 import org.apache.iotdb.db.qp.sql.IoTDBSqlParser;
 import org.apache.iotdb.db.qp.sql.SqlLexer;
@@ -406,6 +407,12 @@ public class StatementGenerator {
     return statement;
   }
 
+  public static Statement createStatement(List<String> storageGroups) {
+    DeleteStorageGroupStatement statement = new DeleteStorageGroupStatement();
+    statement.setPrefixPath(storageGroups);
+    return statement;
+  }
+
   private static Statement invokeParser(String sql, ZoneId zoneId) {
     ASTVisitor astVisitor = new ASTVisitor();
     astVisitor.setZoneId(zoneId);
diff --git a/server/src/main/java/org/apache/iotdb/db/service/thrift/impl/DataNodeTSIServiceImpl.java b/server/src/main/java/org/apache/iotdb/db/service/thrift/impl/DataNodeTSIServiceImpl.java
index f7f863a33c..c86f88b097 100644
--- a/server/src/main/java/org/apache/iotdb/db/service/thrift/impl/DataNodeTSIServiceImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/service/thrift/impl/DataNodeTSIServiceImpl.java
@@ -45,6 +45,7 @@ import org.apache.iotdb.db.mpp.plan.statement.crud.InsertTabletStatement;
 import org.apache.iotdb.db.mpp.plan.statement.metadata.CreateAlignedTimeSeriesStatement;
 import org.apache.iotdb.db.mpp.plan.statement.metadata.CreateMultiTimeSeriesStatement;
 import org.apache.iotdb.db.mpp.plan.statement.metadata.CreateTimeSeriesStatement;
+import org.apache.iotdb.db.mpp.plan.statement.metadata.DeleteStorageGroupStatement;
 import org.apache.iotdb.db.mpp.plan.statement.metadata.SetStorageGroupStatement;
 import org.apache.iotdb.db.query.control.SessionManager;
 import org.apache.iotdb.db.query.control.SessionTimeoutManager;
@@ -298,7 +299,7 @@ public class DataNodeTSIServiceImpl implements TSIEventHandler {
       return result.status;
     } catch (Exception e) {
       return onNPEOrUnexpectedException(
-          e, OperationType.CREATE_TIMESERIES, TSStatusCode.EXECUTE_STATEMENT_ERROR);
+          e, OperationType.SET_STORAGE_GROUP, TSStatusCode.EXECUTE_STATEMENT_ERROR);
     }
   }
 
@@ -392,7 +393,7 @@ public class DataNodeTSIServiceImpl implements TSIEventHandler {
       return result.status;
     } catch (Exception e) {
       return onNPEOrUnexpectedException(
-          e, OperationType.CREATE_TIMESERIES, TSStatusCode.EXECUTE_STATEMENT_ERROR);
+          e, OperationType.CREATE_ALIGNED_TIMESERIES, TSStatusCode.EXECUTE_STATEMENT_ERROR);
     }
   }
 
@@ -435,7 +436,7 @@ public class DataNodeTSIServiceImpl implements TSIEventHandler {
       return result.status;
     } catch (Exception e) {
       return onNPEOrUnexpectedException(
-          e, OperationType.CREATE_TIMESERIES, TSStatusCode.EXECUTE_STATEMENT_ERROR);
+          e, OperationType.CREATE_MULTI_TIMESERIES, TSStatusCode.EXECUTE_STATEMENT_ERROR);
     }
   }
 
@@ -445,8 +446,46 @@ public class DataNodeTSIServiceImpl implements TSIEventHandler {
   }
 
   @Override
-  public TSStatus deleteStorageGroups(long sessionId, List<String> storageGroup) {
-    throw new UnsupportedOperationException();
+  public TSStatus deleteStorageGroups(long sessionId, List<String> storageGroups) {
+    try {
+      if (!SESSION_MANAGER.checkLogin(sessionId)) {
+        return getNotLoggedInStatus();
+      }
+
+      if (AUDIT_LOGGER.isDebugEnabled()) {
+        AUDIT_LOGGER.debug(
+            "Session-{} delete {} storage groups, the first is {}",
+            SESSION_MANAGER.getCurrSessionId(),
+            storageGroups.size(),
+            storageGroups.get(0));
+      }
+
+      // Step 1: transfer from DeleteStorageGroupsReq to Statement
+      DeleteStorageGroupStatement statement =
+          (DeleteStorageGroupStatement) StatementGenerator.createStatement(storageGroups);
+
+      // permission check
+      TSStatus status = AuthorityChecker.checkAuthority(statement, sessionId);
+      if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
+        return status;
+      }
+
+      // Step 2: call the coordinator
+      long queryId = SESSION_MANAGER.requestQueryId(false);
+      ExecutionResult result =
+          COORDINATOR.execute(
+              statement,
+              new QueryId(String.valueOf(queryId)),
+              SESSION_MANAGER.getSessionInfo(sessionId),
+              "",
+              PARTITION_FETCHER,
+              SCHEMA_FETCHER);
+
+      return result.status;
+    } catch (Exception e) {
+      return onNPEOrUnexpectedException(
+          e, OperationType.DELETE_STORAGE_GROUPS, TSStatusCode.EXECUTE_STATEMENT_ERROR);
+    }
   }
 
   @Override
@@ -599,7 +638,7 @@ public class DataNodeTSIServiceImpl implements TSIEventHandler {
       return result.status;
     } catch (Exception e) {
       return onNPEOrUnexpectedException(
-          e, OperationType.INSERT_TABLET, TSStatusCode.EXECUTE_STATEMENT_ERROR);
+          e, OperationType.INSERT_RECORDS, TSStatusCode.EXECUTE_STATEMENT_ERROR);
     } finally {
       addOperationLatency(Operation.EXECUTE_RPC_BATCH_INSERT, t1);
     }
@@ -645,7 +684,7 @@ public class DataNodeTSIServiceImpl implements TSIEventHandler {
       return result.status;
     } catch (Exception e) {
       return onNPEOrUnexpectedException(
-          e, OperationType.INSERT_TABLET, TSStatusCode.EXECUTE_STATEMENT_ERROR);
+          e, OperationType.INSERT_RECORDS_OF_ONE_DEVICE, TSStatusCode.EXECUTE_STATEMENT_ERROR);
     } finally {
       addOperationLatency(Operation.EXECUTE_RPC_BATCH_INSERT, t1);
     }
@@ -691,7 +730,9 @@ public class DataNodeTSIServiceImpl implements TSIEventHandler {
       return result.status;
     } catch (Exception e) {
       return onNPEOrUnexpectedException(
-          e, OperationType.INSERT_TABLET, TSStatusCode.EXECUTE_STATEMENT_ERROR);
+          e,
+          OperationType.INSERT_STRING_RECORDS_OF_ONE_DEVICE,
+          TSStatusCode.EXECUTE_STATEMENT_ERROR);
     } finally {
       addOperationLatency(Operation.EXECUTE_RPC_BATCH_INSERT, t1);
     }
@@ -733,7 +774,7 @@ public class DataNodeTSIServiceImpl implements TSIEventHandler {
       return result.status;
     } catch (Exception e) {
       return onNPEOrUnexpectedException(
-          e, OperationType.INSERT_TABLET, TSStatusCode.EXECUTE_STATEMENT_ERROR);
+          e, OperationType.INSERT_RECORD, TSStatusCode.EXECUTE_STATEMENT_ERROR);
     } finally {
       addOperationLatency(Operation.EXECUTE_RPC_BATCH_INSERT, t1);
     }
@@ -771,7 +812,7 @@ public class DataNodeTSIServiceImpl implements TSIEventHandler {
       return result.status;
     } catch (Exception e) {
       return onNPEOrUnexpectedException(
-          e, OperationType.INSERT_TABLET, TSStatusCode.EXECUTE_STATEMENT_ERROR);
+          e, OperationType.INSERT_TABLETS, TSStatusCode.EXECUTE_STATEMENT_ERROR);
     } finally {
       addOperationLatency(Operation.EXECUTE_RPC_BATCH_INSERT, t1);
     }
@@ -852,7 +893,7 @@ public class DataNodeTSIServiceImpl implements TSIEventHandler {
       return result.status;
     } catch (Exception e) {
       return onNPEOrUnexpectedException(
-          e, OperationType.INSERT_TABLET, TSStatusCode.EXECUTE_STATEMENT_ERROR);
+          e, OperationType.INSERT_STRING_RECORDS, TSStatusCode.EXECUTE_STATEMENT_ERROR);
     } finally {
       addOperationLatency(Operation.EXECUTE_RPC_BATCH_INSERT, t1);
     }
@@ -991,7 +1032,7 @@ public class DataNodeTSIServiceImpl implements TSIEventHandler {
       return result.status;
     } catch (Exception e) {
       return onNPEOrUnexpectedException(
-          e, OperationType.INSERT_TABLET, TSStatusCode.EXECUTE_STATEMENT_ERROR);
+          e, OperationType.INSERT_STRING_RECORD, TSStatusCode.EXECUTE_STATEMENT_ERROR);
     } finally {
       addOperationLatency(Operation.EXECUTE_RPC_BATCH_INSERT, t1);
     }