SLIDER-768 split SliderApplicationAPI client into interface and impl; stops users of client getting at raw REST API and other methods unless they want to typecast (Which tests may still do)
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/7f2e0c2d Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/7f2e0c2d Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/7f2e0c2d Branch: refs/heads/develop Commit: 7f2e0c2de94c1ac4ad357c021808c6781d8bb346 Parents: e2388af Author: Steve Loughran <[email protected]> Authored: Mon Feb 2 14:06:14 2015 +0000 Committer: Steve Loughran <[email protected]> Committed: Mon Feb 2 14:06:14 2015 +0000 ---------------------------------------------------------------------- .../slider/client/rest/BaseRestClient.java | 26 +- .../slider/client/rest/RestClientFactory.java | 29 +- .../client/rest/SliderApplicationAPI.java | 318 ------------------- .../client/rest/SliderApplicationAPIImpl.java | 254 +++++++++++++++ .../client/rest/SliderApplicationApi.java | 145 +++++++++ .../rest/RestAPIClientTestDelegates.groovy | 9 +- .../slider/agent/rest/TestStandaloneREST.groovy | 7 +- .../funtest/lifecycle/AgentWebPagesIT.groovy | 2 +- 8 files changed, 441 insertions(+), 349 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/7f2e0c2d/slider-core/src/main/java/org/apache/slider/client/rest/BaseRestClient.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/client/rest/BaseRestClient.java b/slider-core/src/main/java/org/apache/slider/client/rest/BaseRestClient.java index 41cfe9d..de2fe20 100644 --- a/slider-core/src/main/java/org/apache/slider/client/rest/BaseRestClient.java +++ b/slider-core/src/main/java/org/apache/slider/client/rest/BaseRestClient.java @@ -37,7 +37,7 @@ import java.net.URI; /** * This is a base class for Jersey REST clients in Slider. - * It supports bonding to an AM and the execution of operations âwith + * It supports the execution of operations âwith * exceptions uprated to IOExceptions when needed. * <p> * Subclasses can use these operations to provide an API-like view @@ -47,33 +47,19 @@ public class BaseRestClient { private static final Logger log = LoggerFactory.getLogger(BaseRestClient.class); private final Client client; - private WebResource appmaster; public BaseRestClient( - Client client, - WebResource appmaster) { + Client client) { Preconditions.checkNotNull(client, "null jersey client"); this.client = client; - if (appmaster != null) { - bindToAppmaster(appmaster); - } - } - - public Client getClient() { - return client; } /** - * Bind/rebind to the AM - * @param appmaster AM + * Get the jersey client + * @return jersey client */ - public void bindToAppmaster(WebResource appmaster) { - Preconditions.checkArgument(appmaster != null, " Null appmaster"); - this.appmaster = appmaster; - } - - public WebResource getAppmaster() { - return appmaster; + public Client getClient() { + return client; } /** http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/7f2e0c2d/slider-core/src/main/java/org/apache/slider/client/rest/RestClientFactory.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/client/rest/RestClientFactory.java b/slider-core/src/main/java/org/apache/slider/client/rest/RestClientFactory.java index 1b7553e..dc54ba3 100644 --- a/slider-core/src/main/java/org/apache/slider/client/rest/RestClientFactory.java +++ b/slider-core/src/main/java/org/apache/slider/client/rest/RestClientFactory.java @@ -25,6 +25,8 @@ import org.apache.slider.core.registry.info.CustomRegistryConstants; import java.io.IOException; +import static org.apache.slider.server.appmaster.web.rest.RestPaths.SLIDER_PATH_APPLICATION; + public class RestClientFactory { private final RestClientRegistryBinder binder; @@ -53,9 +55,28 @@ public class RestClientFactory { CustomRegistryConstants.AM_REST_BASE); return jerseyClient.resource(restAPI); } - - public SliderApplicationAPI createSliderApplicationApi() throws IOException { - return new SliderApplicationAPI(jerseyClient, locateAppmaster()); + + /** + * Locate the slider AM then instantiate a client instance against + * its Application API. + * @return the instance + * @throws IOException on any failure + */ + public SliderApplicationApi createSliderAppApiClient() throws IOException { + WebResource appmaster = locateAppmaster(); + return createSliderAppApiClient(appmaster); + } + + /** + * Create a Slider application API client instance against + * its Application API. + * @param appmaster The AM to work against. + * @return the instance + * @throws IOException on any failure + */ + public SliderApplicationApi createSliderAppApiClient(WebResource appmaster) { + WebResource appResource = appmaster.path(SLIDER_PATH_APPLICATION); + return new SliderApplicationApiImpl(jerseyClient, appResource); } - + } http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/7f2e0c2d/slider-core/src/main/java/org/apache/slider/client/rest/SliderApplicationAPI.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/client/rest/SliderApplicationAPI.java b/slider-core/src/main/java/org/apache/slider/client/rest/SliderApplicationAPI.java deleted file mode 100644 index ee4760e..0000000 --- a/slider-core/src/main/java/org/apache/slider/client/rest/SliderApplicationAPI.java +++ /dev/null @@ -1,318 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.slider.client.rest; - -import com.google.common.base.Preconditions; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.GenericType; -import com.sun.jersey.api.client.WebResource; -import com.sun.jersey.api.representation.Form; -import org.apache.commons.lang.StringUtils; -import org.apache.slider.api.types.ApplicationLivenessInformation; -import org.apache.slider.api.types.ComponentInformation; -import org.apache.slider.api.types.ContainerInformation; -import org.apache.slider.core.conf.AggregateConf; -import org.apache.slider.core.conf.ConfTree; -import org.apache.slider.core.conf.ConfTreeOperations; -import org.apache.slider.core.restclient.HttpVerb; -import org.apache.slider.api.types.PingResource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.ws.rs.core.MediaType; -import java.io.IOException; -import java.util.Map; - -import static org.apache.slider.server.appmaster.web.rest.RestPaths.*; - -public class SliderApplicationAPI extends BaseRestClient { - private static final Logger log = - LoggerFactory.getLogger(SliderApplicationAPI.class); - private WebResource appResource; - - public SliderApplicationAPI(Client jerseyClient, WebResource appmaster) { - super(jerseyClient, appmaster); - } - - /** - * Bind/rebind to the AM - * @param appmaster AM - */ - public void bindToAppmaster(WebResource appmaster) { - super.bindToAppmaster(appmaster); - this.appResource = appmaster.path(SLIDER_PATH_APPLICATION); - } - - /** - * Create a resource under the application path set up to accept - * JSON - * @param subpath path under application - * @return a resource under the application path - */ - public WebResource applicationResource(String subpath) { - Preconditions.checkArgument(!StringUtils.isEmpty(subpath), - "empty path"); - Preconditions.checkNotNull(appResource, "Null app resource"); - WebResource resource = appResource.path(subpath); - resource.accept(MediaType.APPLICATION_JSON_TYPE); - return resource; - } - - /** - * Get operation against a path under the Application - * @param <T> type expected - * @param subpath path - * @param c class to instantiate - * @return instance - * @throws IOException on any problem - */ - public <T> T getApplicationResource(String subpath, Class<T> c) - throws IOException { - return appResourceOperation(HttpVerb.GET, subpath, c); - } - - /** - * Get operation against a path under the Application - * @param <T> type expected - * @param subpath path - * @param t type info - * @return instance - * @throws IOException on any problem - */ - public <T> T getApplicationResource(String subpath, GenericType<T> t) - throws IOException { - return appResourceOperation(HttpVerb.GET, subpath, t); - } - - /** - * - * @param method method to exec - * @param <T> type expected - * @param subpath path - * @param c class to instantiate - * @return instance - * @throws IOException on any problem - */ - public <T> T appResourceOperation(HttpVerb method, String subpath, Class<T> c) - throws IOException { - WebResource resource = applicationResource(subpath); - return exec(method, resource, c); - } - - - /** - * Get operation against a path under the Application - * @param <T> type expected - * @param subpath path - * @param t type info - * @return instance - * @throws IOException on any problem - */ - public <T> T appResourceOperation(HttpVerb method, String subpath, - GenericType<T> t) - throws IOException { - WebResource resource = applicationResource(subpath); - return exec(method, resource, t); - } - - - /** - * Get the aggregate desired model - * @return the aggregate configuration of what was asked for - * âbefore resolution has taken place - * @throws IOException on any failure - */ - public AggregateConf getDesiredModel() throws IOException { - return getApplicationResource(MODEL_DESIRED, AggregateConf.class); - } - - /** - * Get the desired application configuration - * @return the application configuration asked for - * âbefore resolution has taken place - * @throws IOException on any failure - */ - public ConfTreeOperations getDesiredAppconf() throws IOException { - ConfTree resource = - getApplicationResource(MODEL_DESIRED_APPCONF, ConfTree.class); - return new ConfTreeOperations(resource); - } - - /** - * Get the desired YARN resources - * @return the resources asked for - * âbefore resolution has taken place - * @throws IOException on any failure - */ - public ConfTreeOperations getDesiredYarnResources() throws IOException { - ConfTree resource = - getApplicationResource(MODEL_DESIRED_RESOURCES, ConfTree.class); - return new ConfTreeOperations(resource); - } - - /** - * Get the aggregate resolved model - * @return the aggregate configuration of what was asked for - * âafter resolution has taken place - * @throws IOException on any failure - */ - public AggregateConf getResolvedModel() throws IOException { - return getApplicationResource(MODEL_RESOLVED, AggregateConf.class); - } - - - /** - * Get the resolved application configuration - * @return the application configuration asked for - * âafter resolution has taken place - * @throws IOException on any failure - */ - public ConfTreeOperations getResolvedAppconf() throws IOException { - ConfTree resource = - getApplicationResource(MODEL_RESOLVED_APPCONF, ConfTree.class); - return new ConfTreeOperations(resource); - } - - /** - * Get the resolved YARN resources - * @return the resources asked for - * âafter resolution has taken place - * @throws IOException on any failure - */ - public ConfTreeOperations getResolvedYarnResources() throws IOException { - ConfTree resource = - getApplicationResource(MODEL_RESOLVED_RESOURCES, ConfTree.class); - return new ConfTreeOperations(resource); - } - - /** - * Get the live YARN resources - * @return the live set of resources in the cluster - * @throws IOException on any failure - */ - public ConfTreeOperations getLiveYarnResources() throws IOException { - ConfTree resource = - getApplicationResource(LIVE_RESOURCES, ConfTree.class); - return new ConfTreeOperations(resource); - } - - /** - * Get a map of live containers [containerId:info] - * @return a possibly empty list of serialized containers - * @throws IOException on any failure - */ - public Map<String, ContainerInformation> enumContainers() throws - IOException { - return getApplicationResource(LIVE_CONTAINERS, - new GenericType<Map<String, ContainerInformation>>() { - }); - } - - /** - * Get a container from the container Id - * @param containerId YARN container ID - * @return the container information - * @throws IOException on any failure - */ - public ContainerInformation getContainer( String containerId) throws - IOException { - return getApplicationResource(LIVE_CONTAINERS + "/" + containerId, - ContainerInformation.class); - } - - /** - * List all components into a map of [name:info] - * @return a possibly empty map of components - * @throws IOException on any failure - */ - public Map<String, ComponentInformation> enumComponents() throws - IOException { - return getApplicationResource(LIVE_COMPONENTS, - new GenericType<Map<String, ComponentInformation>>() { - }); - } - - /** - * Get information about a component - * @param componentName name of the component - * @return the component details - * @throws IOException on any failure - */ - public ComponentInformation getComponent(String componentName) throws - IOException { - return getApplicationResource(LIVE_COMPONENTS + "/" + componentName, - ComponentInformation.class); - } - - /** - * Ping as a GET - * @param text text to include - * @return the response - * @throws IOException on any failure - */ - public PingResource ping(String text) throws IOException { - return pingPost(text); - } - - /** - * Ping as a GET - * @param text text to include - * @return the response - * @throws IOException on any failure - */ - public PingResource pingGet(String text) throws IOException { - WebResource pingResource = applicationResource(ACTION_PING); - pingResource.getUriBuilder().queryParam("body", text); - return pingResource.get(PingResource.class); - } - - /** - * Ping as a POST - * @param text text to include - * @return the response - * @throws IOException on any failure - */ - public PingResource pingPost(String text) throws IOException { - WebResource pingResource = applicationResource(ACTION_PING); - pingResource.type(MediaType.APPLICATION_JSON_TYPE); - Form f = new Form(); - f.add("text", text); - return pingResource.post(PingResource.class, f); - } - - /** - * Stop the AM (async operation) - * @param text text to include - * @throws IOException on any failure - */ - public void stop(String text) throws IOException { - WebResource resource = applicationResource(ACTION_STOP); - resource.post(text); - } - - /** - * Get the application liveness - * @return current liveness information - * @throws IOException - */ - public ApplicationLivenessInformation getApplicationLiveness() throws IOException { - return getApplicationResource(LIVE_LIVENESS, - ApplicationLivenessInformation.class); - } -} http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/7f2e0c2d/slider-core/src/main/java/org/apache/slider/client/rest/SliderApplicationAPIImpl.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/client/rest/SliderApplicationAPIImpl.java b/slider-core/src/main/java/org/apache/slider/client/rest/SliderApplicationAPIImpl.java new file mode 100644 index 0000000..676d515 --- /dev/null +++ b/slider-core/src/main/java/org/apache/slider/client/rest/SliderApplicationAPIImpl.java @@ -0,0 +1,254 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.slider.client.rest; + +import com.google.common.base.Preconditions; +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.GenericType; +import com.sun.jersey.api.client.WebResource; +import com.sun.jersey.api.representation.Form; +import org.apache.commons.lang.StringUtils; +import org.apache.slider.api.types.ApplicationLivenessInformation; +import org.apache.slider.api.types.ComponentInformation; +import org.apache.slider.api.types.ContainerInformation; +import org.apache.slider.core.conf.AggregateConf; +import org.apache.slider.core.conf.ConfTree; +import org.apache.slider.core.conf.ConfTreeOperations; +import org.apache.slider.core.restclient.HttpVerb; +import org.apache.slider.api.types.PingResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.ws.rs.core.MediaType; +import java.io.IOException; +import java.util.Map; + +import static org.apache.slider.server.appmaster.web.rest.RestPaths.*; + +/** + * Implementation of the {@link SliderApplicationApi} + */ +public class SliderApplicationApiImpl extends BaseRestClient + implements SliderApplicationApi { + private static final Logger log = + LoggerFactory.getLogger(SliderApplicationApiImpl.class); + private WebResource appResource; + + /** + * Create an instance + * @param jerseyClient jersey client for operations + * @param appResource resource of application API + */ + public SliderApplicationApiImpl(Client jerseyClient, WebResource appResource) { + super(jerseyClient); + this.appResource = appResource; + } + + /** + * Create a resource under the application path set up to accept + * JSON + * @param subpath path under application + * @return a resource under the application path + */ + public WebResource applicationResource(String subpath) { + Preconditions.checkArgument(!StringUtils.isEmpty(subpath), + "empty path"); + Preconditions.checkNotNull(appResource, "Null app resource"); + WebResource resource = appResource.path(subpath); + resource.accept(MediaType.APPLICATION_JSON_TYPE); + return resource; + } + + /** + * Get operation against a path under the Application + * @param <T> type expected + * @param subpath path + * @param c class to instantiate + * @return instance + * @throws IOException on any problem + */ + public <T> T getApplicationResource(String subpath, Class<T> c) + throws IOException { + return appResourceOperation(HttpVerb.GET, subpath, c); + } + + /** + * Get operation against a path under the Application + * @param <T> type expected + * @param subpath path + * @param t type info + * @return instance + * @throws IOException on any problem + */ + public <T> T getApplicationResource(String subpath, GenericType<T> t) + throws IOException { + return appResourceOperation(HttpVerb.GET, subpath, t); + } + + /** + * + * @param method method to exec + * @param <T> type expected + * @param subpath path + * @param c class to instantiate + * @return instance + * @throws IOException on any problem + */ + public <T> T appResourceOperation(HttpVerb method, String subpath, Class<T> c) + throws IOException { + WebResource resource = applicationResource(subpath); + return exec(method, resource, c); + } + + + /** + * Get operation against a path under the Application + * @param <T> type expected + * @param subpath path + * @param t type info + * @return instance + * @throws IOException on any problem + */ + public <T> T appResourceOperation(HttpVerb method, String subpath, + GenericType<T> t) + throws IOException { + WebResource resource = applicationResource(subpath); + return exec(method, resource, t); + } + + + @Override + public AggregateConf getDesiredModel() throws IOException { + return getApplicationResource(MODEL_DESIRED, AggregateConf.class); + } + + @Override + public ConfTreeOperations getDesiredAppconf() throws IOException { + ConfTree resource = + getApplicationResource(MODEL_DESIRED_APPCONF, ConfTree.class); + return new ConfTreeOperations(resource); + } + + @Override + public ConfTreeOperations getDesiredYarnResources() throws IOException { + ConfTree resource = + getApplicationResource(MODEL_DESIRED_RESOURCES, ConfTree.class); + return new ConfTreeOperations(resource); + } + + @Override + public AggregateConf getResolvedModel() throws IOException { + return getApplicationResource(MODEL_RESOLVED, AggregateConf.class); + } + + + @Override + public ConfTreeOperations getResolvedAppconf() throws IOException { + ConfTree resource = + getApplicationResource(MODEL_RESOLVED_APPCONF, ConfTree.class); + return new ConfTreeOperations(resource); + } + + @Override + public ConfTreeOperations getResolvedYarnResources() throws IOException { + ConfTree resource = + getApplicationResource(MODEL_RESOLVED_RESOURCES, ConfTree.class); + return new ConfTreeOperations(resource); + } + + @Override + public ConfTreeOperations getLiveYarnResources() throws IOException { + ConfTree resource = + getApplicationResource(LIVE_RESOURCES, ConfTree.class); + return new ConfTreeOperations(resource); + } + + @Override + public Map<String, ContainerInformation> enumContainers() throws + IOException { + return getApplicationResource(LIVE_CONTAINERS, + new GenericType<Map<String, ContainerInformation>>() { + }); + } + + @Override + public ContainerInformation getContainer(String containerId) throws + IOException { + return getApplicationResource(LIVE_CONTAINERS + "/" + containerId, + ContainerInformation.class); + } + + @Override + public Map<String, ComponentInformation> enumComponents() throws + IOException { + return getApplicationResource(LIVE_COMPONENTS, + new GenericType<Map<String, ComponentInformation>>() { + }); + } + + @Override + public ComponentInformation getComponent(String componentName) throws + IOException { + return getApplicationResource(LIVE_COMPONENTS + "/" + componentName, + ComponentInformation.class); + } + + @Override + public PingResource ping(String text) throws IOException { + return pingPost(text); + } + + /** + * Ping as a GET + * @param text text to include + * @return the response + * @throws IOException on any failure + */ + public PingResource pingGet(String text) throws IOException { + WebResource pingResource = applicationResource(ACTION_PING); + pingResource.getUriBuilder().queryParam("body", text); + return pingResource.get(PingResource.class); + } + + /** + * Ping as a POST + * @param text text to include + * @return the response + * @throws IOException on any failure + */ + public PingResource pingPost(String text) throws IOException { + WebResource pingResource = applicationResource(ACTION_PING); + pingResource.type(MediaType.APPLICATION_JSON_TYPE); + Form f = new Form(); + f.add("text", text); + return pingResource.post(PingResource.class, f); + } + + @Override + public void stop(String text) throws IOException { + WebResource resource = applicationResource(ACTION_STOP); + resource.post(text); + } + + @Override + public ApplicationLivenessInformation getApplicationLiveness() throws IOException { + return getApplicationResource(LIVE_LIVENESS, + ApplicationLivenessInformation.class); + } +} http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/7f2e0c2d/slider-core/src/main/java/org/apache/slider/client/rest/SliderApplicationApi.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/client/rest/SliderApplicationApi.java b/slider-core/src/main/java/org/apache/slider/client/rest/SliderApplicationApi.java new file mode 100644 index 0000000..eec201b --- /dev/null +++ b/slider-core/src/main/java/org/apache/slider/client/rest/SliderApplicationApi.java @@ -0,0 +1,145 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.slider.client.rest; + +import org.apache.slider.api.types.ApplicationLivenessInformation; +import org.apache.slider.api.types.ComponentInformation; +import org.apache.slider.api.types.ContainerInformation; +import org.apache.slider.api.types.PingResource; +import org.apache.slider.core.conf.AggregateConf; +import org.apache.slider.core.conf.ConfTreeOperations; + +import java.io.IOException; +import java.util.Map; + +/** + * API exported by the slider client REST API + */ +public interface SliderApplicationApi { + /** + * Get the aggregate desired model + * @return the aggregate configuration of what was asked for + * âbefore resolution has taken place + * @throws IOException on any failure + */ + AggregateConf getDesiredModel() throws IOException; + + /** + * Get the desired application configuration + * @return the application configuration asked for + * âbefore resolution has taken place + * @throws IOException on any failure + */ + ConfTreeOperations getDesiredAppconf() throws IOException; + + /** + * Get the desired YARN resources + * @return the resources asked for + * âbefore resolution has taken place + * @throws IOException on any failure + */ + ConfTreeOperations getDesiredYarnResources() throws IOException; + + /** + * Get the aggregate resolved model + * @return the aggregate configuration of what was asked for + * âafter resolution has taken place + * @throws IOException on any failure + */ + AggregateConf getResolvedModel() throws IOException; + + /** + * Get the resolved application configuration + * @return the application configuration asked for + * âafter resolution has taken place + * @throws IOException on any failure + */ + ConfTreeOperations getResolvedAppconf() throws IOException; + + /** + * Get the resolved YARN resources + * @return the resources asked for + * âafter resolution has taken place + * @throws IOException on any failure + */ + ConfTreeOperations getResolvedYarnResources() throws IOException; + + /** + * Get the live YARN resources + * @return the live set of resources in the cluster + * @throws IOException on any failure + */ + ConfTreeOperations getLiveYarnResources() throws IOException; + + /** + * Get a map of live containers [containerId:info] + * @return a possibly empty list of serialized containers + * @throws IOException on any failure + */ + Map<String, ContainerInformation> enumContainers() throws + IOException; + + /** + * Get a container from the container Id + * @param containerId YARN container ID + * @return the container information + * @throws IOException on any failure + */ + ContainerInformation getContainer(String containerId) throws + IOException; + + /** + * List all components into a map of [name:info] + * @return a possibly empty map of components + * @throws IOException on any failure + */ + Map<String, ComponentInformation> enumComponents() throws + IOException; + + /** + * Get information about a component + * @param componentName name of the component + * @return the component details + * @throws IOException on any failure + */ + ComponentInformation getComponent(String componentName) throws + IOException; + + /** + * Ping as a GET + * @param text text to include + * @return the response + * @throws IOException on any failure + */ + PingResource ping(String text) throws IOException; + + /** + * Stop the AM (async operation) + * @param text text to include + * @throws IOException on any failure + */ + void stop(String text) throws IOException; + + /** + * Get the application liveness + * @return current liveness information + * @throws IOException + */ + ApplicationLivenessInformation getApplicationLiveness() throws IOException; +} http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/7f2e0c2d/slider-core/src/test/groovy/org/apache/slider/agent/rest/RestAPIClientTestDelegates.groovy ---------------------------------------------------------------------- diff --git a/slider-core/src/test/groovy/org/apache/slider/agent/rest/RestAPIClientTestDelegates.groovy b/slider-core/src/test/groovy/org/apache/slider/agent/rest/RestAPIClientTestDelegates.groovy index 07c5ef0..3762d5d 100644 --- a/slider-core/src/test/groovy/org/apache/slider/agent/rest/RestAPIClientTestDelegates.groovy +++ b/slider-core/src/test/groovy/org/apache/slider/agent/rest/RestAPIClientTestDelegates.groovy @@ -25,7 +25,7 @@ import groovy.util.logging.Slf4j import org.apache.slider.api.StateValues import org.apache.slider.api.types.ComponentInformation import org.apache.slider.api.types.ContainerInformation -import org.apache.slider.client.rest.SliderApplicationAPI +import org.apache.slider.client.rest.SliderApplicationApiImpl import org.apache.slider.core.conf.ConfTree import org.apache.slider.core.conf.ConfTreeOperations import org.apache.slider.server.appmaster.web.rest.application.ApplicationResource @@ -40,7 +40,7 @@ import static org.apache.slider.server.appmaster.web.rest.RestPaths.* /** * Uses the Slider Application API for the tests. - * {@link SliderApplicationAPI} + * {@link SliderApplicationApiImpl} */ @CompileStatic @Slf4j @@ -49,7 +49,7 @@ class RestAPIClientTestDelegates extends AbstractRestTestDelegate { final String appmaster; final String application; final Client jersey; - final SliderApplicationAPI appAPI; + final SliderApplicationApiImpl appAPI; RestAPIClientTestDelegates(String appmaster, Client jersey, @@ -60,7 +60,8 @@ class RestAPIClientTestDelegates extends AbstractRestTestDelegate { application = appendToURL(appmaster, SLIDER_PATH_APPLICATION) WebResource amResource = jersey.resource(appmaster) amResource.type(MediaType.APPLICATION_JSON) - appAPI = new SliderApplicationAPI(jersey, amResource) + def appResource = amResource.path(SLIDER_PATH_APPLICATION); + appAPI = new SliderApplicationApiImpl(jersey, appResource) } http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/7f2e0c2d/slider-core/src/test/groovy/org/apache/slider/agent/rest/TestStandaloneREST.groovy ---------------------------------------------------------------------- diff --git a/slider-core/src/test/groovy/org/apache/slider/agent/rest/TestStandaloneREST.groovy b/slider-core/src/test/groovy/org/apache/slider/agent/rest/TestStandaloneREST.groovy index e210812..e4ce295 100644 --- a/slider-core/src/test/groovy/org/apache/slider/agent/rest/TestStandaloneREST.groovy +++ b/slider-core/src/test/groovy/org/apache/slider/agent/rest/TestStandaloneREST.groovy @@ -164,10 +164,13 @@ class TestStandaloneREST extends AgentMiniClusterTestBase { ugiClient, "~", SliderKeys.APP_TYPE, clustername) - def sliderApplicationApi = restClientFactory.createSliderApplicationApi(); + def sliderApplicationApi = restClientFactory.createSliderAppApiClient(); sliderApplicationApi.desiredModel sliderApplicationApi.resolvedModel - sliderApplicationApi.ping("registry located") + + if (directComplexVerbs) { + sliderApplicationApi.ping("registry located") + } // log the metrics to show what's up direct.logCodahaleMetrics(); http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/7f2e0c2d/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentWebPagesIT.groovy ---------------------------------------------------------------------- diff --git a/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentWebPagesIT.groovy b/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentWebPagesIT.groovy index a364e63..33d45ed 100644 --- a/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentWebPagesIT.groovy +++ b/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentWebPagesIT.groovy @@ -173,7 +173,7 @@ public class AgentWebPagesIT extends AgentCommandTestBase def restClientFactory = new RestClientFactory( operations, ugiClient, "~", SliderKeys.APP_TYPE, CLUSTER) - def sliderApplicationApi = restClientFactory.createSliderApplicationApi(); + def sliderApplicationApi = restClientFactory.createSliderAppApiClient(); sliderApplicationApi.desiredModel sliderApplicationApi.resolvedModel if (proxyComplexVerbs) {
