Tabnine Logo
LoggingContextAccessor
Code IndexAdd Tabnine to your IDE (free)

How to use
LoggingContextAccessor
in
co.cask.cdap.common.logging

Best Java code snippets using co.cask.cdap.common.logging.LoggingContextAccessor (Showing top 20 results out of 315)

origin: co.cask.cdap/cdap-app-fabric

/**
 * Returns the {@link MapReduceTaskContextProvider} associated with this ClassLoader.
 */
public MapReduceTaskContextProvider getTaskContextProvider() {
 // Logging context needs to be set in main thread.
 LoggingContext loggingContext = createMapReduceLoggingContext();
 LoggingContextAccessor.setLoggingContext(loggingContext);
 synchronized (this) {
  taskContextProvider = Optional.fromNullable(taskContextProvider).or(taskContextProviderSupplier);
 }
 taskContextProvider.startAndWait();
 return taskContextProvider;
}
origin: caskdata/cdap

@Override
public final void append(ILoggingEvent eventObject) {
 LoggingContext loggingContext;
 // If the context is not setup, pickup the context from thread-local.
 // If the context is already setup, use the context (in async mode).
 if (eventObject instanceof LogMessage) {
  loggingContext = ((LogMessage) eventObject).getLoggingContext();
 } else {
  loggingContext = LoggingContextAccessor.getLoggingContext();
  if (loggingContext == null) {
   return;
  }
  addExtraTags(eventObject);
 }
 LogMessage logMessage = new LogMessage(eventObject, loggingContext);
 appendEvent(logMessage);
}
origin: co.cask.cdap/cdap-watchdog

@Override
public final void append(ILoggingEvent eventObject) {
 LoggingContext loggingContext;
 // If the context is not setup, pickup the context from thread-local.
 // If the context is already setup, use the context (in async mode).
 if (eventObject instanceof LogMessage) {
  loggingContext = ((LogMessage) eventObject).getLoggingContext();
 } else {
  loggingContext = LoggingContextAccessor.getLoggingContext();
  if (loggingContext == null) {
   return;
  }
  addExtraTags(eventObject);
 }
 LogMessage logMessage = new LogMessage(eventObject, loggingContext);
 appendEvent(logMessage);
}
origin: cdapio/cdap

@Override
protected void startUp() throws Exception {
 LoggingContextAccessor.setLoggingContext(loggingContext);
 runningThread = Thread.currentThread();
 createLocalDatasets();
 workflow = initializeWorkflow();
}
origin: cdapio/cdap

/**
 * Returns the {@link MapReduceTaskContextProvider} associated with this ClassLoader.
 */
public MapReduceTaskContextProvider getTaskContextProvider() {
 // Logging context needs to be set in main thread.
 LoggingContext loggingContext = createMapReduceLoggingContext();
 LoggingContextAccessor.setLoggingContext(loggingContext);
 synchronized (this) {
  taskContextProvider = Optional.fromNullable(taskContextProvider).or(taskContextProviderSupplier);
 }
 taskContextProvider.startAndWait();
 return taskContextProvider;
}
origin: co.cask.cdap/cdap-app-fabric

@Override
protected void startUp() throws Exception {
 LoggingContextAccessor.setLoggingContext(loggingContext);
 runningThread = Thread.currentThread();
 createLocalDatasets();
 workflow = initializeWorkflow();
}
origin: co.cask.cdap/cdap-app-fabric

/**
 * Runs the runnable with the logging context set to the program run's context. Anything logged within the runnable
 * will be treated as if they were logs in the program run.
 *
 * @param programRunId the program run to log as
 * @param systemArgs system arguments for the run
 * @param runnable the runnable to run
 */
private void runWithProgramLogging(ProgramRunId programRunId, Map<String, String> systemArgs, Runnable runnable) {
 LoggingContext loggingContext = LoggingContextHelper.getLoggingContextWithRunId(programRunId, systemArgs);
 Cancellable cancellable = LoggingContextAccessor.setLoggingContext(loggingContext);
 try {
  runnable.run();
 } finally {
  cancellable.cancel();
 }
}
origin: cdapio/cdap

/**
 * Runs the runnable with the logging context set to the program run's context. Anything logged within the runnable
 * will be treated as if they were logs in the program run.
 *
 * @param programRunId the program run to log as
 * @param systemArgs system arguments for the run
 * @param runnable the runnable to run
 */
private void runWithProgramLogging(ProgramRunId programRunId, Map<String, String> systemArgs, Runnable runnable) {
 LoggingContext loggingContext = LoggingContextHelper.getLoggingContextWithRunId(programRunId, systemArgs);
 Cancellable cancellable = LoggingContextAccessor.setLoggingContext(loggingContext);
 try {
  runnable.run();
 } finally {
  cancellable.cancel();
 }
}
origin: cdapio/cdap

@Override
protected Injector doInit(TwillContext context) {
 // Set the hostname of the machine so that cConf can be used to start internal services
 getCConfiguration().set(Constants.Metrics.ADDRESS, context.getHost().getCanonicalHostName());
 LOG.info("{} Setting host name to {}", name, context.getHost().getCanonicalHostName());
 String txClientId = String.format("cdap.service.%s.%d", Constants.Service.METRICS, context.getInstanceId());
 injector = createGuiceInjector(getCConfiguration(), getConfiguration(), txClientId);
 injector.getInstance(LogAppenderInitializer.class).initialize();
 LoggingContextAccessor.setLoggingContext(new ServiceLoggingContext(NamespaceId.SYSTEM.getNamespace(),
                                   Constants.Logging.COMPONENT_NAME,
                                   Constants.Service.METRICS));
 return injector;
}
origin: cdapio/cdap

@Override
protected Injector doInit(TwillContext context) {
 getCConfiguration().set(Constants.Transaction.Container.ADDRESS, context.getHost().getCanonicalHostName());
 // Set the hostname of the machine so that cConf can be used to start internal services
 LOG.info("{} Setting host name to {}", name, context.getHost().getCanonicalHostName());
 String txClientId = String.format("cdap.service.%s.%d", Constants.Service.TRANSACTION, context.getInstanceId());
 injector = createGuiceInjector(getCConfiguration(), getConfiguration(), txClientId);
 injector.getInstance(LogAppenderInitializer.class).initialize();
 LoggingContextAccessor.setLoggingContext(new ServiceLoggingContext(NamespaceId.SYSTEM.getNamespace(),
                                   Constants.Logging.COMPONENT_NAME,
                                   Constants.Service.TRANSACTION));
 return injector;
}
origin: caskdata/cdap

@Override
protected void startUp() throws Exception {
 LoggingContextAccessor.setLoggingContext(new ServiceLoggingContext(Id.Namespace.SYSTEM.getId(),
                                   Constants.Logging.COMPONENT_NAME,
                                   Constants.Service.METRICS));
 LOG.info("Starting Metrics Service...");
 httpService.start();
 LOG.info("Started Metrics HTTP Service...");
 // Register the service
 cancelDiscovery = discoveryService.register(
  ResolvingDiscoverable.of(new Discoverable(Constants.Service.METRICS, httpService.getBindAddress())));
 LOG.info("Metrics Service started successfully on {}", httpService.getBindAddress());
}
origin: co.cask.cdap/cdap-watchdog

@Override
protected void startUp() throws Exception {
 LoggingContextAccessor.setLoggingContext(new ServiceLoggingContext(Id.Namespace.SYSTEM.getId(),
                                   Constants.Logging.COMPONENT_NAME,
                                   Constants.Service.METRICS_PROCESSOR));
 LOG.info("Starting MetricsProcessor Status Service...");
 httpService.start();
 cancellable = discoveryService.register(
  ResolvingDiscoverable.of(new Discoverable(Constants.Service.METRICS_PROCESSOR, httpService.getBindAddress())));
 LOG.info("Started MetricsProcessor Status Service.");
}
origin: co.cask.cdap/cdap-app-fabric

@Override
protected void run() throws Exception {
 LoggingContextAccessor.setLoggingContext(loggingContext);
origin: cdapio/cdap

@Override
protected Injector doInit(TwillContext context) {
 getCConfiguration().set(Constants.MetricsProcessor.ADDRESS, context.getHost().getCanonicalHostName());
 // Set the hostname of the machine so that cConf can be used to start internal services
 LOG.info("{} Setting host name to {}", name, context.getHost().getCanonicalHostName());
 String txClientId = String.format("cdap.service.%s.%d", Constants.Service.METRICS_PROCESSOR,
                  context.getInstanceId());
 injector = createGuiceInjector(getCConfiguration(), getConfiguration(), txClientId, context);
 injector.getInstance(LogAppenderInitializer.class).initialize();
 LoggingContextAccessor.setLoggingContext(new ServiceLoggingContext(NamespaceId.SYSTEM.getNamespace(),
                                   Constants.Logging.COMPONENT_NAME,
                                   Constants.Service.METRICS_PROCESSOR));
 return injector;
}
origin: caskdata/cdap

@Override
protected void startUp() throws Exception {
 LoggingContextAccessor.setLoggingContext(new ServiceLoggingContext(Id.Namespace.SYSTEM.getId(),
                                   Constants.Logging.COMPONENT_NAME,
                                   Constants.Service.METRICS_PROCESSOR));
 LOG.info("Starting MetricsProcessor Status Service...");
 httpService.start();
 cancellable = discoveryService.register(
  ResolvingDiscoverable.of(new Discoverable(Constants.Service.METRICS_PROCESSOR, httpService.getBindAddress())));
 LOG.info("Started MetricsProcessor Status Service.");
}
origin: cdapio/cdap

@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(
  new Discoverable(Constants.Service.EXPLORE_HTTP_USER_SERVICE, httpService.getBindAddress())));
 LOG.info("{} started successfully on {}", ExploreExecutorService.class.getSimpleName(),
      httpService.getBindAddress());
}
origin: co.cask.cdap/cdap-watchdog

@Override
protected void startUp() throws Exception {
 LoggingContextAccessor.setLoggingContext(new ServiceLoggingContext(Id.Namespace.SYSTEM.getId(),
                                   Constants.Logging.COMPONENT_NAME,
                                   Constants.Service.METRICS));
 LOG.info("Starting Metrics Service...");
 httpService.start();
 LOG.info("Started Metrics HTTP Service...");
 // Register the service
 cancelDiscovery = discoveryService.register(
  ResolvingDiscoverable.of(new Discoverable(Constants.Service.METRICS, httpService.getBindAddress())));
 LOG.info("Metrics Service started successfully on {}", httpService.getBindAddress());
}
origin: cdapio/cdap

@Override
protected void startUp() throws Exception {
 LoggingContextAccessor.setLoggingContext(new ServiceLoggingContext(NamespaceId.SYSTEM.getEntityName(),
                                   Constants.Logging.COMPONENT_NAME,
                                   Constants.Service.DATASET_EXECUTOR));
 LOG.info("Starting DatasetOpExecutorService...");
 httpService.start();
 cancellable = discoveryService.register(
  ResolvingDiscoverable.of(new Discoverable(Constants.Service.DATASET_EXECUTOR, httpService.getBindAddress())));
 LOG.info("DatasetOpExecutorService started successfully on {}", httpService.getBindAddress());
}
origin: co.cask.cdap/cdap-explore

@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(
  new Discoverable(Constants.Service.EXPLORE_HTTP_USER_SERVICE, httpService.getBindAddress())));
 LOG.info("{} started successfully on {}", ExploreExecutorService.class.getSimpleName(),
      httpService.getBindAddress());
}
origin: co.cask.cdap/cdap-data-fabric

@Override
protected void startUp() throws Exception {
 LoggingContextAccessor.setLoggingContext(new ServiceLoggingContext(NamespaceId.SYSTEM.getEntityName(),
                                   Constants.Logging.COMPONENT_NAME,
                                   Constants.Service.DATASET_EXECUTOR));
 LOG.info("Starting DatasetOpExecutorService...");
 httpService.start();
 cancellable = discoveryService.register(
  ResolvingDiscoverable.of(new Discoverable(Constants.Service.DATASET_EXECUTOR, httpService.getBindAddress())));
 LOG.info("DatasetOpExecutorService started successfully on {}", httpService.getBindAddress());
}
co.cask.cdap.common.loggingLoggingContextAccessor

Javadoc

Allows to store and access the logging context.

The logging context is injected into log messages emitted via standard logging APIs. This enables grouping logs based on the execution context of the place where log message was emitted and searching messages on the logs processing back-end.

Most used methods

  • setLoggingContext
    Sets the logging context. NOTE: in work execution frameworks where threads are shared between worker
  • getLoggingContext

Popular in Java

  • Running tasks concurrently on multiple threads
  • getApplicationContext (Context)
  • addToBackStack (FragmentTransaction)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • List (java.util)
    An ordered collection (also known as a sequence). The user of this interface has precise control ove
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now