This is an automated email from the ASF dual-hosted git repository.

magicaltrout pushed a commit to branch development
in repository https://gitbox.apache.org/repos/asf/oodt.git


The following commit(s) were added to refs/heads/development by this push:
     new e72c17f  make resourcemanagerutils use resourcemanagerfactory instead 
of instantiating xmlrpcresourcemanagerclient (#102)
e72c17f is described below

commit e72c17f444177a7524b1951fab8352191ea9fb94
Author: Yasith Jayawardana <yasith.jayaward...@icloud.com>
AuthorDate: Fri Aug 16 04:44:27 2019 -0400

    make resourcemanagerutils use resourcemanagerfactory instead of 
instantiating xmlrpcresourcemanagerclient (#102)
    
    remove redundant exception handling in resourcecliaction
---
 .../apache/oodt/pcs/util/ResourceManagerUtils.java    | 19 ++++++++++---------
 .../cas/resource/cli/action/ResourceCliAction.java    |  6 +-----
 .../resource/system/AvroRpcResourceManagerClient.java |  2 +-
 .../resource/system/rpc/ResourceManagerFactory.java   |  4 ++--
 4 files changed, 14 insertions(+), 17 deletions(-)

diff --git 
a/pcs/core/src/main/java/org/apache/oodt/pcs/util/ResourceManagerUtils.java 
b/pcs/core/src/main/java/org/apache/oodt/pcs/util/ResourceManagerUtils.java
index e849eb7..d509d2a 100644
--- a/pcs/core/src/main/java/org/apache/oodt/pcs/util/ResourceManagerUtils.java
+++ b/pcs/core/src/main/java/org/apache/oodt/pcs/util/ResourceManagerUtils.java
@@ -25,20 +25,21 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 
 //OODT imports
-import org.apache.oodt.cas.resource.system.XmlRpcResourceManagerClient;
+import org.apache.oodt.cas.resource.system.ResourceManagerClient;
+import org.apache.oodt.cas.resource.system.rpc.ResourceManagerFactory;
 
 /**
  * A set of utility methods that can be used by PCS that need to
  * communicate with the Resource Manager.
- * 
+ *
  * @author mattmann
  * @version $Revision$
- * 
+ *
  */
 public class ResourceManagerUtils {
 
   /* our resource manager client */
-  private XmlRpcResourceManagerClient client;
+  private ResourceManagerClient client;
 
   /* our log stream */
   private static final Logger LOG = Logger.getLogger(ResourceManagerUtils.class
@@ -51,19 +52,19 @@ public class ResourceManagerUtils {
   }
 
   public ResourceManagerUtils(URL url) {
-    this.client = new XmlRpcResourceManagerClient(url);
+    this.client = ResourceManagerFactory.getResourceManagerClient(url);
     this.rmUrl = url;
 
   }
 
-  public ResourceManagerUtils(XmlRpcResourceManagerClient client) {
+  public ResourceManagerUtils(ResourceManagerClient client) {
     this.client = client;
   }
 
   /**
    * @return the client
    */
-  public XmlRpcResourceManagerClient getClient() {
+  public ResourceManagerClient getClient() {
     return client;
   }
 
@@ -71,7 +72,7 @@ public class ResourceManagerUtils {
    * @param client
    *          the client to set
    */
-  public void setClient(XmlRpcResourceManagerClient client) {
+  public void setClient(ResourceManagerClient client) {
     this.client = client;
     if (this.client != null) {
       this.rmUrl = this.client.getResMgrUrl();
@@ -90,7 +91,7 @@ public class ResourceManagerUtils {
   }
 
   /**
-   * 
+   *
    * @return The {@link URL} for the Resource Manager that this
    *         ResourceManagerUtils communicates with.
    */
diff --git 
a/resource/src/main/java/org/apache/oodt/cas/resource/cli/action/ResourceCliAction.java
 
b/resource/src/main/java/org/apache/oodt/cas/resource/cli/action/ResourceCliAction.java
index 114be7f..ed6761e 100644
--- 
a/resource/src/main/java/org/apache/oodt/cas/resource/cli/action/ResourceCliAction.java
+++ 
b/resource/src/main/java/org/apache/oodt/cas/resource/cli/action/ResourceCliAction.java
@@ -47,11 +47,7 @@ public abstract class ResourceCliAction extends 
CmdLineAction {
         if (client != null) {
             return client;
         } else {
-            try {
-                return ResourceManagerFactory.getResourceManagerClient(new 
URL(getUrl()));
-            } catch (Exception e) {
-                throw new IllegalStateException("Unable to create client", e);
-            }
+            return ResourceManagerFactory.getResourceManagerClient(new 
URL(getUrl()));
         }
     }
 
diff --git 
a/resource/src/main/java/org/apache/oodt/cas/resource/system/AvroRpcResourceManagerClient.java
 
b/resource/src/main/java/org/apache/oodt/cas/resource/system/AvroRpcResourceManagerClient.java
index 4dd0f33..dc6e3a6 100644
--- 
a/resource/src/main/java/org/apache/oodt/cas/resource/system/AvroRpcResourceManagerClient.java
+++ 
b/resource/src/main/java/org/apache/oodt/cas/resource/system/AvroRpcResourceManagerClient.java
@@ -46,7 +46,7 @@ public class AvroRpcResourceManagerClient implements 
ResourceManagerClient {
 
     /* our log stream */
     private static Logger LOG = Logger
-            .getLogger(XmlRpcResourceManagerClient.class.getName());
+            .getLogger(AvroRpcResourceManagerClient.class.getName());
 
     /* resource manager url */
     private URL resMgrUrl = null;
diff --git 
a/resource/src/main/java/org/apache/oodt/cas/resource/system/rpc/ResourceManagerFactory.java
 
b/resource/src/main/java/org/apache/oodt/cas/resource/system/rpc/ResourceManagerFactory.java
index 24f56b9..915447d 100644
--- 
a/resource/src/main/java/org/apache/oodt/cas/resource/system/rpc/ResourceManagerFactory.java
+++ 
b/resource/src/main/java/org/apache/oodt/cas/resource/system/rpc/ResourceManagerFactory.java
@@ -64,7 +64,7 @@ public class ResourceManagerFactory {
         return manager;
     }
 
-    public static ResourceManagerClient getResourceManagerClient(URL url) 
throws Exception {
+    public static ResourceManagerClient getResourceManagerClient(URL url) 
throws IllegalStateException {
         loadProperties();
         String resMgrClientClass = System.getProperty("resmgr.manager.client",
                 
"org.apache.oodt.cas.resource.system.AvroRpcResourceManagerClient");
@@ -77,7 +77,7 @@ public class ResourceManagerFactory {
             client = (ResourceManagerClient) constructor.newInstance(url);
         } catch (Exception e) {
             logger.error("Unable to create resource manager", e);
-            throw e;
+            throw new IllegalStateException("Unable to create client", e);
         }
 
         return client;

Reply via email to