This is an automated email from the ASF dual-hosted git repository.
haonan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new f29b0f7609 [IOTDB-3486] Support deleteStorageGroup for new standalone
IoTDB (#6280)
f29b0f7609 is described below
commit f29b0f76092c6e8e09492a11d60c1e808e40e178
Author: Haonan <[email protected]>
AuthorDate: Tue Jun 14 21:27:28 2022 +0800
[IOTDB-3486] Support deleteStorageGroup for new standalone IoTDB (#6280)
---
.../iotdb/db/localconfignode/LocalConfigNode.java | 12 +++++++++++
.../executor/StandsloneConfigTaskExecutor.java | 24 ++++++++--------------
2 files changed, 21 insertions(+), 15 deletions(-)
diff --git
a/server/src/main/java/org/apache/iotdb/db/localconfignode/LocalConfigNode.java
b/server/src/main/java/org/apache/iotdb/db/localconfignode/LocalConfigNode.java
index daa08cae18..456fc8252b 100644
---
a/server/src/main/java/org/apache/iotdb/db/localconfignode/LocalConfigNode.java
+++
b/server/src/main/java/org/apache/iotdb/db/localconfignode/LocalConfigNode.java
@@ -268,6 +268,12 @@ public class LocalConfigNode {
public void deleteStorageGroup(PartialPath storageGroup) throws
MetadataException {
+ if (config.isMppMode() && !config.isClusterMode()) {
+ deleteDataRegionsInStorageGroup(
+ dataPartitionTable.getDataRegionIdsByStorageGroup(storageGroup));
+ dataPartitionTable.deleteStorageGroup(storageGroup);
+ }
+
DeleteTimeSeriesPlan deleteTimeSeriesPlan =
SchemaSyncManager.getInstance().isEnableSync()
? SchemaSyncManager.getInstance()
@@ -313,6 +319,12 @@ public class LocalConfigNode {
}
}
+ private void deleteDataRegionsInStorageGroup(List<DataRegionId>
dataRegionIdSet) {
+ for (DataRegionId dataRegionId : dataRegionIdSet) {
+ storageEngine.deleteDataRegion(dataRegionId);
+ }
+ }
+
/**
* Delete storage groups of given paths from MTree.
*
diff --git
a/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/executor/StandsloneConfigTaskExecutor.java
b/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/executor/StandsloneConfigTaskExecutor.java
index 4a2ff08050..7061be6eb3 100644
---
a/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/executor/StandsloneConfigTaskExecutor.java
+++
b/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/executor/StandsloneConfigTaskExecutor.java
@@ -21,7 +21,6 @@ package
org.apache.iotdb.db.mpp.plan.execution.config.executor;
import org.apache.iotdb.common.rpc.thrift.TFlushReq;
import org.apache.iotdb.common.rpc.thrift.TSStatus;
-import org.apache.iotdb.commons.exception.IllegalPathException;
import org.apache.iotdb.commons.exception.MetadataException;
import org.apache.iotdb.commons.path.PartialPath;
import org.apache.iotdb.commons.udf.service.UDFExecutableManager;
@@ -48,10 +47,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.stream.Collectors;
public class StandsloneConfigTaskExecutor implements IConfigTaskExecutor {
@@ -103,9 +102,9 @@ public class StandsloneConfigTaskExecutor implements
IConfigTaskExecutor {
String storageGroup = storageGroupMNode.getFullPath();
TStorageGroupSchema storageGroupSchema =
storageGroupMNode.getStorageGroupSchema();
storageGroupSchemaMap.put(storageGroup, storageGroupSchema);
- // build TSBlock
- ShowStorageGroupTask.buildTSBlock(storageGroupSchemaMap, future);
}
+ // build TSBlock
+ ShowStorageGroupTask.buildTSBlock(storageGroupSchemaMap, future);
} catch (MetadataException e) {
future.setException(e);
}
@@ -158,17 +157,12 @@ public class StandsloneConfigTaskExecutor implements
IConfigTaskExecutor {
DeleteStorageGroupStatement deleteStorageGroupStatement) {
SettableFuture<ConfigTaskResult> future = SettableFuture.create();
try {
- List<PartialPath> deletePathList =
- deleteStorageGroupStatement.getPrefixPath().stream()
- .map(
- path -> {
- try {
- return new PartialPath(path);
- } catch (IllegalPathException e) {
- return null;
- }
- })
- .collect(Collectors.toList());
+ List<PartialPath> deletePathList = new ArrayList<>();
+ for (String path : deleteStorageGroupStatement.getPrefixPath()) {
+ PartialPath prefixPath = new PartialPath(path);
+ deletePathList.addAll(
+ LocalConfigNode.getInstance().getMatchedStorageGroups(prefixPath,
false));
+ }
LocalConfigNode.getInstance().deleteStorageGroups(deletePathList);
} catch (MetadataException e) {
future.setException(e);