use of io.strimzi.operator.cluster.model.components.JmxTransServers in project strimzi by strimzi.
the class JmxTrans method generateJMXConfig.
/**
* Generates the string'd config that the JmxTrans deployment needs to run. It is configured by the user in the yaml
* and this method will convert that into the config the JmxTrans understands.
* @param spec The JmxTrans that was defined by the user
* @param numOfBrokers number of kafka brokers
* @return the jmx trans config file that targets each broker
*/
private String generateJMXConfig(JmxTransSpec spec, int numOfBrokers) throws JsonProcessingException {
JmxTransServers servers = new JmxTransServers();
servers.setServers(new ArrayList<>());
ObjectMapper mapper = new ObjectMapper();
String headlessService = KafkaCluster.headlessServiceName(cluster);
for (int brokerNumber = 0; brokerNumber < numOfBrokers; brokerNumber++) {
String brokerServiceName = KafkaCluster.externalServiceName(clusterName, brokerNumber) + "." + headlessService;
servers.getServers().add(convertSpecToServers(spec, brokerServiceName));
}
try {
return mapper.writeValueAsString(servers);
} catch (JsonProcessingException e) {
LOGGER.errorCr(reconciliation, "Could not create JmxTrans config json because: " + e.getMessage());
throw e;
}
}
use of io.strimzi.operator.cluster.model.components.JmxTransServers in project strimzi by strimzi.
the class JmxTrans method generateJMXConfig.
/**
* Generates the string'd config that the JmxTrans deployment needs to run. It is configured by the user in the yaml
* and this method will convert that into the config the JmxTrans understands.
*
* @return the jmx trans config file that targets each broker
*/
private String generateJMXConfig() {
List<JmxTransQueries> queries = jmxTransQueries();
List<JmxTransServer> servers = new ArrayList<>(numberOfBrokers);
String headlessService = KafkaResources.brokersServiceName(cluster);
for (int brokerNumber = 0; brokerNumber < numberOfBrokers; brokerNumber++) {
String brokerServiceName = KafkaResources.kafkaStatefulSetName(cluster) + "-" + brokerNumber + "." + headlessService;
servers.add(jmxTransServer(queries, brokerServiceName));
}
JmxTransServers jmxTransConfiguration = new JmxTransServers();
jmxTransConfiguration.setServers(servers);
try {
ObjectMapper mapper = new ObjectMapper();
return mapper.writeValueAsString(jmxTransConfiguration);
} catch (JsonProcessingException e) {
LOGGER.errorCr(reconciliation, "Failed to convert JMX Trans configuration to JSON", e);
throw new RuntimeException("Failed to convert JMX Trans configuration to JSON", e);
}
}
use of io.strimzi.operator.cluster.model.components.JmxTransServers in project strimzi-kafka-operator by strimzi.
the class JmxTrans method generateJMXConfig.
/**
* Generates the string'd config that the JmxTrans deployment needs to run. It is configured by the user in the yaml
* and this method will convert that into the config the JmxTrans understands.
*
* @return the jmx trans config file that targets each broker
*/
private String generateJMXConfig() {
List<JmxTransQueries> queries = jmxTransQueries();
List<JmxTransServer> servers = new ArrayList<>(numberOfBrokers);
String headlessService = KafkaResources.brokersServiceName(cluster);
for (int brokerNumber = 0; brokerNumber < numberOfBrokers; brokerNumber++) {
String brokerServiceName = KafkaResources.kafkaStatefulSetName(cluster) + "-" + brokerNumber + "." + headlessService;
servers.add(jmxTransServer(queries, brokerServiceName));
}
JmxTransServers jmxTransConfiguration = new JmxTransServers();
jmxTransConfiguration.setServers(servers);
try {
ObjectMapper mapper = new ObjectMapper();
return mapper.writeValueAsString(jmxTransConfiguration);
} catch (JsonProcessingException e) {
LOGGER.errorCr(reconciliation, "Failed to convert JMX Trans configuration to JSON", e);
throw new RuntimeException("Failed to convert JMX Trans configuration to JSON", e);
}
}
use of io.strimzi.operator.cluster.model.components.JmxTransServers in project strimzi-kafka-operator by strimzi.
the class JmxTrans method generateJMXConfig.
/**
* Generates the string'd config that the JmxTrans deployment needs to run. It is configured by the user in the yaml
* and this method will convert that into the config the JmxTrans understands.
* @param spec The JmxTrans that was defined by the user
* @param numOfBrokers number of kafka brokers
* @return the jmx trans config file that targets each broker
*/
private String generateJMXConfig(JmxTransSpec spec, int numOfBrokers) throws JsonProcessingException {
JmxTransServers servers = new JmxTransServers();
servers.setServers(new ArrayList<>());
ObjectMapper mapper = new ObjectMapper();
String headlessService = KafkaCluster.headlessServiceName(cluster);
for (int brokerNumber = 0; brokerNumber < numOfBrokers; brokerNumber++) {
String brokerServiceName = KafkaCluster.externalServiceName(clusterName, brokerNumber) + "." + headlessService;
servers.getServers().add(convertSpecToServers(spec, brokerServiceName));
}
try {
return mapper.writeValueAsString(servers);
} catch (JsonProcessingException e) {
LOGGER.errorCr(reconciliation, "Could not create JmxTrans config json because: " + e.getMessage());
throw e;
}
}
Aggregations