use of co.cask.cdap.logging.context.MapReduceLoggingContext in project cdap by caskdata.
the class MockLogReader method generateLogs.
public void generateLogs() throws InterruptedException {
// Add logs for app testApp2, flow testFlow1
generateLogs(new FlowletLoggingContext(NamespaceId.DEFAULT.getEntityName(), "testApp2", "testFlow1", "testFlowlet1", "", ""), NamespaceId.DEFAULT.app("testApp2").flow("testFlow1"), ProgramRunStatus.RUNNING);
// Add logs for app testApp3, mapreduce testMapReduce1
generateLogs(new MapReduceLoggingContext(NamespaceId.DEFAULT.getEntityName(), "testApp3", "testMapReduce1", ""), NamespaceId.DEFAULT.app("testApp3").mr("testMapReduce1"), ProgramRunStatus.SUSPENDED);
// Add logs for app testApp1, service testService1
generateLogs(new UserServiceLoggingContext(NamespaceId.DEFAULT.getEntityName(), "testApp4", "testService1", "test1", "", ""), NamespaceId.DEFAULT.app("testApp4").service("testService1"), ProgramRunStatus.RUNNING);
// Add logs for app testApp1, mapreduce testMapReduce1
generateLogs(new MapReduceLoggingContext(TEST_NAMESPACE_ID.getNamespace(), "testTemplate1", "testMapReduce1", ""), TEST_NAMESPACE_ID.app("testTemplate1").mr("testMapReduce1"), ProgramRunStatus.COMPLETED);
// Add logs for app testApp1, flow testFlow1 in testNamespace
generateLogs(new FlowletLoggingContext(TEST_NAMESPACE_ID.getNamespace(), "testApp1", "testFlow1", "testFlowlet1", "", ""), TEST_NAMESPACE_ID.app("testApp1").flow("testFlow1"), ProgramRunStatus.COMPLETED);
// Add logs for app testApp1, service testService1 in testNamespace
generateLogs(new UserServiceLoggingContext(TEST_NAMESPACE_ID.getNamespace(), "testApp4", "testService1", "test1", "", ""), TEST_NAMESPACE_ID.app("testApp4").service("testService1"), ProgramRunStatus.KILLED);
// Add logs for testWorkflow1 in testNamespace
generateLogs(new WorkflowLoggingContext(TEST_NAMESPACE_ID.getNamespace(), "testTemplate1", "testWorkflow1", "testRun1"), TEST_NAMESPACE_ID.app("testTemplate1").workflow("testWorkflow1"), ProgramRunStatus.COMPLETED);
// Add logs for testWorkflow1 in default namespace
generateLogs(new WorkflowLoggingContext(NamespaceId.DEFAULT.getEntityName(), "testTemplate1", "testWorkflow1", "testRun2"), NamespaceId.DEFAULT.app("testTemplate1").workflow("testWorkflow1"), ProgramRunStatus.COMPLETED);
generateWorkflowLogs();
}
use of co.cask.cdap.logging.context.MapReduceLoggingContext in project cdap by caskdata.
the class MapReduceClassLoader method createMapReduceLoggingContext.
/**
* Creates logging context for MapReduce program. If the program is started
* by Workflow an instance of {@link WorkflowProgramLoggingContext} is returned,
* otherwise an instance of {@link MapReduceLoggingContext} is returned.
*/
private LoggingContext createMapReduceLoggingContext() {
MapReduceContextConfig contextConfig = new MapReduceContextConfig(parameters.getHConf());
ProgramId programId = contextConfig.getProgramId();
RunId runId = ProgramRunners.getRunId(contextConfig.getProgramOptions());
WorkflowProgramInfo workflowProgramInfo = contextConfig.getWorkflowProgramInfo();
if (workflowProgramInfo == null) {
return new MapReduceLoggingContext(programId.getNamespace(), programId.getApplication(), programId.getProgram(), runId.getId());
}
String workflowId = workflowProgramInfo.getName();
String workflowRunId = workflowProgramInfo.getRunId().getId();
return new WorkflowProgramLoggingContext(programId.getNamespace(), programId.getApplication(), workflowId, workflowRunId, ProgramType.MAPREDUCE, programId.getProgram(), runId.getId());
}
Aggregations