Updated Branches:
  refs/heads/master 06a7b5744 -> b7db600f9

Implemented cartridge agent extension points initial version


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

Branch: refs/heads/master
Commit: b7db600f9f915f5e64a77071fc4c180bda7f1dc7
Parents: 06a7b57
Author: Imesh Gunaratne <[email protected]>
Authored: Wed Jan 1 08:43:57 2014 +0530
Committer: Imesh Gunaratne <[email protected]>
Committed: Wed Jan 1 08:43:57 2014 +0530

----------------------------------------------------------------------
 .../stratos/cartridge/agent/CartridgeAgent.java |  12 +++
 .../config/CartridgeAgentConfiguration.java     |  18 ----
 .../publisher/CartridgeAgentEventPublisher.java |   5 +
 .../agent/util/CartridgeAgentConstants.java     |   6 ++
 .../agent/util/CartridgeAgentUtils.java         |  19 ++++
 .../cartridge/agent/util/ExtensionUtils.java    | 101 +++++++++++++++++++
 .../apache/stratos/common/util/CommandUtil.java |  66 ++++++++++++
 .../load-balancer/haproxy-extension/pom.xml     |   5 +
 .../stratos/haproxy/extension/CommandUtil.java  |  66 ------------
 .../stratos/haproxy/extension/HAProxy.java      |   1 +
 .../extension/HAProxyStatisticsReader.java      |   1 +
 .../distribution/src/main/assembly/bin.xml      |  11 ++
 .../src/main/bin/cartridge-agent.sh             |   1 +
 .../src/main/extensions/artifacts-updated.sh    |  28 +++++
 .../src/main/extensions/instance-activated.sh   |  28 +++++
 .../src/main/extensions/instance-started.sh     |  27 +++++
 .../src/main/extensions/start-servers.sh        |  27 +++++
 17 files changed, 338 insertions(+), 84 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b7db600f/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/CartridgeAgent.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/CartridgeAgent.java
 
b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/CartridgeAgent.java
index 919de44..ada94f7 100644
--- 
a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/CartridgeAgent.java
+++ 
b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/CartridgeAgent.java
@@ -9,6 +9,7 @@ import 
org.apache.stratos.cartridge.agent.artifact.deployment.synchronizer.git.i
 import 
org.apache.stratos.cartridge.agent.event.publisher.CartridgeAgentEventPublisher;
 import org.apache.stratos.cartridge.agent.util.CartridgeAgentConstants;
 import org.apache.stratos.cartridge.agent.util.CartridgeAgentUtils;
+import org.apache.stratos.cartridge.agent.util.ExtensionUtils;
 import org.apache.stratos.messaging.event.Event;
 import 
org.apache.stratos.messaging.event.instance.notifier.ArtifactUpdatedEvent;
 import 
org.apache.stratos.messaging.listener.instance.notifier.ArtifactUpdateEventListener;
@@ -41,6 +42,11 @@ public class CartridgeAgent implements Runnable {
             throw new RuntimeException(String.format("System property not 
found: %s", CartridgeAgentConstants.PARAM_FILE_PATH));
         }
 
+        String extensionsDir = 
System.getProperty(CartridgeAgentConstants.EXTENSIONS_DIR);
+        if(StringUtils.isBlank(extensionsDir)) {
+            throw new RuntimeException(String.format("System property not 
found: %s", CartridgeAgentConstants.EXTENSIONS_DIR));
+        }
+
         // Start instance notifier listener thread
         if(log.isDebugEnabled()) {
             log.debug("Starting instance notifier event message receiver 
thread");
@@ -69,6 +75,9 @@ public class CartridgeAgent implements Runnable {
         // Publish instance started event
         CartridgeAgentEventPublisher.publishInstanceStartedEvent();
 
+        // Execute start servers extension
+        ExtensionUtils.executeStartServersExtension();
+
         // Wait for all ports to be active
         CartridgeAgentUtils.waitUntilPortsActive();
 
@@ -118,6 +127,9 @@ public class CartridgeAgent implements Runnable {
             repoInformation.setTenantId(tenantId);
             boolean cloneExists = 
GitBasedArtifactRepository.cloneExists(repoInformation);
             GitBasedArtifactRepository.checkout(repoInformation);
+
+            ExtensionUtils.executeArtifactsUpdatedExtension();
+
             if(!cloneExists){
                 // Executed git clone, publish instance activated event
                 CartridgeAgentEventPublisher.publishInstanceActivatedEvent();

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b7db600f/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/config/CartridgeAgentConfiguration.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/config/CartridgeAgentConfiguration.java
 
b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/config/CartridgeAgentConfiguration.java
index 65c3408..62acbca 100644
--- 
a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/config/CartridgeAgentConfiguration.java
+++ 
b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/config/CartridgeAgentConfiguration.java
@@ -27,8 +27,6 @@ public class CartridgeAgentConfiguration {
     private final String appPath;
     private final String repoUrl;
     private final List<Integer> ports;
-    private CharSequence mbIp;
-    private Object mbPort;
 
     private CartridgeAgentConfiguration() {
         serviceName = readParameterValue(CartridgeAgentConstants.SERVICE_NAME);
@@ -144,20 +142,4 @@ public class CartridgeAgentConfiguration {
     public List<Integer> getPorts() {
         return ports;
     }
-
-    public CharSequence getMbIp() {
-        return mbIp;
-    }
-
-    public void setMbIp(CharSequence mbIp) {
-        this.mbIp = mbIp;
-    }
-
-    public Object getMbPort() {
-        return mbPort;
-    }
-
-    public void setMbPort(Object mbPort) {
-        this.mbPort = mbPort;
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b7db600f/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/event/publisher/CartridgeAgentEventPublisher.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/event/publisher/CartridgeAgentEventPublisher.java
 
b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/event/publisher/CartridgeAgentEventPublisher.java
index 9e6372d..e7be139 100644
--- 
a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/event/publisher/CartridgeAgentEventPublisher.java
+++ 
b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/event/publisher/CartridgeAgentEventPublisher.java
@@ -4,6 +4,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.cartridge.agent.config.CartridgeAgentConfiguration;
 import 
org.apache.stratos.cartridge.agent.statistics.publisher.HealthStatisticsNotifier;
+import org.apache.stratos.cartridge.agent.util.ExtensionUtils;
 import org.apache.stratos.messaging.broker.publish.EventPublisher;
 import 
org.apache.stratos.messaging.event.instance.status.InstanceActivatedEvent;
 import org.apache.stratos.messaging.event.instance.status.InstanceStartedEvent;
@@ -35,6 +36,8 @@ public class CartridgeAgentEventPublisher {
             if (log.isInfoEnabled()) {
                 log.info("Instance started event published");
             }
+
+            ExtensionUtils.executeInstanceStartedExtension();
         } else {
             if (log.isWarnEnabled()) {
                 log.warn("Instance already started");
@@ -60,6 +63,8 @@ public class CartridgeAgentEventPublisher {
                 log.info("Instance activated event published");
             }
 
+            ExtensionUtils.executeInstanceActivatedExtension();
+
             if (log.isInfoEnabled()) {
                 log.info("Starting health statistics notifier");
             }

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b7db600f/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/CartridgeAgentConstants.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/CartridgeAgentConstants.java
 
b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/CartridgeAgentConstants.java
index 0992b51..dc24f28 100644
--- 
a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/CartridgeAgentConstants.java
+++ 
b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/CartridgeAgentConstants.java
@@ -25,6 +25,12 @@ public class CartridgeAgentConstants implements Serializable{
 
        public static final String JNDI_PROPERTIES_DIR = "jndi.properties.dir";
        public static final String PARAM_FILE_PATH = "param.file.path";
+    public static final String EXTENSIONS_DIR = "extensions.dir";
+
+    public static final String INSTANCE_STARTED_SH = "instance-started.sh";
+    public static final String START_SERVERS_SH = "start-servers.sh";
+    public static final String INSTANCE_ACTIVATED_SH = "instance-activated.sh";
+    public static final String ARTIFACTS_UPDATED_SH = "artifacts-updated.sh";
        
        public static final String CARTRIDGE_KEY = "CARTRIDGE_KEY";
        public static final String APP_PATH = "APP_PATH";

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b7db600f/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/CartridgeAgentUtils.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/CartridgeAgentUtils.java
 
b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/CartridgeAgentUtils.java
index 0137966..3650bb3 100644
--- 
a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/CartridgeAgentUtils.java
+++ 
b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/CartridgeAgentUtils.java
@@ -1,3 +1,22 @@
+/*
+ * 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.cartridge.agent.util;
 
 import org.apache.commons.codec.binary.Base64;

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b7db600f/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
new file mode 100644
index 0000000..ec17b52
--- /dev/null
+++ 
b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/ExtensionUtils.java
@@ -0,0 +1,101 @@
+/*
+ * 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.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 java.io.File;
+
+/**
+ * Cartridge agent extension utility methods.
+ */
+public class ExtensionUtils {
+    private static final Log log = LogFactory.getLog(ExtensionUtils.class);
+
+    private static String getExtensionsDir() {
+        String extensionsDir = 
System.getProperty(CartridgeAgentConstants.EXTENSIONS_DIR);
+        if(StringUtils.isBlank(extensionsDir)) {
+            throw new RuntimeException(String.format("System property not 
found: %s", CartridgeAgentConstants.EXTENSIONS_DIR));
+        }
+        return extensionsDir;
+    }
+
+    private static String prepareCommand(String scriptFile) {
+        String extensionsDir = getExtensionsDir();
+        return (extensionsDir.endsWith(File.separator)) ?
+                extensionsDir + scriptFile:
+                extensionsDir + File.separator + scriptFile;
+    }
+
+    public static void executeStartServersExtension() {
+        try {
+            if(log.isDebugEnabled()) {
+                log.debug("Executing start servers extension");
+            }
+            String command = 
prepareCommand(CartridgeAgentConstants.START_SERVERS_SH);
+            CommandUtil.executeCommand(command);
+        }
+        catch (Exception e) {
+            log.error("Could not execute start servers extension", e);
+        }
+    }
+
+    public static void executeInstanceStartedExtension() {
+        try {
+            if(log.isDebugEnabled()) {
+                log.debug("Executing instance started extension");
+            }
+            String command = 
prepareCommand(CartridgeAgentConstants.INSTANCE_STARTED_SH);
+            CommandUtil.executeCommand(command);
+        }
+        catch (Exception e) {
+            log.error("Could not execute instance started extension", e);
+        }
+    }
+
+    public static void executeInstanceActivatedExtension() {
+        try {
+            if(log.isDebugEnabled()) {
+                log.debug("Executing instance activated extension");
+            }
+            String command = 
prepareCommand(CartridgeAgentConstants.INSTANCE_ACTIVATED_SH);
+            CommandUtil.executeCommand(command);
+        }
+        catch (Exception e) {
+            log.error("Could not execute instance activated extension", e);
+        }
+    }
+
+    public static void executeArtifactsUpdatedExtension() {
+        try {
+            if(log.isDebugEnabled()) {
+                log.debug("Executing artifacts updated extension");
+            }
+            String command = 
prepareCommand(CartridgeAgentConstants.ARTIFACTS_UPDATED_SH);
+            CommandUtil.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/b7db600f/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
new file mode 100644
index 0000000..5afef73
--- /dev/null
+++ 
b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/util/CommandUtil.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 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/b7db600f/extensions/load-balancer/haproxy-extension/pom.xml
----------------------------------------------------------------------
diff --git a/extensions/load-balancer/haproxy-extension/pom.xml 
b/extensions/load-balancer/haproxy-extension/pom.xml
index 7c0ae5f..1e633c9 100644
--- a/extensions/load-balancer/haproxy-extension/pom.xml
+++ b/extensions/load-balancer/haproxy-extension/pom.xml
@@ -42,6 +42,11 @@
         </dependency>
         <dependency>
             <groupId>org.apache.stratos</groupId>
+            <artifactId>org.apache.stratos.common</artifactId>
+            <version>4.0.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.stratos</groupId>
             <artifactId>org.apache.stratos.messaging</artifactId>
             <version>4.0.0-SNAPSHOT</version>
         </dependency>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b7db600f/extensions/load-balancer/haproxy-extension/src/main/java/org/apache/stratos/haproxy/extension/CommandUtil.java
----------------------------------------------------------------------
diff --git 
a/extensions/load-balancer/haproxy-extension/src/main/java/org/apache/stratos/haproxy/extension/CommandUtil.java
 
b/extensions/load-balancer/haproxy-extension/src/main/java/org/apache/stratos/haproxy/extension/CommandUtil.java
deleted file mode 100644
index 2bb3074..0000000
--- 
a/extensions/load-balancer/haproxy-extension/src/main/java/org/apache/stratos/haproxy/extension/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.haproxy.extension;
-
-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/b7db600f/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 827d33a..8014fe3 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,6 +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.load.balancer.extension.api.LoadBalancer;
 import 
org.apache.stratos.load.balancer.extension.api.exception.LoadBalancerExtensionException;
 import org.apache.stratos.messaging.domain.topology.Topology;

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b7db600f/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 24fc423..1c80969 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,6 +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.load.balancer.common.statistics.LoadBalancerStatisticsReader;
 import org.apache.stratos.messaging.domain.topology.Cluster;
 import org.apache.stratos.messaging.domain.topology.Member;

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b7db600f/products/cartridge-agent/modules/distribution/src/main/assembly/bin.xml
----------------------------------------------------------------------
diff --git 
a/products/cartridge-agent/modules/distribution/src/main/assembly/bin.xml 
b/products/cartridge-agent/modules/distribution/src/main/assembly/bin.xml
index b61c0df..8eeb5b1 100644
--- a/products/cartridge-agent/modules/distribution/src/main/assembly/bin.xml
+++ b/products/cartridge-agent/modules/distribution/src/main/assembly/bin.xml
@@ -42,6 +42,17 @@
             </includes>
         </fileSet>
         <fileSet>
+            <directory>${project.basedir}/src/main/extensions</directory>
+            <outputDirectory>/extensions</outputDirectory>
+            <fileMode>0755</fileMode>
+            <includes>
+                <include>artifacts-updated.sh</include>
+                <include>instance-activated.sh</include>
+                <include>instance-started.sh</include>
+                <include>start-servers.sh</include>
+            </includes>
+        </fileSet>
+        <fileSet>
             <directory>${project.basedir}/src/main/conf/templates</directory>
             <outputDirectory>/conf/templates</outputDirectory>
             <fileMode>0600</fileMode>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b7db600f/products/cartridge-agent/modules/distribution/src/main/bin/cartridge-agent.sh
----------------------------------------------------------------------
diff --git 
a/products/cartridge-agent/modules/distribution/src/main/bin/cartridge-agent.sh 
b/products/cartridge-agent/modules/distribution/src/main/bin/cartridge-agent.sh
index b933c7d..a3cc4b4 100644
--- 
a/products/cartridge-agent/modules/distribution/src/main/bin/cartridge-agent.sh
+++ 
b/products/cartridge-agent/modules/distribution/src/main/bin/cartridge-agent.sh
@@ -32,6 +32,7 @@ properties="-Dmb.ip=MB-IP
             -Djndi.properties.dir=${script_path}/../conf
             
-Dlog4j.properties.file.path=${script_path}/../conf/log4j.properties
             
-Dparam.file.path=/opt/apache-stratos-cartridge-agent/payload/launch-params
+            -Dextensions.dir=${script_path}/../extensions
             -Dcep.stats.publisher.enabled=true
             -Djavax.net.ssl.trustStore=CERT-TRUSTSTORE
             -Djavax.net.ssl.trustStorePassword=TRUSTSTORE-PASSWORD"

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b7db600f/products/cartridge-agent/modules/distribution/src/main/extensions/artifacts-updated.sh
----------------------------------------------------------------------
diff --git 
a/products/cartridge-agent/modules/distribution/src/main/extensions/artifacts-updated.sh
 
b/products/cartridge-agent/modules/distribution/src/main/extensions/artifacts-updated.sh
new file mode 100644
index 0000000..7f112b1
--- /dev/null
+++ 
b/products/cartridge-agent/modules/distribution/src/main/extensions/artifacts-updated.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+# --------------------------------------------------------------
+#
+# 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.
+#
+# --------------------------------------------------------------
+# This extension script will be executed once the update artifacts
+# event is received and they are copied to the given path.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+echo "Artifacts updated" | tee -a $log
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b7db600f/products/cartridge-agent/modules/distribution/src/main/extensions/instance-activated.sh
----------------------------------------------------------------------
diff --git 
a/products/cartridge-agent/modules/distribution/src/main/extensions/instance-activated.sh
 
b/products/cartridge-agent/modules/distribution/src/main/extensions/instance-activated.sh
new file mode 100644
index 0000000..c892ca7
--- /dev/null
+++ 
b/products/cartridge-agent/modules/distribution/src/main/extensions/instance-activated.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+# --------------------------------------------------------------
+#
+# 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.
+#
+# --------------------------------------------------------------
+# This extension script will be executed once the instance is
+# activated and ready to serve incoming requests.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+echo "Instance activated" | tee -a $log
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b7db600f/products/cartridge-agent/modules/distribution/src/main/extensions/instance-started.sh
----------------------------------------------------------------------
diff --git 
a/products/cartridge-agent/modules/distribution/src/main/extensions/instance-started.sh
 
b/products/cartridge-agent/modules/distribution/src/main/extensions/instance-started.sh
new file mode 100644
index 0000000..b6c9105
--- /dev/null
+++ 
b/products/cartridge-agent/modules/distribution/src/main/extensions/instance-started.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+# --------------------------------------------------------------
+#
+# 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.
+#
+# --------------------------------------------------------------
+# This extension script will be executed once the instance is started.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+echo "Instance started" | tee -a $log
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b7db600f/products/cartridge-agent/modules/distribution/src/main/extensions/start-servers.sh
----------------------------------------------------------------------
diff --git 
a/products/cartridge-agent/modules/distribution/src/main/extensions/start-servers.sh
 
b/products/cartridge-agent/modules/distribution/src/main/extensions/start-servers.sh
new file mode 100644
index 0000000..1bb3f84
--- /dev/null
+++ 
b/products/cartridge-agent/modules/distribution/src/main/extensions/start-servers.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+# --------------------------------------------------------------
+#
+# 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.
+#
+# --------------------------------------------------------------
+# This extension script will be executed to start the servers.
+# --------------------------------------------------------------
+#
+
+log=/var/log/apache-stratos/cartridge-agent-extensions.log
+echo "Starting servers" | tee -a $log
\ No newline at end of file

Reply via email to