private static RMApp createRMApp(ApplicationId appId) { RMApp app = mock(RMApp.class); when(app.getApplicationId()).thenReturn(appId); when(app.getName()).thenReturn("test app"); when(app.getApplicationType()).thenReturn("test app type"); when(app.getUser()).thenReturn("test user"); when(app.getQueue()).thenReturn("test queue"); when(app.getSubmitTime()).thenReturn(0L); when(app.getStartTime()).thenReturn(1L); when(app.getFinishTime()).thenReturn(2L); when(app.getDiagnostics()).thenReturn( new StringBuilder("test diagnostics info")); when(app.getFinalApplicationStatus()).thenReturn( FinalApplicationStatus.UNDEFINED); return app; }
private static RMApp createMockAppForRemove(ApplicationId appId, ApplicationAttemptId... attemptIds) { RMApp app = mock(RMApp.class); ApplicationSubmissionContextPBImpl context = new ApplicationSubmissionContextPBImpl(); context.setApplicationId(appId); when(app.getApplicationSubmissionContext()).thenReturn(context); when(app.getUser()).thenReturn("test"); if (attemptIds.length > 0) { HashMap<ApplicationAttemptId, RMAppAttempt> attempts = new HashMap<>(); for (ApplicationAttemptId attemptId : attemptIds) { RMAppAttempt appAttempt = mock(RMAppAttempt.class); when(appAttempt.getAppAttemptId()).thenReturn(attemptId); attempts.put(attemptId, appAttempt); } when(app.getAppAttempts()).thenReturn(attempts); } return app; }
private static RMApp createRMApp(ApplicationId appId) { RMApp app = mock(RMApp.class); when(app.getApplicationId()).thenReturn(appId); when(app.getName()).thenReturn("test app"); when(app.getApplicationType()).thenReturn("test app type"); when(app.getUser()).thenReturn("test user"); when(app.getQueue()).thenReturn("test queue"); when(app.getSubmitTime()).thenReturn(0L); when(app.getStartTime()).thenReturn(1L); when(app.getFinishTime()).thenReturn(2L); when(app.getDiagnostics()).thenReturn( new StringBuilder("test diagnostics info")); when(app.getFinalApplicationStatus()).thenReturn( FinalApplicationStatus.UNDEFINED); return app; }
private String getTimelineEntityDir() { String outputDirApp = testRootDir.getAbsolutePath() + "/" + FileSystemTimelineWriterImpl.ENTITIES_DIR + "/" + YarnConfiguration.DEFAULT_RM_CLUSTER_ID + "/" + app.getUser() + "/" + app.getName() + "/" + TimelineUtils.DEFAULT_FLOW_VERSION + "/" + app.getStartTime() + "/" + app.getApplicationId(); return outputDirApp; }
protected RMApp storeApp(RMStateStore store, ApplicationId appId, long submitTime, long startTime) throws Exception { ApplicationSubmissionContext context = new ApplicationSubmissionContextPBImpl(); context.setApplicationId(appId); RMApp mockApp = mock(RMApp.class); when(mockApp.getApplicationId()).thenReturn(appId); when(mockApp.getSubmitTime()).thenReturn(submitTime); when(mockApp.getStartTime()).thenReturn(startTime); when(mockApp.getApplicationSubmissionContext()).thenReturn(context); when(mockApp.getUser()).thenReturn("test"); store.storeNewApplication(mockApp); return mockApp; }
private String getTimelineEntityDir(RMApp app) { String outputDirApp = testRootDir.getAbsolutePath() + "/" + FileSystemTimelineWriterImpl.ENTITIES_DIR + "/" + YarnConfiguration.DEFAULT_RM_CLUSTER_ID + "/" + app.getUser() + "/" + app.getName() + "/" + TimelineUtils.DEFAULT_FLOW_VERSION + "/" + app.getStartTime() + "/" + app.getApplicationId(); return outputDirApp; }
/** * Non-blocking API * ResourceManager services call this to remove an application from the state * store * This does not block the dispatcher threads * There is no notification of completion for this operation. */ @SuppressWarnings("unchecked") public void removeApplication(RMApp app) { ApplicationStateData appState = ApplicationStateData.newInstance( app.getSubmitTime(), app.getStartTime(), app.getApplicationSubmissionContext(), app.getUser()); for(RMAppAttempt appAttempt : app.getAppAttempts().values()) { appState.attempts.put(appAttempt.getAppAttemptId(), null); } dispatcher.getEventHandler().handle(new RMStateStoreRemoveAppEvent(appState)); }
/** * Non-blocking API * ResourceManager services call this to remove an application from the state * store * This does not block the dispatcher threads * There is no notification of completion for this operation. */ @SuppressWarnings("unchecked") public void removeApplication(RMApp app) { ApplicationStateData appState = ApplicationStateData.newInstance( app.getSubmitTime(), app.getStartTime(), app.getApplicationSubmissionContext(), app.getUser()); for(RMAppAttempt appAttempt : app.getAppAttempts().values()) { appState.attempts.put(appAttempt.getAppAttemptId(), null); } dispatcher.getEventHandler().handle(new RMStateStoreRemoveAppEvent(appState)); }
protected Boolean hasAccess(RMApp app, HttpServletRequest hsr) { // Check for the authorization. UserGroupInformation callerUGI = getCallerUserGroupInformation(hsr, true); if (callerUGI != null && !(this.rm.getApplicationACLsManager().checkAccess(callerUGI, ApplicationAccessType.VIEW_APP, app.getUser(), app.getApplicationId()) || this.rm.getQueueACLsManager().checkAccess(callerUGI, QueueACL.ADMINISTER_QUEUE, app.getQueue()))) { return false; } return true; }
protected Boolean hasAccess(RMApp app, HttpServletRequest hsr) { // Check for the authorization. UserGroupInformation callerUGI = getCallerUserGroupInformation(hsr, true); if (callerUGI != null && !(this.rm.getApplicationACLsManager().checkAccess(callerUGI, ApplicationAccessType.VIEW_APP, app.getUser(), app.getApplicationId()) || this.rm.getQueueACLsManager().checkAccess(callerUGI, QueueACL.ADMINISTER_QUEUE, app.getQueue()))) { return false; } return true; }
/** * Non-Blocking API * ResourceManager services use this to store the application's state * This does not block the dispatcher threads * RMAppStoredEvent will be sent on completion to notify the RMApp */ @SuppressWarnings("unchecked") public void storeNewApplication(RMApp app) { ApplicationSubmissionContext context = app .getApplicationSubmissionContext(); assert context instanceof ApplicationSubmissionContextPBImpl; ApplicationStateData appState = ApplicationStateData.newInstance( app.getSubmitTime(), app.getStartTime(), context, app.getUser()); dispatcher.getEventHandler().handle(new RMStateStoreAppEvent(appState)); }
/** * Non-Blocking API * ResourceManager services use this to store the application's state * This does not block the dispatcher threads * RMAppStoredEvent will be sent on completion to notify the RMApp */ @SuppressWarnings("unchecked") public void storeNewApplication(RMApp app) { ApplicationSubmissionContext context = app .getApplicationSubmissionContext(); assert context instanceof ApplicationSubmissionContextPBImpl; ApplicationStateData appState = ApplicationStateData.newInstance( app.getSubmitTime(), app.getStartTime(), context, app.getUser()); dispatcher.getEventHandler().handle(new RMStateStoreAppEvent(appState)); }
@SuppressWarnings("unchecked") public void appCreated(RMApp app, long createdTime) { if (publishSystemMetrics) { dispatcher.getEventHandler().handle( new ApplicationCreatedEvent( app.getApplicationId(), app.getName(), app.getApplicationType(), app.getUser(), app.getQueue(), app.getSubmitTime(), createdTime)); } }
@SuppressWarnings("unchecked") public void appCreated(RMApp app, long createdTime) { if (publishSystemMetrics) { dispatcher.getEventHandler().handle( new ApplicationCreatedEvent( app.getApplicationId(), app.getName(), app.getApplicationType(), app.getUser(), app.getQueue(), app.getSubmitTime(), createdTime)); } }
@SuppressWarnings("unchecked") public void applicationStarted(RMApp app) { if (historyServiceEnabled) { dispatcher.getEventHandler().handle( new WritingApplicationStartEvent(app.getApplicationId(), ApplicationStartData.newInstance(app.getApplicationId(), app.getName(), app.getApplicationType(), app.getQueue(), app.getUser(), app.getSubmitTime(), app.getStartTime()))); } }
public void createRMStateForApplications( Map<ApplicationId, ApplicationStateData> applicationState, RMAppState rmAppState) { RMApp app = createNewTestApp(null); ApplicationStateData appState = ApplicationStateData.newInstance(app.getSubmitTime(), app.getStartTime(), app.getUser(), app.getApplicationSubmissionContext(), rmAppState, null, app.getFinishTime()); applicationState.put(app.getApplicationId(), appState); }
@SuppressWarnings("unchecked") public void applicationStarted(RMApp app) { if (historyServiceEnabled) { dispatcher.getEventHandler().handle( new WritingApplicationStartEvent(app.getApplicationId(), ApplicationStartData.newInstance(app.getApplicationId(), app.getName(), app.getApplicationType(), app.getQueue(), app.getUser(), app.getSubmitTime(), app.getStartTime()))); } }
@SuppressWarnings("unchecked") public void applicationStarted(RMApp app) { if (historyServiceEnabled) { dispatcher.getEventHandler().handle( new WritingApplicationStartEvent(app.getApplicationId(), ApplicationStartData.newInstance(app.getApplicationId(), app.getName(), app.getApplicationType(), app.getQueue(), app.getUser(), app.getSubmitTime(), app.getStartTime()))); } }
/** * Non-Blocking API * ResourceManager services use this to store the application's state * This does not block the dispatcher threads * RMAppStoredEvent will be sent on completion to notify the RMApp */ @SuppressWarnings("unchecked") public void storeNewApplication(RMApp app) { ApplicationSubmissionContext context = app .getApplicationSubmissionContext(); assert context instanceof ApplicationSubmissionContextPBImpl; ApplicationStateData appState = ApplicationStateData.newInstance(app.getSubmitTime(), app.getStartTime(), context, app.getUser(), app.getCallerContext()); appState.setApplicationTimeouts(app.getApplicationTimeouts()); getRMStateStoreEventHandler().handle(new RMStateStoreAppEvent(appState)); }
public void createRMStateForApplications( Map<ApplicationId, ApplicationStateData> applicationState, RMAppState rmAppState) throws IOException { RMApp app = createNewTestApp(null); ApplicationStateData appState = ApplicationStateData.newInstance(app.getSubmitTime(), app.getStartTime(), app.getUser(), app.getApplicationSubmissionContext(), rmAppState, null, app.getLaunchTime(), app.getFinishTime(), null); applicationState.put(app.getApplicationId(), appState); }