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);
}
}
Aggregations