use of io.cdap.cdap.master.spi.twill.ExtendedTwillContext in project cdap by caskdata.
the class PreviewRunnerTwillRunnable method doInitialize.
private void doInitialize(TwillContext context) throws Exception {
CConfiguration cConf = CConfiguration.create(new File(getArgument("cConf")).toURI().toURL());
Configuration hConf = new Configuration();
hConf.clear();
hConf.addResource(new File(getArgument("hConf")).toURI().toURL());
PreviewRequestPollerInfo pollerInfo;
if (context instanceof ExtendedTwillContext) {
pollerInfo = new PreviewRequestPollerInfo(context.getInstanceId(), ((ExtendedTwillContext) context).getUID());
} else {
pollerInfo = new PreviewRequestPollerInfo(context.getInstanceId(), null);
}
LOG.debug("Initializing preview runner with poller info {} in total {} runners", pollerInfo, context.getInstanceCount());
Injector injector = createInjector(cConf, hConf, pollerInfo);
// Initialize logging context
logAppenderInitializer = injector.getInstance(LogAppenderInitializer.class);
logAppenderInitializer.initialize();
LoggingContext loggingContext = new ServiceLoggingContext(NamespaceId.SYSTEM.getNamespace(), Constants.Logging.COMPONENT_NAME, PreviewRunnerTwillApplication.NAME);
LoggingContextAccessor.setLoggingContext(loggingContext);
// Optionally get the storage provider. It is for destroy() method to close it on shutdown.
Binding<StorageProvider> storageBinding = injector.getExistingBinding(Key.get(StorageProvider.class));
if (storageBinding != null) {
storageProvider = storageBinding.getProvider().get();
}
previewRunnerManager = injector.getInstance(PreviewRunnerManager.class);
}
Aggregations