@Test public void testLaunchApplicationAlreadyCreated() throws Exception { when(authenticatedContextMock.getCloudContext()).thenReturn(new CloudContext(1L, "name", "platform", null, null, null, USER_NAME, WORKSPACE_ID)); when(yarnClientUtilMock.createYarnClient(authenticatedContextMock)).thenReturn(yarnClientMock); ArgumentCaptor<ApplicationDetailRequest> requestCaptor = ArgumentCaptor.forClass(ApplicationDetailRequest.class); when(yarnClientMock.getApplicationDetail(requestCaptor.capture())) .thenReturn(createResponseContext(YarnResourceConstants.HTTP_SUCCESS)); when(applicationNameUtilMock.decorateName("name-1", "horton")).thenReturn("n-1-hort"); List<CloudResourceStatus> cloudResourceStatusList = underTest.launch(authenticatedContextMock, stackMock, persistenceNotifierMock, AdjustmentType.EXACT, Long.MAX_VALUE); ApplicationDetailRequest capturedRequest = requestCaptor.getValue(); String expectedAppName = "n-1-hort"; assertEquals(expectedAppName, capturedRequest.getName()); assertCloudResourceStatusList(cloudResourceStatusList, "n-1-hort"); }
@Override public List<CloudResourceStatus> launch(AuthenticatedContext authenticatedContext, CloudStack stack, PersistenceNotifier persistenceNotifier, AdjustmentType adjustmentType, Long threshold) throws Exception { YarnClient yarnClient = yarnClientUtil.createYarnClient(authenticatedContext); String applicationName = createApplicationName(authenticatedContext); if (!checkApplicationAlreadyCreated(yarnClient, applicationName)) { CreateApplicationRequest createApplicationRequest = createRequest(stack, applicationName); createApplication(yarnClient, createApplicationRequest); } CloudResource yarnApplication = new Builder().type(YARN_APPLICATION).name(applicationName).build(); persistenceNotifier.notifyAllocation(yarnApplication, authenticatedContext.getCloudContext()); return check(authenticatedContext, Collections.singletonList(yarnApplication)); }
YarnResourceConnector implements ResourceConnector<Object> { @Override public List<CloudResourceStatus> launch(AuthenticatedContext authenticatedContext, CloudStack stack, PersistenceNotifier persistenceNotifier, AdjustmentType adjustmentType, Long threshold) throws Exception { YarnClient yarnClient = yarnClientUtil.createYarnClient(authenticatedContext); String applicationName = createApplicationName(authenticatedContext); if (!checkApplicationAlreadyCreated(yarnClient, applicationName)) { CreateApplicationRequest createApplicationRequest = createRequest(stack, applicationName); createApplication(yarnClient, createApplicationRequest); } CloudResource yarnApplication = new Builder().type(YARN_APPLICATION).name(applicationName).build(); persistenceNotifier.notifyAllocation(yarnApplication, authenticatedContext.getCloudContext()); return check(authenticatedContext, Collections.singletonList(yarnApplication)); } }
YarnResourceConnector implements ResourceConnector<Object> { @Override public List<CloudResourceStatus> launch(AuthenticatedContext authenticatedContext, CloudStack stack, PersistenceNotifier persistenceNotifier, AdjustmentType adjustmentType, Long threshold) throws Exception { YarnClient yarnClient = yarnClientUtil.createYarnClient(authenticatedContext); String applicationName = createApplicationName(authenticatedContext); if (!checkApplicationAlreadyCreated(yarnClient, applicationName)) { CreateApplicationRequest createApplicationRequest = createRequest(stack, applicationName); createApplication(yarnClient, createApplicationRequest); } CloudResource yarnApplication = new Builder().type(YARN_APPLICATION).name(applicationName).build(); persistenceNotifier.notifyAllocation(yarnApplication, authenticatedContext.getCloudContext()); return check(authenticatedContext, Collections.singletonList(yarnApplication)); }  }
YarnResourceConnector implements ResourceConnector<Object> { @Override public List<CloudResourceStatus> launch(AuthenticatedContext authenticatedContext, CloudStack stack, PersistenceNotifier persistenceNotifier, AdjustmentType adjustmentType, Long threshold) throws Exception { YarnClient yarnClient = yarnClientUtil.createYarnClient(authenticatedContext); String applicationName = createApplicationName(authenticatedContext); if (!checkApplicationAlreadyCreated(yarnClient, applicationName)) { CreateApplicationRequest createApplicationRequest = createRequest(stack, applicationName); createApplication(yarnClient, createApplicationRequest); } CloudResource yarnApplication = new Builder().type(YARN_APPLICATION).name(applicationName).build(); persistenceNotifier.notifyAllocation(yarnApplication, authenticatedContext.getCloudContext()); return check(authenticatedContext, Collections.singletonList(yarnApplication)); }  @Override List<CloudResourceStatus> launch(AuthenticatedContext authenticatedContext, CloudStack stack, PersistenceNotifier persistenceNotifier,
            AdjustmentType adjustmentType, Long threshold); @Override List<CloudResourceStatus> launchDatabaseServer(AuthenticatedContext authenticatedContext, DatabaseStack stack,
            PersistenceNotifier persistenceNotifier); @Override List<CloudResourceStatus> check(AuthenticatedContext authenticatedContext, List<CloudResource> resources); @Override List<CloudResourceStatus> terminate(AuthenticatedContext authenticatedContext, CloudStack stack, List<CloudResource> cloudResources); @Override List<CloudResourceStatus> terminateDatabaseServer(AuthenticatedContext authenticatedContext, DatabaseStack stack,
            List<CloudResource> resources, PersistenceNotifier persistenceNotifier, boolean force); @Override void startDatabaseServer(AuthenticatedContext authenticatedContext, DatabaseStack stack); @Override void stopDatabaseServer(AuthenticatedContext authenticatedContext, DatabaseStack stack); @Override ExternalDatabaseStatus getDatabaseServerStatus(AuthenticatedContext authenticatedContext, DatabaseStack stack); @Override List<CloudResourceStatus> update(AuthenticatedContext authenticatedContext, CloudStack stack, List<CloudResource> resources); @Override List<CloudResourceStatus> upscale(AuthenticatedContext authenticatedContext, CloudStack stack, List<CloudResource> resources); @Override List<CloudResourceStatus> downscale(AuthenticatedContext authenticatedContext, CloudStack stack, List<CloudResource> resources,
            List<CloudInstance> vms, Object resourcesToRemove); @Override Object collectResourcesToRemove(AuthenticatedContext authenticatedContext, CloudStack stack, List<CloudResource> resources, List<CloudInstance> vms); @Override TlsInfo getTlsInfo(AuthenticatedContext authenticatedContext, CloudStack cloudStack); @Override String getStackTemplate(); @Override String getDBStackTemplate(); }
YarnResourceConnector implements ResourceConnector<Object> { @Override public List<CloudResourceStatus> launch(AuthenticatedContext authenticatedContext, CloudStack stack, PersistenceNotifier persistenceNotifier, AdjustmentType adjustmentType, Long threshold) throws Exception { YarnClient yarnClient = yarnClientUtil.createYarnClient(authenticatedContext); String applicationName = createApplicationName(authenticatedContext); if (!checkApplicationAlreadyCreated(yarnClient, applicationName)) { CreateApplicationRequest createApplicationRequest = createRequest(stack, applicationName); createApplication(yarnClient, createApplicationRequest); } CloudResource yarnApplication = new Builder().type(YARN_APPLICATION).name(applicationName).build(); persistenceNotifier.notifyAllocation(yarnApplication, authenticatedContext.getCloudContext()); return check(authenticatedContext, Collections.singletonList(yarnApplication)); }  @Override List<CloudResourceStatus> launch(AuthenticatedContext authenticatedContext, CloudStack stack, PersistenceNotifier persistenceNotifier,
            AdjustmentType adjustmentType, Long threshold); @Override List<CloudResourceStatus> launchDatabaseServer(AuthenticatedContext authenticatedContext, DatabaseStack stack,
            PersistenceNotifier persistenceNotifier); @Override List<CloudResourceStatus> check(AuthenticatedContext authenticatedContext, List<CloudResource> resources); @Override List<CloudResourceStatus> terminate(AuthenticatedContext authenticatedContext, CloudStack stack, List<CloudResource> cloudResources); @Override List<CloudResourceStatus> terminateDatabaseServer(AuthenticatedContext authenticatedContext, DatabaseStack stack,
            List<CloudResource> resources, PersistenceNotifier persistenceNotifier, boolean force); @Override void startDatabaseServer(AuthenticatedContext authenticatedContext, DatabaseStack stack); @Override void stopDatabaseServer(AuthenticatedContext authenticatedContext, DatabaseStack stack); @Override ExternalDatabaseStatus getDatabaseServerStatus(AuthenticatedContext authenticatedContext, DatabaseStack stack); @Override List<CloudResourceStatus> update(AuthenticatedContext authenticatedContext, CloudStack stack, List<CloudResource> resources); @Override List<CloudResourceStatus> upscale(AuthenticatedContext authenticatedContext, CloudStack stack, List<CloudResource> resources); @Override List<CloudResourceStatus> downscale(AuthenticatedContext authenticatedContext, CloudStack stack, List<CloudResource> resources,
            List<CloudInstance> vms, Object resourcesToRemove); @Override Object collectResourcesToRemove(AuthenticatedContext authenticatedContext, CloudStack stack, List<CloudResource> resources, List<CloudInstance> vms); @Override TlsInfo getTlsInfo(AuthenticatedContext authenticatedContext, CloudStack cloudStack); @Override String getStackTemplate(); @Override String getDBStackTemplate();  }