org.apache.hadoop.yarn.event.EventHandler Java Examples
The following examples show how to use
org.apache.hadoop.yarn.event.EventHandler.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestContainerLaunch.java From big-c with Apache License 2.0 | 6 votes |
@SuppressWarnings("rawtypes") @Test (timeout = 10000) public void testCallFailureWithNullLocalizedResources() { Container container = mock(Container.class); when(container.getContainerId()).thenReturn(ContainerId.newContainerId( ApplicationAttemptId.newInstance(ApplicationId.newInstance( System.currentTimeMillis(), 1), 1), 1)); ContainerLaunchContext clc = mock(ContainerLaunchContext.class); when(clc.getCommands()).thenReturn(Collections.<String>emptyList()); when(container.getLaunchContext()).thenReturn(clc); when(container.getLocalizedResources()).thenReturn(null); Dispatcher dispatcher = mock(Dispatcher.class); EventHandler eventHandler = new EventHandler() { public void handle(Event event) { Assert.assertTrue(event instanceof ContainerExitEvent); ContainerExitEvent exitEvent = (ContainerExitEvent) event; Assert.assertEquals(ContainerEventType.CONTAINER_EXITED_WITH_FAILURE, exitEvent.getType()); } }; when(dispatcher.getEventHandler()).thenReturn(eventHandler); ContainerLaunch launch = new ContainerLaunch(context, new Configuration(), dispatcher, exec, null, container, dirsHandler, containerManager); launch.call(); }
Example #2
Source File: TestEdge.java From tez with Apache License 2.0 | 6 votes |
@Test(timeout = 5000) public void testInvalidConsumerNumber() throws Exception { EventHandler mockEventHandler = mock(EventHandler.class); Edge edge = new Edge(EdgeProperty.create( EdgeManagerPluginDescriptor.create(CustomEdgeManagerWithInvalidReturnValue.class.getName()) .setUserPayload(new CustomEdgeManagerWithInvalidReturnValue.EdgeManagerConfig(1,1,0,1).toUserPayload()), DataSourceType.PERSISTED, SchedulingType.SEQUENTIAL, OutputDescriptor.create(""), InputDescriptor.create("")), mockEventHandler, new TezConfiguration()); TezVertexID v1Id = createVertexID(1); TezVertexID v2Id = createVertexID(2); edge.setSourceVertex(mockVertex("v1", v1Id, new LinkedHashMap<TezTaskID, Task>())); edge.setDestinationVertex(mockVertex("v2", v2Id, new LinkedHashMap<TezTaskID, Task>())); edge.initialize(); try { TezEvent ireEvent = new TezEvent(InputReadErrorEvent.create("diag", 0, 1), new EventMetaData(EventProducerConsumerType.INPUT, "v2", "v1", TezTaskAttemptID.getInstance(TezTaskID.getInstance(v2Id, 1), 1))); edge.sendTezEventToSourceTasks(ireEvent); Assert.fail(); } catch (AMUserCodeException e) { e.printStackTrace(); assertTrue(e.getCause().getMessage().contains("ConsumerTaskNum must be positive")); } }
Example #3
Source File: TestLocalContainerAllocator.java From hadoop with Apache License 2.0 | 6 votes |
private static AppContext createAppContext() { ApplicationId appId = ApplicationId.newInstance(1, 1); ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance(appId, 1); Job job = mock(Job.class); @SuppressWarnings("rawtypes") EventHandler eventHandler = mock(EventHandler.class); AppContext ctx = mock(AppContext.class); when(ctx.getApplicationID()).thenReturn(appId); when(ctx.getApplicationAttemptId()).thenReturn(attemptId); when(ctx.getJob(isA(JobId.class))).thenReturn(job); when(ctx.getClusterInfo()).thenReturn( new ClusterInfo(Resource.newInstance(10240, 1, 0))); when(ctx.getEventHandler()).thenReturn(eventHandler); return ctx; }
Example #4
Source File: TestContainerLaunch.java From hadoop with Apache License 2.0 | 6 votes |
@SuppressWarnings("rawtypes") @Test (timeout = 10000) public void testCallFailureWithNullLocalizedResources() { Container container = mock(Container.class); when(container.getContainerId()).thenReturn(ContainerId.newContainerId( ApplicationAttemptId.newInstance(ApplicationId.newInstance( System.currentTimeMillis(), 1), 1), 1)); ContainerLaunchContext clc = mock(ContainerLaunchContext.class); when(clc.getCommands()).thenReturn(Collections.<String>emptyList()); when(container.getLaunchContext()).thenReturn(clc); when(container.getLocalizedResources()).thenReturn(null); Dispatcher dispatcher = mock(Dispatcher.class); EventHandler eventHandler = new EventHandler() { public void handle(Event event) { Assert.assertTrue(event instanceof ContainerExitEvent); ContainerExitEvent exitEvent = (ContainerExitEvent) event; Assert.assertEquals(ContainerEventType.CONTAINER_EXITED_WITH_FAILURE, exitEvent.getType()); } }; when(dispatcher.getEventHandler()).thenReturn(eventHandler); ContainerLaunch launch = new ContainerLaunch(context, new Configuration(), dispatcher, exec, null, container, dirsHandler, containerManager); launch.call(); }
Example #5
Source File: QueryUnit.java From incubator-tajo with Apache License 2.0 | 6 votes |
public QueryUnit(Configuration conf, QueryUnitAttemptScheduleContext scheduleContext, QueryUnitId id, boolean isLeafTask, EventHandler eventHandler) { this.systemConf = conf; this.taskId = id; this.eventHandler = eventHandler; this.isLeafTask = isLeafTask; scan = new ArrayList<ScanNode>(); fetchMap = Maps.newHashMap(); fragMap = Maps.newHashMap(); shuffleFileOutputs = new ArrayList<ShuffleFileOutput>(); attempts = Collections.emptyMap(); lastAttemptId = null; nextAttempt = -1; failedAttempts = 0; ReadWriteLock readWriteLock = new ReentrantReadWriteLock(); this.readLock = readWriteLock.readLock(); this.writeLock = readWriteLock.writeLock(); this.scheduleContext = scheduleContext; stateMachine = stateMachineFactory.make(this); totalFragmentNum = 0; }
Example #6
Source File: TestEdge.java From tez with Apache License 2.0 | 6 votes |
@Test(timeout = 5000) public void testInvalidSourceTaskIndex() throws Exception { EventHandler mockEventHandler = mock(EventHandler.class); Edge edge = new Edge(EdgeProperty.create( EdgeManagerPluginDescriptor.create(CustomEdgeManagerWithInvalidReturnValue.class.getName()) .setUserPayload(new CustomEdgeManagerWithInvalidReturnValue.EdgeManagerConfig(1,1,1,-1).toUserPayload()), DataSourceType.PERSISTED, SchedulingType.SEQUENTIAL, OutputDescriptor.create(""), InputDescriptor.create("")), mockEventHandler, new TezConfiguration()); TezVertexID v1Id = createVertexID(1); TezVertexID v2Id = createVertexID(2); edge.setSourceVertex(mockVertex("v1", v1Id, new LinkedHashMap<TezTaskID, Task>())); edge.setDestinationVertex(mockVertex("v2", v2Id, new LinkedHashMap<TezTaskID, Task>())); edge.initialize(); try { TezEvent ireEvent = new TezEvent(InputReadErrorEvent.create("diag", 0, 1), new EventMetaData(EventProducerConsumerType.INPUT, "v2", "v1", TezTaskAttemptID.getInstance(TezTaskID.getInstance(v2Id, 1), 1))); edge.sendTezEventToSourceTasks(ireEvent); Assert.fail(); } catch (AMUserCodeException e) { e.printStackTrace(); assertTrue(e.getCause().getMessage().contains("SourceTaskIndex should not be negative")); } }
Example #7
Source File: TestClientRMService.java From big-c with Apache License 2.0 | 6 votes |
@Test public void testGetApplicationResourceUsageReportDummy() throws YarnException, IOException { ApplicationAttemptId attemptId = getApplicationAttemptId(1); YarnScheduler yarnScheduler = mockYarnScheduler(); RMContext rmContext = mock(RMContext.class); mockRMContext(yarnScheduler, rmContext); when(rmContext.getDispatcher().getEventHandler()).thenReturn( new EventHandler<Event>() { public void handle(Event event) { } }); ApplicationSubmissionContext asContext = mock(ApplicationSubmissionContext.class); YarnConfiguration config = new YarnConfiguration(); RMAppAttemptImpl rmAppAttemptImpl = new RMAppAttemptImpl(attemptId, rmContext, yarnScheduler, null, asContext, config, false, null); ApplicationResourceUsageReport report = rmAppAttemptImpl .getApplicationResourceUsageReport(); assertEquals(report, RMServerUtils.DUMMY_APPLICATION_RESOURCE_USAGE_REPORT); }
Example #8
Source File: TestJobImpl.java From hadoop with Apache License 2.0 | 6 votes |
private static StubbedJob createStubbedJob(Configuration conf, Dispatcher dispatcher, int numSplits, AppContext appContext) { JobID jobID = JobID.forName("job_1234567890000_0001"); JobId jobId = TypeConverter.toYarn(jobID); if (appContext == null) { appContext = mock(AppContext.class); when(appContext.hasSuccessfullyUnregistered()).thenReturn(true); } StubbedJob job = new StubbedJob(jobId, ApplicationAttemptId.newInstance(ApplicationId.newInstance(0, 0), 0), conf,dispatcher.getEventHandler(), true, "somebody", numSplits, appContext); dispatcher.register(JobEventType.class, job); EventHandler mockHandler = mock(EventHandler.class); dispatcher.register(TaskEventType.class, mockHandler); dispatcher.register(org.apache.hadoop.mapreduce.jobhistory.EventType.class, mockHandler); dispatcher.register(JobFinishEvent.Type.class, mockHandler); return job; }
Example #9
Source File: MiniYARNCluster.java From big-c with Apache License 2.0 | 6 votes |
private synchronized void initResourceManager(int index, Configuration conf) { if (HAUtil.isHAEnabled(conf)) { conf.set(YarnConfiguration.RM_HA_ID, rmIds[index]); } resourceManagers[index].init(conf); resourceManagers[index].getRMContext().getDispatcher().register( RMAppAttemptEventType.class, new EventHandler<RMAppAttemptEvent>() { public void handle(RMAppAttemptEvent event) { if (event instanceof RMAppAttemptRegistrationEvent) { appMasters.put(event.getApplicationAttemptId(), event.getTimestamp()); } else if (event instanceof RMAppAttemptUnregistrationEvent) { appMasters.remove(event.getApplicationAttemptId()); } } }); }
Example #10
Source File: TestAMRMClientOnRMRestart.java From hadoop with Apache License 2.0 | 5 votes |
@Override protected EventHandler<SchedulerEvent> createSchedulerEventDispatcher() { // Dispatch inline for test sanity return new EventHandler<SchedulerEvent>() { @Override public void handle(SchedulerEvent event) { scheduler.handle(event); } }; }
Example #11
Source File: TestRecovery.java From big-c with Apache License 2.0 | 5 votes |
@Override protected EventHandler<JobHistoryEvent> createJobHistoryHandler( AppContext context) { JobHistoryEventHandler eventHandler = new JobHistoryEventHandler(context, getStartCount()); return eventHandler; }
Example #12
Source File: TestRecovery.java From hadoop with Apache License 2.0 | 5 votes |
private MapTaskImpl getMockMapTask(long clusterTimestamp, EventHandler eh) { ApplicationId appId = ApplicationId.newInstance(clusterTimestamp, 1); JobId jobId = MRBuilderUtils.newJobId(appId, 1); int partitions = 2; Path remoteJobConfFile = mock(Path.class); JobConf conf = new JobConf(); TaskAttemptListener taskAttemptListener = mock(TaskAttemptListener.class); Token<JobTokenIdentifier> jobToken = (Token<JobTokenIdentifier>) mock(Token.class); Credentials credentials = null; Clock clock = new SystemClock(); int appAttemptId = 3; MRAppMetrics metrics = mock(MRAppMetrics.class); Resource minContainerRequirements = mock(Resource.class); when(minContainerRequirements.getMemory()).thenReturn(1000); ClusterInfo clusterInfo = mock(ClusterInfo.class); AppContext appContext = mock(AppContext.class); when(appContext.getClusterInfo()).thenReturn(clusterInfo); TaskSplitMetaInfo taskSplitMetaInfo = mock(TaskSplitMetaInfo.class); MapTaskImpl mapTask = new MapTaskImpl(jobId, partitions, eh, remoteJobConfFile, conf, taskSplitMetaInfo, taskAttemptListener, jobToken, credentials, clock, appAttemptId, metrics, appContext); return mapTask; }
Example #13
Source File: TestVertexImpl.java From incubator-tez with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Override public void handle(TaskEvent event) { VertexImpl vertex = vertexIdMap.get(event.getTaskID().getVertexID()); Task task = vertex.getTask(event.getTaskID()); if (task != null) { ((EventHandler<TaskEvent>)task).handle(event); } else { LOG.warn("Task null for vertex: " + vertex.getName() + " taskId: " + event.getTaskID() + ". Please check if this is important for the test"); } }
Example #14
Source File: TestRecovery.java From big-c with Apache License 2.0 | 5 votes |
private MapTaskImpl getMockMapTask(long clusterTimestamp, EventHandler eh) { ApplicationId appId = ApplicationId.newInstance(clusterTimestamp, 1); JobId jobId = MRBuilderUtils.newJobId(appId, 1); int partitions = 2; Path remoteJobConfFile = mock(Path.class); JobConf conf = new JobConf(); TaskAttemptListener taskAttemptListener = mock(TaskAttemptListener.class); Token<JobTokenIdentifier> jobToken = (Token<JobTokenIdentifier>) mock(Token.class); Credentials credentials = null; Clock clock = new SystemClock(); int appAttemptId = 3; MRAppMetrics metrics = mock(MRAppMetrics.class); Resource minContainerRequirements = mock(Resource.class); when(minContainerRequirements.getMemory()).thenReturn(1000); ClusterInfo clusterInfo = mock(ClusterInfo.class); AppContext appContext = mock(AppContext.class); when(appContext.getClusterInfo()).thenReturn(clusterInfo); TaskSplitMetaInfo taskSplitMetaInfo = mock(TaskSplitMetaInfo.class); MapTaskImpl mapTask = new MapTaskImpl(jobId, partitions, eh, remoteJobConfFile, conf, taskSplitMetaInfo, taskAttemptListener, jobToken, credentials, clock, appAttemptId, metrics, appContext); return mapTask; }
Example #15
Source File: TaskAttemptImpl.java From tez with Apache License 2.0 | 5 votes |
@SuppressWarnings("rawtypes") public TaskAttemptImpl(TezTaskAttemptID attemptId, EventHandler eventHandler, TaskCommunicatorManagerInterface taskCommunicatorManagerInterface, Configuration conf, Clock clock, TaskHeartbeatHandler taskHeartbeatHandler, AppContext appContext, boolean isRescheduled, Resource resource, ContainerContext containerContext, boolean leafVertex, Task task, TaskLocationHint locationHint, TaskSpec taskSpec) { this(attemptId, eventHandler, taskCommunicatorManagerInterface, conf, clock, taskHeartbeatHandler, appContext, isRescheduled, resource, containerContext, leafVertex, task, locationHint, taskSpec, null); }
Example #16
Source File: TestVertexImpl.java From incubator-tez with Apache License 2.0 | 5 votes |
@Override protected RootInputInitializerManager createRootInputInitializerManager( String dagName, String vertexName, TezVertexID vertexID, EventHandler eventHandler, int numTasks, int numNodes, Resource taskResource, Resource totalResource) { try { rootInputInitializerManager = new RootInputInitializerManagerControlled(this, this.getAppContext(), eventHandler, dispatcher); } catch (IOException e) { throw new RuntimeException(e); } return rootInputInitializerManager; }
Example #17
Source File: TestTaskAttempt.java From hadoop with Apache License 2.0 | 5 votes |
@Test public void testHostResolveAttempt() throws Exception { TaskAttemptImpl.RequestContainerTransition rct = new TaskAttemptImpl.RequestContainerTransition(false); EventHandler eventHandler = mock(EventHandler.class); String[] hosts = new String[3]; hosts[0] = "192.168.1.1"; hosts[1] = "host2"; hosts[2] = "host3"; TaskSplitMetaInfo splitInfo = new TaskSplitMetaInfo(hosts, 0, 128 * 1024 * 1024l); TaskAttemptImpl mockTaskAttempt = createMapTaskAttemptImplForTest(eventHandler, splitInfo); TaskAttemptImpl spyTa = spy(mockTaskAttempt); when(spyTa.resolveHost(hosts[0])).thenReturn("host1"); spyTa.dataLocalHosts = spyTa.resolveHosts(splitInfo.getLocations()); TaskAttemptEvent mockTAEvent = mock(TaskAttemptEvent.class); rct.transition(spyTa, mockTAEvent); verify(spyTa).resolveHost(hosts[0]); ArgumentCaptor<Event> arg = ArgumentCaptor.forClass(Event.class); verify(eventHandler, times(2)).handle(arg.capture()); if (!(arg.getAllValues().get(1) instanceof ContainerRequestEvent)) { Assert.fail("Second Event not of type ContainerRequestEvent"); } Map<String, Boolean> expected = new HashMap<String, Boolean>(); expected.put("host1", true); expected.put("host2", true); expected.put("host3", true); ContainerRequestEvent cre = (ContainerRequestEvent) arg.getAllValues().get(1); String[] requestedHosts = cre.getHosts(); for (String h : requestedHosts) { expected.remove(h); } assertEquals(0, expected.size()); }
Example #18
Source File: TestMRAppMaster.java From hadoop with Apache License 2.0 | 5 votes |
@Override protected EventHandler<JobHistoryEvent> createJobHistoryHandler( AppContext context) { spyHistoryService = Mockito.spy((JobHistoryEventHandler) super .createJobHistoryHandler(context)); spyHistoryService.setForcejobCompletion(this.isLastAMRetry); return spyHistoryService; }
Example #19
Source File: ReduceTaskAttemptImpl.java From hadoop with Apache License 2.0 | 5 votes |
public ReduceTaskAttemptImpl(TaskId id, int attempt, EventHandler eventHandler, Path jobFile, int partition, int numMapTasks, JobConf conf, TaskAttemptListener taskAttemptListener, Token<JobTokenIdentifier> jobToken, Credentials credentials, Clock clock, AppContext appContext) { super(id, attempt, eventHandler, taskAttemptListener, jobFile, partition, conf, new String[] {}, jobToken, credentials, clock, appContext); this.numMapTasks = numMapTasks; }
Example #20
Source File: TestTaskAttempt.java From big-c with Apache License 2.0 | 5 votes |
protected EventHandler<JobHistoryEvent> createJobHistoryHandler( AppContext context) { return new EventHandler<JobHistoryEvent>() { @Override public void handle(JobHistoryEvent event) { if (event.getType() == org.apache.hadoop.mapreduce.jobhistory.EventType.MAP_ATTEMPT_FAILED) { TaskAttemptUnsuccessfulCompletion datum = (TaskAttemptUnsuccessfulCompletion) event .getHistoryEvent().getDatum(); Assert.assertEquals("Diagnostic Information is not Correct", "Test Diagnostic Event", datum.get(8).toString()); } } }; }
Example #21
Source File: TestProportionalCapacityPreemptionPolicy.java From big-c with Apache License 2.0 | 5 votes |
@Before @SuppressWarnings("unchecked") public void setup() { conf = new Configuration(false); conf.setLong(WAIT_TIME_BEFORE_KILL, 10000); conf.setLong(MONITORING_INTERVAL, 3000); // report "ideal" preempt conf.setFloat(TOTAL_PREEMPTION_PER_ROUND, (float) 1.0); conf.setFloat(NATURAL_TERMINATION_FACTOR, (float) 1.0); conf.set(YarnConfiguration.RM_SCHEDULER_MONITOR_POLICIES, ProportionalCapacityPreemptionPolicy.class.getCanonicalName()); conf.setBoolean(YarnConfiguration.RM_SCHEDULER_ENABLE_MONITORS, true); // FairScheduler doesn't support this test, // Set CapacityScheduler as the scheduler for this test. conf.set("yarn.resourcemanager.scheduler.class", CapacityScheduler.class.getName()); mClock = mock(Clock.class); mCS = mock(CapacityScheduler.class); when(mCS.getResourceCalculator()).thenReturn(rc); lm = mock(RMNodeLabelsManager.class); schedConf = new CapacitySchedulerConfiguration(); when(mCS.getConfiguration()).thenReturn(schedConf); rmContext = mock(RMContext.class); when(mCS.getRMContext()).thenReturn(rmContext); when(rmContext.getNodeLabelManager()).thenReturn(lm); mDisp = mock(EventHandler.class); rand = new Random(); long seed = rand.nextLong(); System.out.println(name.getMethodName() + " SEED: " + seed); rand.setSeed(seed); appAlloc = 0; }
Example #22
Source File: DAGAppMaster.java From tez with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Override public void handle(DAGEvent event) { DAG dag = context.getCurrentDAG(); int eventDagIndex = event.getDAGId().getId(); if (dag == null || eventDagIndex != dag.getID().getId()) { return; // event not relevant any more } ((EventHandler<DAGEvent>)dag).handle(event); }
Example #23
Source File: TestDAGImpl.java From incubator-tez with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Override public void handle(TaskEvent event) { TezDAGID id = event.getTaskID().getVertexID().getDAGId(); DAGImpl handler = id.equals(dagId) ? dag : (id.equals(mrrDagId) ? mrrDag : groupDag); Vertex vertex = handler.getVertex(event.getTaskID().getVertexID()); Task task = vertex.getTask(event.getTaskID()); ((EventHandler<TaskEvent>)task).handle(event); }
Example #24
Source File: TestJobImpl.java From big-c with Apache License 2.0 | 5 votes |
private boolean testUberDecision(Configuration conf) { JobID jobID = JobID.forName("job_1234567890000_0001"); JobId jobId = TypeConverter.toYarn(jobID); MRAppMetrics mrAppMetrics = MRAppMetrics.create(); JobImpl job = new JobImpl(jobId, ApplicationAttemptId.newInstance( ApplicationId.newInstance(0, 0), 0), conf, mock(EventHandler.class), null, new JobTokenSecretManager(), new Credentials(), null, null, mrAppMetrics, null, true, null, 0, null, null, null, null); InitTransition initTransition = getInitTransition(2); JobEvent mockJobEvent = mock(JobEvent.class); initTransition.transition(job, mockJobEvent); boolean isUber = job.isUber(); return isUber; }
Example #25
Source File: TestSpeculativeExecutionWithMRApp.java From big-c with Apache License 2.0 | 5 votes |
private static TaskAttempt[] makeFirstAttemptWin( EventHandler appEventHandler, Task speculatedTask) { // finish 1st TA, 2nd will be killed Collection<TaskAttempt> attempts = speculatedTask.getAttempts().values(); TaskAttempt[] ta = new TaskAttempt[attempts.size()]; attempts.toArray(ta); appEventHandler.handle( new TaskAttemptEvent(ta[0].getID(), TaskAttemptEventType.TA_DONE)); appEventHandler.handle(new TaskAttemptEvent(ta[0].getID(), TaskAttemptEventType.TA_CONTAINER_CLEANED)); return ta; }
Example #26
Source File: JobHistoryCopyService.java From hadoop with Apache License 2.0 | 5 votes |
public JobHistoryCopyService(ApplicationAttemptId applicationAttemptId, EventHandler handler) { super("JobHistoryCopyService"); this.applicationAttemptId = applicationAttemptId; this.jobId = TypeConverter.toYarn( TypeConverter.fromYarn(applicationAttemptId.getApplicationId())); this.handler = handler; }
Example #27
Source File: TestJobImpl.java From hadoop with Apache License 2.0 | 5 votes |
@Test public void testReportDiagnostics() throws Exception { JobID jobID = JobID.forName("job_1234567890000_0001"); JobId jobId = TypeConverter.toYarn(jobID); final String diagMsg = "some diagnostic message"; final JobDiagnosticsUpdateEvent diagUpdateEvent = new JobDiagnosticsUpdateEvent(jobId, diagMsg); MRAppMetrics mrAppMetrics = MRAppMetrics.create(); AppContext mockContext = mock(AppContext.class); when(mockContext.hasSuccessfullyUnregistered()).thenReturn(true); JobImpl job = new JobImpl(jobId, Records .newRecord(ApplicationAttemptId.class), new Configuration(), mock(EventHandler.class), null, mock(JobTokenSecretManager.class), null, new SystemClock(), null, mrAppMetrics, null, true, null, 0, null, mockContext, null, null); job.handle(diagUpdateEvent); String diagnostics = job.getReport().getDiagnostics(); Assert.assertNotNull(diagnostics); Assert.assertTrue(diagnostics.contains(diagMsg)); job = new JobImpl(jobId, Records .newRecord(ApplicationAttemptId.class), new Configuration(), mock(EventHandler.class), null, mock(JobTokenSecretManager.class), null, new SystemClock(), null, mrAppMetrics, null, true, null, 0, null, mockContext, null, null); job.handle(new JobEvent(jobId, JobEventType.JOB_KILL)); job.handle(diagUpdateEvent); diagnostics = job.getReport().getDiagnostics(); Assert.assertNotNull(diagnostics); Assert.assertTrue(diagnostics.contains(diagMsg)); }
Example #28
Source File: AsyncDispatcherConcurrent.java From tez with Apache License 2.0 | 5 votes |
protected void dispatch(Event event) { //all events go thru this loop if (LOG.isDebugEnabled()) { LOG.debug("Dispatching the event " + event.getClass().getName() + "." + event.toString()); } Class<? extends Enum> type = event.getType().getDeclaringClass(); try{ EventHandler handler = eventHandlers.get(type); if(handler != null) { handler.handle(event); } else { throw new Exception("No handler for registered for " + type); } } catch (Throwable t) { LOG.error("Error in dispatcher thread", t); // If serviceStop is called, we should exit this thread gracefully. if (exitOnDispatchException && (ShutdownHookManager.get().isShutdownInProgress()) == false && stopped == false) { Thread shutDownThread = new Thread(createShutDownThread()); shutDownThread.setName("AsyncDispatcher ShutDown handler"); shutDownThread.start(); } } }
Example #29
Source File: DAGAppMaster.java From incubator-tez with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Override public void handle(TaskAttemptEvent event) { DAG dag = context.getCurrentDAG(); int eventDagIndex = event.getTaskAttemptID().getTaskID().getVertexID().getDAGId().getId(); if (dag == null || eventDagIndex != dag.getID().getId()) { return; // event not relevant any more } Task task = dag.getVertex(event.getTaskAttemptID().getTaskID().getVertexID()). getTask(event.getTaskAttemptID().getTaskID()); TaskAttempt attempt = task.getAttempt(event.getTaskAttemptID()); ((EventHandler<TaskAttemptEvent>) attempt).handle(event); }
Example #30
Source File: TestRMContainerAllocator.java From big-c with Apache License 2.0 | 5 votes |
@Override protected EventHandler<SchedulerEvent> createSchedulerEventDispatcher() { // Dispatch inline for test sanity return new EventHandler<SchedulerEvent>() { @Override public void handle(SchedulerEvent event) { scheduler.handle(event); } }; }