You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by im...@apache.org on 2013/10/24 18:17:26 UTC

[1/2] git commit: Implemented initial version of the java based cartridge agent

Updated Branches:
  refs/heads/master 48a48986d -> 3d2376fa3


Implemented initial version of the java based cartridge agent


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

Branch: refs/heads/master
Commit: 76067d930e404e7171b7f216c2a730f2c5fde650
Parents: 35dffa0
Author: Imesh Gunaratne <im...@apache.org>
Authored: Thu Oct 24 21:47:02 2013 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Thu Oct 24 21:47:02 2013 +0530

----------------------------------------------------------------------
 products/cartridge-agent/README.txt             |  27 +++++
 products/cartridge-agent/pom.xml                | 108 ++++++++++++++++++
 .../src/main/assembly/assembly.xml              |  52 +++++++++
 .../src/main/bin/cartridge-agent.sh             |  24 ++++
 .../stratos/cartridge/agent/CartridgeAgent.java | 114 +++++++++++++++++++
 .../stratos/cartridge/agent/EventPublisher.java | 101 ++++++++++++++++
 .../apache/stratos/cartridge/agent/Main.java    |  58 ++++++++++
 .../stratos/cartridge/agent/UserData.java       |  71 ++++++++++++
 .../src/main/resources/jndi.properties          |  22 ++++
 .../src/main/resources/log4j.properties         |  37 ++++++
 10 files changed, 614 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/76067d93/products/cartridge-agent/README.txt
----------------------------------------------------------------------
diff --git a/products/cartridge-agent/README.txt b/products/cartridge-agent/README.txt
new file mode 100644
index 0000000..2903eac
--- /dev/null
+++ b/products/cartridge-agent/README.txt
@@ -0,0 +1,27 @@
+#
+# 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 Stratos Cartridge Agent
+------------------------------
+
+How to use:
+1. Extract the cartridge agent binary package to a directory inside the cartridge image.
+2. Read the payload and set following environment variables:
+   $service-name $cluster-id $member-id $ip-address $port
+3. Execute cartridge-agent.sh
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/76067d93/products/cartridge-agent/pom.xml
----------------------------------------------------------------------
diff --git a/products/cartridge-agent/pom.xml b/products/cartridge-agent/pom.xml
new file mode 100644
index 0000000..da1bc7d
--- /dev/null
+++ b/products/cartridge-agent/pom.xml
@@ -0,0 +1,108 @@
+<?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">
+    <parent>
+        <artifactId>stratos-products-parent</artifactId>
+        <groupId>org.apache.stratos</groupId>
+        <version>3.0.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>apache-stratos-cartridge-agent</artifactId>
+    <name>Apache Stratos - Cartridge Agent</name>
+
+    <repositories>
+        <repository>
+            <id>wso2-nexus</id>
+            <name>WSO2 internal Repository</name>
+            <url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
+            <releases>
+                <enabled>true</enabled>
+                <updatePolicy>daily</updatePolicy>
+                <checksumPolicy>ignore</checksumPolicy>
+            </releases>
+        </repository>
+    </repositories>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.wso2.andes.wso2</groupId>
+            <artifactId>andes-client</artifactId>
+            <version>0.13.wso2v8</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs.wso2</groupId>
+            <artifactId>geronimo-jms_1.1_spec</artifactId>
+            <version>1.1.0.wso2v1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <version>1.7.5</version>
+        </dependency>
+        <dependency>
+            <groupId>com.google.code.gson</groupId>
+            <artifactId>gson</artifactId>
+            <version>2.2.4</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.stratos</groupId>
+            <artifactId>org.apache.stratos.messaging</artifactId>
+            <version>3.0.0-SNAPSHOT</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <version>2.4</version>
+                <configuration>
+                    <archive>
+                        <manifest>
+                            <mainClass>org.apache.stratos.cartridge.agent.Main</mainClass>
+                        </manifest>
+                    </archive>
+                </configuration>
+            </plugin>
+            <plugin>
+            <artifactId>maven-assembly-plugin</artifactId>
+            <version>2.2.1</version>
+            <configuration>
+                <descriptors>
+                    <descriptor>src/main/assembly/assembly.xml</descriptor>
+                </descriptors>
+            </configuration>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>single</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/76067d93/products/cartridge-agent/src/main/assembly/assembly.xml
----------------------------------------------------------------------
diff --git a/products/cartridge-agent/src/main/assembly/assembly.xml b/products/cartridge-agent/src/main/assembly/assembly.xml
new file mode 100644
index 0000000..98595a1
--- /dev/null
+++ b/products/cartridge-agent/src/main/assembly/assembly.xml
@@ -0,0 +1,52 @@
+<!--
+  ~ 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>
+            <includes>
+                <include>cartridge-agent.sh</include>
+            </includes>
+        </fileSet>
+        <fileSet>
+            <directory>${project.basedir}</directory>
+            <outputDirectory>/</outputDirectory>
+            <includes>
+                <include>README*</include>
+                <include>LICENSE*</include>
+                <include>NOTICE*</include>
+            </includes>
+        </fileSet>
+    </fileSets>
+    <dependencySets>
+        <dependencySet>
+            <outputDirectory>/lib</outputDirectory>
+            <useProjectArtifact>true</useProjectArtifact>
+            <scope>runtime</scope>
+        </dependencySet>
+    </dependencySets>
+</assembly>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/76067d93/products/cartridge-agent/src/main/bin/cartridge-agent.sh
----------------------------------------------------------------------
diff --git a/products/cartridge-agent/src/main/bin/cartridge-agent.sh b/products/cartridge-agent/src/main/bin/cartridge-agent.sh
new file mode 100755
index 0000000..c677d3a
--- /dev/null
+++ b/products/cartridge-agent/src/main/bin/cartridge-agent.sh
@@ -0,0 +1,24 @@
+#!/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.
+#
+
+lib_path=./../lib/
+class_path=${lib_path}andes-client-0.13.wso2v8.jar:${lib_path}apache-stratos-cartridge-agent-3.0.0-SNAPSHOT.jar:${lib_path}commons-codec-1.8.jar:${lib_path}commons-logging-1.1.1.jar:${lib_path}geronimo-jms_1.1_spec-1.1.0.wso2v1.jar:${lib_path}geronimo-jms_1.1_spec-1.1.jar:${lib_path}gson-2.2.4.jar:${lib_path}log4j-1.2.13.jar:${lib_path}org.apache.log4j-1.2.13.v200706111418.jar:${lib_path}org.apache.stratos.messaging-3.0.0-SNAPSHOT.jar:${lib_path}org.wso2.carbon.logging-4.1.0.jar:${lib_path}slf4j-api-1.7.5.jar:${lib_path}slf4j-log4j12-1.7.5.jar
+
+java -cp $class_path org.apache.stratos.cartridge.agent.Main
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/76067d93/products/cartridge-agent/src/main/java/org/apache/stratos/cartridge/agent/CartridgeAgent.java
----------------------------------------------------------------------
diff --git a/products/cartridge-agent/src/main/java/org/apache/stratos/cartridge/agent/CartridgeAgent.java b/products/cartridge-agent/src/main/java/org/apache/stratos/cartridge/agent/CartridgeAgent.java
new file mode 100644
index 0000000..72656ec
--- /dev/null
+++ b/products/cartridge-agent/src/main/java/org/apache/stratos/cartridge/agent/CartridgeAgent.java
@@ -0,0 +1,114 @@
+/*
+ * 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;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.Event;
+import org.apache.stratos.messaging.event.instance.status.MemberActivatedEvent;
+import org.apache.stratos.messaging.event.instance.status.MemberStartedEvent;
+
+import javax.jms.JMSException;
+import javax.naming.NamingException;
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.net.SocketAddress;
+
+/**
+ * Cartridge agent lifecycle implementation.
+ */
+public class CartridgeAgent implements Runnable {
+    private static final Log log = LogFactory.getLog(CartridgeAgent.class);
+
+    private UserData userData;
+
+    public CartridgeAgent(UserData userData) {
+        this.userData = userData;
+    }
+
+    @Override
+    public void run() {
+        try {
+            if (log.isInfoEnabled()) {
+                log.info("\nCartridge agent started");
+            }
+            publishMemberStartedEvent(userData);
+
+            // Wait for the application to become active
+            while (!isApplicationActive(userData)) {
+                Thread.sleep(1000);
+            }
+
+            publishMemberActivatedEvent(userData);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    private boolean isApplicationActive(UserData userData) {
+        try {
+            if (log.isInfoEnabled()) {
+                log.info(String.format("Trying to connect to application socket: %s %d", userData.getIpAddress(), userData.getPort()));
+            }
+
+            SocketAddress httpSockaddr = new InetSocketAddress(userData.getIpAddress(), userData.getPort());
+            new Socket().connect(httpSockaddr, 1000);
+
+            if (log.isInfoEnabled()) {
+                log.info("Successfully connected to socket");
+            }
+            return true;
+        } catch (IOException e) {
+        }
+        if (log.isInfoEnabled()) {
+            log.info("Socket is not available");
+        }
+        return false;
+    }
+
+    private void publishMemberStartedEvent(UserData userData) throws JMSException, NamingException, IOException, InterruptedException {
+        MemberStartedEvent event = new MemberStartedEvent();
+        event.setServiceName(userData.getServiceName());
+        event.setClusterId(userData.getClusterId());
+        event.setMemberId(userData.getMemberId());
+        publishEvent(event);
+    }
+
+    private void publishMemberActivatedEvent(UserData userData) throws JMSException, NamingException, IOException, InterruptedException {
+        MemberActivatedEvent event = new MemberActivatedEvent();
+        event.setServiceName(userData.getServiceName());
+        event.setClusterId(userData.getClusterId());
+        event.setMemberId(userData.getMemberId());
+        publishEvent(event);
+    }
+
+    private void publishEvent(Event event) throws JMSException, NamingException, IOException, InterruptedException {
+        EventPublisher publisher = new EventPublisher(org.apache.stratos.messaging.util.Constants.INSTANCE_STATUS_TOPIC);
+        try {
+            publisher.connect();
+            publisher.publish(event);
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            publisher.close();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/76067d93/products/cartridge-agent/src/main/java/org/apache/stratos/cartridge/agent/EventPublisher.java
----------------------------------------------------------------------
diff --git a/products/cartridge-agent/src/main/java/org/apache/stratos/cartridge/agent/EventPublisher.java b/products/cartridge-agent/src/main/java/org/apache/stratos/cartridge/agent/EventPublisher.java
new file mode 100644
index 0000000..f120a17
--- /dev/null
+++ b/products/cartridge-agent/src/main/java/org/apache/stratos/cartridge/agent/EventPublisher.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;
+
+import com.google.gson.Gson;
+import org.apache.stratos.messaging.event.Event;
+import org.apache.stratos.messaging.util.Constants;
+
+import javax.jms.*;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.Properties;
+
+/**
+ * A generic topic publisher.
+ */
+public class EventPublisher {
+    private TopicConnection topicConnection;
+    private TopicSession topicSession;
+    private Topic topic;
+    private String topicName;
+
+    public EventPublisher(String topicName) {
+        this.topicName = topicName;
+    }
+
+    private Properties getProperties() throws IOException {
+        Properties prop = new Properties();
+        prop.load(EventPublisher.class.getClassLoader().getResourceAsStream("jndi.properties"));
+        return prop;
+    }
+
+    public void connect() throws NamingException, JMSException, IOException {
+        // Prepare JNDI properties
+        Properties properties = getProperties();
+        InitialContext ctx = new InitialContext(properties);
+
+        // Lookup connection factory
+        String connectionFactoryName = properties.get("connectionfactoryName").toString();
+        TopicConnectionFactory connectionFactory = (TopicConnectionFactory) ctx.lookup(connectionFactoryName);
+        topicConnection = connectionFactory.createTopicConnection();
+        topicConnection.start();
+        topicSession = topicConnection.createTopicSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+
+        // Create topic
+        topic = topicSession.createTopic(topicName);
+    }
+
+    public void publish(Event event) throws NamingException, JMSException, IOException {
+        Gson gson = new Gson();
+        String json = gson.toJson(event);
+        publish(json, event.getClass().getName());
+    }
+
+    private void publish(Object message, String eventClassName) throws NamingException, JMSException, IOException {
+        // Send message
+        if (message instanceof String) {
+            TextMessage textMessage = topicSession.createTextMessage((String) message);
+            textMessage.setStringProperty(Constants.EVENT_CLASS_NAME, eventClassName);
+            javax.jms.TopicPublisher topicPublisher = topicSession.createPublisher(topic);
+            topicPublisher.publish(textMessage);
+
+            System.out.println("Text message sent: " + (String) message);
+        } else if (message instanceof Serializable) {
+            ObjectMessage objectMessage = topicSession.createObjectMessage((Serializable) message);
+            javax.jms.TopicPublisher topicPublisher = topicSession.createPublisher(topic);
+            topicPublisher.publish(objectMessage);
+
+            System.out.println("Object message sent: " + ((Serializable) message).toString());
+        } else {
+            throw new RuntimeException("Unknown message type");
+        }
+    }
+
+    public void close() throws JMSException {
+        // Clean up resources
+        if (topicSession != null)
+            topicSession.close();
+        if (topicConnection != null)
+            topicConnection.close();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/76067d93/products/cartridge-agent/src/main/java/org/apache/stratos/cartridge/agent/Main.java
----------------------------------------------------------------------
diff --git a/products/cartridge-agent/src/main/java/org/apache/stratos/cartridge/agent/Main.java b/products/cartridge-agent/src/main/java/org/apache/stratos/cartridge/agent/Main.java
new file mode 100644
index 0000000..f578ef1
--- /dev/null
+++ b/products/cartridge-agent/src/main/java/org/apache/stratos/cartridge/agent/Main.java
@@ -0,0 +1,58 @@
+/*
+ * 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;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Cartridge agent main class.
+ */
+public class Main {
+    private static final Log log = LogFactory.getLog(Main.class);
+
+    public static void main(String[] args) {
+        try {
+            if ((args != null) && (args.length == 5)) {
+                UserData userData = new UserData();
+                userData.setServiceName(args[0]);
+                userData.setClusterId(args[1]);
+                userData.setMemberId(args[2]);
+                userData.setIpAddress(args[3]);
+                userData.setPort(Integer.parseInt(args[4]));
+
+                Runnable runnable = new CartridgeAgent(userData);
+                Thread thread = new Thread(runnable);
+                thread.start();
+            } else {
+                printInvalidArgs();
+            }
+        } catch (Exception e) {
+            printInvalidArgs();
+        }
+    }
+
+    private static void printInvalidArgs() {
+        if (log.isErrorEnabled()) {
+            log.error("Arguments are not valid. Cartridge agent could not be started.");
+            log.error("Expected: service-name cluster-id member-id ip-address port");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/76067d93/products/cartridge-agent/src/main/java/org/apache/stratos/cartridge/agent/UserData.java
----------------------------------------------------------------------
diff --git a/products/cartridge-agent/src/main/java/org/apache/stratos/cartridge/agent/UserData.java b/products/cartridge-agent/src/main/java/org/apache/stratos/cartridge/agent/UserData.java
new file mode 100644
index 0000000..e7a275f
--- /dev/null
+++ b/products/cartridge-agent/src/main/java/org/apache/stratos/cartridge/agent/UserData.java
@@ -0,0 +1,71 @@
+/*
+ * 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;
+
+/**
+ * User data definition.
+ */
+public class UserData {
+    private String serviceName;
+    private String clusterId;
+    private String memberId;
+    private String ipAddress;
+    private int port;
+
+    public String getServiceName() {
+        return serviceName;
+    }
+
+    public void setServiceName(String serviceName) {
+        this.serviceName = serviceName;
+    }
+
+    public String getClusterId() {
+        return clusterId;
+    }
+
+    public void setClusterId(String clusterId) {
+        this.clusterId = clusterId;
+    }
+
+    public String getMemberId() {
+        return memberId;
+    }
+
+    public void setMemberId(String memberId) {
+        this.memberId = memberId;
+    }
+
+    public String getIpAddress() {
+        return ipAddress;
+    }
+
+    public void setIpAddress(String ipAddress) {
+        this.ipAddress = ipAddress;
+    }
+
+    public int getPort() {
+        return port;
+    }
+
+    public void setPort(int port) {
+        this.port = port;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/76067d93/products/cartridge-agent/src/main/resources/jndi.properties
----------------------------------------------------------------------
diff --git a/products/cartridge-agent/src/main/resources/jndi.properties b/products/cartridge-agent/src/main/resources/jndi.properties
new file mode 100644
index 0000000..05bb5c3
--- /dev/null
+++ b/products/cartridge-agent/src/main/resources/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
+connectionfactory.topicConnectionfactory=amqp://admin:admin@carbon/carbon?brokerlist='tcp://localhost:5677'
+java.naming.factory.initial=org.wso2.andes.jndi.PropertiesFileInitialContextFactory

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/76067d93/products/cartridge-agent/src/main/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/products/cartridge-agent/src/main/resources/log4j.properties b/products/cartridge-agent/src/main/resources/log4j.properties
new file mode 100644
index 0000000..17c221d
--- /dev/null
+++ b/products/cartridge-agent/src/main/resources/log4j.properties
@@ -0,0 +1,37 @@
+#
+# 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=/var/log/apache-stratos/cartridge-agent.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=ERROR
\ No newline at end of file


[2/2] git commit: Merge remote-tracking branch 'origin/master'

Posted by im...@apache.org.
Merge remote-tracking branch 'origin/master'


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

Branch: refs/heads/master
Commit: 3d2376fa33abdbe818724fbf16e54c988160d28d
Parents: 76067d9 48a4898
Author: Imesh Gunaratne <im...@apache.org>
Authored: Thu Oct 24 21:47:19 2013 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Thu Oct 24 21:47:19 2013 +0530

----------------------------------------------------------------------
 .../org.apache.stratos.autoscaler/pom.xml       | 15 +++--
 .../cloud/controller/CloudControllerClient.java | 53 +++++++++++++---
 .../autoscaler/exception/SpawningException.java | 15 +++++
 .../exception/TerminationException.java         | 10 +++
 .../impl/CloudControllerServiceImpl.java        |  4 +-
 .../interfaces/CloudControllerService.java      |  2 +-
 .../internal/CloudControllerDSComponent.java    |  9 ++-
 .../runtime/FasterLookUpDataHolder.java         | 11 +---
 .../topic/TopologySynchronizerTask.java         |  5 +-
 .../controller/topology/TopologyBuilder.java    | 66 ++++++++++----------
 .../controller/topology/TopologyManager.java    | 63 +++++++++++--------
 .../util/CloudControllerConstants.java          |  1 +
 .../main/resources/CloudControllerService.wsdl  |  2 +-
 13 files changed, 168 insertions(+), 88 deletions(-)
----------------------------------------------------------------------