You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by im...@apache.org on 2014/01/01 04:23:34 UTC

git commit: Renamed CommandUtil to CommandUtils

Updated Branches:
  refs/heads/master b7db600f9 -> b2fccb20a


Renamed CommandUtil to CommandUtils


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

Branch: refs/heads/master
Commit: b2fccb20a1a20f06b1aece7db284a6e35327a39e
Parents: b7db600
Author: Imesh Gunaratne <im...@apache.org>
Authored: Wed Jan 1 08:53:10 2014 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Wed Jan 1 08:53:10 2014 +0530

----------------------------------------------------------------------
 .../cartridge/agent/util/ExtensionUtils.java    | 10 +--
 .../apache/stratos/common/util/CommandUtil.java | 66 --------------------
 .../stratos/common/util/CommandUtils.java       | 66 ++++++++++++++++++++
 .../stratos/haproxy/extension/HAProxy.java      |  8 +--
 .../extension/HAProxyStatisticsReader.java      |  4 +-
 5 files changed, 77 insertions(+), 77 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b2fccb20/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/ExtensionUtils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/ExtensionUtils.java b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/ExtensionUtils.java
index ec17b52..06b113f 100644
--- a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/ExtensionUtils.java
+++ b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/ExtensionUtils.java
@@ -22,7 +22,7 @@ package org.apache.stratos.cartridge.agent.util;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.common.util.CommandUtil;
+import org.apache.stratos.common.util.CommandUtils;
 
 import java.io.File;
 
@@ -53,7 +53,7 @@ public class ExtensionUtils {
                 log.debug("Executing start servers extension");
             }
             String command = prepareCommand(CartridgeAgentConstants.START_SERVERS_SH);
-            CommandUtil.executeCommand(command);
+            CommandUtils.executeCommand(command);
         }
         catch (Exception e) {
             log.error("Could not execute start servers extension", e);
@@ -66,7 +66,7 @@ public class ExtensionUtils {
                 log.debug("Executing instance started extension");
             }
             String command = prepareCommand(CartridgeAgentConstants.INSTANCE_STARTED_SH);
-            CommandUtil.executeCommand(command);
+            CommandUtils.executeCommand(command);
         }
         catch (Exception e) {
             log.error("Could not execute instance started extension", e);
@@ -79,7 +79,7 @@ public class ExtensionUtils {
                 log.debug("Executing instance activated extension");
             }
             String command = prepareCommand(CartridgeAgentConstants.INSTANCE_ACTIVATED_SH);
-            CommandUtil.executeCommand(command);
+            CommandUtils.executeCommand(command);
         }
         catch (Exception e) {
             log.error("Could not execute instance activated extension", e);
@@ -92,7 +92,7 @@ public class ExtensionUtils {
                 log.debug("Executing artifacts updated extension");
             }
             String command = prepareCommand(CartridgeAgentConstants.ARTIFACTS_UPDATED_SH);
-            CommandUtil.executeCommand(command);
+            CommandUtils.executeCommand(command);
         }
         catch (Exception e) {
             log.error("Could not execute artifacts updated extension", e);

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b2fccb20/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/util/CommandUtil.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/util/CommandUtil.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/util/CommandUtil.java
deleted file mode 100644
index 5afef73..0000000
--- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/util/CommandUtil.java
+++ /dev/null
@@ -1,66 +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.stratos.common.util;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-
-/**
- * A utility class for executing shell commands.
- */
-public class CommandUtil {
-    private static final Log log = LogFactory.getLog(CommandUtil.class);
-    private static final String NEW_LINE = System.getProperty("line.separator");
-
-    public static String executeCommand(String command) throws IOException {
-        String line;
-        Runtime r = Runtime.getRuntime();
-        if (log.isDebugEnabled()) {
-            log.debug("command = " + command);
-        }
-        Process p = r.exec(command);
-
-        StringBuilder output = new StringBuilder();
-        BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
-        while ((line = in.readLine()) != null) {
-            if (log.isDebugEnabled()) {
-                log.debug("output = " + line);
-            }
-            output.append(line).append(NEW_LINE);
-        }
-        StringBuilder errors = new StringBuilder();
-        BufferedReader error = new BufferedReader(new InputStreamReader(p.getErrorStream()));
-        while ((line = error.readLine()) != null) {
-            if (log.isDebugEnabled()) {
-                log.debug("error = " + line);
-            }
-            errors.append(line).append(NEW_LINE);
-        }
-        if (errors.length() > 0) {
-            throw new RuntimeException("Command execution failed: " + NEW_LINE + errors.toString());
-        }
-
-        return output.toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b2fccb20/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/util/CommandUtils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/util/CommandUtils.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/util/CommandUtils.java
new file mode 100644
index 0000000..0eaf369
--- /dev/null
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/util/CommandUtils.java
@@ -0,0 +1,66 @@
+/*
+ * 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.stratos.common.util;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+/**
+ * A utility class for executing shell commands.
+ */
+public class CommandUtils {
+    private static final Log log = LogFactory.getLog(CommandUtils.class);
+    private static final String NEW_LINE = System.getProperty("line.separator");
+
+    public static String executeCommand(String command) throws IOException {
+        String line;
+        Runtime r = Runtime.getRuntime();
+        if (log.isDebugEnabled()) {
+            log.debug("command = " + command);
+        }
+        Process p = r.exec(command);
+
+        StringBuilder output = new StringBuilder();
+        BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
+        while ((line = in.readLine()) != null) {
+            if (log.isDebugEnabled()) {
+                log.debug("output = " + line);
+            }
+            output.append(line).append(NEW_LINE);
+        }
+        StringBuilder errors = new StringBuilder();
+        BufferedReader error = new BufferedReader(new InputStreamReader(p.getErrorStream()));
+        while ((line = error.readLine()) != null) {
+            if (log.isDebugEnabled()) {
+                log.debug("error = " + line);
+            }
+            errors.append(line).append(NEW_LINE);
+        }
+        if (errors.length() > 0) {
+            throw new RuntimeException("Command execution failed: " + NEW_LINE + errors.toString());
+        }
+
+        return output.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b2fccb20/extensions/load-balancer/haproxy-extension/src/main/java/org/apache/stratos/haproxy/extension/HAProxy.java
----------------------------------------------------------------------
diff --git a/extensions/load-balancer/haproxy-extension/src/main/java/org/apache/stratos/haproxy/extension/HAProxy.java b/extensions/load-balancer/haproxy-extension/src/main/java/org/apache/stratos/haproxy/extension/HAProxy.java
index 8014fe3..75efdc2 100644
--- a/extensions/load-balancer/haproxy-extension/src/main/java/org/apache/stratos/haproxy/extension/HAProxy.java
+++ b/extensions/load-balancer/haproxy-extension/src/main/java/org/apache/stratos/haproxy/extension/HAProxy.java
@@ -21,7 +21,7 @@ package org.apache.stratos.haproxy.extension;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.common.util.CommandUtil;
+import org.apache.stratos.common.util.CommandUtils;
 import org.apache.stratos.load.balancer.extension.api.LoadBalancer;
 import org.apache.stratos.load.balancer.extension.api.exception.LoadBalancerExtensionException;
 import org.apache.stratos.messaging.domain.topology.Topology;
@@ -71,7 +71,7 @@ public class HAProxy implements LoadBalancer {
 
             // Execute hot configuration deployment
             String command = executableFilePath + " -f " + confFilePath + " -p " + processIdFilePath + " -sf " + pid;
-            CommandUtil.executeCommand(command);
+            CommandUtils.executeCommand(command);
             if (log.isInfoEnabled()) {
                 log.info("Configuration done");
             }
@@ -120,7 +120,7 @@ public class HAProxy implements LoadBalancer {
         // Start haproxy and write pid to processIdFilePath
         try {
             String command = executableFilePath + " -f " + confFilePath + " -p " + processIdFilePath;
-            CommandUtil.executeCommand(command);
+            CommandUtils.executeCommand(command);
             if (log.isInfoEnabled()) {
                 log.info("haproxy started");
             }
@@ -146,7 +146,7 @@ public class HAProxy implements LoadBalancer {
             // Kill all haproxy processes
             for (String pid : pids) {
                 String command = "kill -s 9 " + pid;
-                CommandUtil.executeCommand(command);
+                CommandUtils.executeCommand(command);
                 if (log.isInfoEnabled()) {
                     log.info(String.format("haproxy stopped [pid] %s", pid));
                 }

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b2fccb20/extensions/load-balancer/haproxy-extension/src/main/java/org/apache/stratos/haproxy/extension/HAProxyStatisticsReader.java
----------------------------------------------------------------------
diff --git a/extensions/load-balancer/haproxy-extension/src/main/java/org/apache/stratos/haproxy/extension/HAProxyStatisticsReader.java b/extensions/load-balancer/haproxy-extension/src/main/java/org/apache/stratos/haproxy/extension/HAProxyStatisticsReader.java
index 1c80969..b38aa3c 100644
--- a/extensions/load-balancer/haproxy-extension/src/main/java/org/apache/stratos/haproxy/extension/HAProxyStatisticsReader.java
+++ b/extensions/load-balancer/haproxy-extension/src/main/java/org/apache/stratos/haproxy/extension/HAProxyStatisticsReader.java
@@ -21,7 +21,7 @@ package org.apache.stratos.haproxy.extension;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.common.util.CommandUtil;
+import org.apache.stratos.common.util.CommandUtils;
 import org.apache.stratos.load.balancer.common.statistics.LoadBalancerStatisticsReader;
 import org.apache.stratos.messaging.domain.topology.Cluster;
 import org.apache.stratos.messaging.domain.topology.Member;
@@ -67,7 +67,7 @@ public class HAProxyStatisticsReader implements LoadBalancerStatisticsReader {
                             // echo "get weight <backend>/<server>" | socat stdio <stats-socket>
                             command = String.format("%s/get-weight.sh %s %s %s", scriptsPath, backendId, member.getMemberId(), statsSocketFilePath);
                             try {
-                                output = CommandUtil.executeCommand(command);
+                                output = CommandUtils.executeCommand(command);
                                 if ((output != null) && (output.length() > 0)) {
                                     array = output.split(" ");
                                     if ((array != null) && (array.length > 0)) {