You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/05/25 13:10:04 UTC

[GitHub] [iotdb] xingtanzjr commented on a diff in pull request #5994: [IOTDB-2919] Refactor delete storage group

xingtanzjr commented on code in PR #5994:
URL: https://github.com/apache/iotdb/pull/5994#discussion_r881633230


##########
confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java:
##########
@@ -40,45 +43,84 @@ public class ConfigNodeProcedureEnv {
 
   private final ConfigManager configManager;
 
+  private static boolean skipForTest = false;
+
+  private static boolean invalidCacheResult = true;
+
+  public static void setSkipForTest(boolean skipForTest) {
+    ConfigNodeProcedureEnv.skipForTest = skipForTest;
+  }
+
+  public static void setInvalidCacheResult(boolean result) {
+    ConfigNodeProcedureEnv.invalidCacheResult = result;
+  }
+
   public ConfigNodeProcedureEnv(ConfigManager configManager) {
     this.configManager = configManager;
   }
 
-  // TODO: reuse the same ClientPool with other module
-  private static final IClientManager<TEndPoint, SyncDataNodeInternalServiceClient>
-      INTERNAL_SERVICE_CLIENT_MANAGER =
-          new IClientManager.Factory<TEndPoint, SyncDataNodeInternalServiceClient>()
-              .createClientManager(
-                  new DataNodeClientPoolFactory.SyncDataNodeInternalServiceClientPoolFactory());
-
   public ConfigManager getConfigManager() {
     return configManager;
   }
 
-  public InternalService.Client getDataNodeClient(TRegionReplicaSet dataRegionReplicaSet)
-      throws IOException {
-    List<TDataNodeLocation> dataNodeLocations = dataRegionReplicaSet.getDataNodeLocations();
-    int retry = dataNodeLocations.size() - 1;
-    for (TDataNodeLocation dataNodeLocation : dataNodeLocations) {
-      try {
-        return INTERNAL_SERVICE_CLIENT_MANAGER.borrowClient(dataNodeLocation.getInternalEndPoint());
-      } catch (IOException e) {
-        if (retry-- > 0) {
-          LOG.warn(
-              "Connect dataRegion-{} at dataNode-{} failed, trying next replica..",
-              dataRegionReplicaSet.getRegionId(),
-              dataNodeLocation);
-        } else {
-          LOG.warn("Connect dataRegion{} failed", dataRegionReplicaSet.getRegionId());
-          throw e;
-        }
+  /**
+   * Delete config node information, includes (mTree, partitionInfo, regionMap)
+   *
+   * @param deleteSgSchema storage group name
+   * @return tsStatus
+   */
+  public TSStatus deleteConfig(TStorageGroupSchema deleteSgSchema) {
+    DeleteStorageGroupReq deleteStorageGroupReq = new DeleteStorageGroupReq(deleteSgSchema);
+    return configManager.getClusterSchemaManager().deleteStorageGroup(deleteStorageGroupReq);
+  }
+
+  /**
+   * Pre delete a storage group
+   *
+   * @param preDeleteType execute/rollback
+   * @param deleteSgName storage group name
+   */
+  public void preDelete(PreDeleteStorageGroupReq.PreDeleteType preDeleteType, String deleteSgName) {
+    configManager.getPartitionManager().preDeleteStorageGroup(deleteSgName, preDeleteType);
+  }
+
+  /**
+   * @param storageGroupName Storage group name
+   * @return ALL SUCCESS OR NOT
+   * @throws IOException IOE
+   * @throws TException Thrift IOE
+   */
+  public boolean invalidateCache(String storageGroupName) throws IOException, TException {
+    // TODO: Remove it after IT is supported
+    if (skipForTest) {
+      return invalidCacheResult;
+    }
+    List<TDataNodeInfo> allDataNodes = configManager.getNodeManager().getOnlineDataNodes(-1);
+    TInvalidateCacheReq invalidateCacheReq = new TInvalidateCacheReq();
+    invalidateCacheReq.setStorageGroup(true);
+    invalidateCacheReq.setFullPath(storageGroupName);
+    for (TDataNodeInfo dataNodeInfo : allDataNodes) {

Review Comment:
   Maybe we can speed up this step by send the request to each DataNode in parallel and wait the result together at the end



-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org