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/11/02 12:57:39 UTC

[GitHub] [iotdb] Cpaulyz opened a new pull request, #7885: [IOTDB-4827][IOTDB-4840] Adaptation and fix mlog logic for for cluster template

Cpaulyz opened a new pull request, #7885:
URL: https://github.com/apache/iotdb/pull/7885

   ## Description
   WIP


-- 
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


[GitHub] [iotdb] MarcosZyk commented on a diff in pull request #7885: [IOTDB-4827][IOTDB-4840] Adaptation and fix mlog logic for for cluster template

Posted by GitBox <gi...@apache.org>.
MarcosZyk commented on code in PR #7885:
URL: https://github.com/apache/iotdb/pull/7885#discussion_r1012806103


##########
server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionSchemaFileImpl.java:
##########
@@ -2001,39 +1990,75 @@ public void setUsingSchemaTemplate(IActivateTemplatePlan plan) throws MetadataEx
   @Override
   public void activateSchemaTemplate(IActivateTemplateInClusterPlan plan, Template template)
       throws MetadataException {
-    throw new UnsupportedOperationException();
+
+    try {
+      IMNode deviceNode = getDeviceNodeWithAutoCreate(plan.getActivatePath());
+      try {
+        mtree.activateTemplate(plan.getActivatePath(), template);
+        writeToMLog(plan);
+      } finally {
+        mtree.unPinMNode(deviceNode);
+      }
+    } catch (IOException e) {
+      logger.error(e.getMessage(), e);
+      throw new MetadataException(e);
+    }
   }
 
   @Override
   public List<String> getPathsUsingTemplate(PartialPath pathPattern, int templateId)
       throws MetadataException {
-    throw new UnsupportedOperationException();
+    return mtree.getPathsUsingTemplate(pathPattern, templateId);
   }
 
   @Override
   public int constructSchemaBlackListWithTemplate(IPreDeactivateTemplatePlan plan)
       throws MetadataException {
-    throw new UnsupportedOperationException();
+    Map<PartialPath, List<Integer>> resultTemplateSetInfo =
+        mtree.constructSchemaBlackListWithTemplate(plan.getTemplateSetInfo());
+    try {
+      writeToMLog(SchemaRegionPlanFactory.getPreDeactivateTemplatePlan(resultTemplateSetInfo));
+    } catch (IOException e) {
+      throw new MetadataException(e);
+    }
+    return resultTemplateSetInfo.size();

Review Comment:
   Such process is guaranteed by consensus layer making all write request execution serial.



-- 
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


[GitHub] [iotdb] MarcosZyk merged pull request #7885: [IOTDB-4827][IOTDB-4840] Adaptation and fix mlog logic for for cluster template

Posted by GitBox <gi...@apache.org>.
MarcosZyk merged PR #7885:
URL: https://github.com/apache/iotdb/pull/7885


-- 
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


[GitHub] [iotdb] MarcosZyk commented on a diff in pull request #7885: [IOTDB-4827][IOTDB-4840] Adaptation and fix mlog logic for for cluster template

Posted by GitBox <gi...@apache.org>.
MarcosZyk commented on code in PR #7885:
URL: https://github.com/apache/iotdb/pull/7885#discussion_r1012795720


##########
server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTreeBelowSGCachedImpl.java:
##########
@@ -1733,6 +1748,162 @@ public String getTemplateOnPath(PartialPath path) throws MetadataException {
     }
   }
 
+  @Override
+  public void activateTemplate(PartialPath activatePath, Template template)
+      throws MetadataException {
+    String[] nodes = activatePath.getNodes();
+    IMNode cur = storageGroupMNode;
+    List<IMNode> pinedNodes = new ArrayList<>();

Review Comment:
   should be pinnedNodes



##########
server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionMemoryImpl.java:
##########
@@ -2096,10 +2097,14 @@ public int constructSchemaBlackListWithTemplate(IPreDeactivateTemplatePlan plan)
     for (Map.Entry<PartialPath, List<Integer>> entry : templateSetInfo.entrySet()) {
       for (IEntityMNode entityMNode :
           mtree.getDeviceMNodeUsingTargetTemplate(entry.getKey(), entry.getValue())) {
+        HashMap<PartialPath, List<Integer>> subTemplateSetInfo = new HashMap<>();

Review Comment:
   Use Map rather than HashMap.



##########
confignode/src/main/java/org/apache/iotdb/confignode/consensus/response/TemplateSetInfoResp.java:
##########
@@ -30,6 +30,7 @@
 public class TemplateSetInfoResp implements DataSet {
 
   private TSStatus status;
+  // <possible device paths for setting templates, possible set templates>

Review Comment:
   path pattern represents possible device paths.



##########
server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionSchemaFileImpl.java:
##########
@@ -940,7 +939,7 @@ private IMNode getDeviceNodeWithAutoCreate(PartialPath path)
         mtree.pinMNode(node);
         return node;
       } catch (MetadataException e) {
-        // the node in mNodeCache has been evicted, thus get it via the following progress
+        //         the node in mNodeCache has been evicted, thus get it via the following progress

Review Comment:
   remove the tab



##########
server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionSchemaFileImpl.java:
##########
@@ -2001,39 +1990,75 @@ public void setUsingSchemaTemplate(IActivateTemplatePlan plan) throws MetadataEx
   @Override
   public void activateSchemaTemplate(IActivateTemplateInClusterPlan plan, Template template)
       throws MetadataException {
-    throw new UnsupportedOperationException();
+
+    try {
+      IMNode deviceNode = getDeviceNodeWithAutoCreate(plan.getActivatePath());
+      try {
+        mtree.activateTemplate(plan.getActivatePath(), template);
+        writeToMLog(plan);
+      } finally {
+        mtree.unPinMNode(deviceNode);
+      }
+    } catch (IOException e) {
+      logger.error(e.getMessage(), e);
+      throw new MetadataException(e);
+    }
   }
 
   @Override
   public List<String> getPathsUsingTemplate(PartialPath pathPattern, int templateId)
       throws MetadataException {
-    throw new UnsupportedOperationException();
+    return mtree.getPathsUsingTemplate(pathPattern, templateId);
   }
 
   @Override
   public int constructSchemaBlackListWithTemplate(IPreDeactivateTemplatePlan plan)
       throws MetadataException {
-    throw new UnsupportedOperationException();
+    Map<PartialPath, List<Integer>> resultTemplateSetInfo =
+        mtree.constructSchemaBlackListWithTemplate(plan.getTemplateSetInfo());
+    try {
+      writeToMLog(SchemaRegionPlanFactory.getPreDeactivateTemplatePlan(resultTemplateSetInfo));
+    } catch (IOException e) {
+      throw new MetadataException(e);
+    }
+    return resultTemplateSetInfo.size();

Review Comment:
   Such process is guaranteed by consensus layer making all write request execution serial.



-- 
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


[GitHub] [iotdb] Cpaulyz commented on a diff in pull request #7885: [IOTDB-4827][IOTDB-4840] Adaptation and fix mlog logic for for cluster template

Posted by GitBox <gi...@apache.org>.
Cpaulyz commented on code in PR #7885:
URL: https://github.com/apache/iotdb/pull/7885#discussion_r1012942434


##########
server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionMemoryImpl.java:
##########
@@ -2096,10 +2097,14 @@ public int constructSchemaBlackListWithTemplate(IPreDeactivateTemplatePlan plan)
     for (Map.Entry<PartialPath, List<Integer>> entry : templateSetInfo.entrySet()) {
       for (IEntityMNode entityMNode :
           mtree.getDeviceMNodeUsingTargetTemplate(entry.getKey(), entry.getValue())) {
+        HashMap<PartialPath, List<Integer>> subTemplateSetInfo = new HashMap<>();

Review Comment:
   done



##########
confignode/src/main/java/org/apache/iotdb/confignode/consensus/response/TemplateSetInfoResp.java:
##########
@@ -30,6 +30,7 @@
 public class TemplateSetInfoResp implements DataSet {
 
   private TSStatus status;
+  // <possible device paths for setting templates, possible set templates>

Review Comment:
   done



##########
server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionSchemaFileImpl.java:
##########
@@ -940,7 +939,7 @@ private IMNode getDeviceNodeWithAutoCreate(PartialPath path)
         mtree.pinMNode(node);
         return node;
       } catch (MetadataException e) {
-        // the node in mNodeCache has been evicted, thus get it via the following progress
+        //         the node in mNodeCache has been evicted, thus get it via the following progress

Review Comment:
   done



##########
server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTreeBelowSGCachedImpl.java:
##########
@@ -1733,6 +1748,162 @@ public String getTemplateOnPath(PartialPath path) throws MetadataException {
     }
   }
 
+  @Override
+  public void activateTemplate(PartialPath activatePath, Template template)
+      throws MetadataException {
+    String[] nodes = activatePath.getNodes();
+    IMNode cur = storageGroupMNode;
+    List<IMNode> pinedNodes = new ArrayList<>();

Review Comment:
   done



-- 
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