You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ud...@apache.org on 2013/12/06 10:30:53 UTC
[1/2] git commit: Adding registry persisting in Auto Scaler
Updated Branches:
refs/heads/master 69843755d -> cbe7b4c6f
Adding registry persisting in Auto Scaler
Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/cefbde6d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/cefbde6d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/cefbde6d
Branch: refs/heads/master
Commit: cefbde6db5f6013bd79a228d3ffb1943e5eb23a2
Parents: 90a1af7
Author: Udara Liyanage <ud...@wso2.com>
Authored: Fri Dec 6 14:59:33 2013 -0500
Committer: Udara Liyanage <ud...@wso2.com>
Committed: Fri Dec 6 14:59:33 2013 -0500
----------------------------------------------------------------------
.../org.apache.stratos.autoscaler/pom.xml | 6 ++
.../autoscaler/registry/RegistryManager.java | 81 ++++++++++++++++++++
.../stratos/autoscaler/util/Serializer.java | 33 ++++++++
.../autoscaler/util/ServiceReferenceHolder.java | 28 +++++++
products/autoscaler/modules/p2-profile/pom.xml | 29 ++++++-
5 files changed, 176 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/cefbde6d/components/org.apache.stratos.autoscaler/pom.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/pom.xml b/components/org.apache.stratos.autoscaler/pom.xml
index b92fc94..479db8f 100644
--- a/components/org.apache.stratos.autoscaler/pom.xml
+++ b/components/org.apache.stratos.autoscaler/pom.xml
@@ -35,6 +35,12 @@
<url>http://apache.org</url>
<dependencies>
+ <dependency>
+ <groupId>org.wso2.carbon</groupId>
+ <artifactId>org.wso2.carbon.registry.core</artifactId>
+ <version>${carbon.platform.version}</version>
+ </dependency>
+
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/cefbde6d/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
new file mode 100644
index 0000000..595b0bd
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
@@ -0,0 +1,81 @@
+package org.apache.stratos.autoscaler.registry;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.registry.core.Registry;
+import org.wso2.carbon.registry.core.Resource;
+import org.wso2.carbon.registry.core.exceptions.RegistryException;
+import org.apache.stratos.autoscaler.util.AutoScalerConstants;
+import org.apache.stratos.autoscaler.util.ServiceReferenceHolder;
+import org.apache.stratos.autoscaler.util.Serializer;
+
+public class RegistryManager {
+
+ private final static Log log = LogFactory.getLog(RegistryManager.class);
+ private static Registry registryService;
+ private static RegistryManager registryManager;
+
+ public static RegistryManager getInstance() {
+
+ registryService = ServiceReferenceHolder.getInstance().getRegistry();
+
+ synchronized (RegistryManager.class) {
+ if (registryManager == null) {
+ if (registryService == null) {
+ // log.warn("Registry Service is null. Hence unable to fetch data from registry.");
+ return registryManager;
+ }
+ registryManager = new RegistryManager();
+ }
+ }
+ return registryManager;
+ }
+
+ private RegistryManager() {
+ try {
+ if (!registryService.resourceExists(AutoScalerConstants.AUTOSCALER_RESOURCE)) {
+ registryService.put(AutoScalerConstants.AUTOSCALER_RESOURCE,
+ registryService.newCollection());
+ }
+ } catch (RegistryException e) {
+ String msg =
+ "Failed to create the registry resource " +
+ AutoScalerConstants.AUTOSCALER_RESOURCE;
+ log.error(msg, e);
+ //throw new CloudControllerException(msg, e);
+
+ }
+ }
+
+ /**
+ * Persist an object in the local registry.
+ *
+ * @param dataObj object to be persisted.
+ * @param path resource path to be persisted.
+ */
+ public void persist(Object dataObj, String path) throws RegistryException {
+
+ try {
+ registryService.beginTransaction();
+
+ Resource nodeResource = registryService.newResource();
+
+ nodeResource.setContent(Serializer.serializeToByteArray(dataObj));
+
+ //registryService.put(AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.DATA_RESOURCE + "/"+id, nodeResource);
+ registryService.put(path, nodeResource);
+ registryService.commitTransaction();
+
+ if(log.isDebugEnabled()){
+
+ }
+
+ } catch (Exception e) {
+ String msg = "Failed to persist the cloud controller data in registry.";
+ registryService.rollbackTransaction();
+ log.error(msg, e);
+ //throw new CloudControllerException(msg, e);
+
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/cefbde6d/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/Serializer.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/Serializer.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/Serializer.java
new file mode 100644
index 0000000..e0e19a5
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/Serializer.java
@@ -0,0 +1,33 @@
+package org.apache.stratos.autoscaler.util;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutput;
+import java.io.ObjectOutputStream;
+
+public class Serializer {
+ /**
+ * Serialize a object to a byte array.
+ * @param serializableObj
+ * @return byte[]
+ * @throws IOException
+ */
+ public static byte[] serializeToByteArray(Object serializableObj) throws IOException {
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ ObjectOutput out = null;
+ try {
+ out = new ObjectOutputStream(bos);
+ out.writeObject(serializableObj);
+
+ return bos.toByteArray();
+
+ } finally {
+ if (out != null) {
+ out.close();
+ }
+ bos.close();
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/cefbde6d/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/ServiceReferenceHolder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/ServiceReferenceHolder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/ServiceReferenceHolder.java
new file mode 100644
index 0000000..eac4c60
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/ServiceReferenceHolder.java
@@ -0,0 +1,28 @@
+package org.apache.stratos.autoscaler.util;
+
+import org.wso2.carbon.registry.core.Registry;
+import org.wso2.carbon.registry.core.session.UserRegistry;
+
+public class ServiceReferenceHolder {
+
+ private static ServiceReferenceHolder instance;
+ private Registry registry;
+
+ private ServiceReferenceHolder() {
+ }
+
+ public static ServiceReferenceHolder getInstance() {
+ if (instance == null) {
+ instance = new ServiceReferenceHolder();
+ }
+ return instance;
+ }
+
+ public void setRegistry(UserRegistry governanceSystemRegistry) {
+ registry = governanceSystemRegistry;
+ }
+
+ public Registry getRegistry() {
+ return registry;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/cefbde6d/products/autoscaler/modules/p2-profile/pom.xml
----------------------------------------------------------------------
diff --git a/products/autoscaler/modules/p2-profile/pom.xml b/products/autoscaler/modules/p2-profile/pom.xml
index 354e091..7e86429 100644
--- a/products/autoscaler/modules/p2-profile/pom.xml
+++ b/products/autoscaler/modules/p2-profile/pom.xml
@@ -109,7 +109,18 @@
<featureArtifactDef>
org.apache.stratos:org.apache.stratos.messaging.feature:${project.version}
</featureArtifactDef>
-
+
+ <!-- Registry -->
+ <featureArtifactDef>
+ org.wso2.carbon:org.wso2.carbon.registry.core.feature:${carbon.version}
+ </featureArtifactDef>
+ <featureArtifactDef>
+ org.wso2.carbon:org.wso2.carbon.registry.ui.menu.feature:${carbon.version}
+ </featureArtifactDef>
+ <featureArtifactDef>
+ org.wso2.carbon:org.wso2.carbon.registry.resource.properties.feature:${carbon.version}
+ </featureArtifactDef>
+
</featureArtifacts>
</configuration>
</execution>
@@ -141,6 +152,22 @@
<id>org.apache.stratos.messaging.feature.group</id>
<version>${project.version}</version>
</feature>
+ <!-- Registry feature -->
+ <feature>
+ <id>org.wso2.carbon.registry.core.feature.group</id>
+ <version>${carbon.version}</version>
+ </feature>
+
+ <feature>
+ <id>org.wso2.carbon.registry.ui.menu.feature.group</id>
+ <version>${carbon.version}</version>
+ </feature>
+
+ <feature>
+ <id>org.wso2.carbon.registry.resource.properties.feature.group
+ </id>
+ <version>${carbon.version}</version>
+ </feature>
</features>
</configuration>
[2/2] git commit: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/incubator-stratos
Posted by ud...@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/cbe7b4c6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/cbe7b4c6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/cbe7b4c6
Branch: refs/heads/master
Commit: cbe7b4c6f25572fb5111fe91f11456436833596a
Parents: cefbde6 6984375
Author: Udara Liyanage <ud...@wso2.com>
Authored: Fri Dec 6 15:00:48 2013 -0500
Committer: Udara Liyanage <ud...@wso2.com>
Committed: Fri Dec 6 15:00:48 2013 -0500
----------------------------------------------------------------------
components/org.apache.stratos.adc.mgt/pom.xml | 6 +-
.../adc/mgt/client/AutoscalerServiceClient.java | 111 ++++
.../stratos/adc/mgt/utils/PojoConverter.java | 25 +
.../stratos/messaging/domain/tenant/Tenant.java | 4 +
.../event/tenant/TenantCreatedEvent.java | 18 +-
.../tenant/TenantCreatedMessageProcessor.java | 36 +-
.../tenant/TenantRemovedMessageProcessor.java | 45 +-
.../tenant/TenantUpdatedMessageProcessor.java | 45 +-
.../bean/util/convert/PojoConverter.java | 25 -
.../bean/util/converter/PojoConverter.java | 297 ++++++++++
.../service/client/AutoscalerServiceClient.java | 111 ----
.../rest/endpoint/services/ServiceUtils.java | 282 +--------
tools/stratos-installer/conf/setup.conf | 31 +-
.../config/agent/bin/stratos.sh | 298 ----------
.../agent/repository/conf/agent.properties | 47 --
.../config/agent/repository/conf/carbon.xml | 586 -------------------
.../config/as/repository/conf/carbon.xml | 586 +++++++++++++++++++
.../config/as/repository/conf/jndi.properties | 4 +
.../stratos-installer/config/elb/bin/stratos.sh | 298 ----------
.../config/elb/repository/conf/axis2/axis2.xml | 526 -----------------
.../conf/datasources/master-datasources.xml | 109 ----
.../elb/repository/conf/loadbalancer.conf | 85 ---
.../config/lb/repository/conf/axis2/axis2.xml | 526 +++++++++++++++++
.../config/lb/repository/conf/loadbalancer.conf | 118 ++++
tools/stratos-installer/setup.sh | 174 ++----
tools/stratos-installer/start-servers.sh | 36 +-
26 files changed, 1907 insertions(+), 2522 deletions(-)
----------------------------------------------------------------------