use of org.apache.samza.monitor.SamzaMonitorService in project samza by apache.
the class SamzaRestService method main.
/**
* Command line interface to run the server.
*
* @param args arguments supported by {@link org.apache.samza.util.CommandLine}.
* In particular, --config-path and --config-factory are used to read the Samza REST config file.
* @throws Exception if the server could not be successfully started.
*/
public static void main(String[] args) throws Exception {
try {
SamzaRestConfig config = parseConfig(args);
ReadableMetricsRegistry metricsRegistry = new MetricsRegistryMap();
log.info("Creating new SamzaRestService with config: {}", config);
MetricsConfig metricsConfig = new MetricsConfig(config);
Map<String, MetricsReporter> metricsReporters = MetricsReporterLoader.getMetricsReporters(metricsConfig, Util.getLocalHost().getHostName());
SamzaRestService restService = new SamzaRestService(new Server(config.getPort()), metricsRegistry, metricsReporters, new ServletContextHandler(ServletContextHandler.SESSIONS));
// Add applications
SamzaRestApplication samzaRestApplication = new SamzaRestApplication(config);
ServletContainer container = new ServletContainer(samzaRestApplication);
restService.addServlet(container, "/*");
// Schedule monitors to run
ScheduledExecutorService schedulingService = Executors.newScheduledThreadPool(1);
ScheduledExecutorSchedulingProvider schedulingProvider = new ScheduledExecutorSchedulingProvider(schedulingService);
SamzaMonitorService monitorService = new SamzaMonitorService(config, metricsRegistry, schedulingProvider);
monitorService.start();
restService.runBlocking();
monitorService.stop();
} catch (Throwable t) {
log.error("Exception in main.", t);
}
}
Aggregations