Search in sources :

Example 1 with SamzaContainerListener

use of org.apache.samza.container.SamzaContainerListener in project samza by apache.

the class LocalContainerRunner method run.

@Override
public void run(StreamApplication streamApp) {
    ContainerModel containerModel = jobModel.getContainers().get(containerId);
    Object taskFactory = TaskFactoryUtil.createTaskFactory(config, streamApp, this);
    container = SamzaContainer$.MODULE$.apply(containerModel, config, jobModel.maxChangeLogStreamPartitions, Util.<String, MetricsReporter>javaMapAsScalaMap(new HashMap<>()), taskFactory);
    container.setContainerListener(new SamzaContainerListener() {

        @Override
        public void onContainerStart() {
            log.info("Container Started");
        }

        @Override
        public void onContainerStop(boolean invokedExternally) {
            log.info("Container Stopped");
        }

        @Override
        public void onContainerFailed(Throwable t) {
            log.info("Container Failed");
            containerRunnerException = t;
        }
    });
    startContainerHeartbeatMonitor();
    container.run();
    stopContainerHeartbeatMonitor();
    if (containerRunnerException != null) {
        log.error("Container stopped with Exception. Exiting process now.", containerRunnerException);
        System.exit(1);
    }
}
Also used : SamzaContainerListener(org.apache.samza.container.SamzaContainerListener) MetricsReporter(org.apache.samza.metrics.MetricsReporter) ContainerModel(org.apache.samza.job.model.ContainerModel)

Aggregations

SamzaContainerListener (org.apache.samza.container.SamzaContainerListener)1 ContainerModel (org.apache.samza.job.model.ContainerModel)1 MetricsReporter (org.apache.samza.metrics.MetricsReporter)1