private String doClusterDestroy(RestTemplate restTemplate, YarnClient client, ApplicationId applicationId, String clusterId) { YarnContainerClusterOperations operations = buildClusterOperations(restTemplate, client, applicationId); operations.clusterDestroy(clusterId); return "Cluster " + clusterId + " destroyed."; }
/** * Run a {@link SpringApplication} build by a * {@link SpringApplicationBuilder} using an empty args. * * @return the application id * @see #run(String...) */ public ApplicationId run() { return run(new String[0]); }
/** * Sets an Applications base directory to be used by a builder. * * @param applicationBaseDir the applications base directory * @return the T for chaining */ public T applicationBaseDir(String applicationBaseDir) { // can be empty because value may come from an existing properties this.applicationBaseDir = applicationBaseDir; return getThis(); }
@Override public String runWithSpringApplication(ApplicationContext context) throws Exception { OperationProperties operationProperties = context.getBean(OperationProperties.class); if (Operation.PUSHED == operationProperties.getOperation()) { return getInstalledReport(context); } else if (Operation.SUBMITTED == operationProperties.getOperation()) { YarnClient client = context.getBean(YarnClient.class); return getSubmittedReport(client, operationProperties.isVerbose(), operationProperties.getType(), operationProperties.getHeaders()); } return null; }
private String doClusterStart(RestTemplate restTemplate, YarnClient client, ApplicationId applicationId, String clusterId) { YarnContainerClusterOperations operations = buildClusterOperations(restTemplate, client, applicationId); ContainerClusterModifyRequest request = new ContainerClusterModifyRequest(); request.setAction("start"); operations.clusterStart(clusterId, request); return "Cluster " + clusterId + " started."; }
private String doClusterStop(RestTemplate restTemplate, YarnClient client, ApplicationId applicationId, String clusterId) { YarnContainerClusterOperations operations = buildClusterOperations(restTemplate, client, applicationId); ContainerClusterModifyRequest request = new ContainerClusterModifyRequest(); request.setAction("stop"); operations.clusterStop(clusterId, request); return "Cluster " + clusterId + " stopped."; }
@Override public abstract R run(String... args);
private String doClusterModify(RestTemplate restTemplate, YarnClient client, ApplicationId applicationId, String clusterId, Integer projectionDataAny, Map<String, Integer> hosts, Map<String, Integer> racks, Map<String, Object> properties) { YarnContainerClusterOperations operations = buildClusterOperations(restTemplate, client, applicationId); ContainerClusterCreateRequest request = new ContainerClusterCreateRequest(); request.setClusterId(clusterId); ProjectionDataType projectionData = new ProjectionDataType(); projectionData.setAny(projectionDataAny); projectionData.setHosts(hosts); projectionData.setRacks(racks); projectionData.setProperties(properties); request.setProjectionData(projectionData); operations.clusterModify(clusterId, request); return "Cluster " + clusterId + " modified."; }
@Override public ContainerClusterResource clusterInfo(String clusterId) throws YarnContainerClusterClientException { try { return restTemplate.getForObject(baseUri + "/" + clusterId, ContainerClusterResource.class); } catch (RestClientException e) { throw convertException(e); } }
@Override protected void handleApplicationRun(ClientApplicationRunner<String> app) { app.run(); handleOutput("New version installed"); }
/** * Sets the application name used for submit. Effectively this will override * setting from set for yarn client for configuration properties. * * @param applicationName the application name * @return the YarnSubmitApplication for chaining */ public YarnSubmitApplication applicationName(String applicationName) { this.applicationName = applicationName; return getThis(); }
/** * Run a {@link SpringApplication} build by a * {@link SpringApplicationBuilder} using an empty args. * * @see #run(String...) * * @return report */ public String run() { return run(new String[0]); }
/** * Run a {@link SpringApplication} build by a * {@link SpringApplicationBuilder} using an empty args. * * @see #run(String...) */ public String run() { return run(new String[0]); }
private YarnContainerClusterClientException convertException(Exception e) { return new YarnContainerClusterClientException("Error communicating with rest endpoint",e); }
public String run() { return run(new String[0]); }
public String run() { return run(new String[0]); }
public String run() { return run(new String[0]); }
/** * Sets application properties which will be passed into a Spring Boot * environment. Properties are placed with a priority which is just below * command line arguments put above all other properties. * <p> * Effectively this means that these properties allow to override all * existing properties but still doesn't override properties based on * command-line arguments. Command-line arguments in this context are the * ones passed to <code>run</code> method in a sub-class. * * @param appProperties the app properties * @return the T for chaining */ public T appProperties(Properties appProperties) { this.appProperties = appProperties; return getThis(); }
@Override public ContainerClusterResource clusterCreate(ContainerClusterCreateRequest request) throws YarnContainerClusterClientException { try { return restTemplate.postForObject(baseUri, request, ContainerClusterResource.class); } catch (RestClientException e) { throw convertException(e); } }
@Override protected void handleApplicationRun(ClientApplicationRunner<ApplicationId> app) { ApplicationId applicationId = app.run(); handleOutput("New instance submitted with id " + applicationId); }