use of io.cdap.cdap.common.logging.ServiceLoggingContext in project cdap by cdapio.
the class SystemWorkerTwillRunnable method doInitialize.
private void doInitialize(TwillContext context) throws Exception {
CConfiguration cConf = CConfiguration.create(new File(getArgument("cConf")).toURI().toURL());
// Overwrite the app fabric temp directory with the task worker temp directory
cConf.set(Constants.CFG_LOCAL_DATA_DIR, cConf.get(Constants.TaskWorker.LOCAL_DATA_DIR));
Configuration hConf = new Configuration();
hConf.clear();
hConf.addResource(new File(getArgument("hConf")).toURI().toURL());
Injector injector = createInjector(cConf, hConf);
// Initialize logging context
logAppenderInitializer = injector.getInstance(LogAppenderInitializer.class);
logAppenderInitializer.initialize();
metricsCollectionService = injector.getInstance(MetricsCollectionService.class);
metricsCollectionService.startAndWait();
LoggingContext loggingContext = new ServiceLoggingContext(NamespaceId.SYSTEM.getNamespace(), Constants.Logging.COMPONENT_NAME, SystemWorkerTwillApplication.NAME);
LoggingContextAccessor.setLoggingContext(loggingContext);
taskWorker = injector.getInstance(TaskWorkerService.class);
}
use of io.cdap.cdap.common.logging.ServiceLoggingContext in project cdap by cdapio.
the class ArtifactLocalizerTwillRunnable method doInitialize.
private void doInitialize() throws Exception {
CConfiguration cConf = CConfiguration.create();
cConf.clear();
cConf.addResource(new File(getArgument("cConf")).toURI().toURL());
Configuration hConf = new Configuration();
hConf.clear();
hConf.addResource(new File(getArgument("hConf")).toURI().toURL());
Injector injector = createInjector(cConf, hConf);
// Initialize logging context
logAppenderInitializer = injector.getInstance(LogAppenderInitializer.class);
logAppenderInitializer.initialize();
LoggingContext loggingContext = new ServiceLoggingContext(NamespaceId.SYSTEM.getNamespace(), Constants.Logging.COMPONENT_NAME, Constants.Service.ARTIFACT_LOCALIZER);
LoggingContextAccessor.setLoggingContext(loggingContext);
tokenManager = injector.getInstance(TokenManager.class);
tokenManager.startAndWait();
artifactLocalizerService = injector.getInstance(ArtifactLocalizerService.class);
}
use of io.cdap.cdap.common.logging.ServiceLoggingContext in project cdap by cdapio.
the class ExploreExecutorService method startUp.
@Override
protected void startUp() throws Exception {
LoggingContextAccessor.setLoggingContext(new ServiceLoggingContext(NamespaceId.SYSTEM.getNamespace(), Constants.Logging.COMPONENT_NAME, Constants.Service.EXPLORE_HTTP_USER_SERVICE));
LOG.info("Starting {}...", ExploreExecutorService.class.getSimpleName());
if (!startOnDemand) {
exploreService.startAndWait();
}
httpService.start();
cancellable = discoveryService.register(ResolvingDiscoverable.of(URIScheme.createDiscoverable(Constants.Service.EXPLORE_HTTP_USER_SERVICE, httpService)));
LOG.info("{} started successfully on {}", ExploreExecutorService.class.getSimpleName(), httpService.getBindAddress());
}
use of io.cdap.cdap.common.logging.ServiceLoggingContext in project cdap by cdapio.
the class PreviewHttpServer method startUp.
/**
* Configures the AppFabricService pre-start.
*/
@Override
protected void startUp() throws Exception {
LoggingContextAccessor.setLoggingContext(new ServiceLoggingContext(NamespaceId.SYSTEM.getNamespace(), Constants.Logging.COMPONENT_NAME, Constants.Service.PREVIEW_HTTP));
if (previewManager instanceof Service) {
((Service) previewManager).startAndWait();
}
httpService.start();
cancelHttpService = discoveryService.register(ResolvingDiscoverable.of(URIScheme.createDiscoverable(Constants.Service.PREVIEW_HTTP, httpService)));
LOG.info("Preview HTTP server started on {}", httpService.getBindAddress());
}
use of io.cdap.cdap.common.logging.ServiceLoggingContext in project cdap by cdapio.
the class DefaultPreviewRunner method startUp.
@Override
protected void startUp() throws Exception {
LOG.debug("Starting preview runner service");
StoreDefinition.createAllTables(structuredTableAdmin);
if (messagingService instanceof Service) {
((Service) messagingService).startAndWait();
}
dsOpExecService.startAndWait();
datasetService.startAndWait();
// It is recommended to initialize log appender after datasetService is started,
// since log appender instantiates a dataset.
logAppenderInitializer.initialize();
LoggingContextAccessor.setLoggingContext(new ServiceLoggingContext(NamespaceId.SYSTEM.getNamespace(), Constants.Logging.COMPONENT_NAME, Constants.Service.PREVIEW_HTTP));
Futures.allAsList(applicationLifecycleService.start(), programRuntimeService.start(), metricsCollectionService.start(), programNotificationSubscriberService.start()).get();
Files.createDirectories(previewIdDirPath);
// Reconcile status for abruptly terminated preview runs
try (Stream<Path> paths = Files.walk(Paths.get(previewIdDirPath.toString()))) {
paths.filter(Files::isRegularFile).forEach(path -> {
try (Reader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
ProgramId programId = GSON.fromJson(reader, ProgramId.class);
long submitTimeMillis = RunIds.getTime(programId.getApplication(), TimeUnit.MILLISECONDS);
PreviewStatus status = new PreviewStatus(PreviewStatus.Status.KILLED_BY_EXCEEDING_MEMORY_LIMIT, submitTimeMillis, new BasicThrowable(new Exception("Preview runner container killed possibly because of out of memory. " + "Please try running preview again.")), null, null);
previewTerminated(programId, status);
} catch (IOException e) {
LOG.warn("Error reading file {}. Ignoring", path, e);
}
});
}
}
Aggregations