stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject [02/12] stratos git commit: Adding initial files for gce load balancer extension
Date Thu, 04 Jun 2015 06:32:54 GMT
Adding initial files for gce load balancer extension


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

Branch: refs/heads/master
Commit: dfe2e2c4f56f3b4a297b107a6e60525d24c78459
Parents: 9a262f2
Author: asanka sanjaya <angal.sh@gmail.com>
Authored: Wed Jun 3 10:07:29 2015 +0000
Committer: asanka sanjaya <angal.sh@gmail.com>
Committed: Wed Jun 3 10:07:29 2015 +0000

----------------------------------------------------------------------
 .../load-balancer/gce-extension/README.md       |   6 +
 extensions/load-balancer/gce-extension/pom.xml  | 109 +++++++++++++++++++
 .../gce-extension/src/main/assembly/bin.xml     |  69 ++++++++++++
 .../gce-extension/src/main/bin/gce-extension.sh |  46 ++++++++
 .../gce-extension/src/main/conf/jndi.properties |  22 ++++
 .../src/main/conf/log4j.properties              |  40 +++++++
 .../src/main/conf/thrift-client-config.xml      |  27 +++++
 .../stratos/gce/extension/GCELoadBalancer.java  |  48 ++++++++
 .../stratos/gce/extension/GCEOperations.java    |  24 ++++
 .../gce/extension/GCEStatisticsReader.java      |  37 +++++++
 .../org/apache/stratos/gce/extension/Main.java  |  88 +++++++++++++++
 extensions/load-balancer/pom.xml                |   1 +
 12 files changed, 517 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/dfe2e2c4/extensions/load-balancer/gce-extension/README.md
----------------------------------------------------------------------
diff --git a/extensions/load-balancer/gce-extension/README.md b/extensions/load-balancer/gce-extension/README.md
new file mode 100644
index 0000000..9406ee6
--- /dev/null
+++ b/extensions/load-balancer/gce-extension/README.md
@@ -0,0 +1,6 @@
+# Apache Stratos GCE Extension
+
+Apache Stratos GCE extension is a load balancer extension for Google Compute Engine Load
Balancer. It is an executable program
+which can manage the life-cycle of a GCE load balancer instance according to the topology,
composite application model,
+tenant application signups and domain mapping information received from Stratos via the message
broker.
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/dfe2e2c4/extensions/load-balancer/gce-extension/pom.xml
----------------------------------------------------------------------
diff --git a/extensions/load-balancer/gce-extension/pom.xml b/extensions/load-balancer/gce-extension/pom.xml
new file mode 100644
index 0000000..0981d49
--- /dev/null
+++ b/extensions/load-balancer/gce-extension/pom.xml
@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.stratos</groupId>
+        <artifactId>stratos-load-balancer-extensions</artifactId>
+        <version>4.1.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>org.apache.stratos.gce.extension</artifactId>
+    <name>Apache Stratos - GCE Extension</name>
+    <description>Apache Stratos GCE Extension for Load Balancing</description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <version>1.7.5</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.stratos</groupId>
+            <artifactId>org.apache.stratos.common</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.stratos</groupId>
+            <artifactId>org.apache.stratos.messaging</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.stratos</groupId>
+            <artifactId>org.apache.stratos.load.balancer.extension.api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>2.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.velocity</groupId>
+            <artifactId>velocity</artifactId>
+            <version>1.7</version>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.andes.wso2</groupId>
+            <artifactId>andes-client</artifactId>
+            <version>0.13.wso2v8</version>
+        </dependency>
+    </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-assembly-plugin</artifactId>
+                <configuration>
+                    <descriptors>
+                        <descriptor>src/main/assembly/bin.xml</descriptor>
+                    </descriptors>
+                    <archiverConfig>
+                        <fileMode>420</fileMode>
+                        <directoryMode>493</directoryMode>
+                        <defaultDirectoryMode>493</defaultDirectoryMode>
+                    </archiverConfig>
+                    <appendAssemblyId>false</appendAssemblyId>
+                </configuration>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>attached</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <version>2.4</version>
+                <configuration>
+                    <archive>
+                        <manifest>
+                            <mainClass>org.apache.stratos.gce.extension.Main</mainClass>
+                        </manifest>
+                    </archive>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>

http://git-wip-us.apache.org/repos/asf/stratos/blob/dfe2e2c4/extensions/load-balancer/gce-extension/src/main/assembly/bin.xml
----------------------------------------------------------------------
diff --git a/extensions/load-balancer/gce-extension/src/main/assembly/bin.xml b/extensions/load-balancer/gce-extension/src/main/assembly/bin.xml
new file mode 100644
index 0000000..2cbc6d5
--- /dev/null
+++ b/extensions/load-balancer/gce-extension/src/main/assembly/bin.xml
@@ -0,0 +1,69 @@
+<!--
+  ~ 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.
+  -->
+
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0
http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+    <id>bin</id>
+    <formats>
+        <format>zip</format>
+    </formats>
+    <fileSets>
+    <fileSet>
+        <directory>${project.basedir}/src/main/bin</directory>
+        <outputDirectory>/bin</outputDirectory>
+        <fileMode>0755</fileMode>
+        <includes>
+            <include>gce-extension.sh</include>
+        </includes>
+    </fileSet>
+    <fileSet>
+        <directory>${project.basedir}/src/main/conf</directory>
+        <outputDirectory>/conf</outputDirectory>
+        <fileMode>0600</fileMode>
+        <includes>
+            <include>jndi.properties</include>
+            <include>log4j.properties</include>
+            <include>thrift-client-config.xml</include>
+        </includes>
+    </fileSet>
+    <fileSet>
+        <directory>${project.basedir}/src/main/security</directory>
+        <outputDirectory>/security</outputDirectory>
+        <fileMode>0600</fileMode>
+        <includes>
+            <include>client-truststore.jks</include>
+        </includes>
+    </fileSet>
+    </fileSets>
+    <dependencySets>
+        <dependencySet>
+            <outputDirectory>/lib</outputDirectory>
+            <excludes>
+                <exclude>*:icu4j*</exclude>
+                <exclude>*:jaxen*</exclude>
+                <exclude>*:jboss-transaction-api*</exclude>
+                <exclude>*:wrapper*</exclude>
+                <exclude>*:xom*</exclude>
+            </excludes>
+            <useProjectArtifact>true</useProjectArtifact>
+            <scope>runtime</scope>
+        </dependencySet>
+    </dependencySets>
+</assembly>

http://git-wip-us.apache.org/repos/asf/stratos/blob/dfe2e2c4/extensions/load-balancer/gce-extension/src/main/bin/gce-extension.sh
----------------------------------------------------------------------
diff --git a/extensions/load-balancer/gce-extension/src/main/bin/gce-extension.sh b/extensions/load-balancer/gce-extension/src/main/bin/gce-extension.sh
new file mode 100755
index 0000000..c67d831
--- /dev/null
+++ b/extensions/load-balancer/gce-extension/src/main/bin/gce-extension.sh
@@ -0,0 +1,46 @@
+#!/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.
+#
+# --------------------------------------------------------------
+
+echo "Starting gce load balancer extension..."
+script_path="$( cd -P "$( dirname "$SOURCE" )" && pwd )/`dirname $0`"
+echo ${script_path}
+lib_path=${script_path}/../lib/
+class_path=`echo ${lib_path}/*.jar | tr ' ' ':'`
+
+
+
+properties="-Djndi.properties.dir=${script_path}/../conf
+            -Dstats.socket.file.path=/tmp/haproxy-stats.socket
+            -Dlog4j.properties.file.path=${script_path}/../conf/log4j.properties
+            -Djavax.net.ssl.trustStore=${script_path}/../security/client-truststore.jks
+            -Djavax.net.ssl.trustStorePassword=wso2carbon
+            -Dthrift.client.config.file.path=${script_path}/../conf/thrift-client-config.xml
+            -Dcep.stats.publisher.enabled=false
+            -Dthrift.receiver.ip=127.0.0.1
+            -Dthrift.receiver.port=7615
+            -Dnetwork.partition.id=network-partition-1"
+
+
+# Uncomment below line to enable remote debugging
+debug="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5006"
+
+java -cp "${class_path}" ${properties} ${debug} org.apache.stratos.gce.extension.Main $*

http://git-wip-us.apache.org/repos/asf/stratos/blob/dfe2e2c4/extensions/load-balancer/gce-extension/src/main/conf/jndi.properties
----------------------------------------------------------------------
diff --git a/extensions/load-balancer/gce-extension/src/main/conf/jndi.properties b/extensions/load-balancer/gce-extension/src/main/conf/jndi.properties
new file mode 100644
index 0000000..21d7420
--- /dev/null
+++ b/extensions/load-balancer/gce-extension/src/main/conf/jndi.properties
@@ -0,0 +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.
+#
+
+connectionfactoryName=TopicConnectionFactory
+java.naming.provider.url=tcp://localhost:61616
+java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory

http://git-wip-us.apache.org/repos/asf/stratos/blob/dfe2e2c4/extensions/load-balancer/gce-extension/src/main/conf/log4j.properties
----------------------------------------------------------------------
diff --git a/extensions/load-balancer/gce-extension/src/main/conf/log4j.properties b/extensions/load-balancer/gce-extension/src/main/conf/log4j.properties
new file mode 100644
index 0000000..ec45878
--- /dev/null
+++ b/extensions/load-balancer/gce-extension/src/main/conf/log4j.properties
@@ -0,0 +1,40 @@
+#
+# 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.
+#
+
+# Set root logger level and appenders
+log4j.rootLogger=INFO, CONSOLE_APPENDER, FILE_APPENDER
+
+# CONSOLE_APPENDER is set to be a ConsoleAppender.
+log4j.appender.CONSOLE_APPENDER=org.apache.log4j.ConsoleAppender
+
+# The standard error log where all the warnings, errors and fatal errors will be logged
+log4j.appender.FILE_APPENDER=org.apache.log4j.FileAppender
+log4j.appender.FILE_APPENDER.File=logs/haproxy-extension.log
+log4j.appender.FILE_APPENDER.layout=org.apache.log4j.PatternLayout
+log4j.appender.FILE_APPENDER.layout.ConversionPattern=%d{ISO8601} [%X{ip}-%X{host}] [%t]
%5p %c{1} %m%n
+log4j.appender.FILE_APPENDER.threshold=DEBUG
+
+# CONSOLE_APPENDER uses PatternLayout.
+log4j.appender.CONSOLE_APPENDER.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE_APPENDER.layout.ConversionPattern=[%d{ISO8601}] %5p - [%c{1}] %m%n
+
+log4j.logger.org.apache.stratos.haproxy.extension=INFO
+log4j.logger.org.apache.stratos.load.balancer.extension.api=INFO
+log4j.logger.org.apache.stratos.messaging=INFO
+log4j.logger.org.wso2.andes.client=ERROR
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/dfe2e2c4/extensions/load-balancer/gce-extension/src/main/conf/thrift-client-config.xml
----------------------------------------------------------------------
diff --git a/extensions/load-balancer/gce-extension/src/main/conf/thrift-client-config.xml
b/extensions/load-balancer/gce-extension/src/main/conf/thrift-client-config.xml
new file mode 100644
index 0000000..5cacada
--- /dev/null
+++ b/extensions/load-balancer/gce-extension/src/main/conf/thrift-client-config.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<!-- Apache thrift client configuration for publishing statistics to WSO2 CEP -->
+<thriftClientConfiguration>
+    <username>admin</username>
+    <password>admin</password>
+    <ip>localhost</ip>
+    <port>7611</port>
+</thriftClientConfiguration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/dfe2e2c4/extensions/load-balancer/gce-extension/src/main/java/org/apache/stratos/gce/extension/GCELoadBalancer.java
----------------------------------------------------------------------
diff --git a/extensions/load-balancer/gce-extension/src/main/java/org/apache/stratos/gce/extension/GCELoadBalancer.java
b/extensions/load-balancer/gce-extension/src/main/java/org/apache/stratos/gce/extension/GCELoadBalancer.java
new file mode 100644
index 0000000..d1240f2
--- /dev/null
+++ b/extensions/load-balancer/gce-extension/src/main/java/org/apache/stratos/gce/extension/GCELoadBalancer.java
@@ -0,0 +1,48 @@
+package org.apache.stratos.gce.extension;
+
+import org.apache.stratos.load.balancer.common.domain.Topology;
+import org.apache.stratos.load.balancer.extension.api.LoadBalancer;
+import org.apache.stratos.load.balancer.extension.api.exception.LoadBalancerExtensionException;
+
+/*
+ * 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.
+ */
+
+public class GCELoadBalancer implements LoadBalancer {
+
+
+    @Override
+    public void start() throws LoadBalancerExtensionException {
+
+    }
+
+    @Override
+    public void stop() throws LoadBalancerExtensionException {
+
+    }
+
+    @Override
+    public boolean configure(Topology topology) throws LoadBalancerExtensionException {
+        return false;
+    }
+
+    @Override
+    public void reload() throws LoadBalancerExtensionException {
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/dfe2e2c4/extensions/load-balancer/gce-extension/src/main/java/org/apache/stratos/gce/extension/GCEOperations.java
----------------------------------------------------------------------
diff --git a/extensions/load-balancer/gce-extension/src/main/java/org/apache/stratos/gce/extension/GCEOperations.java
b/extensions/load-balancer/gce-extension/src/main/java/org/apache/stratos/gce/extension/GCEOperations.java
new file mode 100644
index 0000000..a380c82
--- /dev/null
+++ b/extensions/load-balancer/gce-extension/src/main/java/org/apache/stratos/gce/extension/GCEOperations.java
@@ -0,0 +1,24 @@
+package org.apache.stratos.gce.extension;
+
+/*
+ * 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.
+ */
+public class GCEOperations {
+
+
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/dfe2e2c4/extensions/load-balancer/gce-extension/src/main/java/org/apache/stratos/gce/extension/GCEStatisticsReader.java
----------------------------------------------------------------------
diff --git a/extensions/load-balancer/gce-extension/src/main/java/org/apache/stratos/gce/extension/GCEStatisticsReader.java
b/extensions/load-balancer/gce-extension/src/main/java/org/apache/stratos/gce/extension/GCEStatisticsReader.java
new file mode 100644
index 0000000..8333306
--- /dev/null
+++ b/extensions/load-balancer/gce-extension/src/main/java/org/apache/stratos/gce/extension/GCEStatisticsReader.java
@@ -0,0 +1,37 @@
+package org.apache.stratos.gce.extension;
+
+/*
+ * 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.
+ */
+
+import org.apache.stratos.load.balancer.common.statistics.LoadBalancerStatisticsReader;
+
+/**
+ * GCE extension statistics reader class.
+ */
+public class GCEStatisticsReader implements LoadBalancerStatisticsReader {
+    @Override
+    public String getClusterInstanceId() {
+        return null;
+    }
+
+    @Override
+    public int getInFlightRequestCount(String clusterId) {
+        return 0;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/dfe2e2c4/extensions/load-balancer/gce-extension/src/main/java/org/apache/stratos/gce/extension/Main.java
----------------------------------------------------------------------
diff --git a/extensions/load-balancer/gce-extension/src/main/java/org/apache/stratos/gce/extension/Main.java
b/extensions/load-balancer/gce-extension/src/main/java/org/apache/stratos/gce/extension/Main.java
new file mode 100644
index 0000000..6fb7a53
--- /dev/null
+++ b/extensions/load-balancer/gce-extension/src/main/java/org/apache/stratos/gce/extension/Main.java
@@ -0,0 +1,88 @@
+/*
+ * 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.gce.extension;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.log4j.PropertyConfigurator;
+import org.apache.stratos.common.threading.StratosThreadPool;
+import org.apache.stratos.load.balancer.common.topology.TopologyProvider;
+import org.apache.stratos.load.balancer.extension.api.LoadBalancerExtension;
+
+import java.util.concurrent.ExecutorService;
+
+/**
+ * GCE extension main class.
+ */
+public class Main {
+    private static final Log log = LogFactory.getLog(Main.class);
+    private static ExecutorService executorService;
+
+    public static void main(String[] args) {
+
+        LoadBalancerExtension extension = null;
+        try {
+            // Configure log4j properties
+            PropertyConfigurator.configure(System.getProperty("log4j.properties.file.path"));
+
+            if (log.isInfoEnabled()) {
+                log.info("GCE extension started");
+            }
+
+            // Add shutdown hook
+            final Thread mainThread = Thread.currentThread();
+            final LoadBalancerExtension finalExtension = extension;
+            Runtime.getRuntime().addShutdownHook(new Thread() {
+                public void run() {
+                    try {
+                        if(finalExtension != null) {
+                            log.info("GCE gce instance...");
+                            finalExtension.stop();
+                        }
+                        mainThread.join();
+                    } catch (Exception e) {
+                        log.error(e);
+                    }
+                }
+            });
+
+            executorService = StratosThreadPool.getExecutorService("gce.extension.thread.pool",
10);
+
+            // Validate runtime parameters
+
+            TopologyProvider topologyProvider = new TopologyProvider();
+            //ToDo: pass topology provider inside the statsReader. Look line 70 in HAProxy.java
+            GCEStatisticsReader statisticsReader = new GCEStatisticsReader();
+            extension = new LoadBalancerExtension(new GCELoadBalancer(), statisticsReader,
topologyProvider);
+            extension.setExecutorService(executorService);
+            extension.execute();
+
+
+        } catch (Exception e) {
+            if (log.isErrorEnabled()) {
+                log.error(e);
+            }
+            if (extension != null) {
+                log.info("Shutting GCE instance...");
+                extension.stop();
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/dfe2e2c4/extensions/load-balancer/pom.xml
----------------------------------------------------------------------
diff --git a/extensions/load-balancer/pom.xml b/extensions/load-balancer/pom.xml
index ff89360..5b27928 100644
--- a/extensions/load-balancer/pom.xml
+++ b/extensions/load-balancer/pom.xml
@@ -36,6 +36,7 @@
     <modules>
         <module>haproxy-extension</module>
         <module>nginx-extension</module>
+        <module>gce-extension</module>
     </modules>
 </project>
 


Mime
View raw message