Skip to content

Commit

Permalink
BIGTOP-4300: Install Kafka with tarball
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinw66 committed Dec 10, 2024
1 parent faa3f19 commit a2250fe
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,23 @@

import java.io.IOException;
import java.text.MessageFormat;
import java.util.Properties;

@Slf4j
@AutoService(Script.class)
public class KafkaBrokerScript extends AbstractServerScript {

@Override
public ShellResult add(Params params) {
Properties properties = new Properties();
properties.setProperty(PROPERTY_KEY_SKIP_LEVELS, "1");

return super.add(params, properties);
}

@Override
public ShellResult configure(Params params) {
return KafkaSetup.config(params);
return KafkaSetup.configure(params);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ public String kafkaLimits() {
return (String) kafkaLimits.get("content");
}

@Override
public String confDir() {
return serviceHome() + "/config";
}

@Override
public String getServiceName() {
return "kafka";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class KafkaSetup {

public static ShellResult config(Params params) {
public static ShellResult configure(Params params) {
log.info("Configuring Kafka");
KafkaParams kafkaParams = (KafkaParams) params;

String confDir = kafkaParams.confDir();
Expand All @@ -52,7 +53,6 @@ public static ShellResult config(Params params) {
LinuxFileUtils.createDirectories(kafkaParams.getKafkaLogDir(), kafkaUser, kafkaGroup, PERMISSION_755, true);
LinuxFileUtils.createDirectories(kafkaParams.getKafkaPidDir(), kafkaUser, kafkaGroup, PERMISSION_755, true);

// server.properties
List<String> zookeeperServerHosts = LocalSettings.hosts("zookeeper_server");
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("zk_server_list", zookeeperServerHosts);
Expand All @@ -66,7 +66,6 @@ public static ShellResult config(Params params) {
kafkaParams.kafkaBroker(),
paramMap);

// kafka-env
LinuxFileUtils.toFileByTemplate(
kafkaParams.getKafkaEnvContent(),
MessageFormat.format("{0}/kafka-env.sh", confDir),
Expand All @@ -75,7 +74,6 @@ public static ShellResult config(Params params) {
PERMISSION_644,
kafkaParams.getGlobalParamsMap());

// log4j
LinuxFileUtils.toFileByTemplate(
kafkaParams.getKafkaLog4jContent(),
MessageFormat.format("{0}/log4j.properties", confDir),
Expand All @@ -84,7 +82,6 @@ public static ShellResult config(Params params) {
PERMISSION_644,
kafkaParams.getGlobalParamsMap());

// kafka.limits
LinuxFileUtils.toFileByTemplate(
kafkaParams.kafkaLimits(),
MessageFormat.format("{0}/kafka.conf", KafkaParams.LIMITS_CONF_DIR),
Expand All @@ -93,6 +90,7 @@ public static ShellResult config(Params params) {
PERMISSION_644,
kafkaParams.getGlobalParamsMap());

return ShellResult.success("Kafka Server Configure success!");
log.info("Successfully configured Kafka");
return ShellResult.success();
}
}

0 comments on commit a2250fe

Please sign in to comment.