use of loghub.configuration.Configuration in project LogHub by fbacchella.
the class Start method launch.
public void launch(Properties props) throws ConfigException, IOException {
for (Source s : props.sources.values()) {
if (!s.configure(props)) {
logger.error("failed to start source {}", s.getName());
throw new IllegalStateException();
}
;
}
props.pipelines.stream().forEach(i -> i.configure(props));
for (Sender s : props.senders) {
if (s.configure(props)) {
s.start();
} else {
logger.error("failed to configure output {}", s.getName());
throw new IllegalStateException();
}
;
}
for (int i = 0; i < props.numWorkers; i++) {
Thread t = new EventsProcessor(props.mainQueue, props.outputQueues, props.namedPipeLine, props.maxSteps, props.repository);
t.setName("ProcessingThread" + i);
t.setDaemon(false);
t.start();
}
for (Receiver r : props.receivers) {
if (r.configure(props)) {
r.start();
} else {
logger.error("failed to configure input {}", r.getName());
throw new IllegalStateException();
}
}
try {
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
mbs.registerMBean(new StatsMBean.Implementation(), StatsMBean.Implementation.NAME);
JmxReporter reporter = Properties.metrics.getJmxReporter();
reporter.start();
mbs.queryNames(ObjectName.getInstance("metrics", "name", "Pipeline.*.timer"), null).stream().map(i -> i.getKeyProperty("name")).map(i -> i.replaceAll("^Pipeline\\.(.*)\\.timer$", "$1")).forEach(i -> {
try {
mbs.registerMBean(new PipelineStat.Implementation(i), null);
} catch (NotCompliantMBeanException | InstanceAlreadyExistsException | MBeanRegistrationException e) {
}
});
int port = props.jmxport;
if (port > 0) {
Helper.start(props.jmxproto, props.jmxlisten, port);
}
} catch (IOException | NotBoundException | NotCompliantMBeanException | MalformedObjectNameException | InstanceAlreadyExistsException | MBeanRegistrationException e) {
throw new RuntimeException("jmx configuration failed: " + e.getMessage(), e);
}
if (props.httpPort >= 0) {
AbstractHttpServer server = new DashboardHttpServer();
server.setPort(props.httpPort);
server.configure(props);
}
}
Aggregations