chia7712 commented on code in PR #16666:
URL: https://github.com/apache/kafka/pull/16666#discussion_r1695540825


##########
core/src/test/java/kafka/testkit/TestKitNodes.java:
##########
@@ -216,4 +218,90 @@ public ListenerName externalListenerName() {
     public ListenerName controllerListenerName() {
         return new ListenerName("CONTROLLER");
     }
-}
+
+    public static TestKitNode buildBrokerNode(int id,

Review Comment:
   `private static`



##########
core/src/test/java/kafka/testkit/TestKitNodes.java:
##########
@@ -216,4 +218,90 @@ public ListenerName externalListenerName() {
     public ListenerName controllerListenerName() {
         return new ListenerName("CONTROLLER");
     }
-}
+
+    public static TestKitNode buildBrokerNode(int id,
+                                              String baseDirectory,
+                                              String clusterId,
+                                              boolean combined,
+                                              Map<String, String> 
propertyOverrides,
+                                              int numDisksPerBroker) {
+        List<String> logDataDirectories = IntStream
+            .range(0, numDisksPerBroker)
+            .mapToObj(i -> {
+                if (combined) {
+                    return String.format("combined_%d_%d", id, i);
+                }
+                return String.format("broker_%d_data%d", id, i);
+            })
+            .map(logDir -> {
+                if (Paths.get(logDir).isAbsolute()) {
+                    return logDir;
+                }
+                return new File(baseDirectory, logDir).getAbsolutePath();
+            })
+            .collect(Collectors.toList());
+        MetaPropertiesEnsemble.Copier copier = new 
MetaPropertiesEnsemble.Copier(MetaPropertiesEnsemble.EMPTY);
+
+        copier.setMetaLogDir(Optional.of(logDataDirectories.get(0)));
+        for (String logDir : logDataDirectories) {
+            copier.setLogDirProps(
+                logDir,
+                new MetaProperties.Builder()
+                    .setVersion(MetaPropertiesVersion.V1)
+                    .setClusterId(clusterId)
+                    .setNodeId(id)
+                    .setDirectoryId(copier.generateValidDirectoryId())
+                    .build()
+            );
+        }
+
+        return new TestKitNode() {
+            private final MetaPropertiesEnsemble ensemble = copier.copy();
+
+            @Override
+            public MetaPropertiesEnsemble initialMetaPropertiesEnsemble() {
+                return ensemble;
+            }
+
+            @Override
+            public Map<String, String> propertyOverrides() {
+                return Collections.unmodifiableMap(propertyOverrides);
+            }
+        };
+    }
+
+    public static TestKitNode buildControllerNode(int id,

Review Comment:
   `private static`



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