Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(deploy): modify common config overrides with server node distinc… #2331

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

package com.automq.shell.commands.cluster;

import org.apache.kafka.common.utils.Exit;

import com.automq.shell.model.ClusterTopology;
import com.automq.shell.model.Env;
import com.automq.shell.model.Node;
Expand All @@ -22,8 +20,9 @@
import com.automq.stream.s3.operator.ObjectStorageFactory;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;

import org.apache.commons.lang3.StringUtils;
import org.apache.kafka.common.utils.Exit;
import picocli.CommandLine;

import java.io.File;
import java.io.IOException;
Expand All @@ -36,8 +35,6 @@
import java.util.concurrent.Callable;
import java.util.stream.Collectors;

import picocli.CommandLine;

@CommandLine.Command(name = "deploy", description = "Deploy AutoMQ cluster", mixinStandardHelpOptions = true)
public class Deploy implements Callable<Integer> {
@CommandLine.Parameters(index = "0", description = "cluster project path")
Expand Down Expand Up @@ -134,7 +131,7 @@ private static String genServerStartupCmd(ClusterTopology topo, Node node) {
StringBuilder sb = new StringBuilder();
appendEnvs(sb, topo);
sb.append("./bin/kafka-server-start.sh -daemon config/kraft/server.properties ");
appendCommonConfigsOverride(sb, topo, node);
appendCommonConfigsOverride(sb, topo, node, true);
appendExtConfigsOverride(sb, topo.getGlobal().getConfig());
return sb.toString();
}
Expand All @@ -143,7 +140,7 @@ private static String genBrokerStartupCmd(ClusterTopology topo, Node node) {
StringBuilder sb = new StringBuilder();
appendEnvs(sb, topo);
sb.append("./bin/kafka-server-start.sh -daemon config/kraft/broker.properties ");
appendCommonConfigsOverride(sb, topo, node);
appendCommonConfigsOverride(sb, topo, node, false);
appendExtConfigsOverride(sb, topo.getGlobal().getConfig());
return sb.toString();
}
Expand All @@ -152,15 +149,20 @@ private static void appendEnvs(StringBuilder sb, ClusterTopology topo) {
topo.getGlobal().getEnvs().forEach(env -> sb.append(env.getName()).append("='").append(env.getValue()).append("' "));
}

private static void appendCommonConfigsOverride(StringBuilder sb, ClusterTopology topo, Node node) {
private static void appendCommonConfigsOverride(StringBuilder sb, ClusterTopology topo, Node node, boolean isServerNode) {
if (node.getNodeId() == Constants.NOOP_NODE_ID) {
throw new IllegalArgumentException(String.format("The host[%s]'s nodeId is required", node.getHost()));
}
sb.append("--override cluster.id=").append(topo.getGlobal().getClusterId()).append(" ");
sb.append("--override node.id=").append(node.getNodeId()).append(" ");
sb.append("--override controller.quorum.voters=").append(getQuorumVoters(topo)).append(" ");
sb.append("--override controller.quorum.bootstrap.servers=").append(getBootstrapServers(topo)).append(" ");
sb.append("--override advertised.listeners=").append("PLAINTEXT://").append(node.getHost()).append(":9092").append(" ");
sb.append("--override advertised.listeners=").append("PLAINTEXT://").append(node.getHost()).append(":9092");
if (isServerNode) {
sb.append(",").append("CONTROLLER://").append(node.getHost()).append(":9092").append(" ");
} else {
sb.append(" ");
}
}

private static void appendExtConfigsOverride(StringBuilder sb, String rawConfigs) {
Expand Down
Loading