SLIDER-782 rename RESTy API client to emphasise its not the IPC one

Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/e155f649
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/e155f649
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/e155f649

Branch: refs/heads/develop
Commit: e155f649e72a70c1acf15d2e076b790305e1cf08
Parents: 77d3154
Author: Steve Loughran <ste...@apache.org>
Authored: Thu Feb 12 18:17:24 2015 +0000
Committer: Steve Loughran <ste...@apache.org>
Committed: Thu Feb 12 18:17:24 2015 +0000

----------------------------------------------------------------------
 .../slider/client/rest/RestClientFactory.java   |   2 +-
 .../client/rest/SliderApplicationApiClient.java | 255 -------------------
 .../rest/SliderApplicationApiRestClient.java    | 255 +++++++++++++++++++
 .../rest/RestAPIClientTestDelegates.groovy      |   8 +-
 4 files changed, 260 insertions(+), 260 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/e155f649/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 d337ffd..f0f7868 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
@@ -76,7 +76,7 @@ public class RestClientFactory {
    */
   public SliderApplicationApi createSliderAppApiClient(WebResource appmaster) {
     WebResource appResource = appmaster.path(SLIDER_PATH_APPLICATION);
-    return new SliderApplicationApiClient(jerseyClient, appResource);
+    return new SliderApplicationApiRestClient(jerseyClient, appResource);
   }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/e155f649/slider-core/src/main/java/org/apache/slider/client/rest/SliderApplicationApiClient.java
----------------------------------------------------------------------
diff --git 
a/slider-core/src/main/java/org/apache/slider/client/rest/SliderApplicationApiClient.java
 
b/slider-core/src/main/java/org/apache/slider/client/rest/SliderApplicationApiClient.java
deleted file mode 100644
index 8c920d5..0000000
--- 
a/slider-core/src/main/java/org/apache/slider/client/rest/SliderApplicationApiClient.java
+++ /dev/null
@@ -1,255 +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.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 SliderApplicationApiClient extends BaseRestClient
-      implements SliderApplicationApi {
-  private static final Logger log =
-      LoggerFactory.getLogger(SliderApplicationApiClient.class);
-  private WebResource appResource;
-
-  /**
-   * Create an instance
-   * @param jerseyClient jersey client for operations
-   * @param appResource resource of application API
-   */
-  public SliderApplicationApiClient(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 PingInformation 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 PingInformation pingGet(String text) throws IOException {
-    WebResource pingResource = applicationResource(ACTION_PING);
-    pingResource.getUriBuilder().queryParam("body", text);
-    return pingResource.get(PingInformation.class);
-  }
-  
-  /**
-   * Ping as a POST
-   * @param text text to include
-   * @return the response
-   * @throws IOException on any failure
-   */
-  public PingInformation 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(PingInformation.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/e155f649/slider-core/src/main/java/org/apache/slider/client/rest/SliderApplicationApiRestClient.java
----------------------------------------------------------------------
diff --git 
a/slider-core/src/main/java/org/apache/slider/client/rest/SliderApplicationApiRestClient.java
 
b/slider-core/src/main/java/org/apache/slider/client/rest/SliderApplicationApiRestClient.java
new file mode 100644
index 0000000..ddb78ed
--- /dev/null
+++ 
b/slider-core/src/main/java/org/apache/slider/client/rest/SliderApplicationApiRestClient.java
@@ -0,0 +1,255 @@
+/*
+ * 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.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 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 PingInformation 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 PingInformation pingGet(String text) throws IOException {
+    WebResource pingResource = applicationResource(ACTION_PING);
+    pingResource.getUriBuilder().queryParam("body", text);
+    return pingResource.get(PingInformation.class);
+  }
+  
+  /**
+   * Ping as a POST
+   * @param text text to include
+   * @return the response
+   * @throws IOException on any failure
+   */
+  public PingInformation 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(PingInformation.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/e155f649/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 ca4be4d..d6cabfa 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.SliderApplicationApiClient
+import org.apache.slider.client.rest.SliderApplicationApiRestClient
 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 SliderApplicationApiClient}
+ * {@link SliderApplicationApiRestClient}
  */
 @CompileStatic
 @Slf4j
@@ -49,7 +49,7 @@ class RestAPIClientTestDelegates extends 
AbstractRestTestDelegate {
   final String appmaster;
   final String application;
   final Client jersey;
-  final SliderApplicationApiClient appAPI;
+  final SliderApplicationApiRestClient appAPI;
 
 
   RestAPIClientTestDelegates(String appmaster, Client jersey,
@@ -61,7 +61,7 @@ class RestAPIClientTestDelegates extends 
AbstractRestTestDelegate {
     WebResource amResource = jersey.resource(appmaster)
     amResource.type(MediaType.APPLICATION_JSON)
     def appResource = amResource.path(SLIDER_PATH_APPLICATION);
-    appAPI = new SliderApplicationApiClient(jersey, appResource)
+    appAPI = new SliderApplicationApiRestClient(jersey, appResource)
   }
 
 

Reply via email to