Search in sources :

Example 16 with LoggingContext

use of co.cask.cdap.common.logging.LoggingContext in project cdap by caskdata.

the class MapReduceClassLoader method getTaskContextProvider.

/**
   * 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;
}
Also used : LoggingContext(co.cask.cdap.common.logging.LoggingContext) MapReduceLoggingContext(co.cask.cdap.logging.context.MapReduceLoggingContext) WorkflowProgramLoggingContext(co.cask.cdap.logging.context.WorkflowProgramLoggingContext)

Example 17 with LoggingContext

use of co.cask.cdap.common.logging.LoggingContext in project cdap by caskdata.

the class LogHandler method getRunIdLogs.

@GET
@Path("/namespaces/{namespace-id}/apps/{app-id}/{program-type}/{program-id}/runs/{run-id}/logs")
public void getRunIdLogs(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("app-id") String appId, @PathParam("program-type") String programType, @PathParam("program-id") String programId, @PathParam("run-id") String runId, @QueryParam("start") @DefaultValue("-1") long fromTimeSecsParam, @QueryParam("stop") @DefaultValue("-1") long toTimeSecsParam, @QueryParam("escape") @DefaultValue("true") boolean escape, @QueryParam("filter") @DefaultValue("") String filterStr, @QueryParam("format") @DefaultValue("text") String format, @QueryParam("suppress") List<String> suppress) throws NotFoundException {
    ProgramType type = ProgramType.valueOfCategoryName(programType);
    RunRecordMeta runRecord = getRunRecordMeta(namespaceId, appId, type, programId, runId);
    LoggingContext loggingContext = LoggingContextHelper.getLoggingContextWithRunId(namespaceId, appId, programId, type, runId, runRecord.getSystemArgs());
    doGetLogs(responder, loggingContext, fromTimeSecsParam, toTimeSecsParam, escape, filterStr, runRecord, format, suppress);
}
Also used : LoggingContext(co.cask.cdap.common.logging.LoggingContext) RunRecordMeta(co.cask.cdap.internal.app.store.RunRecordMeta) ProgramType(co.cask.cdap.proto.ProgramType) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 18 with LoggingContext

use of co.cask.cdap.common.logging.LoggingContext in project cdap by caskdata.

the class LogHandler method prev.

@GET
@Path("/namespaces/{namespace-id}/apps/{app-id}/{program-type}/{program-id}/logs/prev")
public void prev(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("app-id") String appId, @PathParam("program-type") String programType, @PathParam("program-id") String programId, @QueryParam("max") @DefaultValue("50") int maxEvents, @QueryParam("fromOffset") @DefaultValue("") String fromOffsetStr, @QueryParam("escape") @DefaultValue("true") boolean escape, @QueryParam("filter") @DefaultValue("") String filterStr) {
    LoggingContext loggingContext = LoggingContextHelper.getLoggingContext(namespaceId, appId, programId, ProgramType.valueOfCategoryName(programType));
    doPrev(responder, loggingContext, maxEvents, fromOffsetStr, escape, filterStr, null, "text", ImmutableList.<String>of());
}
Also used : LoggingContext(co.cask.cdap.common.logging.LoggingContext) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 19 with LoggingContext

use of co.cask.cdap.common.logging.LoggingContext in project cdap by caskdata.

the class LogHandler method sysNext.

@GET
@Path("/system/{component-id}/{service-id}/logs/next")
public void sysNext(HttpRequest request, HttpResponder responder, @PathParam("component-id") String componentId, @PathParam("service-id") String serviceId, @QueryParam("max") @DefaultValue("50") int maxEvents, @QueryParam("fromOffset") @DefaultValue("") String fromOffsetStr, @QueryParam("escape") @DefaultValue("true") boolean escape, @QueryParam("filter") @DefaultValue("") String filterStr, @QueryParam("format") @DefaultValue("text") String format, @QueryParam("suppress") List<String> suppress) {
    LoggingContext loggingContext = LoggingContextHelper.getLoggingContext(Id.Namespace.SYSTEM.getId(), componentId, serviceId);
    doNext(responder, loggingContext, maxEvents, fromOffsetStr, escape, filterStr, null, format, suppress);
}
Also used : LoggingContext(co.cask.cdap.common.logging.LoggingContext) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 20 with LoggingContext

use of co.cask.cdap.common.logging.LoggingContext in project cdap by caskdata.

the class LogHandler method getLogs.

@GET
@Path("/namespaces/{namespace-id}/apps/{app-id}/{program-type}/{program-id}/logs")
public void getLogs(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("app-id") String appId, @PathParam("program-type") String programType, @PathParam("program-id") String programId, @QueryParam("start") @DefaultValue("-1") long fromTimeSecsParam, @QueryParam("stop") @DefaultValue("-1") long toTimeSecsParam, @QueryParam("escape") @DefaultValue("true") boolean escape, @QueryParam("filter") @DefaultValue("") String filterStr) {
    LoggingContext loggingContext = LoggingContextHelper.getLoggingContext(namespaceId, appId, programId, ProgramType.valueOfCategoryName(programType));
    doGetLogs(responder, loggingContext, fromTimeSecsParam, toTimeSecsParam, escape, filterStr, null, "text", ImmutableList.<String>of());
}
Also used : LoggingContext(co.cask.cdap.common.logging.LoggingContext) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Aggregations

LoggingContext (co.cask.cdap.common.logging.LoggingContext)30 GET (javax.ws.rs.GET)12 Path (javax.ws.rs.Path)12 Test (org.junit.Test)11 FlowletLoggingContext (co.cask.cdap.logging.context.FlowletLoggingContext)9 RunRecordMeta (co.cask.cdap.internal.app.store.RunRecordMeta)6 LoggingTester (co.cask.cdap.logging.appender.LoggingTester)5 FileLogReader (co.cask.cdap.logging.read.FileLogReader)4 LogEvent (co.cask.cdap.logging.read.LogEvent)4 CConfiguration (co.cask.cdap.common.conf.CConfiguration)3 ApplicationLoggingContext (co.cask.cdap.common.logging.ApplicationLoggingContext)3 LogPathIdentifier (co.cask.cdap.logging.appender.system.LogPathIdentifier)3 FileMetaDataReader (co.cask.cdap.logging.meta.FileMetaDataReader)3 LogLocation (co.cask.cdap.logging.write.LogLocation)3 ProgramType (co.cask.cdap.proto.ProgramType)3 Transactional (co.cask.cdap.api.Transactional)2 DatasetManager (co.cask.cdap.api.dataset.DatasetManager)2 NamespaceLoggingContext (co.cask.cdap.common.logging.NamespaceLoggingContext)2 ServiceLoggingContext (co.cask.cdap.common.logging.ServiceLoggingContext)2 SystemDatasetInstantiator (co.cask.cdap.data.dataset.SystemDatasetInstantiator)2