Search in sources :

Example 1 with ExtendedTwillContext

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);
}
Also used : ExtendedTwillContext(io.cdap.cdap.master.spi.twill.ExtendedTwillContext) LogAppenderInitializer(io.cdap.cdap.logging.appender.LogAppenderInitializer) Configuration(org.apache.hadoop.conf.Configuration) SConfiguration(io.cdap.cdap.common.conf.SConfiguration) CConfiguration(io.cdap.cdap.common.conf.CConfiguration) LoggingContext(io.cdap.cdap.common.logging.LoggingContext) ServiceLoggingContext(io.cdap.cdap.common.logging.ServiceLoggingContext) Injector(com.google.inject.Injector) PreviewRunnerManager(io.cdap.cdap.app.preview.PreviewRunnerManager) ServiceLoggingContext(io.cdap.cdap.common.logging.ServiceLoggingContext) StorageProvider(io.cdap.cdap.spi.data.StorageProvider) CConfiguration(io.cdap.cdap.common.conf.CConfiguration) File(java.io.File) PreviewRequestPollerInfo(io.cdap.cdap.internal.app.runtime.k8s.PreviewRequestPollerInfo)

Aggregations

Injector (com.google.inject.Injector)1 PreviewRunnerManager (io.cdap.cdap.app.preview.PreviewRunnerManager)1 CConfiguration (io.cdap.cdap.common.conf.CConfiguration)1 SConfiguration (io.cdap.cdap.common.conf.SConfiguration)1 LoggingContext (io.cdap.cdap.common.logging.LoggingContext)1 ServiceLoggingContext (io.cdap.cdap.common.logging.ServiceLoggingContext)1 PreviewRequestPollerInfo (io.cdap.cdap.internal.app.runtime.k8s.PreviewRequestPollerInfo)1 LogAppenderInitializer (io.cdap.cdap.logging.appender.LogAppenderInitializer)1 ExtendedTwillContext (io.cdap.cdap.master.spi.twill.ExtendedTwillContext)1 StorageProvider (io.cdap.cdap.spi.data.StorageProvider)1 File (java.io.File)1 Configuration (org.apache.hadoop.conf.Configuration)1