@Test public void testChangeState_deployRoot_success() throws Exception { TestTargetResolver iaasResolver = new TestTargetResolver(); this.manager.setTargetResolver( iaasResolver ); String targetId = this.manager.targetsMngr().createTarget( "id: tid\nhandler: test" ); this.manager.targetsMngr().associateTargetWith( targetId, this.app, null ); Assert.assertEquals( 0, iaasResolver.instancePathToRunningStatus.size()); this.client.getApplicationDelegate().changeInstanceState( this.app.getName(), InstanceStatus.DEPLOYED_STARTED, InstanceHelpers.computeInstancePath( this.app.getMySqlVm())); String path = InstanceHelpers.computeInstancePath( this.app.getMySqlVm()); Assert.assertEquals( 1, iaasResolver.instancePathToRunningStatus.size()); Assert.assertTrue( iaasResolver.instancePathToRunningStatus.get( path )); }
public void changeInstanceState( String applicationName, InstanceStatus newStatus, String instancePath ) throws ApplicationWsException { this.logger.finer( "Changing state of " + instancePath + " to '" + newStatus + "' in " + applicationName + "." ); WebResource path = this.resource.path( UrlConstants.APP ).path( applicationName ).path( "change-state" ); if( instancePath != null ) path = path.queryParam( "instance-path", instancePath ); if( newStatus != null ) path = path.queryParam( "new-state", newStatus.toString()); ClientResponse response = this.wsClient.createBuilder( path ) .accept( MediaType.APPLICATION_JSON ) .post( ClientResponse.class ); handleResponse( response ); this.logger.finer( String.valueOf( response.getStatusInfo())); }
ApplicationWsDelegate { public void changeInstanceState( String applicationName, InstanceStatus newStatus, String instancePath ) throws ApplicationWsException { this.logger.finer( "Changing state of " + instancePath + " to '" + newStatus + "' in " + applicationName + "." ); WebResource path = this.resource.path( UrlConstants.APP ).path( applicationName ).path( "change-state" ); if( instancePath != null ) path = path.queryParam( "instance-path", instancePath ); if( newStatus != null ) path = path.queryParam( "new-state", newStatus.toString()); ClientResponse response = this.wsClient.createBuilder( path ) .accept( MediaType.APPLICATION_JSON ) .post( ClientResponse.class ); handleResponse( response ); this.logger.finer( String.valueOf( response.getStatusInfo())); } }
ApplicationWsDelegate { public void changeInstanceState( String applicationName, InstanceStatus newStatus, String instancePath ) throws ApplicationWsException { this.logger.finer( "Changing state of " + instancePath + " to '" + newStatus + "' in " + applicationName + "." ); WebResource path = this.resource.path( UrlConstants.APP ).path( applicationName ).path( "change-state" ); if( instancePath != null ) path = path.queryParam( "instance-path", instancePath ); if( newStatus != null ) path = path.queryParam( "new-state", newStatus.toString()); ClientResponse response = this.wsClient.createBuilder( path ) .accept( MediaType.APPLICATION_JSON ) .post( ClientResponse.class ); handleResponse( response ); this.logger.finer( String.valueOf( response.getStatusInfo())); } ApplicationWsDelegate( WebResource resource, WsClient wsClient ); }
ApplicationWsDelegate { public void changeInstanceState( String applicationName, InstanceStatus newStatus, String instancePath ) throws ApplicationWsException { this.logger.finer( "Changing state of " + instancePath + " to '" + newStatus + "' in " + applicationName + "." ); WebResource path = this.resource.path( UrlConstants.APP ).path( applicationName ).path( "change-state" ); if( instancePath != null ) path = path.queryParam( "instance-path", instancePath ); if( newStatus != null ) path = path.queryParam( "new-state", newStatus.toString()); ClientResponse response = this.wsClient.createBuilder( path ) .accept( MediaType.APPLICATION_JSON ) .post( ClientResponse.class ); handleResponse( response ); this.logger.finer( String.valueOf( response.getStatusInfo())); } ApplicationWsDelegate( WebResource resource, WsClient wsClient ); void changeInstanceState( String applicationName, InstanceStatus newStatus, String instancePath ); void setDescription( String applicationName, String newDesc ); void deployAndStartAll( String applicationName, String instancePath ); void stopAll( String applicationName, String instancePath ); void undeployAll( String applicationName, String instancePath ); List<Instance> listChildrenInstances( String applicationName, String instancePath, boolean all ); void addInstance( String applicationName, String parentInstancePath, Instance instance ); void removeInstance( String applicationName, String instancePath ); void resynchronize( String applicationName ); List<Component> listAllComponents( String applicationName ); List<Component> findComponentChildren( String applicationName, String componentName ); List<Component> findComponentAncestors( String applicationName, String componentName ); void bindApplication( String applicationName, String boundTplName, String boundApp ); List<String> listAllCommands( String applicationName ); }
ApplicationWsDelegate { public void changeInstanceState( String applicationName, InstanceStatus newStatus, String instancePath ) throws ApplicationWsException { this.logger.finer( "Changing state of " + instancePath + " to '" + newStatus + "' in " + applicationName + "." ); WebResource path = this.resource.path( UrlConstants.APP ).path( applicationName ).path( "change-state" ); if( instancePath != null ) path = path.queryParam( "instance-path", instancePath ); if( newStatus != null ) path = path.queryParam( "new-state", newStatus.toString()); ClientResponse response = this.wsClient.createBuilder( path ) .accept( MediaType.APPLICATION_JSON ) .post( ClientResponse.class ); handleResponse( response ); this.logger.finer( String.valueOf( response.getStatusInfo())); } ApplicationWsDelegate( WebResource resource, WsClient wsClient ); void changeInstanceState( String applicationName, InstanceStatus newStatus, String instancePath ); void setDescription( String applicationName, String newDesc ); void deployAndStartAll( String applicationName, String instancePath ); void stopAll( String applicationName, String instancePath ); void undeployAll( String applicationName, String instancePath ); List<Instance> listChildrenInstances( String applicationName, String instancePath, boolean all ); void addInstance( String applicationName, String parentInstancePath, Instance instance ); void removeInstance( String applicationName, String instancePath ); void resynchronize( String applicationName ); List<Component> listAllComponents( String applicationName ); List<Component> findComponentChildren( String applicationName, String componentName ); List<Component> findComponentAncestors( String applicationName, String componentName ); void bindApplication( String applicationName, String boundTplName, String boundApp ); List<String> listAllCommands( String applicationName );  }