@Override protected void initDispatcher(Configuration conf) { super.dispatcher = new InlineDispatcher(); }
@Override public void handle(Event event) { dispatch(event); } }
private MockTaskImpl createMockTask(TaskType taskType) { return new MockTaskImpl(jobId, partition, dispatcher.getEventHandler(), remoteJobConfFile, conf, taskAttemptListener, jobToken, credentials, clock, startCount, metrics, appContext, taskType); }
InlineDispatcher rmDispatcher = new InlineDispatcher(); applicationMasterLauncher = mock(ApplicationMasterLauncher.class); rmDispatcher.register(RMAppAttemptEventType.class, new TestApplicationAttemptEventDispatcher()); rmDispatcher.register(RMAppEventType.class, new TestApplicationEventDispatcher()); rmDispatcher.register(SchedulerEventType.class, new TestSchedulerEventDispatcher()); rmDispatcher.register(AMLauncherEventType.class, new TestAMLauncherEventDispatcher()); rmDispatcher.register(RMNodeEventType.class, rmnodeEventHandler); rmDispatcher.init(conf); rmDispatcher.start();
@Test public void testAbortJobCalledAfterKillingTasks() throws IOException { Configuration conf = new Configuration(); conf.set(MRJobConfig.MR_AM_STAGING_DIR, stagingDir); conf.set(MRJobConfig.MR_AM_COMMITTER_CANCEL_TIMEOUT_MS, "1000"); InlineDispatcher dispatcher = new InlineDispatcher(); dispatcher.init(conf); dispatcher.start(); OutputCommitter committer = Mockito.mock(OutputCommitter.class); CommitterEventHandler commitHandler = createCommitterEventHandler(dispatcher, committer); commitHandler.init(conf); commitHandler.start(); JobImpl job = createRunningStubbedJob(conf, dispatcher, 2, null); //Fail one task. This should land the JobImpl in the FAIL_WAIT state job.handle(new JobTaskEvent( MRBuilderUtils.newTaskId(job.getID(), 1, TaskType.MAP), TaskState.FAILED)); //Verify abort job hasn't been called Mockito.verify(committer, Mockito.never()) .abortJob((JobContext) Mockito.any(), (State) Mockito.any()); assertJobState(job, JobStateInternal.FAIL_WAIT); //Verify abortJob is called once and the job failed Mockito.verify(committer, Mockito.timeout(2000).times(1)) .abortJob((JobContext) Mockito.any(), (State) Mockito.any()); assertJobState(job, JobStateInternal.FAILED); dispatcher.stop(); }
@Before @SuppressWarnings("unchecked") public void setup() { dispatcher = new InlineDispatcher(); ++startCount; conf = new JobConf(); taskAttemptListener = mock(TaskAttemptListener.class); jobToken = (Token<JobTokenIdentifier>) mock(Token.class); remoteJobConfFile = mock(Path.class); credentials = null; clock = SystemClock.getInstance(); metrics = mock(MRAppMetrics.class); dataLocations = new String[1]; appId = ApplicationId.newInstance(System.currentTimeMillis(), 1); jobId = Records.newRecord(JobId.class); jobId.setId(1); jobId.setAppId(appId); appContext = mock(AppContext.class); taskSplitMetaInfo = mock(TaskSplitMetaInfo.class); when(taskSplitMetaInfo.getLocations()).thenReturn(dataLocations); taskAttempts = new ArrayList<MockTaskAttemptImpl>(); taskAttemptEventHandler = new MockTaskAttemptEventHandler(); dispatcher.register(TaskAttemptEventType.class, taskAttemptEventHandler); }
InlineDispatcher rmDispatcher = new InlineDispatcher(); applicationMasterLauncher = mock(ApplicationMasterLauncher.class); rmDispatcher.register(RMAppAttemptEventType.class, new TestApplicationAttemptEventDispatcher()); rmDispatcher.register(RMAppEventType.class, new TestApplicationEventDispatcher()); rmDispatcher.register(SchedulerEventType.class, new TestSchedulerEventDispatcher()); rmDispatcher.register(AMLauncherEventType.class, new TestAMLauncherEventDispatcher()); rmDispatcher.register(RMNodeEventType.class, rmnodeEventHandler); rmDispatcher.init(conf); rmDispatcher.start();
@Before public void setUp() throws Exception { InlineDispatcher rmDispatcher = new InlineDispatcher(); rmDispatcher.register(SchedulerEventType.class, new TestSchedulerEventDispatcher()); rmDispatcher.register(NodesListManagerEventType.class, new TestNodeListManagerEventDispatcher());
@Override protected void initDispatcher(Configuration conf) { super.dispatcher = new InlineDispatcher(); }
@Before public void setUp() throws Exception { InlineDispatcher rmDispatcher = new InlineDispatcher(); rmContext = new RMContextImpl(rmDispatcher, null, null, null, null, null, null, null, null); rmContext.setSystemMetricsPublisher(mock(SystemMetricsPublisher.class)); rmContext.setRMApplicationHistoryWriter(mock(RMApplicationHistoryWriter.class)); rmContext .setRMTimelineCollectorManager(mock(RMTimelineCollectorManager.class)); scheduler = mock(YarnScheduler.class); doAnswer( new Answer<Void>() { @Override public Void answer(InvocationOnMock invocation) throws Throwable { final SchedulerEvent event = (SchedulerEvent)(invocation.getArguments()[0]); eventType = event.getType(); if (eventType == SchedulerEventType.NODE_UPDATE) { //DO NOTHING } return null; } } ).when(scheduler).handle(any(SchedulerEvent.class)); rmDispatcher.register(SchedulerEventType.class, new TestSchedulerEventDispatcher()); appId = ApplicationId.newInstance(System.currentTimeMillis(), 1); }
@Override public void handle(Event event) { dispatch(event); } }
@Test public void testFailedTransitions() { mockTask = new MockTaskImpl(jobId, partition, dispatcher.getEventHandler(), remoteJobConfFile, conf, taskAttemptListener, jobToken, credentials, clock, startCount, metrics, appContext, TaskType.MAP) {
@Override protected void initDispatcher(Configuration conf) { super.dispatcher = new InlineDispatcher(); }
@Before public void setUp() throws Exception { InlineDispatcher rmDispatcher = new InlineDispatcher(); rmDispatcher.register(SchedulerEventType.class, new TestSchedulerEventDispatcher()); rmDispatcher.register(NodesListManagerEventType.class, new TestNodeListManagerEventDispatcher());
@Override public void handle(Event event) { dispatch(event); } }
@Test public void testCountersWithSpeculation() { mockTask = new MockTaskImpl(jobId, partition, dispatcher.getEventHandler(), remoteJobConfFile, conf, taskAttemptListener, jobToken, credentials, clock, startCount, metrics, appContext, TaskType.MAP) {
@Override protected void initDispatcher(Configuration conf) { super.dispatcher = new InlineDispatcher(); }
@Override protected void initDispatcher(Configuration conf) { super.dispatcher = new InlineDispatcher(); }
@Override protected void initDispatcher(Configuration conf) { super.dispatcher = new InlineDispatcher(); }
@Override protected void initDispatcher(Configuration conf) { super.dispatcher = new InlineDispatcher(); }