4949import org .apache .hadoop .yarn .client .api .AMRMClient ;
5050import org .apache .hadoop .yarn .client .api .AMRMClient .ContainerRequest ;
5151import org .apache .hadoop .yarn .conf .YarnConfiguration ;
52- import org .apache .hadoop .yarn .event .Dispatcher ;
53- import org .apache .hadoop .yarn .event .DrainDispatcher ;
5452import org .apache .hadoop .yarn .event .EventHandler ;
5553import org .apache .hadoop .yarn .ipc .YarnRPC ;
5654import org .apache .hadoop .yarn .security .AMRMTokenIdentifier ;
@@ -126,22 +124,20 @@ public void testAMRMClientResendsRequestsOnRMRestart() throws Exception {
126124 // Phase-1 Start 1st RM
127125 MyResourceManager rm1 = new MyResourceManager (conf , memStore );
128126 rm1 .start ();
129- DrainDispatcher dispatcher =
130- (DrainDispatcher ) rm1 .getRMContext ().getDispatcher ();
131127
132128 // Submit the application
133129 RMApp app = rm1 .submitApp (1024 );
134- dispatcher . await ();
130+ rm1 . drainEvents ();
135131
136132 MockNM nm1 = new MockNM ("h1:1234" , 15120 , rm1 .getResourceTrackerService ());
137133 nm1 .registerNode ();
138134 nm1 .nodeHeartbeat (true ); // Node heartbeat
139- dispatcher . await ();
135+ rm1 . drainEvents ();
140136
141137 ApplicationAttemptId appAttemptId =
142138 app .getCurrentAppAttempt ().getAppAttemptId ();
143139 rm1 .sendAMLaunched (appAttemptId );
144- dispatcher . await ();
140+ rm1 . drainEvents ();
145141
146142 org .apache .hadoop .security .token .Token <AMRMTokenIdentifier > token =
147143 rm1 .getRMContext ().getRMApps ().get (appAttemptId .getApplicationId ())
@@ -176,7 +172,7 @@ public void testAMRMClientResendsRequestsOnRMRestart() throws Exception {
176172 blacklistAdditions .remove ("h2" );// remove from local list
177173
178174 AllocateResponse allocateResponse = amClient .allocate (0.1f );
179- dispatcher . await ();
175+ rm1 . drainEvents ();
180176 Assert .assertEquals ("No of assignments must be 0" , 0 , allocateResponse
181177 .getAllocatedContainers ().size ());
182178
@@ -189,10 +185,10 @@ public void testAMRMClientResendsRequestsOnRMRestart() throws Exception {
189185 // Step-2 : NM heart beat is sent.
190186 // On 2nd AM allocate request, RM allocates 3 containers to AM
191187 nm1 .nodeHeartbeat (true ); // Node heartbeat
192- dispatcher . await ();
188+ rm1 . drainEvents ();
193189
194190 allocateResponse = amClient .allocate (0.2f );
195- dispatcher . await ();
191+ rm1 . drainEvents ();
196192 // 3 containers are allocated i.e for cRequest1, cRequest2 and cRequest3.
197193 Assert .assertEquals ("No of assignments must be 0" , 3 , allocateResponse
198194 .getAllocatedContainers ().size ());
@@ -207,7 +203,7 @@ public void testAMRMClientResendsRequestsOnRMRestart() throws Exception {
207203 amClient .removeContainerRequest (cRequest3 );
208204
209205 allocateResponse = amClient .allocate (0.2f );
210- dispatcher . await ();
206+ rm1 . drainEvents ();
211207 Assert .assertEquals ("No of assignments must be 0" , 0 , allocateResponse
212208 .getAllocatedContainers ().size ());
213209 assertAsksAndReleases (4 , 0 , rm1 );
@@ -233,7 +229,7 @@ public void testAMRMClientResendsRequestsOnRMRestart() throws Exception {
233229 // request
234230 nm1 .nodeHeartbeat (containerId .getApplicationAttemptId (),
235231 containerId .getContainerId (), ContainerState .RUNNING );
236- dispatcher . await ();
232+ rm1 . drainEvents ();
237233 amClient .requestContainerUpdate (
238234 container , UpdateContainerRequest .newInstance (
239235 container .getVersion (), container .getId (),
@@ -242,7 +238,7 @@ public void testAMRMClientResendsRequestsOnRMRestart() throws Exception {
242238 it .remove ();
243239
244240 allocateResponse = amClient .allocate (0.3f );
245- dispatcher . await ();
241+ rm1 . drainEvents ();
246242 Assert .assertEquals ("No of assignments must be 0" , 0 , allocateResponse
247243 .getAllocatedContainers ().size ());
248244 assertAsksAndReleases (3 , pendingRelease , rm1 );
@@ -258,7 +254,6 @@ public void testAMRMClientResendsRequestsOnRMRestart() throws Exception {
258254 rm2 .start ();
259255 nm1 .setResourceTrackerService (rm2 .getResourceTrackerService ());
260256 ((MyAMRMClientImpl ) amClient ).updateRMProxy (rm2 );
261- dispatcher = (DrainDispatcher ) rm2 .getRMContext ().getDispatcher ();
262257
263258 // NM should be rebooted on heartbeat, even first heartbeat for nm2
264259 NodeHeartbeatResponse hbResponse = nm1 .nodeHeartbeat (true );
@@ -274,7 +269,7 @@ public void testAMRMClientResendsRequestsOnRMRestart() throws Exception {
274269 Collections .singletonList (
275270 containerId .getApplicationAttemptId ().getApplicationId ()));
276271 nm1 .nodeHeartbeat (true );
277- dispatcher . await ();
272+ rm2 . drainEvents ();
278273
279274 blacklistAdditions .add ("h3" );
280275 amClient .updateBlacklist (blacklistAdditions , null );
@@ -296,7 +291,7 @@ public void testAMRMClientResendsRequestsOnRMRestart() throws Exception {
296291 // containerRequest and blacklisted nodes.
297292 // Intern RM send resync command,AMRMClient resend allocate request
298293 allocateResponse = amClient .allocate (0.3f );
299- dispatcher . await ();
294+ rm2 . drainEvents ();
300295
301296 completedContainer =
302297 allocateResponse .getCompletedContainersStatuses ().size ();
@@ -313,7 +308,7 @@ public void testAMRMClientResendsRequestsOnRMRestart() throws Exception {
313308
314309 // Step-5 : Allocater after resync command
315310 allocateResponse = amClient .allocate (0.5f );
316- dispatcher . await ();
311+ rm2 . drainEvents ();
317312 Assert .assertEquals ("No of assignments must be 0" , 0 , allocateResponse
318313 .getAllocatedContainers ().size ());
319314
@@ -326,10 +321,10 @@ public void testAMRMClientResendsRequestsOnRMRestart() throws Exception {
326321 int count = 5 ;
327322 while (count -- > 0 ) {
328323 nm1 .nodeHeartbeat (true );
329- dispatcher . await ();
324+ rm2 . drainEvents ();
330325
331326 allocateResponse = amClient .allocate (0.5f );
332- dispatcher . await ();
327+ rm2 . drainEvents ();
333328 noAssignedContainer += allocateResponse .getAllocatedContainers ().size ();
334329 if (noAssignedContainer == 3 ) {
335330 break ;
@@ -358,22 +353,20 @@ public void testAMRMClientForUnregisterAMOnRMRestart() throws Exception {
358353 // Phase-1 Start 1st RM
359354 MyResourceManager rm1 = new MyResourceManager (conf , memStore );
360355 rm1 .start ();
361- DrainDispatcher dispatcher =
362- (DrainDispatcher ) rm1 .getRMContext ().getDispatcher ();
363356
364357 // Submit the application
365358 RMApp app = rm1 .submitApp (1024 );
366- dispatcher . await ();
359+ rm1 . drainEvents ();
367360
368361 MockNM nm1 = new MockNM ("h1:1234" , 15120 , rm1 .getResourceTrackerService ());
369362 nm1 .registerNode ();
370363 nm1 .nodeHeartbeat (true ); // Node heartbeat
371- dispatcher . await ();
364+ rm1 . drainEvents ();
372365
373366 ApplicationAttemptId appAttemptId =
374367 app .getCurrentAppAttempt ().getAppAttemptId ();
375368 rm1 .sendAMLaunched (appAttemptId );
376- dispatcher . await ();
369+ rm1 . drainEvents ();
377370
378371 org .apache .hadoop .security .token .Token <AMRMTokenIdentifier > token =
379372 rm1 .getRMContext ().getRMApps ().get (appAttemptId .getApplicationId ())
@@ -393,7 +386,6 @@ public void testAMRMClientForUnregisterAMOnRMRestart() throws Exception {
393386 rm2 .start ();
394387 nm1 .setResourceTrackerService (rm2 .getResourceTrackerService ());
395388 ((MyAMRMClientImpl ) amClient ).updateRMProxy (rm2 );
396- dispatcher = (DrainDispatcher ) rm2 .getRMContext ().getDispatcher ();
397389
398390 // NM should be rebooted on heartbeat, even first heartbeat for nm2
399391 NodeHeartbeatResponse hbResponse = nm1 .nodeHeartbeat (true );
@@ -409,7 +401,7 @@ public void testAMRMClientForUnregisterAMOnRMRestart() throws Exception {
409401 Priority .newInstance (0 ), 0 );
410402 nm1 .registerNode (Arrays .asList (containerReport ), null );
411403 nm1 .nodeHeartbeat (true );
412- dispatcher . await ();
404+ rm2 . drainEvents ();
413405
414406 amClient .unregisterApplicationMaster (FinalApplicationStatus .SUCCEEDED ,
415407 null , null );
@@ -421,7 +413,6 @@ public void testAMRMClientForUnregisterAMOnRMRestart() throws Exception {
421413 amClient .stop ();
422414 rm1 .stop ();
423415 rm2 .stop ();
424-
425416 }
426417
427418
@@ -439,22 +430,20 @@ public void testAMRMClientOnAMRMTokenRollOverOnRMRestart() throws Exception {
439430 // start first RM
440431 MyResourceManager2 rm1 = new MyResourceManager2 (conf , memStore );
441432 rm1 .start ();
442- DrainDispatcher dispatcher =
443- (DrainDispatcher ) rm1 .getRMContext ().getDispatcher ();
444433 Long startTime = System .currentTimeMillis ();
445434 // Submit the application
446435 RMApp app = rm1 .submitApp (1024 );
447- dispatcher . await ();
436+ rm1 . drainEvents ();
448437
449438 MockNM nm1 = new MockNM ("h1:1234" , 15120 , rm1 .getResourceTrackerService ());
450439 nm1 .registerNode ();
451440 nm1 .nodeHeartbeat (true ); // Node heartbeat
452- dispatcher . await ();
441+ rm1 . drainEvents ();
453442
454443 ApplicationAttemptId appAttemptId =
455444 app .getCurrentAppAttempt ().getAppAttemptId ();
456445 rm1 .sendAMLaunched (appAttemptId );
457- dispatcher . await ();
446+ rm1 . drainEvents ();
458447
459448 AMRMTokenSecretManager amrmTokenSecretManagerForRM1 =
460449 rm1 .getRMContext ().getAMRMTokenSecretManager ();
@@ -513,7 +502,6 @@ public void testAMRMClientOnAMRMTokenRollOverOnRMRestart() throws Exception {
513502 rm2 .start ();
514503 nm1 .setResourceTrackerService (rm2 .getResourceTrackerService ());
515504 ((MyAMRMClientImpl ) amClient ).updateRMProxy (rm2 );
516- dispatcher = (DrainDispatcher ) rm2 .getRMContext ().getDispatcher ();
517505
518506 AMRMTokenSecretManager amrmTokenSecretManagerForRM2 =
519507 rm2 .getRMContext ().getAMRMTokenSecretManager ();
@@ -615,11 +603,6 @@ public void serviceStart() throws Exception {
615603 MyResourceManager .setClusterTimeStamp (fakeClusterTimeStamp );
616604 }
617605
618- @ Override
619- protected Dispatcher createDispatcher () {
620- return new DrainDispatcher ();
621- }
622-
623606 @ Override
624607 protected EventHandler <SchedulerEvent > createSchedulerEventDispatcher () {
625608 // Dispatch inline for test sanity
0 commit comments