You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by is...@apache.org on 2013/08/13 08:47:16 UTC

[1/2] git commit: Changed TopologyPublisher to support generic AMQP protocol

Updated Branches:
  refs/heads/master 365c478fe -> a3e0e932b


Changed TopologyPublisher to support generic AMQP protocol


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

Branch: refs/heads/master
Commit: 946669724bc575006d6386d737c170e91379a465
Parents: 84dc901
Author: Isuru Perera <is...@apache.org>
Authored: Tue Aug 13 12:16:37 2013 +0530
Committer: Isuru Perera <is...@apache.org>
Committed: Tue Aug 13 12:16:37 2013 +0530

----------------------------------------------------------------------
 .../controller/topic/AMQPTopologyPublisher.java | 119 +++++++++++++++++++
 .../topic/WSO2MBTopologyPublisher.java          | 108 -----------------
 .../util/CloudControllerConstants.java          |  11 +-
 .../cloud/controller/util/TopologyConfig.java   |   4 +-
 .../src/test/resources/cloud-controller.xml     |   1 -
 5 files changed, 130 insertions(+), 113 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/94666972/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topic/AMQPTopologyPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topic/AMQPTopologyPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topic/AMQPTopologyPublisher.java
new file mode 100644
index 0000000..f29f460
--- /dev/null
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topic/AMQPTopologyPublisher.java
@@ -0,0 +1,119 @@
+/*
+ * 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.cloud.controller.topic;
+
+import java.util.Properties;
+
+import javax.jms.*;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.apache.stratos.cloud.controller.interfaces.TopologyPublisher;
+import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder;
+import org.apache.stratos.cloud.controller.util.CloudControllerConstants;
+import org.apache.stratos.cloud.controller.util.TopologyConfig;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class AMQPTopologyPublisher extends TopologyPublisher {
+	private TopicPublisher topicPublisher;
+	private TopicSession topicSession;
+	private TopicConnection topicConnection;
+	private TopicConnectionFactory topicConnectionFactory;
+	private String topologySynchronizerCron = CloudControllerConstants.TOPOLOGY_SYNC_CRON;
+	private String amqpConnectionUrl = CloudControllerConstants.AMQP_CONNECTION_URL;
+	private String amqpInitialContextFactory = CloudControllerConstants.AMQP_INITIAL_CONTEXT_FACTORY;
+	private String amqpTopicConnectionFactory = CloudControllerConstants.AMQP_TOPIC_CONNECTION_FACTORY;
+	private static final Log log = LogFactory
+			.getLog(AMQPTopologyPublisher.class);
+
+	public void publish(String topicName, String message) {
+		try {
+			topicConnection = topicConnectionFactory.createTopicConnection();
+			topicConnection.start();
+			topicSession = topicConnection.createTopicSession(false,
+					Session.AUTO_ACKNOWLEDGE);
+
+			Topic topic = topicSession.createTopic(topicName);
+			topicPublisher = topicSession.createPublisher(topic);
+			TextMessage textMessage = topicSession.createTextMessage(message);
+
+			topicPublisher.publish(textMessage);
+
+			topicPublisher.close();
+			topicSession.close();
+			topicConnection.stop();
+			topicConnection.close();
+
+		} catch (JMSException e) {
+			log.error(e.getMessage(), e);
+		}
+	}
+
+	@Override
+	public void init() {
+		TopologyConfig config = FasterLookUpDataHolder.getInstance()
+				.getTopologyConfig();
+		String cron = config.getProperty(CloudControllerConstants.CRON_PROPERTY);
+		topologySynchronizerCron = cron == null ? topologySynchronizerCron
+				: cron;
+
+		String url = config
+				.getProperty(CloudControllerConstants.AMQP_CONNECTION_URL_PROPERTY);
+		amqpConnectionUrl = url == null ? amqpConnectionUrl : url;
+
+		Properties initialContextProperties = new Properties();
+
+		String initialContextFactory = config
+				.getProperty(CloudControllerConstants.AMQP_INITIAL_CONTEXT_FACTORY_PROPERTY);
+		amqpInitialContextFactory = initialContextFactory == null ? amqpInitialContextFactory
+				: initialContextFactory;
+
+		initialContextProperties.put("java.naming.factory.initial",
+				amqpInitialContextFactory);
+
+		initialContextProperties.put("connectionfactory.qpidConnectionfactory",
+				amqpConnectionUrl);
+
+		String connectionFactory = config
+				.getProperty(CloudControllerConstants.AMQP_TOPIC_CONNECTION_FACTORY_PROPERTY);
+		amqpTopicConnectionFactory = connectionFactory == null ? amqpTopicConnectionFactory
+				: connectionFactory;
+
+		try {
+			InitialContext initialContext = new InitialContext(
+					initialContextProperties);
+			topicConnectionFactory = (TopicConnectionFactory) initialContext
+					.lookup(amqpTopicConnectionFactory);
+
+			// topicConnection.stop();
+			// topicConnection.close();
+
+		} catch (NamingException e) {
+			log.error(e.getMessage(), e);
+		}
+
+	}
+
+	@Override
+	public String getCron() {
+		return topologySynchronizerCron;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/94666972/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topic/WSO2MBTopologyPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topic/WSO2MBTopologyPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topic/WSO2MBTopologyPublisher.java
deleted file mode 100644
index 36871aa..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topic/WSO2MBTopologyPublisher.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one 
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
- * KIND, either express or implied.  See the License for the 
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.cloud.controller.topic;
-
-import java.util.Properties;
-
-import javax.jms.*;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.apache.stratos.cloud.controller.interfaces.TopologyPublisher;
-import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder;
-import org.apache.stratos.cloud.controller.util.CloudControllerConstants;
-import org.apache.stratos.cloud.controller.util.TopologyConfig;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public class WSO2MBTopologyPublisher extends TopologyPublisher {
-	private TopicPublisher topicPublisher;
-	private TopicSession topicSession;
-	private TopicConnection topicConnection;
-	private TopicConnectionFactory topicConnectionFactory;
-	private String topologySynchronizerCron = CloudControllerConstants.TOPOLOGY_SYNC_CRON;
-	private String mbServerUrl = CloudControllerConstants.MB_SERVER_URL;
-	private static final Log log = LogFactory
-			.getLog(WSO2MBTopologyPublisher.class);
-
-	public void publish(String topicName, String message) {
-		try {
-			topicConnection = topicConnectionFactory.createTopicConnection();
-			topicConnection.start();
-			topicSession = topicConnection.createTopicSession(false,
-					Session.AUTO_ACKNOWLEDGE);
-
-			Topic topic = topicSession.createTopic(topicName);
-			topicPublisher = topicSession.createPublisher(topic);
-			TextMessage textMessage = topicSession.createTextMessage(message);
-
-			topicPublisher.publish(textMessage);
-
-			topicPublisher.close();
-			topicSession.close();
-			topicConnection.stop();
-			topicConnection.close();
-
-		} catch (JMSException e) {
-			log.error(e.getMessage(), e);
-		}
-	}
-
-	@Override
-	public void init() {
-		TopologyConfig config = FasterLookUpDataHolder.getInstance()
-				.getTopologyConfig();
-		String cron = config.getProperty(CloudControllerConstants.CRON_ELEMENT);
-		topologySynchronizerCron = cron == null ? topologySynchronizerCron
-				: cron;
-
-		String url = config
-				.getProperty(CloudControllerConstants.MB_SERVER_ELEMENT);
-		mbServerUrl = url == null ? mbServerUrl : url;
-
-		Properties initialContextProperties = new Properties();
-		initialContextProperties.put("java.naming.factory.initial",
-				"org.wso2.andes.jndi.PropertiesFileInitialContextFactory");
-
-		String connectionString = "amqp://admin:admin@clientID/carbon?brokerlist='tcp://"
-				+ mbServerUrl + "'";
-		initialContextProperties.put("connectionfactory.qpidConnectionfactory",
-				connectionString);
-
-		try {
-			InitialContext initialContext = new InitialContext(
-					initialContextProperties);
-			topicConnectionFactory = (TopicConnectionFactory) initialContext
-					.lookup("qpidConnectionfactory");
-
-			// topicConnection.stop();
-			// topicConnection.close();
-
-		} catch (NamingException e) {
-			log.error(e.getMessage(), e);
-		}
-
-	}
-
-	@Override
-	public String getCron() {
-		return topologySynchronizerCron;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/94666972/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerConstants.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerConstants.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerConstants.java
index f07c67c..979ded1 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerConstants.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerConstants.java
@@ -76,7 +76,6 @@ public final class CloudControllerConstants {
     public static final String TOPOLOGY_SYNC_ELEMENT = "topologySync";
     public static final String ENABLE_ATTR = "enable";
     public static final String BAM_SERVER_ELEMENT = "bamServer";
-    public static final String MB_SERVER_ELEMENT = "mbServerUrl";
     public static final String CRON_ELEMENT = "cron";
     public static final String BAM_SERVER_ADMIN_USERNAME_ELEMENT = "adminUserName";
     public static final String BAM_SERVER_ADMIN_PASSWORD_ELEMENT = "adminPassword";
@@ -89,6 +88,7 @@ public final class CloudControllerConstants {
     public static final String CLOUD_CONTROLLER_EVENT_STREAM = "org.wso2.stratos.cloud.controller";
     public static final String CLOUD_CONTROLLER_COL_FAMILY = CLOUD_CONTROLLER_EVENT_STREAM.replaceAll("[/.]", "_");
     
+    
     /**
      * column names
      */
@@ -123,6 +123,11 @@ public final class CloudControllerConstants {
     public static final String TENANT_ID_PROPERTY = "tenant_id";
     public static final String ALIAS_PROPERTY = "alias";
     public static final String AUTO_ASSIGN_IP_PROPERTY = "autoAssignIp";
+    public static final String CRON_PROPERTY = "cron";
+    public static final String AMQP_CONNECTION_URL_PROPERTY = "amqpConnectionUrl";
+    public static final String AMQP_INITIAL_CONTEXT_FACTORY_PROPERTY = "amqpInitialContextFactory";
+    public static final String AMQP_TOPIC_CONNECTION_FACTORY_PROPERTY = "amqpTopicConnectionFactory";
+    
     
     /**
      * XPath expressions
@@ -206,7 +211,9 @@ public final class CloudControllerConstants {
 	public static final String TOPOLOGY_SYNC_CRON = "1 * * * * ? *";
 	public static final String TOPOLOGY_SYNC_TASK_NAME = "TopologySynchronizerTask";
 	public static final String TOPOLOGY_SYNC_TASK_TYPE = "TOPOLOGY_SYNC_TASK";
-	public static final String MB_SERVER_URL = "localhost:5672";
+	public static final String AMQP_CONNECTION_URL = "amqp://admin:admin@clientID/carbon?brokerlist='tcp://localhost:5672'";
+	public static final String AMQP_INITIAL_CONTEXT_FACTORY = "org.wso2.andes.jndi.PropertiesFileInitialContextFactory";
+	public static final String AMQP_TOPIC_CONNECTION_FACTORY = "qpidConnectionfactory";
     
 	/**
 	 * Persistence

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/94666972/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/TopologyConfig.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/TopologyConfig.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/TopologyConfig.java
index 899062f..2c79c9c 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/TopologyConfig.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/TopologyConfig.java
@@ -30,8 +30,8 @@ public class TopologyConfig implements Serializable{
 	
 	private static final long serialVersionUID = 4435173744617096911L;
 	
-	// default implementation is WSO2MBTopologyPublisher
-	private String className = "org.apache.stratos.cloud.controller.topic.WSO2MBTopologyPublisher";
+	// default implementation is AMQPTopologyPublisher
+	private String className = "org.apache.stratos.cloud.controller.topic.AMQPTopologyPublisher";
 	
 	/**
      * Key - Value pair.

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/94666972/components/org.apache.stratos.cloud.controller/src/test/resources/cloud-controller.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/test/resources/cloud-controller.xml b/components/org.apache.stratos.cloud.controller/src/test/resources/cloud-controller.xml
index fd8e656..299f4d4 100644
--- a/components/org.apache.stratos.cloud.controller/src/test/resources/cloud-controller.xml
+++ b/components/org.apache.stratos.cloud.controller/src/test/resources/cloud-controller.xml
@@ -43,7 +43,6 @@
 	<topologySync enable="true">
 		<!-- properties related to topology syncher -->
 		<property name="className" value="org.apache.stratos.cloud.controller.ABC"/>
-		<property name="mbServerUrl" value="localhost:5674"/>
 		<property name="cron" value="1 * * * * ? *"/>
 	</topologySync>
 	


[2/2] git commit: Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-stratos

Posted by is...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-stratos


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

Branch: refs/heads/master
Commit: a3e0e932b6f26c01b209e96bada9c186c6362f74
Parents: 9466697 365c478
Author: Isuru Perera <is...@apache.org>
Authored: Tue Aug 13 12:17:02 2013 +0530
Committer: Isuru Perera <is...@apache.org>
Committed: Tue Aug 13 12:17:02 2013 +0530

----------------------------------------------------------------------
 .../pom.xml                                     |  87 --------------
 .../service/RepositorySynchronizer.java         |  37 ------
 .../src/main/webapp/WEB-INF/cxf-servlet.xml     |  35 ------
 .../src/main/webapp/WEB-INF/web.xml             |  51 --------
 .../src/main/webapp/servicelist.css             | 117 -------------------
 .../org.apache.stratos.deployment/pom.xml       |   8 --
 .../pom.xml                                     |   8 --
 .../pom.xml                                     |  11 --
 .../org.apache.stratos.tenant.activity/pom.xml  |   6 -
 .../org.apache.stratos.theme.mgt.ui/pom.xml     |  11 --
 components/org.apache.stratos.usage.ui/pom.xml  |  11 --
 components/pom.xml                              |   5 -
 pom.xml                                         |  71 ++++++++---
 .../modules/dashboard/pom.xml                   |  11 --
 .../modules/features-dashboard/pom.xml          |  16 ---
 .../stratos-controller/modules/login/pom.xml    |  11 --
 .../stratos-controller/modules/styles/pom.xml   |   8 --
 products/stratos-controller/pom.xml             |  18 ---
 .../org.apache.stratos.theme.mgt.stub/pom.xml   |  11 --
 .../pom.xml                                     |   8 --
 .../pom.xml                                     |   8 --
 .../org.apache.stratos.usage.stub/pom.xml       |   8 --
 22 files changed, 55 insertions(+), 502 deletions(-)
----------------------------------------------------------------------