use of com.googlecode.jmxtrans.model.Server in project jmxtrans by jmxtrans.
the class ServerListBuilderTest method outputWritersAreReusedOnServersAndQueries.
@Test
public void outputWritersAreReusedOnServersAndQueries() {
Server server = Server.builder(serverWithNoQuery()).addOutputWriterFactory(new DummyOutputWriterFactory("output1")).addQuery(Query.builder(dummyQuery()).addOutputWriterFactory(new DummyOutputWriterFactory("output1")).build()).build();
ImmutableList<Server> servers = new ServerListBuilder().add(singletonList(server)).build();
Server createdServer = servers.iterator().next();
Query createdQuery = createdServer.getQueries().iterator().next();
assertThat(createdQuery.getOutputWriterInstances()).hasSize(1);
assertThat(createdServer.getOutputWriters().iterator().next()).isSameAs(createdQuery.getOutputWriterInstances().iterator().next());
}
use of com.googlecode.jmxtrans.model.Server in project jmxtrans by jmxtrans.
the class JmxTransformer method stopWriterAndClearMasterServerList.
/**
* Shut down the output writers and clear the master server list
* Used both during shutdown and when re-reading config files
*/
private void stopWriterAndClearMasterServerList() {
for (Server server : this.masterServersList) {
for (OutputWriter writer : server.getOutputWriters()) {
try {
writer.close();
} catch (LifecycleException ex) {
log.error("Eror stopping writer: {}", writer);
}
}
for (Query query : server.getQueries()) {
for (OutputWriter writer : query.getOutputWriterInstances()) {
try {
writer.close();
log.debug("Stopped writer: {} for query: {}", writer, query);
} catch (LifecycleException ex) {
log.error("Error stopping writer: {} for query: {}", writer, query, ex);
}
}
}
}
this.masterServersList = ImmutableList.of();
}
Aggregations