yarnClusterInfo;
- try {
- yarnClusterInfo = yarnClient.getNodeReports(NodeState.RUNNING);
- } catch (YarnException e1) {
- log.error("Exception happened when fetching node report from the YARN cluster: "
- + e1.toString());
- throw e1;
- } catch (IOException e1) {
- log.error("Network problem happened when fetching node report YARN cluster: "
- + e1.toString());
- throw e1;
- }
- for (NodeReport nodeReport : yarnClusterInfo) {
- log.info(nodeReport.toString());
- }
-
- if (diagnosticArgs.verbose) {
- Writer configWriter = new StringWriter();
- try {
- Configuration.dumpConfiguration(yarnClient.getConfig(), configWriter);
- } catch (IOException e1) {
- log.error("Network problem happened when retrieving YARN config from YARN: "
- + e1.toString());
- throw e1;
- }
- try {
- converter = new JSONObject(configWriter.toString());
- log.info("the configuration of the YARN cluster is: "
- + converter.toString(2));
-
- } catch (JSONException e) {
- log.error("JSONException happened during parsing response from YARN: "
- + e.toString());
- }
- }
- }
-
- private void actionDiagnosticSlider(ActionDiagnosticArgs diagnosticArgs)
- throws YarnException, IOException {
- // not using member variable clustername because we want to place
- // application name after --application option and member variable
- // cluster name has to be put behind action
- String clusterName = diagnosticArgs.name;
- if(isUnset(clusterName)){
- throw new BadCommandArgumentsException("application name must be provided with --name option");
- }
- AggregateConf instanceDefinition = new AggregateConf();
- String imagePath = instanceDefinition.getInternalOperations().get(
- INTERNAL_APPLICATION_IMAGE_PATH);
- // if null, it will be uploaded by Slider and thus at slider's path
- if (imagePath == null) {
- ApplicationReport appReport = findInstance(clusterName);
- if (appReport != null) {
- Path path1 = sliderFileSystem.getTempPathForCluster(clusterName);
- Path subPath = new Path(path1, appReport.getApplicationId().toString()
- + "/agent");
- imagePath = subPath.toString();
- }
- }
- log.info("The path of slider agent tarball on HDFS is: " + imagePath);
- }
-
- private void actionDiagnosticApplication(ActionDiagnosticArgs diagnosticArgs)
- throws YarnException, IOException {
- // not using member variable clustername because we want to place
- // application name after --application option and member variable
- // cluster name has to be put behind action
- String clusterName = diagnosticArgs.name;
- requireArgumentSet(Arguments.ARG_NAME, clusterName);
- AggregateConf instanceDefinition = new AggregateConf();
- String clusterDir = instanceDefinition.getAppConfOperations()
- .getGlobalOptions().get(AgentKeys.APP_ROOT);
- String pkgTarball = getApplicationDefinitionPath(instanceDefinition.getAppConfOperations());
- String runAsUser = instanceDefinition.getAppConfOperations()
- .getGlobalOptions().get(AgentKeys.RUNAS_USER);
-
- log.info("The location of the cluster instance directory in HDFS is: {}", clusterDir);
- log.info("The name of the application package tarball on HDFS is: {}",pkgTarball);
- log.info("The runas user of the application in the cluster is: {}",runAsUser);
-
- if (diagnosticArgs.verbose) {
- log.info("App config of the application:\n{}",
- instanceDefinition.getAppConf().toJson());
- log.info("Resource config of the application:\n{}",
- instanceDefinition.getResources().toJson());
- }
+ // actionDiagnosticSlider only prints the agent location on hdfs,
+ // which is invalid now.
+ // actionDiagnosticCredentials only runs 'klist' command, IMHO, the user
+ // can just run klist on its own with extra options supported, don't
+ // actually see the point of this method.
}
private void actionDiagnosticClient(ActionDiagnosticArgs diagnosticArgs)
@@ -3242,16 +3038,6 @@ public int actionNodes(String instance, ActionNodesArgs args) throws YarnExcepti
}
/**
- * Create a new IPC client for talking to slider via what follows the REST API.
- * Client must already be bonded to the cluster
- * @return a new IPC client
- */
- public SliderApplicationApi createIpcClient()
- throws IOException, YarnException {
- return new SliderApplicationIpcClient(createClusterOperations());
- }
-
- /**
* Save/list tokens. This is for testing oozie integration
* @param args commands
* @return status
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/ipc/SliderApplicationIpcClient.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/ipc/SliderApplicationIpcClient.java
deleted file mode 100644
index 3b5147f..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/ipc/SliderApplicationIpcClient.java
+++ /dev/null
@@ -1,234 +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.ipc;
-
-import com.google.common.base.Preconditions;
-import org.apache.slider.api.SliderClusterProtocol;
-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.NodeInformation;
-import org.apache.slider.api.types.NodeInformationList;
-import org.apache.slider.api.types.PingInformation;
-import org.apache.slider.api.SliderApplicationApi;
-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.exceptions.NoSuchNodeException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.Map;
-
-/**
- * Implementation of the Slider RESTy Application API over IPC.
- *
- * Operations are executed via the {@link SliderClusterOperations}
- * instance passed in; raised exceptions may be converted into ones
- * consistent with the REST API.
- */
-public class SliderApplicationIpcClient implements SliderApplicationApi {
-
- private static final Logger log =
- LoggerFactory.getLogger(SliderApplicationIpcClient.class);
-
- private final SliderClusterOperations operations;
-
- public SliderApplicationIpcClient(SliderClusterOperations operations) {
- Preconditions.checkArgument(operations != null, "null operations");
- this.operations = operations;
- }
-
- /**
- * Convert received (And potentially unmarshalled) local/remote
- * exceptions into the equivalents in the REST API.
- * Best effort.
- *
- * If there is no translation, the original exception is returned.
- *
- * If a new exception was created, it will have the message of the
- * string value of the original exception, and that original
- * exception will be the nested cause of this one
- * @param exception IOException to convert
- * @return an exception to throw
- */
- private IOException convert(IOException exception) {
- IOException result = exception;
- if (exception instanceof NoSuchNodeException) {
- result = new FileNotFoundException(exception.toString());
- result.initCause(exception);
- } else {
- // TODO: remap any other exceptions
- }
- return result;
- }
-
- public SliderApplicationIpcClient(SliderClusterProtocol proxy) {
- this(new SliderClusterOperations(proxy));
- }
-
- @Override
- public AggregateConf getDesiredModel() throws IOException {
- try {
- return operations.getModelDesired();
- } catch (IOException e) {
- throw convert(e);
- }
- }
-
- @Override
- public ConfTreeOperations getDesiredAppconf() throws IOException {
- try {
- return operations.getModelDesiredAppconf();
- } catch (IOException e) {
- throw convert(e);
- }
- }
-
- @Override
- public ConfTreeOperations getDesiredResources() throws IOException {
- try {
- return operations.getModelDesiredResources();
- } catch (IOException e) {
- throw convert(e);
- }
- }
-
- @Override
- public AggregateConf getResolvedModel() throws IOException {
- try {
- return operations.getModelResolved();
- } catch (IOException e) {
- throw convert(e);
- }
- }
-
- @Override
- public ConfTreeOperations getResolvedAppconf() throws IOException {
- try {
- return operations.getModelResolvedAppconf();
- } catch (IOException e) {
- throw convert(e);
- }
- }
-
- @Override
- public ConfTreeOperations getResolvedResources() throws IOException {
- try {
- return operations.getModelResolvedResources();
- } catch (IOException e) {
- throw convert(e);
- }
- }
-
- @Override
- public ConfTreeOperations getLiveResources() throws IOException {
- try {
- return operations.getLiveResources();
- } catch (IOException e) {
- throw convert(e);
- }
- }
-
- @Override
- public Map enumContainers() throws IOException {
- try {
- return operations.enumContainers();
- } catch (IOException e) {
- throw convert(e);
- }
- }
-
- @Override
- public ContainerInformation getContainer(String containerId) throws
- IOException {
- try {
- return operations.getContainer(containerId);
- } catch (IOException e) {
- throw convert(e);
- }
- }
-
- @Override
- public Map enumComponents() throws IOException {
- try {
- return operations.enumComponents();
- } catch (IOException e) {
- throw convert(e);
- }
- }
-
- @Override
- public ComponentInformation getComponent(String componentName) throws IOException {
- try {
- return operations.getComponent(componentName);
- } catch (IOException e) {
- throw convert(e);
- }
- }
-
- @Override
- public NodeInformationList getLiveNodes() throws IOException {
- try {
- return operations.getLiveNodes();
- } catch (IOException e) {
- throw convert(e);
- }
- }
-
- @Override
- public NodeInformation getLiveNode(String hostname) throws IOException {
- try {
- return operations.getLiveNode(hostname);
- } catch (IOException e) {
- throw convert(e);
- }
- }
-
- @Override
- public PingInformation ping(String text) throws IOException {
- return null;
- }
-
- @Override
- public void stop(String text) throws IOException {
- try {
- operations.stop(text);
- } catch (IOException e) {
- throw convert(e);
- }
- }
-
- @Override
- public ApplicationLivenessInformation getApplicationLiveness() throws
- IOException {
- try {
- return operations.getApplicationLiveness();
- } catch (IOException e) {
- throw convert(e);
- }
- }
-
- @Override
- public String toString() {
- return "IPC implementation of SliderApplicationApi bonded to " + operations;
- }
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/ipc/SliderClusterOperations.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/ipc/SliderClusterOperations.java
index 623b8b0..3bb2af6 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/ipc/SliderClusterOperations.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/ipc/SliderClusterOperations.java
@@ -20,27 +20,20 @@
import com.google.common.annotations.VisibleForTesting;
import org.apache.hadoop.yarn.exceptions.YarnException;
-import org.apache.slider.api.ClusterDescription;
import org.apache.slider.api.ClusterNode;
import org.apache.slider.api.SliderClusterProtocol;
import org.apache.slider.api.StateValues;
import org.apache.slider.api.proto.Messages;
import org.apache.slider.api.resource.Application;
import org.apache.slider.api.resource.Component;
-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.NodeInformation;
import org.apache.slider.api.types.NodeInformationList;
import org.apache.slider.api.types.PingInformation;
import org.apache.slider.common.tools.Duration;
-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.exceptions.NoSuchNodeException;
import org.apache.slider.core.exceptions.SliderException;
import org.apache.slider.core.exceptions.WaitTimeoutException;
-import org.apache.slider.core.persist.ConfTreeSerDeser;
import org.apache.slider.core.persist.JsonSerDeser;
import org.codehaus.jackson.JsonParseException;
import org.slf4j.Logger;
@@ -50,11 +43,9 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
-import static org.apache.slider.api.types.RestTypeMarshalling.*;
+import static org.apache.slider.api.types.RestTypeMarshalling.unmarshall;
/**
* Cluster operations at a slightly higher level than the RPC code
@@ -322,85 +313,6 @@ public void amSuicide(String text, int signal, int delay)
appMaster.amSuicide(req);
}
- /**
- * Get the application liveness
- * @return current liveness information
- * @throws IOException
- */
- public ApplicationLivenessInformation getLivenessInformation() throws IOException {
- Messages.GetApplicationLivenessRequestProto.Builder builder =
- Messages.GetApplicationLivenessRequestProto.newBuilder();
- Messages.ApplicationLivenessInformationProto wire =
- appMaster.getLivenessInformation(builder.build());
- return unmarshall(wire);
-
- }
-
- public AggregateConf getModelDesired() throws IOException {
- return unmarshallToAggregateConf(appMaster.getModelDesired(EMPTY));
- }
-
-
- public ConfTreeOperations getModelDesiredAppconf() throws IOException {
- return unmarshallToCTO(appMaster.getModelDesiredAppconf(EMPTY));
- }
-
-
- public ConfTreeOperations getModelDesiredResources() throws IOException {
- return unmarshallToCTO(appMaster.getModelDesiredResources(EMPTY));
- }
-
-
- public AggregateConf getModelResolved() throws IOException {
- return unmarshallToAggregateConf(appMaster.getModelResolved(EMPTY));
- }
-
-
- public ConfTreeOperations getModelResolvedAppconf() throws IOException {
- return unmarshallToCTO(appMaster.getModelResolvedAppconf(EMPTY));
- }
-
-
- public ConfTreeOperations getModelResolvedResources() throws IOException {
- return unmarshallToCTO(appMaster.getModelDesiredResources(EMPTY));
- }
-
-
- public ConfTreeOperations getLiveResources() throws IOException {
- return unmarshallToCTO(appMaster.getLiveResources(EMPTY));
- }
-
-
- public Map enumContainers() throws IOException {
- Messages.GetLiveContainersResponseProto response =
- appMaster.getLiveContainers(
- Messages.GetLiveContainersRequestProto.newBuilder().build());
-
- int namesCount = response.getNamesCount();
- int records = response.getContainersCount();
- if (namesCount != records) {
- throw new IOException("Number of names returned (" + namesCount
- + ") does not match the number of records returned: "
- + records);
- }
- Map map = new HashMap<>(namesCount);
- for (int i = 0; i < namesCount; i++) {
- map.put(response.getNames(i), unmarshall(response.getContainers(i)));
- }
- return map;
- }
-
-
- public ContainerInformation getContainer(String containerId) throws
- IOException {
- Messages.ContainerInformationProto response =
- appMaster.getLiveContainer(
- Messages.GetLiveContainerRequestProto.newBuilder()
- .setContainerId(containerId)
- .build());
- return unmarshall(response);
- }
-
public List getContainers() throws IOException {
Messages.GetLiveContainersResponseProto response = appMaster
.getLiveContainers(Messages.GetLiveContainersRequestProto.newBuilder()
@@ -408,34 +320,6 @@ public ContainerInformation getContainer(String containerId) throws
return unmarshall(response);
}
- public Map enumComponents() throws IOException {
- Messages.GetLiveComponentsResponseProto response =
- appMaster.getLiveComponents(
- Messages.GetLiveComponentsRequestProto.newBuilder().build());
-
- int namesCount = response.getNamesCount();
- int records = response.getComponentsCount();
- if (namesCount != records) {
- throw new IOException(
- "Number of names returned (" + namesCount + ")" +
- " does not match the number of records returned: " + records);
- }
- Map map = new HashMap<>(namesCount);
- for (int i = 0; i < namesCount; i++) {
- map.put(response.getNames(i), unmarshall(response.getComponents(i)));
- }
- return map;
- }
-
- public ComponentInformation getComponent(String componentName)
- throws IOException {
- Messages.GetLiveComponentRequestProto.Builder builder =
- Messages.GetLiveComponentRequestProto.newBuilder();
- builder.setName(componentName);
- Messages.ComponentInformationProto proto = appMaster.getLiveComponent(builder.build());
- return unmarshall(proto);
- }
-
public NodeInformationList getLiveNodes() throws IOException {
Messages.GetLiveNodesResponseProto response =
appMaster.getLiveNodes(Messages.GetLiveNodesRequestProto.newBuilder().build());
@@ -462,13 +346,4 @@ public PingInformation ping(String text) throws IOException {
public void stop(String text) throws IOException {
amSuicide(text, 3, 0);
}
-
- public ApplicationLivenessInformation getApplicationLiveness() throws
- IOException {
- Messages.ApplicationLivenessInformationProto proto =
- appMaster.getLivenessInformation(
- Messages.GetApplicationLivenessRequestProto.newBuilder().build()
- );
- return unmarshall(proto);
- }
}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/rest/RestClientFactory.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/rest/RestClientFactory.java
deleted file mode 100644
index 4286596..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/rest/RestClientFactory.java
+++ /dev/null
@@ -1,89 +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.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.WebResource;
-import org.apache.hadoop.registry.client.api.RegistryOperations;
-import org.apache.slider.client.ClientRegistryBinder;
-import org.apache.slider.api.SliderApplicationApi;
-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;
-
-/**
- * Factory for the Rest client; hides the lookup and instantiation.
- *
- *
- */
-public class RestClientFactory {
-
- private final ClientRegistryBinder binder;
- private final Client jerseyClient;
- private final String user, serviceclass, instance;
-
- public RestClientFactory(RegistryOperations operations,
- Client jerseyClient,
- String user,
- String serviceclass,
- String instance) {
- this.jerseyClient = jerseyClient;
- this.user = user;
- this.serviceclass = serviceclass;
- this.instance = instance;
- binder = new ClientRegistryBinder(operations);
- }
-
- /**
- * Locate the AM
- * @return a resource to the AM
- * @throws IOException any failure to resolve to the AM
- */
- private WebResource locateAppmaster() throws IOException {
- String restAPI = binder.lookupExternalRestAPI(user, serviceclass, instance,
- CustomRegistryConstants.AM_REST_BASE);
- return jerseyClient.resource(restAPI);
- }
-
- /**
- * 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 SliderApplicationApiRestClient(jerseyClient, appResource);
- }
-
-}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/rest/SliderApplicationApiRestClient.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/rest/SliderApplicationApiRestClient.java
deleted file mode 100644
index 4c376e0..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/rest/SliderApplicationApiRestClient.java
+++ /dev/null
@@ -1,289 +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.ClientHandlerException;
-import com.sun.jersey.api.client.GenericType;
-import com.sun.jersey.api.client.UniformInterfaceException;
-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.api.SliderApplicationApi;
-import org.apache.slider.api.types.NodeInformation;
-import org.apache.slider.api.types.NodeInformationList;
-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.exceptions.ExceptionConverter;
-import org.apache.slider.core.restclient.HttpVerb;
-import org.apache.slider.api.types.PingInformation;
-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 SliderApplicationApiRestClient extends BaseRestClient
- implements SliderApplicationApi {
- private static final Logger log =
- LoggerFactory.getLogger(SliderApplicationApiRestClient.class);
- private WebResource appResource;
-
- /**
- * Create an instance
- * @param jerseyClient jersey client for operations
- * @param appResource resource of application API
- */
- public SliderApplicationApiRestClient(Client jerseyClient,
- WebResource appResource) {
- super(jerseyClient);
- this.appResource = appResource;
- }
-
- /**
- * Create an instance
- * @param jerseyClient jersey client for operations
- * @param appmaster URL of appmaster/proxy to AM
- */
- public SliderApplicationApiRestClient(Client jerseyClient, String appmaster) {
- super(jerseyClient);
- WebResource amResource = jerseyClient.resource(appmaster);
- amResource.type(MediaType.APPLICATION_JSON);
- this.appResource = amResource.path(SLIDER_PATH_APPLICATION);
- }
-
-
- @Override
- public String toString() {
- final StringBuilder sb =
- new StringBuilder("SliderApplicationApiRestClient{");
- sb.append("appResource=").append(appResource);
- sb.append('}');
- return sb.toString();
- }
-
- /**
- * Create a resource under the application path
- * @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");
- return appResource.path(subpath);
- }
-
- /**
- * Get operation against a path under the Application
- * @param type expected
- * @param subpath path
- * @param c class to instantiate
- * @return instance
- * @throws IOException on any problem
- */
- public T getApplicationResource(String subpath, Class c)
- throws IOException {
- return appResourceOperation(HttpVerb.GET, subpath, c);
- }
-
- /**
- * Get operation against a path under the Application
- * @param type expected
- * @param subpath path
- * @param t type info
- * @return instance
- * @throws IOException on any problem
- */
- public T getApplicationResource(String subpath, GenericType t)
- throws IOException {
- return appResourceOperation(HttpVerb.GET, subpath, t);
- }
-
- /**
- *
- * @param method method to exec
- * @param type expected
- * @param subpath path
- * @param c class to instantiate
- * @return instance
- * @throws IOException on any problem
- */
- public T appResourceOperation(HttpVerb method, String subpath, Class c)
- throws IOException {
- return exec(method, applicationResource(subpath), c);
- }
-
-
- /**
- * Get operation against a path under the Application
- * @param type expected
- * @param subpath path
- * @param t type info
- * @return instance
- * @throws IOException on any problem
- */
- public T appResourceOperation(HttpVerb method, String subpath,
- GenericType t)
- throws IOException {
- return exec(method, applicationResource(subpath), 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 getDesiredResources() 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 getResolvedResources() throws IOException {
- ConfTree resource =
- getApplicationResource(MODEL_RESOLVED_RESOURCES, ConfTree.class);
- return new ConfTreeOperations(resource);
- }
-
- @Override
- public ConfTreeOperations getLiveResources() throws IOException {
- ConfTree resource =
- getApplicationResource(LIVE_RESOURCES, ConfTree.class);
- return new ConfTreeOperations(resource);
- }
-
- @Override
- public Map enumContainers() throws
- IOException {
- return getApplicationResource(LIVE_CONTAINERS,
- new GenericType