Search in sources :

Example 1 with JmxTransServers

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;
    }
}
Also used : JmxTransServers(io.strimzi.operator.cluster.model.components.JmxTransServers) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 2 with JmxTransServers

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);
    }
}
Also used : ArrayList(java.util.ArrayList) JmxTransServers(io.strimzi.operator.cluster.model.components.JmxTransServers) JmxTransServer(io.strimzi.operator.cluster.model.components.JmxTransServer) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) JmxTransQueries(io.strimzi.operator.cluster.model.components.JmxTransQueries) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 3 with JmxTransServers

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);
    }
}
Also used : ArrayList(java.util.ArrayList) JmxTransServers(io.strimzi.operator.cluster.model.components.JmxTransServers) JmxTransServer(io.strimzi.operator.cluster.model.components.JmxTransServer) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) JmxTransQueries(io.strimzi.operator.cluster.model.components.JmxTransQueries) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 4 with JmxTransServers

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;
    }
}
Also used : JmxTransServers(io.strimzi.operator.cluster.model.components.JmxTransServers) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)4 JmxTransServers (io.strimzi.operator.cluster.model.components.JmxTransServers)4 JmxTransQueries (io.strimzi.operator.cluster.model.components.JmxTransQueries)2 JmxTransServer (io.strimzi.operator.cluster.model.components.JmxTransServer)2 ArrayList (java.util.ArrayList)2