jt2594838 commented on code in PR #17985:
URL: https://github.com/apache/iotdb/pull/17985#discussion_r3434405518


##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/pipe/PipeTaskInfo.java:
##########
@@ -998,6 +1009,45 @@ public void processLoadSnapshot(final File snapshotDir) 
throws IOException {
     }
   }
 
+  public void enrichPipeMetasWithRootUserForCompatibility() {
+    acquireWriteLock();
+    try {
+      pipeMetaKeeper
+          .getPipeMetaList()
+          .forEach(
+              pipeMeta -> 
enrichPipeMetaWithRootUserForCompatibility(pipeMeta.getStaticMeta()));
+    } finally {
+      releaseWriteLock();
+    }
+  }
+
+  private void enrichPipeMetaWithRootUserForCompatibility(final PipeStaticMeta 
pipeStaticMeta) {
+    if (pipeUserPasswordProvider == null) {
+      return;
+    }
+    final boolean shouldEnrichSource = 
pipeStaticMeta.mayNeedCompatibleRootUserForIoTDBSource();
+    final boolean shouldEnrichSink = 
pipeStaticMeta.mayNeedCompatibleRootUserForWriteBackSink();
+    if (!shouldEnrichSource && !shouldEnrichSink) {
+      return;
+    }
+
+    final String rootUserName = 
CommonDescriptor.getInstance().getConfig().getDefaultAdminName();
+    final String password = pipeUserPasswordProvider.apply(rootUserName, null);

Review Comment:
   What is the point of the second parameter?



##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/pipe/PipeTaskInfo.java:
##########
@@ -95,10 +97,16 @@ public class PipeTaskInfo implements SnapshotProcessor {
 
   // Pure in-memory object, not involved in snapshot serialization and 
deserialization.
   private final PipeTaskInfoVersion pipeTaskInfoVersion;
+  private final BiFunction<String, String, String> pipeUserPasswordProvider;

Review Comment:
   Explain the parameters



##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/pipe/PipeTaskInfo.java:
##########
@@ -998,6 +1009,45 @@ public void processLoadSnapshot(final File snapshotDir) 
throws IOException {
     }
   }
 
+  public void enrichPipeMetasWithRootUserForCompatibility() {
+    acquireWriteLock();
+    try {
+      pipeMetaKeeper
+          .getPipeMetaList()
+          .forEach(
+              pipeMeta -> 
enrichPipeMetaWithRootUserForCompatibility(pipeMeta.getStaticMeta()));
+    } finally {
+      releaseWriteLock();
+    }
+  }
+
+  private void enrichPipeMetaWithRootUserForCompatibility(final PipeStaticMeta 
pipeStaticMeta) {
+    if (pipeUserPasswordProvider == null) {
+      return;
+    }
+    final boolean shouldEnrichSource = 
pipeStaticMeta.mayNeedCompatibleRootUserForIoTDBSource();
+    final boolean shouldEnrichSink = 
pipeStaticMeta.mayNeedCompatibleRootUserForWriteBackSink();
+    if (!shouldEnrichSource && !shouldEnrichSink) {
+      return;
+    }
+
+    final String rootUserName = 
CommonDescriptor.getInstance().getConfig().getDefaultAdminName();
+    final String password = pipeUserPasswordProvider.apply(rootUserName, null);
+    if (Objects.isNull(password)) {
+      throw new PipeException(
+          String.format(
+              "Failed to enrich pipe %s with root user for compatibility 
because root user %s does not exist.",
+              pipeStaticMeta.getPipeName(), rootUserName));

Review Comment:
   i18n



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to