-
Notifications
You must be signed in to change notification settings - Fork 1
/
KafkaServerDriverProperties.java
91 lines (73 loc) · 3 KB
/
KafkaServerDriverProperties.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package nl.darwinit.kafka.properties;
/**
* @author Martien van den Akker, Darwin-IT Professionals
* @version 1.0
*
* Class to parse and hold properties applicable to ZooKeeperServer.
* History
* 2019-01-19 - 1.0 - Initial Creation
*/
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.List;
import nl.darwinit.kafka.logging.Log;
import org.apache.zookeeper.server.ServerCnxnFactory;
import org.apache.zookeeper.server.ZooKeeperServer;
public class KafkaServerDriverProperties {
private static Log log = new Log(KafkaServerDriverProperties.class);
private List<String> kafkaServerList;
private HashMap<String, Properties> serverPropertiesMap = new HashMap<String, Properties> ();
/**
* Set Properties
* @param ksdProperties
* @throws UnknownHostException
*/
public void setProperties(Properties ksdProperties) throws UnknownHostException {
final String methodName = "setProperties(Properties)";
/*
server0.propertyfile=server0.properties
server0.startupEnabled=true
server1.propertyfile=server1.properties
server1.startupEnabled=true
*/
log.start(methodName);
List<String> kafkaServerList = ksdProperties.getListValue("kafkaservers");
setKafkaServerList(kafkaServerList);
for (String kafkaServerName : kafkaServerList) {
log.debug(methodName, "Set properties for kafkaServer: " + kafkaServerName);
Properties serverProperties = new Properties();
serverProperties.put("propertyfile", ksdProperties.getStringValue(kafkaServerName + ".propertyfile"));
serverProperties.put("startupEnabled", ksdProperties.getStringValue(kafkaServerName + ".startupEnabled"));
this.addServerProperties(kafkaServerName, serverProperties);
}
log.end(methodName);
}
public KafkaServerDriverProperties(Properties ksdProperties) throws UnknownHostException {
super();
final String methodName = "KafkaServerDriverProperties(Properties)";
log.start(methodName);
setProperties(ksdProperties);
log.end(methodName);
}
public void setKafkaServerList(List<String> kafkaServerList) {
this.kafkaServerList = kafkaServerList;
}
public List<String> getKafkaServerList() {
return kafkaServerList;
}
public void setServerPropertiesMap(HashMap<String, Properties> serverPropertiesMap) {
this.serverPropertiesMap = serverPropertiesMap;
}
public HashMap<String, Properties> getServerPropertiesMap() {
return serverPropertiesMap;
}
public void addServerProperties(String serverName, Properties serverProperties) {
this.serverPropertiesMap.put(serverName, serverProperties);
}
public Properties getServerProperties(String serverName) {
Properties serverProperties = this.serverPropertiesMap.get(serverName);
return serverProperties;
}
}