use of io.strimzi.operator.cluster.model.components.JmxTransServer in project strimzi-kafka-operator by strimzi.
the class JmxTransTest method testServersDeserialization.
@ParallelTest
public void testServersDeserialization() {
JmxTransServer server = new JmxTransServer();
server.setHost("host");
server.setPort(9999);
server.setUsername("username");
server.setPassword("password");
server.setQueries(Collections.emptyList());
JsonObject targetJson = JsonObject.mapFrom(server);
assertThat(targetJson.getString("host"), is("host"));
assertThat(targetJson.getInteger("port"), is(9999));
assertThat(targetJson.getString("username"), is("username"));
assertThat(targetJson.getString("password"), is("password"));
assertThat(targetJson.getJsonArray("queries").getList().size(), is(0));
}
use of io.strimzi.operator.cluster.model.components.JmxTransServer in project strimzi by strimzi.
the class JmxTransTest method testServersDeserialization.
@ParallelTest
public void testServersDeserialization() {
JmxTransServer server = new JmxTransServer();
server.setHost("host");
server.setPort(9999);
server.setUsername("username");
server.setPassword("password");
server.setQueries(Collections.emptyList());
JsonObject targetJson = JsonObject.mapFrom(server);
assertThat(targetJson.getString("host"), is("host"));
assertThat(targetJson.getInteger("port"), is(9999));
assertThat(targetJson.getString("username"), is("username"));
assertThat(targetJson.getString("password"), is("password"));
assertThat(targetJson.getJsonArray("queries").getList().size(), is(0));
}
use of io.strimzi.operator.cluster.model.components.JmxTransServer in project strimzi-kafka-operator by strimzi.
the class JmxTrans method convertSpecToServers.
private JmxTransServer convertSpecToServers(JmxTransSpec spec, String brokerServiceName) {
JmxTransServer server = new JmxTransServer();
server.setHost(brokerServiceName);
server.setPort(AbstractModel.JMX_PORT);
if (isJmxAuthenticated()) {
server.setUsername("${kafka.username}");
server.setPassword("${kafka.password}");
}
List<JmxTransQueries> queries = new ArrayList<>();
for (JmxTransQueryTemplate queryTemplate : spec.getKafkaQueries()) {
JmxTransQueries query = new JmxTransQueries();
query.setObj(queryTemplate.getTargetMBean());
query.setAttr(queryTemplate.getAttributes());
query.setOutputWriters(new ArrayList<>());
for (JmxTransOutputDefinitionTemplate outputDefinitionTemplate : spec.getOutputDefinitions()) {
if (queryTemplate.getOutputs().contains(outputDefinitionTemplate.getName())) {
JmxTransOutputWriter outputWriter = new JmxTransOutputWriter();
outputWriter.setAtClass(outputDefinitionTemplate.getOutputType());
if (outputDefinitionTemplate.getHost() != null) {
outputWriter.setHost(outputDefinitionTemplate.getHost());
}
if (outputDefinitionTemplate.getPort() != null) {
outputWriter.setPort(outputDefinitionTemplate.getPort());
}
if (outputDefinitionTemplate.getFlushDelayInSeconds() != null) {
outputWriter.setFlushDelayInSeconds(outputDefinitionTemplate.getFlushDelayInSeconds());
}
outputWriter.setTypeNames(outputDefinitionTemplate.getTypeNames());
query.getOutputWriters().add(outputWriter);
}
}
queries.add(query);
}
server.setQueries(queries);
return server;
}
Aggregations