stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject stratos git commit: Update the INSTALL.md file and samples
Date Fri, 22 May 2015 09:12:23 GMT
Repository: stratos
Updated Branches:
  refs/heads/lvs_extension 168b258cd -> f5bb41e92


Update the INSTALL.md file and samples


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

Branch: refs/heads/lvs_extension
Commit: f5bb41e924707b01379dd7a14348b9f732cd8b04
Parents: 168b258
Author: Gayan Gunarathne <gayang@wso2.com>
Authored: Fri May 22 14:41:55 2015 +0530
Committer: Gayan Gunarathne <gayang@wso2.com>
Committed: Fri May 22 14:41:55 2015 +0530

----------------------------------------------------------------------
 .../apache/stratos/cartridge/agent/Main.java    |  29 +++++
 .../stratos/common/util/CommandUtils.java       |  30 +++++
 .../extensions/bash/CreateLVSDummyInterface.sh  |   0
 .../src/test/resources/payload/launch-params    |   2 +-
 .../src/test/resources/payload/launch-params2   |   2 +-
 .../load-balancer/lvs-extension/INSTALL.md      |  23 ++--
 .../org/apache/stratos/lvs/extension/LVS.java   |   8 +-
 .../lvs/extension/LVSStatisticsReader.java      | 130 +++++++------------
 .../org/apache/stratos/lvs/extension/Main.java  |   2 +-
 .../src/test/resources/JMSOutputAdaptor.xml     |   2 +-
 .../artifacts/application.json                  |  12 +-
 .../artifacts/application.json                  |   5 +-
 .../single-group-app/artifacts/application.json |   6 +-
 samples/cartridges/mock/php.json                |   2 +-
 samples/cartridges/mock/tomcat.json             |   5 +
 samples/cartridges/openstack/php.json           |  10 +-
 samples/cartridges/openstack/tomcat.json        |   7 +-
 17 files changed, 155 insertions(+), 120 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/f5bb41e9/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/Main.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/Main.java
b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/Main.java
index 4bb1b89..d72fd76 100644
--- a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/Main.java
+++ b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/Main.java
@@ -23,9 +23,11 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.log4j.PropertyConfigurator;
 import org.apache.stratos.cartridge.agent.config.CartridgeAgentConfiguration;
+import org.apache.stratos.common.util.CommandUtils;
 import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
 import org.apache.stratos.messaging.util.MessagingUtil;
 
+import java.io.IOException;
 import java.lang.reflect.Constructor;
 
 /**
@@ -37,6 +39,33 @@ public class Main {
     private static CartridgeAgent cartridgeAgent = null;
 
     public static void main(String[] args) {
+
+	    String output;
+	    String[] array;
+	    int totalWeight = 0, weight;
+
+
+			    String[] command = { "/bin/sh", "-c","sudo ipvsadm -l --stats | grep TCP"};
+			    try {
+				    output = CommandUtils.executeCommand(command);
+				    if ((output != null) && (output.length() > 0)) {
+					    array = output.split("\n");
+					    for (int i = 0; i < array.length; i++) {
+						   weight=Integer.parseInt(array[i].substring(38,42).toString().trim());
+						   totalWeight += weight;
+						   }
+				    }
+			    } catch (IOException e) {
+				    if (log.isErrorEnabled()) {
+					    log.error(e);
+				    }
+			    }
+			    if (log.isInfoEnabled()) {
+				    log.info(String.format("Cluster weight found: [cluster] %s [weight] %d","",
+				                           totalWeight));
+
+		        }
+
         try {
             // Add shutdown hook
             final Thread mainThread = Thread.currentThread();

http://git-wip-us.apache.org/repos/asf/stratos/blob/f5bb41e9/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
index d581057..4168afe 100644
--- 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
@@ -65,6 +65,36 @@ public class CommandUtils {
         return output.toString();
     }
 
+	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();
+	}
     public static String executeCommand(String command, Map<String, String> envParameters)
throws IOException {
         String line;
         ProcessBuilder pb = new ProcessBuilder(command);

http://git-wip-us.apache.org/repos/asf/stratos/blob/f5bb41e9/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CreateLVSDummyInterface.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CreateLVSDummyInterface.sh
b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CreateLVSDummyInterface.sh
old mode 100644
new mode 100755

http://git-wip-us.apache.org/repos/asf/stratos/blob/f5bb41e9/components/org.apache.stratos.python.cartridge.agent/src/test/resources/payload/launch-params
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/test/resources/payload/launch-params
b/components/org.apache.stratos.python.cartridge.agent/src/test/resources/payload/launch-params
index 00ce19c..a2df82b 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/test/resources/payload/launch-params
+++ b/components/org.apache.stratos.python.cartridge.agent/src/test/resources/payload/launch-params
@@ -1 +1 @@
-APPLICATION_ID=single_group_v1,APPLICATION_PATH=/tmp/tomcat/webapps,BASH=/bin/bash,BASHOPTS=cmdhist:complete_fullquote:extquote:force_fignore:hostcomplete:interactive_comments:progcomp:promptvars:sourcepath,BASH_ALIASES=(),BASH_ARGC=(),BASH_ARGV=(),BASH_CMDS=(),BASH_LINENO=([0]="0"),BASH_SOURCE=([0]="/usr/local/bin/populate-user-data.sh"),BASH_VERSINFO=([0]="4"
[1]="3" [2]="30" [3]="1" [4]="release" [5]="x86_64-pc-linux-gnu"),BASH_VERSION='4.3.30(1)-release',CARTRIDGE_ALIAS=mytomcat,CARTRIDGE_KEY=PUjpXCLujDhYr5A6,CATALINA_HOME=/opt/tomcat,CEP_IP=54.179.197.243,CEP_PORT=7711,CLUSTER_ID=php.php.domain,CLUSTER_INSTANCE_ID=single_group_v1-1,DEPENDENCY_CLUSTER_IDS=myphp.php.domain,DEPLOYMENT=default,DIRSTACK=(),EUID=0,GROUPS=(),GROUP_NAME=null,HOME=/root,HOSTNAME=mytomcat-tomcat-domain3bd3cd47-b95d-475a-aa11-3e3ddc089d49,HOSTTYPE=x86_64,HOST_NAME=mytomcat.tomcat.stratos.org,IFS='
	,',INSTANCE_ID=null,INTERNAL=false,JAVA_HOME=/opt/jdk1.7.0_67,KUBERNETES_CLUSTER_ID=kubernetes-cluster-1,KUB
 ERNETES_PORT=tcp://10.100.0.2:443,KUBERNETES_PORT_443_TCP=tcp://10.100.0.2:443,KUBERNETES_PORT_443_TCP_ADDR=10.100.0.2,KUBERNETES_PORT_443_TCP_PORT=443,KUBERNETES_PORT_443_TCP_PROTO=tcp,KUBERNETES_RO_PORT=tcp://10.100.0.1:80,KUBERNETES_RO_PORT_80_TCP=tcp://10.100.0.1:80,KUBERNETES_RO_PORT_80_TCP_ADDR=10.100.0.1,KUBERNETES_RO_PORT_80_TCP_PORT=80,KUBERNETES_RO_PORT_80_TCP_PROTO=tcp,KUBERNETES_RO_SERVICE_HOST=10.100.0.1,KUBERNETES_RO_SERVICE_PORT=80,KUBERNETES_SERVICE_HOST=10.100.0.2,KUBERNETES_SERVICE_PORT=443,LB_CLUSTER_ID=null,LOG_LEVEL=DEBUG,MACHTYPE=x86_64-pc-linux-gnu,MB_IP=54.179.197.243,MB_PORT=1883,MEMBER_ID=php.member-1,MIN_COUNT=1,MULTITENANT=false,MYPHP_PHP_DOMAIN_1_PORT=tcp://10.100.171.218:4500,MYPHP_PHP_DOMAIN_1_PORT_4500_TCP=tcp://10.100.171.218:4500,MYPHP_PHP_DOMAIN_1_PORT_4500_TCP_ADDR=10.100.171.218,MYPHP_PHP_DOMAIN_1_PORT_4500_TCP_PORT=4500,MYPHP_PHP_DOMAIN_1_PORT_4500_TCP_PROTO=tcp,MYPHP_PHP_DOMAIN_1_SERVICE_HOST=10.100.171.218,MYPHP_PHP_DOMAIN_1_SERVICE_PORT=4500,
 MYTOMCAT_TOMCAT_DOMAIN_1_PORT=tcp://10.100.16.250:4500,MYTOMCAT_TOMCAT_DOMAIN_1_PORT_4500_TCP=tcp://10.100.16.250:4500,MYTOMCAT_TOMCAT_DOMAIN_1_PORT_4500_TCP_ADDR=10.100.16.250,MYTOMCAT_TOMCAT_DOMAIN_1_PORT_4500_TCP_PORT=4500,MYTOMCAT_TOMCAT_DOMAIN_1_PORT_4500_TCP_PROTO=tcp,MYTOMCAT_TOMCAT_DOMAIN_1_SERVICE_HOST=10.100.16.250,MYTOMCAT_TOMCAT_DOMAIN_1_SERVICE_PORT=4500,NETWORK_PARTITION_ID=network-partition-1,OPTERR=1,OPTIND=1,OSTYPE=linux-gnu,PARTITION_ID=partition-1,PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin,PIPESTATUS=([0]="0"),PORTS=8080,POSIXLY_CORRECT=y,PPID=14,PRIMARY=false,PROVIDER=apache,PS4='+
',PUPPET_DNS_AVAILABLE=null,PUPPET_ENV=false,PUPPET_HOSTNAME=puppet.apache.stratos.org,PUPPET_IP=127.0.0.1,PWD=/opt,REPO_URL=https://github.com/imesh/stratos-tomcat-applications.git,SERVICE_NAME=php,SHELL=/bin/bash,SHELLOPTS=braceexpand:hashall:interactive-comments:posix,SHLVL=2,TENANT_ID=-1234,TENANT_RANGE='*',TERM=dumb,TOKEN=eyJhbGciOiJSUzI1NiJ9.eyJleHAiOi04NzI
 0ODEyNDEsInN1YiI6ImFkbWluIiwiYXpwIjoid3I5SllVaDNtTXd6bVhHVllqWmVIWnhCV2xFYSIsImFwcElkIjoic2luZ2xlX2dyb3VwX3YxIiwiYXVkIjpbIndyOUpZVWgzbU13em1YR1ZZalplSFp4QldsRWEiXSwiaXNzIjoiaHR0cHM6XC9cL2xvY2FsaG9zdDo5NDQzXC9vYXV0aDJlbmRwb2ludHNcL3Rva2VuIiwiaWF0IjotODcyNDgwMjQwfQ.OSa1gIXUT9amhk1YEU02Yc3JtUYqanzrXh5K1YyvRXcpSiY2Ccn2BfJO0hILF5UooRcGBihzfX3979NRcvGwcUDUvOUJ0eaGPmxFZYbu0nr3xD8lhAO3fa1QYsKAvMnMdwyu2uSgSp6R6EUdVleiwlabUoDsuEcKGkIAn_VQvG0,UID=0,_=posix
\ No newline at end of file
+APPLICATION_ID=single_group_v1,APPLICATION_PATH=/tmp/tomcat/webapps,BASH=/bin/bash,BASHOPTS=cmdhist:complete_fullquote:extquote:force_fignore:hostcomplete:interactive_comments:progcomp:promptvars:sourcepath,BASH_ALIASES=(),BASH_ARGC=(),BASH_ARGV=(),BASH_CMDS=(),BASH_LINENO=([0]="0"),BASH_SOURCE=([0]="/usr/local/bin/populate-user-data.sh"),BASH_VERSINFO=([0]="4"
[1]="3" [2]="30" [3]="1" [4]="release" [5]="x86_64-pc-linux-gnu"),BASH_VERSION='4.3.30(1)-release',CARTRIDGE_ALIAS=mytomcat,CARTRIDGE_KEY=PUjpXCLujDhYr5A6,CATALINA_HOME=/opt/tomcat,CEP_IP=54.179.197.243,CEP_PORT=7711,CLUSTER_ID=php.php.domain,CLUSTER_INSTANCE_ID=single_group_v1-1,DEPENDENCY_CLUSTER_IDS=myphp.php.domain,DEPLOYMENT=default,DIRSTACK=(),EUID=0,GROUPS=(),GROUP_NAME=null,HOME=/root,HOSTNAME=mytomcat-tomcat-domain3bd3cd47-b95d-475a-aa11-3e3ddc089d49,HOSTTYPE=x86_64,HOST_NAME=mytomcat.tomcat.stratos.org,IFS='
	,',INSTANCE_ID=null,INTERNAL=false,JAVA_HOME=/opt/jdk1.7.0_67,KUBERNETES_CLUSTER_ID=kubernetes-cluster-1,KUB
 ERNETES_PORT=tcp://10.100.0.2:443,KUBERNETES_PORT_443_TCP=tcp://10.100.0.2:443,KUBERNETES_PORT_443_TCP_ADDR=10.100.0.2,KUBERNETES_PORT_443_TCP_PORT=443,KUBERNETES_PORT_443_TCP_PROTO=tcp,KUBERNETES_RO_PORT=tcp://10.100.0.1:80,KUBERNETES_RO_PORT_80_TCP=tcp://10.100.0.1:80,KUBERNETES_RO_PORT_80_TCP_ADDR=10.100.0.1,KUBERNETES_RO_PORT_80_TCP_PORT=80,KUBERNETES_RO_PORT_80_TCP_PROTO=tcp,KUBERNETES_RO_SERVICE_HOST=10.100.0.1,KUBERNETES_RO_SERVICE_PORT=80,KUBERNETES_SERVICE_HOST=10.100.0.2,KUBERNETES_SERVICE_PORT=443,LB_CLUSTER_ID=null,LOG_LEVEL=DEBUG,MACHTYPE=x86_64-pc-linux-gnu,MB_IP=54.179.197.243,MB_PORT=1883,MEMBER_ID=php.member-1,MIN_COUNT=1,MULTITENANT=false,MYPHP_PHP_DOMAIN_1_PORT=tcp://10.100.171.218:4500,MYPHP_PHP_DOMAIN_1_PORT_4500_TCP=tcp://10.100.171.218:4500,MYPHP_PHP_DOMAIN_1_PORT_4500_TCP_ADDR=10.100.171.218,MYPHP_PHP_DOMAIN_1_PORT_4500_TCP_PORT=4500,MYPHP_PHP_DOMAIN_1_PORT_4500_TCP_PROTO=tcp,MYPHP_PHP_DOMAIN_1_SERVICE_HOST=10.100.171.218,MYPHP_PHP_DOMAIN_1_SERVICE_PORT=4500,
 MYTOMCAT_TOMCAT_DOMAIN_1_PORT=tcp://10.100.16.250:4500,MYTOMCAT_TOMCAT_DOMAIN_1_PORT_4500_TCP=tcp://10.100.16.250:4500,MYTOMCAT_TOMCAT_DOMAIN_1_PORT_4500_TCP_ADDR=10.100.16.250,MYTOMCAT_TOMCAT_DOMAIN_1_PORT_4500_TCP_PORT=4500,MYTOMCAT_TOMCAT_DOMAIN_1_PORT_4500_TCP_PROTO=tcp,MYTOMCAT_TOMCAT_DOMAIN_1_SERVICE_HOST=10.100.16.250,MYTOMCAT_TOMCAT_DOMAIN_1_SERVICE_PORT=4500,NETWORK_PARTITION_ID=network-partition-1,OPTERR=1,OPTIND=1,OSTYPE=linux-gnu,PARTITION_ID=partition-1,PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin,PIPESTATUS=([0]="0"),PORTS=8080,POSIXLY_CORRECT=y,PPID=14,PRIMARY=false,PROVIDER=apache,PS4='+
',PUPPET_DNS_AVAILABLE=null,PUPPET_ENV=false,PUPPET_HOSTNAME=puppet.apache.stratos.org,PUPPET_IP=127.0.0.1,PWD=/opt,REPO_URL=https://github.com/imesh/stratos-tomcat-applications.git,SERVICE_NAME=php,SHELL=/bin/bash,SHELLOPTS=braceexpand:hashall:interactive-comments:posix,SHLVL=2,TENANT_ID=-1234,TENANT_RANGE='*',TERM=dumb,TOKEN=eyJhbGciOiJSUzI1NiJ9.eyJleHAiOi04NzI
 0ODEyNDEsInN1YiI6ImFkbWluIiwiYXpwIjoid3I5SllVaDNtTXd6bVhHVllqWmVIWnhCV2xFYSIsImFwcElkIjoic2luZ2xlX2dyb3VwX3YxIiwiYXVkIjpbIndyOUpZVWgzbU13em1YR1ZZalplSFp4QldsRWEiXSwiaXNzIjoiaHR0cHM6XC9cL2xvY2FsaG9zdDo5NDQzXC9vYXV0aDJlbmRwb2ludHNcL3Rva2VuIiwiaWF0IjotODcyNDgwMjQwfQ.OSa1gIXUT9amhk1YEU02Yc3JtUYqanzrXh5K1YyvRXcpSiY2Ccn2BfJO0hILF5UooRcGBihzfX3979NRcvGwcUDUvOUJ0eaGPmxFZYbu0nr3xD8lhAO3fa1QYsKAvMnMdwyu2uSgSp6R6EUdVleiwlabUoDsuEcKGkIAn_VQvG0,UID=0,_=posix,LVS_VIRTUAL_IP=192.168.0.40
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/f5bb41e9/components/org.apache.stratos.python.cartridge.agent/src/test/resources/payload/launch-params2
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/test/resources/payload/launch-params2
b/components/org.apache.stratos.python.cartridge.agent/src/test/resources/payload/launch-params2
index 9e67ebd..5c31d1f 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/test/resources/payload/launch-params2
+++ b/components/org.apache.stratos.python.cartridge.agent/src/test/resources/payload/launch-params2
@@ -15,4 +15,4 @@
 # specific language governing permissions and limitations
 # under the License.
 
-APPLICATION_ID=application1,SERVICE_NAME=php,HOST_NAME=php.php.stratos.org,MULTITENANT=false,TENANT_ID=-1234,TENANT_RANGE=*,CARTRIDGE_ALIAS=php,CLUSTER_ID=php.php.domain,CLUSTER_INSTANCE_ID=single-cartridge-app-1,CARTRIDGE_KEY=PUjpXCLujDhYr5A6,DEPLOYMENT=default,REPO_URL=https://github.com/imesh/stratos-php-applications.git,PORTS=9080,PUPPET_IP=127.0.0.1,PUPPET_HOSTNAME=puppet.apache.stratos.org,PUPPET_ENV=false,MEMBER_ID=php.member-1,LB_CLUSTER_ID=null,NETWORK_PARTITION_ID=network-p1,PARTITION_ID=p1,APPLICATION_PATH=/tmp/stratos-pca-test-app-path/,MIN_COUNT=1,INTERNAL=false,CLUSTERING_PRIMARY_KEY=A,LOG_FILE_PATHS=/tmp/temp.log,PERSISTENCE_MAPPING=null,MP_IP=192.168.1.4,MB_PORT=1883
\ No newline at end of file
+APPLICATION_ID=application1,SERVICE_NAME=php,HOST_NAME=php.php.stratos.org,MULTITENANT=false,TENANT_ID=-1234,TENANT_RANGE=*,CARTRIDGE_ALIAS=php,CLUSTER_ID=php.php.domain,CLUSTER_INSTANCE_ID=single-cartridge-app-1,CARTRIDGE_KEY=PUjpXCLujDhYr5A6,DEPLOYMENT=default,REPO_URL=https://github.com/imesh/stratos-php-applications.git,PORTS=9080,PUPPET_IP=127.0.0.1,PUPPET_HOSTNAME=puppet.apache.stratos.org,PUPPET_ENV=false,MEMBER_ID=php.member-1,LB_CLUSTER_ID=null,NETWORK_PARTITION_ID=network-p1,PARTITION_ID=p1,APPLICATION_PATH=/tmp/stratos-pca-test-app-path/,MIN_COUNT=1,INTERNAL=false,CLUSTERING_PRIMARY_KEY=A,LOG_FILE_PATHS=/tmp/temp.log,PERSISTENCE_MAPPING=null,MP_IP=192.168.1.4,MB_PORT=1883,LVS_VIRTUAL_IP=192.168.0.40
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/f5bb41e9/extensions/load-balancer/lvs-extension/INSTALL.md
----------------------------------------------------------------------
diff --git a/extensions/load-balancer/lvs-extension/INSTALL.md b/extensions/load-balancer/lvs-extension/INSTALL.md
index 3e0aa5a..2b3f491 100644
--- a/extensions/load-balancer/lvs-extension/INSTALL.md
+++ b/extensions/load-balancer/lvs-extension/INSTALL.md
@@ -1,19 +1,18 @@
 # Installing Apache Stratos Nginx Extension
 
-Apache Stratos Nginx Extension could be used for integrating Nginx load balancer with Apache
Stratos. Please follow
+Apache Stratos LVS Extension could be used for integrating LVS load balancer with Apache
Stratos. Please follow
 below steps to proceed with the installation:
 
-1. Download and extract Nginx binary distribution to a desired location: <nginx-home>.
+1. Install keepalived and ipvsadm
+   apt-get install keepalived ipvsadm
 
-2. Extract org.apache.stratos.nginx.extension-<version>.zip to a desired location:
<nginx-extension-home>.
-
-3. Open <nginx-extension-home>/bin/nginx-extension.sh file in a text editor and update
following system properties:
+2. Open <lvs-extension-home>/bin/lvs-extension.sh file in a text editor and update
following system properties:
    ```
    # Define nginx host private ip address:
-   -Dnginx.private.ip=127.0.0.1
+   -Dlvs.private.ip=127.0.0.1
 
    # Define the nginx executable file path:
-   -Dexecutable.file.path=<nginx-home>/nginx
+   -Dexecutable.file.path=<lvs-home>/nginx
 
    # Enable/disable cep statistics publisher:
    -Dcep.stats.publisher.enabled=false
@@ -22,12 +21,18 @@ below steps to proceed with the installation:
    -Dthrift.receiver.ip=127.0.0.1
    -Dthrift.receiver.port=7615
    -Dnetwork.partition.id=network-partition-1
+
+   # LVS server Virtual IP set for services
+   -Dlvs.service.virtualip.set=tomcat2|192.168.56.40,tomcat1|192.168.56.41,tomcat|192.168.56.40
+   # Server state (MASTER|BACKUP)
+   -Dserver.state=MASTER
+
    ```
 
-4. Open <nginx-extension-home>/conf/jndi.properties file in a text editor and update
message broker information:
+4. Open <lvs-extension-home>/conf/jndi.properties file in a text editor and update
message broker information:
    ```
    java.naming.provider.url=tcp://localhost:61616
    ```
 
-5. Run <nginx-extension-home>/bin/nginx-extension.sh as the root user.
+5. Run <lvs-extension-home>/bin/lvs-extension.sh as the root user.
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/f5bb41e9/extensions/load-balancer/lvs-extension/src/main/java/org/apache/stratos/lvs/extension/LVS.java
----------------------------------------------------------------------
diff --git a/extensions/load-balancer/lvs-extension/src/main/java/org/apache/stratos/lvs/extension/LVS.java
b/extensions/load-balancer/lvs-extension/src/main/java/org/apache/stratos/lvs/extension/LVS.java
index 3dce7e7..257a60e 100644
--- a/extensions/load-balancer/lvs-extension/src/main/java/org/apache/stratos/lvs/extension/LVS.java
+++ b/extensions/load-balancer/lvs-extension/src/main/java/org/apache/stratos/lvs/extension/LVS.java
@@ -64,7 +64,7 @@ public class LVS implements LoadBalancer {
      */
     public boolean configure(Topology topology) throws LoadBalancerExtensionException {
         try {
-            log.info("Generating nginx configuration...");
+            log.info("Generating lvs configuration...");
             LVSConfigWriter writer = new LVSConfigWriter(templatePath, templateName, confFilePath,
statsSocketFilePath,
                                                          virtualIPsForServices,serverState);
             if(writer.write(topology)) {
@@ -72,13 +72,13 @@ public class LVS implements LoadBalancer {
             }
             return false;
         } catch (Exception e) {
-            log.error("Could not generate nginx configuration");
+            log.error("Could not generate lvs configuration");
             throw new LoadBalancerExtensionException(e);
         }
     }
 
     /**
-     * Start nginx instance
+     * Start lvs instance
      * @throws LoadBalancerExtensionException
      */
     public void start() throws LoadBalancerExtensionException {
@@ -123,7 +123,7 @@ public class LVS implements LoadBalancer {
     }
 
     /**
-     * Stop nginx instance
+     * Stop lvs instance
      * @throws LoadBalancerExtensionException
      */
     public void stop() throws LoadBalancerExtensionException {

http://git-wip-us.apache.org/repos/asf/stratos/blob/f5bb41e9/extensions/load-balancer/lvs-extension/src/main/java/org/apache/stratos/lvs/extension/LVSStatisticsReader.java
----------------------------------------------------------------------
diff --git a/extensions/load-balancer/lvs-extension/src/main/java/org/apache/stratos/lvs/extension/LVSStatisticsReader.java
b/extensions/load-balancer/lvs-extension/src/main/java/org/apache/stratos/lvs/extension/LVSStatisticsReader.java
index b3b1fa4..f707090 100644
--- a/extensions/load-balancer/lvs-extension/src/main/java/org/apache/stratos/lvs/extension/LVSStatisticsReader.java
+++ b/extensions/load-balancer/lvs-extension/src/main/java/org/apache/stratos/lvs/extension/LVSStatisticsReader.java
@@ -21,106 +21,64 @@ package org.apache.stratos.lvs.extension;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.conn.HttpHostConnectException;
-import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.stratos.common.util.CommandUtils;
 import org.apache.stratos.load.balancer.common.domain.Cluster;
-import org.apache.stratos.load.balancer.common.domain.Port;
-import org.apache.stratos.load.balancer.common.domain.Service;
 import org.apache.stratos.load.balancer.common.statistics.LoadBalancerStatisticsReader;
 import org.apache.stratos.load.balancer.common.topology.TopologyProvider;
 
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+import java.io.IOException;
 
 /**
  * LVS statistics reader.
  */
 public class LVSStatisticsReader implements LoadBalancerStatisticsReader {
 
-    private static final Log log = LogFactory.getLog(LVSStatisticsReader.class);
+	private static final Log log = LogFactory.getLog(LVSStatisticsReader.class);
+	private static final String IPVSADM_STATS_COMMAND = "sudo ipvsadm -l --stats | grep TCP";
 
-    private TopologyProvider topologyProvider;
+	private TopologyProvider topologyProvider;
 
-    public LVSStatisticsReader(TopologyProvider topologyProvider) {
-        this.topologyProvider = topologyProvider;
-    }
+	public LVSStatisticsReader(TopologyProvider topologyProvider) {
+		this.topologyProvider = topologyProvider;
+	}
 
-    @Override
-    public int getInFlightRequestCount(String clusterId) {
-        Cluster cluster = topologyProvider.getClusterByClusterId(clusterId);
-        if(cluster != null) {
-            String serviceName = cluster.getServiceName();
-            Service service = topologyProvider.getTopology().getService(serviceName);
-            if(service != null) {
-                int inFlightRequestCount = 0;
-                for(Port port : service.getPorts()) {
-                    inFlightRequestCount += findWritingCount(port.getProxy());
-                }
-                if(log.isDebugEnabled()) {
-                    log.debug(String.format("In-flight request count: [cluster-id] %s [value]
%d",
-                            clusterId, inFlightRequestCount));
-                }
-                return inFlightRequestCount;
-            }
-        }
-        return 0;
-    }
+	@Override
+	public int getInFlightRequestCount(String clusterId) {
+		String output;
+		String[] array;
+		int totalWeight = 0, weight;
 
-    /**
-     * Make a http request to http://127.0.0.1:<proxy-port>/nginx_status and find writing
count.
-     * @param proxyPort
-     * @return
-     */
-    private int findWritingCount(int proxyPort) {
-        try {
-            URL url = new URL("http", "127.0.0.1", proxyPort, "/nginx_status");
-            DefaultHttpClient httpClient = new DefaultHttpClient();
-            HttpUriRequest request = new HttpGet(url.toURI());
-            HttpResponse response = httpClient.execute(request);
-            if (response.getStatusLine().getStatusCode() != 200) {
-                throw new RuntimeException("http://127.0.0.1:" + proxyPort + "/nginx_status
was not found");
-            }
-            BufferedReader reader = new BufferedReader(new InputStreamReader(
-                    (response.getEntity().getContent())));
-            String output, result = "";
-            while ((output = reader.readLine()) != null) {
-                result += output;
-            }
-            Pattern pattern = Pattern.compile("(Writing: )([0-1]*)");
-            Matcher matcher = pattern.matcher(result);
-            if (matcher.find()) {
-                // Deduct one to remove the above request
-                int writingCount = Integer.parseInt(matcher.group(2)) - 1;
-                if(log.isDebugEnabled()) {
-                    log.debug(String.format("Writing count: [proxy] %d [value] %d", proxyPort,
writingCount));
-                }
-                return writingCount;
-            }
-            throw new RuntimeException("Writing block was not found in nginx_status response");
-        } catch (HttpHostConnectException ignore) {
-            if(ignore.getMessage().contains("Connection refused")) {
-                log.warn("Could not find in-flight request count, connection refused: " +
-                        "http://127.0.0.1:" + proxyPort + "/nginx_status");
-            }
-        } catch (Exception e) {
-            log.error("Could not find in-flight request count: http://127.0.0.1:" + proxyPort
+ "/nginx_status", e);
-        }
-        return 0;
-    }
+		// Command to get the statistics : sudo ipvsadm -l --stats | grep TCP
+		String[] command = { "/bin/sh", "-c", IPVSADM_STATS_COMMAND };
+		try {
+			output = CommandUtils.executeCommand(command);
+			if ((output != null) && (output.length() > 0)) {
+				array = output.split("\n");
+				for (int i = 0; i < array.length; i++) {
+					weight = Integer.parseInt(array[i].substring(38, 42).toString().trim());
+					totalWeight += weight;
+				}
+			}
+		} catch (IOException e) {
+			if (log.isErrorEnabled()) {
+				log.error(e);
+			}
+		}
+		if (log.isInfoEnabled()) {
+			log.info(String.format("Cluster weight found: [cluster] %s [weight] %d", clusterId,
+			                       totalWeight));
 
-    @Override
-    public int getServedRequestCount(String clusterId) {
-        return 0;
-    }
+		}
+		return totalWeight;
+	}
 
-    @Override
-    public int getActiveInstancesCount(Cluster cluster) {
-        return 0;
-    }
+	@Override
+	public int getServedRequestCount(String clusterId) {
+		return 0;
+	}
+
+	@Override
+	public int getActiveInstancesCount(Cluster cluster) {
+		return 0;
+	}
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/f5bb41e9/extensions/load-balancer/lvs-extension/src/main/java/org/apache/stratos/lvs/extension/Main.java
----------------------------------------------------------------------
diff --git a/extensions/load-balancer/lvs-extension/src/main/java/org/apache/stratos/lvs/extension/Main.java
b/extensions/load-balancer/lvs-extension/src/main/java/org/apache/stratos/lvs/extension/Main.java
index 2df201d..52463e0 100644
--- a/extensions/load-balancer/lvs-extension/src/main/java/org/apache/stratos/lvs/extension/Main.java
+++ b/extensions/load-balancer/lvs-extension/src/main/java/org/apache/stratos/lvs/extension/Main.java
@@ -77,7 +77,7 @@ public class Main {
 				log.error(e);
 			}
 			if (extension != null) {
-                log.info("Shutting nginx instance...");
+                log.info("Shutting lvs instance...");
 				extension.stop();
 			}
 		}

http://git-wip-us.apache.org/repos/asf/stratos/blob/f5bb41e9/products/stratos/modules/integration/src/test/resources/JMSOutputAdaptor.xml
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/JMSOutputAdaptor.xml
b/products/stratos/modules/integration/src/test/resources/JMSOutputAdaptor.xml
index a6a2cff..59c3653 100755
--- a/products/stratos/modules/integration/src/test/resources/JMSOutputAdaptor.xml
+++ b/products/stratos/modules/integration/src/test/resources/JMSOutputAdaptor.xml
@@ -23,7 +23,7 @@
 <outputEventAdaptor name="JMSOutputAdaptor" statistics="disable"
   trace="enable" type="jms" xmlns="http://wso2.org/carbon/eventadaptormanager">
   <!--property name="java.naming.provider.url">CEP_HOME/repository/conf/jndi.properties</property-->
-  <property name="java.naming.provider.url">tcp://localhost:61617</property>
+  <property name="java.naming.provider.url">tcp://localhost:61616</property>
   <property name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</property>
   <property name="transport.jms.ConnectionFactoryJNDIName">TopicConnectionFactory</property>
   <property name="transport.jms.DestinationType">topic</property>

http://git-wip-us.apache.org/repos/asf/stratos/blob/f5bb41e9/samples/applications/nested/single-level-nested-group-app/artifacts/application.json
----------------------------------------------------------------------
diff --git a/samples/applications/nested/single-level-nested-group-app/artifacts/application.json
b/samples/applications/nested/single-level-nested-group-app/artifacts/application.json
index c4640ce..ab4942e 100644
--- a/samples/applications/nested/single-level-nested-group-app/artifacts/application.json
+++ b/samples/applications/nested/single-level-nested-group-app/artifacts/application.json
@@ -18,7 +18,7 @@
                         "cartridges": [
                             {
                                 "type": "tomcat1",
-                                "cartridgeMin": 1,
+                                "cartridgeMin": 2,
                                 "cartridgeMax": 2,
                                 "subscribableInfo": {
                                     "alias": "my-tomcat1-group7",
@@ -29,7 +29,7 @@
                                         "repoUsername":"",
                                         "repoPassword":""
                                     },
-                                    "lvsVirtualIP":"192.168.0.40"
+                                    "lvsVirtualIP":"192.168.56.40"
                                 }
                             }
                         ]
@@ -38,7 +38,7 @@
                 "cartridges": [
                     {
                         "type": "tomcat2",
-                        "cartridgeMin": 1,
+                        "cartridgeMin": 2,
                         "cartridgeMax": 2,
                         "subscribableInfo": {
                             "alias": "my-tomcat2-group6",
@@ -49,7 +49,7 @@
                                 "repoUsername":"",
                                 "repoPassword":""
                             },
-                            "lvsVirtualIP":"192.168.0.41"
+                            "lvsVirtualIP":"192.168.56.41"
                         }
                     }
                 ]
@@ -58,13 +58,13 @@
         "cartridges": [
             {
                 "type": "tomcat",
-                "cartridgeMin": 1,
+                "cartridgeMin": 2,
                 "cartridgeMax": 2,
                 "subscribableInfo": {
                     "alias": "my-tomcat",
                     "autoscalingPolicy": "autoscaling-policy-1",
                     "deploymentPolicy":"deployment-policy-2",
-                    "lvsVirtualIP":"192.168.0.42",
+                    "lvsVirtualIP":"192.168.56.42",
                     "artifactRepository":{
                         "privateRepo":false,
                         "repoUrl":"https://github.com/imesh/stratos-tomcat-applications.git",

http://git-wip-us.apache.org/repos/asf/stratos/blob/f5bb41e9/samples/applications/simple/single-cartridge-app/artifacts/application.json
----------------------------------------------------------------------
diff --git a/samples/applications/simple/single-cartridge-app/artifacts/application.json b/samples/applications/simple/single-cartridge-app/artifacts/application.json
index 6e66fe3..68fb4a4 100644
--- a/samples/applications/simple/single-cartridge-app/artifacts/application.json
+++ b/samples/applications/simple/single-cartridge-app/artifacts/application.json
@@ -6,7 +6,7 @@
         "cartridges": [
             {
                 "type": "php",
-		"cartridgeMin": 1,
+		"cartridgeMin": 2,
                 "cartridgeMax": 10,
                 "subscribableInfo": {
                     "alias": "my-php",
@@ -17,7 +17,8 @@
                         "repoUrl": "https://github.com/imesh/stratos-php-applications.git",
                         "repoUsername": "",
                         "repoPassword": ""
-                    }
+                    },
+                    "lvsVirtualIP":"192.168.30.30"
                 }
             }
         ]

http://git-wip-us.apache.org/repos/asf/stratos/blob/f5bb41e9/samples/applications/simple/single-group-app/artifacts/application.json
----------------------------------------------------------------------
diff --git a/samples/applications/simple/single-group-app/artifacts/application.json b/samples/applications/simple/single-group-app/artifacts/application.json
index 59c1398..5a7a9eb 100644
--- a/samples/applications/simple/single-group-app/artifacts/application.json
+++ b/samples/applications/simple/single-group-app/artifacts/application.json
@@ -28,8 +28,9 @@
                     },
                     {
                         "type": "php",
-                        "cartridgeMin": 1,
-                        "cartridgeMax": 2,
+                        "cartridgeMin": 2,
+                        "cartridgeMax": 4,
+                        "lvsVirtualIP": "192.168.56.60",
                         "subscribableInfo": {
                             "alias": "my-php",
                             "autoscalingPolicy": "autoscaling-policy-1",
@@ -50,6 +51,7 @@
                 "type": "tomcat",
                 "cartridgeMin": 2,
                 "cartridgeMax": 4,
+                "lvsVirtualIP": "192.168.56.50",
                 "subscribableInfo": {
                     "alias": "my-tomcat",
                     "autoscalingPolicy": "autoscaling-policy-1",

http://git-wip-us.apache.org/repos/asf/stratos/blob/f5bb41e9/samples/cartridges/mock/php.json
----------------------------------------------------------------------
diff --git a/samples/cartridges/mock/php.json b/samples/cartridges/mock/php.json
index 08ea098..2a60258 100755
--- a/samples/cartridges/mock/php.json
+++ b/samples/cartridges/mock/php.json
@@ -10,7 +10,7 @@
     "portMapping": [
         {
             "protocol": "http",
-            "port": "80",
+            "port": "8080",
             "proxyPort": "8280"
         },
         {

http://git-wip-us.apache.org/repos/asf/stratos/blob/f5bb41e9/samples/cartridges/mock/tomcat.json
----------------------------------------------------------------------
diff --git a/samples/cartridges/mock/tomcat.json b/samples/cartridges/mock/tomcat.json
index 44e9310..b352662 100755
--- a/samples/cartridges/mock/tomcat.json
+++ b/samples/cartridges/mock/tomcat.json
@@ -12,6 +12,11 @@
             "protocol": "http",
             "port": "22",
             "proxyPort": "8280"
+        },
+        {
+            "protocol": "http",
+            "port": "8080",
+            "proxyPort": "80"
         }
     ],
     "deployment": {

http://git-wip-us.apache.org/repos/asf/stratos/blob/f5bb41e9/samples/cartridges/openstack/php.json
----------------------------------------------------------------------
diff --git a/samples/cartridges/openstack/php.json b/samples/cartridges/openstack/php.json
index 98eb3f0..0d2d1d6 100755
--- a/samples/cartridges/openstack/php.json
+++ b/samples/cartridges/openstack/php.json
@@ -10,7 +10,7 @@
     "portMapping": [
         {
             "protocol": "http",
-            "port": "80",
+            "port": "8080",
             "proxyPort": "8280"
         }
     ],
@@ -22,18 +22,18 @@
             "imageId": "RegionOne/b4ca55e3-58ab-4937-82ce-817ebd10240e",
             "networkInterfaces": [
                 {
-                    "name": "network-non-routable",
-                    "networkUuid": "b55f009a-1cc6-4b17-924f-4ae0ee18db5e"
+                    "name": "network-routable",
+                    "networkUuid": "512e1f54-1e85-4dac-b2e6-f0b30fc552cf"
                 }
             ],
             "property": [
                 {
                     "name": "instanceType",
-                    "value": "RegionOne/aa5f45a2-c6d6-419d-917a-9dd2e3888594"
+                    "value": "RegionOne/15c3065c-462c-4977-9143-094d63d1c2c7"
                 },
                 {
                     "name": "keyPair",
-                    "value": "vishanth-key"
+                    "value": "gayan-os"
                 },
                 {
                     "name": "securityGroups",

http://git-wip-us.apache.org/repos/asf/stratos/blob/f5bb41e9/samples/cartridges/openstack/tomcat.json
----------------------------------------------------------------------
diff --git a/samples/cartridges/openstack/tomcat.json b/samples/cartridges/openstack/tomcat.json
index 0301599..12e5c9b 100755
--- a/samples/cartridges/openstack/tomcat.json
+++ b/samples/cartridges/openstack/tomcat.json
@@ -12,6 +12,11 @@
             "protocol": "http",
             "port": "22",
             "proxyPort": "8280"
+        },
+        {
+            "protocol": "http",
+            "port": "8080",
+            "proxyPort": "80"
         }
     ],
     "deployment": {
@@ -33,7 +38,7 @@
             },
             {
                "name":"keyPair",
-               "value":"vishanth-key"
+               "value":"gayan-os"
             },
             {
                "name":"securityGroups",


Mime
View raw message