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 2014/07/07 08:41:10 UTC
git commit: initial impl. for composite application deployment and
subscription
Repository: stratos
Updated Branches:
refs/heads/4.0.0-grouping f8b27de43 -> 62dc96e9f
initial impl. for composite application deployment and subscription
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/62dc96e9
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/62dc96e9
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/62dc96e9
Branch: refs/heads/4.0.0-grouping
Commit: 62dc96e9f9cb07106887b3f7adadca52ba4bde81
Parents: f8b27de
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Mon Jul 7 12:10:37 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Mon Jul 7 12:10:37 2014 +0530
----------------------------------------------------------------------
.../CompositeApplicationManager.java | 131 ---------------
.../application/utils/ApplicationUtils.java | 104 ------------
.../CompositeApplicationManager.java | 143 ++++++++++++++++
.../beans/CompositeAppDefinition.java | 68 ++++++++
.../application/beans/GroupDefinition.java | 87 ++++++++++
.../beans/SubscribableDefinition.java | 47 ++++++
.../application/beans/SubscribableInfo.java | 93 +++++++++++
.../parser/CompositeApplicationParser.java | 29 ++++
.../DefaultCompositeApplicationParser.java | 166 +++++++++++++++++++
.../application/utils/ApplicationUtils.java | 102 ++++++++++++
...CompositeApplicationDefinitionException.java | 47 ++++++
.../deployer/DefaultServiceGroupDeployer.java | 125 ++++++++++++++
.../grouping/deployer/ServiceGroupDeployer.java | 36 ++++
.../manager/ServiceGroupingManager.java | 73 +-------
.../internal/ADCManagementServerComponent.java | 2 -
.../bean/util/converter/PojoConverter.java | 8 -
.../rest/endpoint/services/ServiceUtils.java | 20 ++-
.../rest/endpoint/services/StratosAdmin.java | 17 +-
18 files changed, 986 insertions(+), 312 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/62dc96e9/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/application/CompositeApplicationManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/application/CompositeApplicationManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/application/CompositeApplicationManager.java
deleted file mode 100644
index 8631694..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/application/CompositeApplicationManager.java
+++ /dev/null
@@ -1,131 +0,0 @@
-package org.apache.stratos.manager.application;
-
-import java.util.Collection;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.manager.application.utils.ApplicationUtils;
-import org.apache.stratos.manager.exception.ADCException;
-import org.apache.stratos.manager.exception.PersistenceManagerException;
-import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager;
-import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication;
-
-//Grouping
-public class CompositeApplicationManager {
-
- private static Log log = LogFactory.getLog(CompositeApplicationManager.class);
-
- public void deployCompositeApplication(ConfigCompositeApplication configCompositeApplication) throws ADCException {
- if (log.isDebugEnabled()) {
- log.debug("deploying composite application " + configCompositeApplication.getAlias());
- }
- registerCompositeApplication(configCompositeApplication);
- if (log.isDebugEnabled()) {
- log.debug("publishing composite application " + configCompositeApplication.getAlias());
- }
- ApplicationUtils.publishApplicationCreatedEvent(configCompositeApplication);
- if (log.isDebugEnabled()) {
- log.debug("composite application successfully deployed" + configCompositeApplication.getAlias());
- }
- }
-
- public void unDeployCompositeApplication(String configApplicationAlias) throws ADCException {
- if (log.isDebugEnabled()) {
- log.debug("undeploying composite application " + configApplicationAlias);
- }
- // unregister application
- unRegisterCompositeApplication(configApplicationAlias);
- if (log.isDebugEnabled()) {
- log.debug("publishing composite application removed event" + configApplicationAlias);
- }
- ApplicationUtils.publishApplicationUnDeployEvent(configApplicationAlias);
- if (log.isDebugEnabled()) {
- log.debug("composite application successfully removed " + configApplicationAlias);
- }
- }
-
- private void registerCompositeApplication(ConfigCompositeApplication configCompositeApplication) throws ADCException {
-
- try {
- if (log.isDebugEnabled()) {
- log.debug("registering composite application " + configCompositeApplication.getAlias());
- }
- DataInsertionAndRetrievalManager mgr = new DataInsertionAndRetrievalManager();
- mgr.persistCompositeApplication ( configCompositeApplication);
-
- if (log.isDebugEnabled()) {
- log.debug("testing to retrieve persisted composite application ");
- Collection<ConfigCompositeApplication> apps = mgr.getCompositeApplications();
- log.debug("retrieved persisted composite application " + apps.size());
- for (ConfigCompositeApplication app : apps) {
- log.debug("retrieved persisted composite application " + app.getAlias());
- }
- }
-
- } catch (PersistenceManagerException e) {
- String errorMsg = "Error saving composite application " + configCompositeApplication.getAlias();
- log.error(errorMsg);
- throw new ADCException(errorMsg, e);
- }
-
- log.info("Successfully registered composite application " + configCompositeApplication.getAlias());
-
- }
-
- private void unRegisterCompositeApplication(String configApplicationAlias) throws ADCException {
-
- try {
- if (log.isDebugEnabled()) {
- log.debug("unregistering composite application " + configApplicationAlias);
- }
- DataInsertionAndRetrievalManager mgr = new DataInsertionAndRetrievalManager();
- mgr.removeCompositeApplication(configApplicationAlias);
-
- if (log.isDebugEnabled()) {
- log.debug("removed persisted composite application successfully");
- }
-
- } catch (PersistenceManagerException e) {
- String errorMsg = "Error undeploying composite application " + configApplicationAlias;
- log.error(errorMsg);
- throw new ADCException(errorMsg, e);
- }
-
- log.info("Successfully undeployed composite application " + configApplicationAlias);
-
- }
-
- public void restoreCompositeApplications () throws ADCException {
- try {
- if (log.isDebugEnabled()) {
- log.debug("restoring composite applications " );
- }
- DataInsertionAndRetrievalManager mgr = new DataInsertionAndRetrievalManager();
- Collection<ConfigCompositeApplication> apps = mgr.getCompositeApplications();
-
- if (apps == null) {
- if (log.isDebugEnabled()) {
- log.debug("no composite application configured");
- }
- return;
- }
- if (log.isDebugEnabled()) {
- log.debug("retrieved persisted composite application " + apps.size());
- for (ConfigCompositeApplication app : apps) {
- log.debug("retrieved persisted composite application " + app.getAlias());
- }
- }
- // sending application created event to restore in Toplogy
- for (ConfigCompositeApplication app : apps) {
- log.debug("restoring composite application " + app.getAlias());
- ApplicationUtils.publishApplicationCreatedEvent(app);
- }
-
- } catch (PersistenceManagerException e) {
- String errorMsg = "Error restoring composite application ";
- log.error(errorMsg);
- throw new ADCException(errorMsg, e);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/62dc96e9/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/application/utils/ApplicationUtils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/application/utils/ApplicationUtils.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/application/utils/ApplicationUtils.java
deleted file mode 100644
index d1634b0..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/application/utils/ApplicationUtils.java
+++ /dev/null
@@ -1,104 +0,0 @@
-package org.apache.stratos.manager.application.utils;
-
-import java.util.Set;
-import java.util.concurrent.Executor;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.broker.publish.EventPublisher;
-import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
-import org.apache.stratos.messaging.event.topology.CompositeApplicationCreatedEvent;
-import org.apache.stratos.messaging.event.topology.CompositeApplicationRemovedEvent;
-import org.apache.stratos.messaging.util.Constants;
-import org.apache.stratos.messaging.domain.topology.CompositeApplication;
-import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication;
-
-
-// Grouping
-public class ApplicationUtils {
-
- private static Log log = LogFactory.getLog(ApplicationUtils.class);
-
- static class ApplicationCreatedEventPublisher implements Runnable {
-
- private ConfigCompositeApplication configCompositeApplication;
-
- public ApplicationCreatedEventPublisher(ConfigCompositeApplication configCompositeApplication) {
- this.configCompositeApplication = configCompositeApplication;
-
- }
-
- @Override
- public void run() {
- try {
- if(log.isInfoEnabled()) {
- log.info(String.format("Publishing application createdevent: [application-alias] %s ", configCompositeApplication.getAlias()));
- }
- CompositeApplicationCreatedEvent event = new CompositeApplicationCreatedEvent(configCompositeApplication);
- EventPublisher eventPublisher = EventPublisherPool.getPublisher(Constants.TOPOLOGY_TOPIC);
- eventPublisher.publish(event);
- } catch (Exception e) {
- if (log.isErrorEnabled()) {
- log.error(String.format("Could not publish tenant subscribed event: [application-alias] %s ", configCompositeApplication.getAlias()), e);
- }
- }
-
- }
-
- }
-
- public static void publishApplicationCreatedEvent(ConfigCompositeApplication configCompositeApplication) {
-
-
- Executor exec = new Executor() {
- @Override
- public void execute(Runnable command) {
- command.run();
- }
- };
-
- exec.execute(new ApplicationCreatedEventPublisher(configCompositeApplication));
- }
-
-
- static class ApplicationRemovedEventPublisher implements Runnable {
-
- private String configCompositeApplicationAlias;
-
- public ApplicationRemovedEventPublisher(String configCompositeApplicationAlias) {
- this.configCompositeApplicationAlias = configCompositeApplicationAlias;
-
- }
-
- @Override
- public void run() {
- try {
- if(log.isInfoEnabled()) {
- log.info(String.format("Publishing application createdevent: [application-alias] %s ", configCompositeApplicationAlias));
- }
- CompositeApplicationRemovedEvent event = new CompositeApplicationRemovedEvent(configCompositeApplicationAlias);
- EventPublisher eventPublisher = EventPublisherPool.getPublisher(Constants.TOPOLOGY_TOPIC);
- eventPublisher.publish(event);
- } catch (Exception e) {
- if (log.isErrorEnabled()) {
- log.error(String.format("Could not publish composite removed event event: [application-alias] %s ", configCompositeApplicationAlias), e);
- }
- }
-
- }
-
- }
-
- public static void publishApplicationUnDeployEvent(String configApplicationAlias) {
- Executor exec = new Executor() {
- @Override
- public void execute(Runnable command) {
- command.run();
- }
- };
-
- exec.execute(new ApplicationRemovedEventPublisher(configApplicationAlias));
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/62dc96e9/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java
new file mode 100644
index 0000000..c905320
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java
@@ -0,0 +1,143 @@
+package org.apache.stratos.manager.composite.application;
+
+import java.util.Collection;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.manager.composite.application.beans.CompositeAppDefinition;
+import org.apache.stratos.manager.composite.application.parser.CompositeApplicationParser;
+import org.apache.stratos.manager.composite.application.parser.DefaultCompositeApplicationParser;
+import org.apache.stratos.manager.composite.application.utils.ApplicationUtils;
+import org.apache.stratos.manager.exception.ADCException;
+import org.apache.stratos.manager.exception.CompositeApplicationDefinitionException;
+import org.apache.stratos.manager.exception.PersistenceManagerException;
+import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager;
+import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication;
+
+//Grouping
+public class CompositeApplicationManager {
+
+ private static Log log = LogFactory.getLog(CompositeApplicationManager.class);
+
+ public void deployCompositeApplication (CompositeAppDefinition compositeAppDefinition) throws CompositeApplicationDefinitionException {
+// if (log.isDebugEnabled()) {
+// log.debug("deploying composite application " + configCompositeApplication.getAlias());
+// }
+// registerCompositeApplication(configCompositeApplication);
+// if (log.isDebugEnabled()) {
+// log.debug("publishing composite application " + configCompositeApplication.getAlias());
+// }
+// ApplicationUtils.publishApplicationCreatedEvent(configCompositeApplication);
+// if (log.isDebugEnabled()) {
+// log.debug("composite application successfully deployed" + configCompositeApplication.getAlias());
+// }
+
+ CompositeApplicationParser compositeAppParser = new DefaultCompositeApplicationParser();
+ compositeAppParser.parse(compositeAppDefinition);
+
+ // TODO: traverse the data structure and create the subscriptions
+
+ log.info("Composite Application [ Id: " + compositeAppDefinition.getApplicationId() + " , alias: "
+ + compositeAppDefinition.getAlias() + " ] deployed successfully");
+ }
+
+ public void unDeployCompositeApplication(String configApplicationAlias) throws ADCException {
+ if (log.isDebugEnabled()) {
+ log.debug("undeploying composite application " + configApplicationAlias);
+ }
+ // unregister application
+ unRegisterCompositeApplication(configApplicationAlias);
+ if (log.isDebugEnabled()) {
+ log.debug("publishing composite application removed event" + configApplicationAlias);
+ }
+ ApplicationUtils.publishApplicationUnDeployEvent(configApplicationAlias);
+ if (log.isDebugEnabled()) {
+ log.debug("composite application successfully removed " + configApplicationAlias);
+ }
+ }
+
+ private void registerCompositeApplication(ConfigCompositeApplication configCompositeApplication) throws ADCException {
+
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug("registering composite application " + configCompositeApplication.getAlias());
+ }
+ DataInsertionAndRetrievalManager mgr = new DataInsertionAndRetrievalManager();
+ mgr.persistCompositeApplication ( configCompositeApplication);
+
+ if (log.isDebugEnabled()) {
+ log.debug("testing to retrieve persisted composite application ");
+ Collection<ConfigCompositeApplication> apps = mgr.getCompositeApplications();
+ log.debug("retrieved persisted composite application " + apps.size());
+ for (ConfigCompositeApplication app : apps) {
+ log.debug("retrieved persisted composite application " + app.getAlias());
+ }
+ }
+
+ } catch (PersistenceManagerException e) {
+ String errorMsg = "Error saving composite application " + configCompositeApplication.getAlias();
+ log.error(errorMsg);
+ throw new ADCException(errorMsg, e);
+ }
+
+ log.info("Successfully registered composite application " + configCompositeApplication.getAlias());
+
+ }
+
+ private void unRegisterCompositeApplication(String configApplicationAlias) throws ADCException {
+
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug("unregistering composite application " + configApplicationAlias);
+ }
+ DataInsertionAndRetrievalManager mgr = new DataInsertionAndRetrievalManager();
+ mgr.removeCompositeApplication(configApplicationAlias);
+
+ if (log.isDebugEnabled()) {
+ log.debug("removed persisted composite application successfully");
+ }
+
+ } catch (PersistenceManagerException e) {
+ String errorMsg = "Error undeploying composite application " + configApplicationAlias;
+ log.error(errorMsg);
+ throw new ADCException(errorMsg, e);
+ }
+
+ log.info("Successfully undeployed composite application " + configApplicationAlias);
+
+ }
+
+ public void restoreCompositeApplications () throws ADCException {
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug("restoring composite applications " );
+ }
+ DataInsertionAndRetrievalManager mgr = new DataInsertionAndRetrievalManager();
+ Collection<ConfigCompositeApplication> apps = mgr.getCompositeApplications();
+
+ if (apps == null) {
+ if (log.isDebugEnabled()) {
+ log.debug("no composite application configured");
+ }
+ return;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("retrieved persisted composite application " + apps.size());
+ for (ConfigCompositeApplication app : apps) {
+ log.debug("retrieved persisted composite application " + app.getAlias());
+ }
+ }
+ // sending application created event to restore in Toplogy
+ for (ConfigCompositeApplication app : apps) {
+ log.debug("restoring composite application " + app.getAlias());
+ ApplicationUtils.publishApplicationCreatedEvent(app);
+ }
+
+ } catch (PersistenceManagerException e) {
+ String errorMsg = "Error restoring composite application ";
+ log.error(errorMsg);
+ throw new ADCException(errorMsg, e);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/62dc96e9/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/CompositeAppDefinition.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/CompositeAppDefinition.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/CompositeAppDefinition.java
new file mode 100644
index 0000000..2eea073
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/CompositeAppDefinition.java
@@ -0,0 +1,68 @@
+/*
+ * 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.manager.composite.application.beans;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.List;
+
+@XmlRootElement
+public class CompositeAppDefinition {
+
+ private String applicationId;
+
+ private String alias;
+
+ private List<GroupDefinition> groups;
+
+ private List<SubscribableInfo> subscribableInfo;
+
+
+ public String getApplicationId() {
+ return applicationId;
+ }
+
+ public void setApplicationId(String applicationId) {
+ this.applicationId = applicationId;
+ }
+
+ public String getAlias() {
+ return alias;
+ }
+
+ public void setAlias(String alias) {
+ this.alias = alias;
+ }
+
+ public List<GroupDefinition> getGroups() {
+ return groups;
+ }
+
+ public void setGroups(List<GroupDefinition> groups) {
+ this.groups = groups;
+ }
+
+ public List<SubscribableInfo> getSubscribableInfo() {
+ return subscribableInfo;
+ }
+
+ public void setSubscribableInfo(List<SubscribableInfo> subscribableInfo) {
+ this.subscribableInfo = subscribableInfo;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/62dc96e9/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/GroupDefinition.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/GroupDefinition.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/GroupDefinition.java
new file mode 100644
index 0000000..3e92eb5
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/GroupDefinition.java
@@ -0,0 +1,87 @@
+/*
+ * 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.manager.composite.application.beans;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.List;
+
+@XmlRootElement
+public class GroupDefinition {
+
+ private String name;
+
+ private String alias;
+
+ private String deploymentPolicy;
+
+ private String autoscalingPolicy;
+
+ private List<SubscribableDefinition> subscribables;
+
+ private List<GroupDefinition> groups;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getAlias() {
+ return alias;
+ }
+
+ public void setAlias(String alias) {
+ this.alias = alias;
+ }
+
+ public String getDeploymentPolicy() {
+ return deploymentPolicy;
+ }
+
+ public void setDeploymentPolicy(String deploymentPolicy) {
+ this.deploymentPolicy = deploymentPolicy;
+ }
+
+ public String getAutoscalingPolicy() {
+ return autoscalingPolicy;
+ }
+
+ public void setAutoscalingPolicy(String autoscalingPolicy) {
+ this.autoscalingPolicy = autoscalingPolicy;
+ }
+
+ public List<SubscribableDefinition> getSubscribables() {
+ return subscribables;
+ }
+
+ public void setSubscribables(List<SubscribableDefinition> subscribableDefinitions) {
+ this.subscribables = subscribableDefinitions;
+ }
+
+ public List<GroupDefinition> getGroups() {
+ return groups;
+ }
+
+ public void setGroups(List<GroupDefinition> groups) {
+ this.groups = groups;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/62dc96e9/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/SubscribableDefinition.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/SubscribableDefinition.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/SubscribableDefinition.java
new file mode 100644
index 0000000..291594b
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/SubscribableDefinition.java
@@ -0,0 +1,47 @@
+/*
+ * 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.manager.composite.application.beans;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class SubscribableDefinition {
+
+ private String type;
+
+ private String alias;
+
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getAlias() {
+ return alias;
+ }
+
+ public void setAlias(String alias) {
+ this.alias = alias;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/62dc96e9/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/SubscribableInfo.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/SubscribableInfo.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/SubscribableInfo.java
new file mode 100644
index 0000000..e3b26ba
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/SubscribableInfo.java
@@ -0,0 +1,93 @@
+/*
+ * 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.manager.composite.application.beans;
+
+public class SubscribableInfo {
+
+ private String alias;
+
+ private String deploymentPolicy;
+
+ private String autoscalingPolicy;
+
+ private String repoUrl;
+
+ private boolean privateRepo;
+
+ private String username;
+
+ private String password;
+
+ public String getAlias() {
+ return alias;
+ }
+
+ public void setAlias(String alias) {
+ this.alias = alias;
+ }
+
+ public String getDeploymentPolicy() {
+ return deploymentPolicy;
+ }
+
+ public void setDeploymentPolicy(String deploymentPolicy) {
+ this.deploymentPolicy = deploymentPolicy;
+ }
+
+ public String getAutoscalingPolicy() {
+ return autoscalingPolicy;
+ }
+
+ public void setAutoscalingPolicy(String autoscalingPolicy) {
+ this.autoscalingPolicy = autoscalingPolicy;
+ }
+
+ public String getRepoUrl() {
+ return repoUrl;
+ }
+
+ public void setRepoUrl(String repoUrl) {
+ this.repoUrl = repoUrl;
+ }
+
+ public boolean isPrivateRepo() {
+ return privateRepo;
+ }
+
+ public void setPrivateRepo(boolean privateRepo) {
+ this.privateRepo = privateRepo;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/62dc96e9/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/CompositeApplicationParser.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/CompositeApplicationParser.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/CompositeApplicationParser.java
new file mode 100644
index 0000000..829da0f
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/CompositeApplicationParser.java
@@ -0,0 +1,29 @@
+/*
+ * 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.manager.composite.application.parser;
+
+import org.apache.stratos.cloud.controller.stub.pojo.CompositeApplicationDefinition;
+import org.apache.stratos.manager.exception.CompositeApplicationDefinitionException;
+
+
+public interface CompositeApplicationParser {
+
+ public CompositeApplicationDefinition parse (Object obj) throws CompositeApplicationDefinitionException;
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/62dc96e9/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java
new file mode 100644
index 0000000..da560a9
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java
@@ -0,0 +1,166 @@
+/*
+ * 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.manager.composite.application.parser;
+
+import org.apache.stratos.cloud.controller.stub.pojo.CompositeApplicationDefinition;
+import org.apache.stratos.manager.composite.application.beans.CompositeAppDefinition;
+import org.apache.stratos.manager.composite.application.beans.GroupDefinition;
+import org.apache.stratos.manager.composite.application.beans.SubscribableDefinition;
+import org.apache.stratos.manager.composite.application.beans.SubscribableInfo;
+import org.apache.stratos.manager.exception.CompositeApplicationDefinitionException;
+import org.apache.stratos.manager.exception.PersistenceManagerException;
+import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition;
+import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager;
+
+import java.util.List;
+
+public class DefaultCompositeApplicationParser implements CompositeApplicationParser {
+
+ DataInsertionAndRetrievalManager dataInsertionAndRetrievalManager;
+
+ public DefaultCompositeApplicationParser () {
+ dataInsertionAndRetrievalManager = new DataInsertionAndRetrievalManager();
+ }
+
+ @Override
+ public CompositeApplicationDefinition parse (Object compositeAppObj) throws CompositeApplicationDefinitionException {
+
+ CompositeAppDefinition compositeAppDefinition = null;
+
+ if (compositeAppObj instanceof CompositeAppDefinition) {
+ compositeAppDefinition = (CompositeAppDefinition) compositeAppObj;
+
+ } else {
+ throw new CompositeApplicationDefinitionException("Invalid Composite Application definition");
+ }
+
+ if (compositeAppDefinition == null) {
+ throw new CompositeApplicationDefinitionException("Composite Application definition not found");
+ }
+
+ String compositeAppId = compositeAppDefinition.getApplicationId();
+ String compositeAppAlias = compositeAppDefinition.getAlias();
+
+ // groups
+ processGroups(compositeAppDefinition.getGroups());
+
+ // get subscription related information
+ if (compositeAppDefinition.getSubscribableInfo() != null) {
+ // get the set (flat structure, not recursive) iterate and fill in..
+ }
+
+ return null;
+ }
+
+ // TODO: should return the relevant object type to send to CC
+ private void processGroups (List<GroupDefinition> groups) throws CompositeApplicationDefinitionException {
+
+ if (groups == null) {
+ return;
+ }
+
+ for (GroupDefinition group : groups) {
+ // process the group definitions
+ String groupName = group.getName();
+ String groupAlias = group.getAlias();
+
+ // neither group name nor alias can be empty
+ if (groupName == null || groupName.isEmpty()) {
+ throw new CompositeApplicationDefinitionException("Group Name is invalid");
+ }
+ if (groupAlias == null || groupAlias.isEmpty()) {
+ throw new CompositeApplicationDefinitionException("Group Alias is invalid");
+ }
+
+ // check if the group is deployed. if not can't continue
+ if (!isGroupDeployed(groupName)) {
+ throw new CompositeApplicationDefinitionException("No Service Group found with name [ " + groupName + " ]");
+ }
+
+ // get group level policy information
+ String groupDepPolicy = group.getDeploymentPolicy();
+ String groupScalePolicy = group.getAutoscalingPolicy();
+
+ // subscribables
+ processSubscribables(group.getSubscribables());
+
+ // nested groups
+ processGroups(group.getGroups());
+ }
+ }
+
+ private boolean isGroupDeployed (String groupName) throws CompositeApplicationDefinitionException {
+
+ ServiceGroupDefinition serviceGroupDefinition = null;
+
+ try {
+ serviceGroupDefinition = dataInsertionAndRetrievalManager.getServiceGroupDefinition(groupName);
+
+ } catch (PersistenceManagerException e) {
+ throw new CompositeApplicationDefinitionException(e);
+ }
+
+ return serviceGroupDefinition != null;
+ }
+
+ // TODO: should return the relevant object type to send to CC
+ private void processSubscribables (List<SubscribableDefinition> subscribables) throws CompositeApplicationDefinitionException {
+
+ if (subscribables == null) {
+ return;
+ }
+
+ for (SubscribableDefinition subscribable : subscribables) {
+
+ String cartridgeType = subscribable.getType();
+ String subscriptionAlias = subscribable.getAlias();
+
+ // neither cartridge type nor alias can be empty
+ if (cartridgeType == null || cartridgeType.isEmpty()) {
+ throw new CompositeApplicationDefinitionException("Cartridge Type is invalid");
+ }
+ if (subscriptionAlias == null || subscriptionAlias.isEmpty()) {
+ throw new CompositeApplicationDefinitionException("Subscription Alias is invalid");
+ }
+
+
+ }
+ }
+
+ // TODO: should return the relevant object type to send to CC
+ private void getSubscriptionInformation (List<SubscribableInfo> subscribables, String subscriptionAlias) throws CompositeApplicationDefinitionException {
+
+ for (SubscribableInfo subscribable : subscribables) {
+
+ if (subscribable.getAlias().equals(subscriptionAlias)) {
+ // match found, retrieve the information
+ String deploymentPolicy = subscribable.getDeploymentPolicy();
+ String autoscalingPolicy = subscribable.getAutoscalingPolicy();
+ String repoUrl = subscribable.getRepoUrl();
+ if (repoUrl != null && !repoUrl.isEmpty()) {
+ boolean privateRepo = subscribable.isPrivateRepo();
+ String repoUsername = subscribable.getUsername();
+ String repoPassword = subscribable.getPassword();
+ }
+ }
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/62dc96e9/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/utils/ApplicationUtils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/utils/ApplicationUtils.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/utils/ApplicationUtils.java
new file mode 100644
index 0000000..8b7cdbb
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/utils/ApplicationUtils.java
@@ -0,0 +1,102 @@
+package org.apache.stratos.manager.composite.application.utils;
+
+import java.util.concurrent.Executor;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.broker.publish.EventPublisher;
+import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
+import org.apache.stratos.messaging.event.topology.CompositeApplicationCreatedEvent;
+import org.apache.stratos.messaging.event.topology.CompositeApplicationRemovedEvent;
+import org.apache.stratos.messaging.util.Constants;
+import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication;
+
+
+// Grouping
+public class ApplicationUtils {
+
+ private static Log log = LogFactory.getLog(ApplicationUtils.class);
+
+ static class ApplicationCreatedEventPublisher implements Runnable {
+
+ private ConfigCompositeApplication configCompositeApplication;
+
+ public ApplicationCreatedEventPublisher(ConfigCompositeApplication configCompositeApplication) {
+ this.configCompositeApplication = configCompositeApplication;
+
+ }
+
+ @Override
+ public void run() {
+ try {
+ if(log.isInfoEnabled()) {
+ log.info(String.format("Publishing application createdevent: [application-alias] %s ", configCompositeApplication.getAlias()));
+ }
+ CompositeApplicationCreatedEvent event = new CompositeApplicationCreatedEvent(configCompositeApplication);
+ EventPublisher eventPublisher = EventPublisherPool.getPublisher(Constants.TOPOLOGY_TOPIC);
+ eventPublisher.publish(event);
+ } catch (Exception e) {
+ if (log.isErrorEnabled()) {
+ log.error(String.format("Could not publish tenant subscribed event: [application-alias] %s ", configCompositeApplication.getAlias()), e);
+ }
+ }
+
+ }
+
+ }
+
+ public static void publishApplicationCreatedEvent(ConfigCompositeApplication configCompositeApplication) {
+
+
+ Executor exec = new Executor() {
+ @Override
+ public void execute(Runnable command) {
+ command.run();
+ }
+ };
+
+ exec.execute(new ApplicationCreatedEventPublisher(configCompositeApplication));
+ }
+
+
+ static class ApplicationRemovedEventPublisher implements Runnable {
+
+ private String configCompositeApplicationAlias;
+
+ public ApplicationRemovedEventPublisher(String configCompositeApplicationAlias) {
+ this.configCompositeApplicationAlias = configCompositeApplicationAlias;
+
+ }
+
+ @Override
+ public void run() {
+ try {
+ if(log.isInfoEnabled()) {
+ log.info(String.format("Publishing application createdevent: [application-alias] %s ", configCompositeApplicationAlias));
+ }
+ CompositeApplicationRemovedEvent event = new CompositeApplicationRemovedEvent(configCompositeApplicationAlias);
+ EventPublisher eventPublisher = EventPublisherPool.getPublisher(Constants.TOPOLOGY_TOPIC);
+ eventPublisher.publish(event);
+ } catch (Exception e) {
+ if (log.isErrorEnabled()) {
+ log.error(String.format("Could not publish composite removed event event: [application-alias] %s ", configCompositeApplicationAlias), e);
+ }
+ }
+
+ }
+
+ }
+
+ public static void publishApplicationUnDeployEvent(String configApplicationAlias) {
+ Executor exec = new Executor() {
+ @Override
+ public void execute(Runnable command) {
+ command.run();
+ }
+ };
+
+ exec.execute(new ApplicationRemovedEventPublisher(configApplicationAlias));
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/62dc96e9/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/CompositeApplicationDefinitionException.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/CompositeApplicationDefinitionException.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/CompositeApplicationDefinitionException.java
new file mode 100644
index 0000000..bda75ab
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/CompositeApplicationDefinitionException.java
@@ -0,0 +1,47 @@
+/*
+ * 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.manager.exception;
+
+public class CompositeApplicationDefinitionException extends Exception {
+
+ private String message;
+
+ public CompositeApplicationDefinitionException () {
+ super();
+ }
+
+ public CompositeApplicationDefinitionException (String message, Throwable cause) {
+ super(message, cause);
+ this.message = message;
+ }
+
+ public CompositeApplicationDefinitionException (String message) {
+ super(message);
+ this.message = message;
+ }
+
+ public CompositeApplicationDefinitionException (Throwable cause) {
+ super(cause);
+ }
+
+ public String getMessage() {
+ return message;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/62dc96e9/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/deployer/DefaultServiceGroupDeployer.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/deployer/DefaultServiceGroupDeployer.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/deployer/DefaultServiceGroupDeployer.java
new file mode 100644
index 0000000..4744f9f
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/deployer/DefaultServiceGroupDeployer.java
@@ -0,0 +1,125 @@
+/*
+ * 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.manager.grouping.deployer;
+
+import org.apache.axis2.AxisFault;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException;
+import org.apache.stratos.manager.client.CloudControllerServiceClient;
+import org.apache.stratos.manager.exception.ADCException;
+import org.apache.stratos.manager.exception.InvalidServiceGroupException;
+import org.apache.stratos.manager.exception.PersistenceManagerException;
+import org.apache.stratos.manager.exception.ServiceGroupDefinitioException;
+import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition;
+import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager;
+
+import java.rmi.RemoteException;
+import java.util.List;
+
+public class DefaultServiceGroupDeployer implements ServiceGroupDeployer {
+
+ private static Log log = LogFactory.getLog(DefaultServiceGroupDeployer.class);
+
+ private DataInsertionAndRetrievalManager dataInsertionAndRetrievalMgr;
+
+ public DefaultServiceGroupDeployer () {
+ dataInsertionAndRetrievalMgr = new DataInsertionAndRetrievalManager();
+ }
+
+ public void deployServiceGroupDefinition (Object serviceGroupDefinitionObj) throws InvalidServiceGroupException,
+ CloudControllerServiceUnregisteredCartridgeExceptionException, ServiceGroupDefinitioException, ADCException {
+
+ ServiceGroupDefinition serviceGroupDefinition = null;
+
+ if (serviceGroupDefinitionObj instanceof ServiceGroupDefinition) {
+ serviceGroupDefinition = (ServiceGroupDefinition) serviceGroupDefinitionObj;
+ } else {
+ throw new InvalidServiceGroupException("Invalid Service Group definition");
+ }
+
+ if (serviceGroupDefinition == null) {
+ throw new InvalidServiceGroupException("Service Group definition not found");
+ }
+
+ // if any cartridges are specified in the group, they should be already deployed
+ if (serviceGroupDefinition.getCartridges() != null) {
+ List<String> cartridgeTypes = serviceGroupDefinition.getCartridges();
+
+ CloudControllerServiceClient ccServiceClient = null;
+
+ try {
+ ccServiceClient = CloudControllerServiceClient.getServiceClient();
+
+ } catch (AxisFault axisFault) {
+ throw new ADCException(axisFault);
+ }
+
+ for (String cartridgeType : cartridgeTypes) {
+ try {
+ if(ccServiceClient.getCartridgeInfo(cartridgeType) == null) {
+ // cartridge is not deployed, can't continue
+ throw new InvalidServiceGroupException("No Cartridge Definition found with type " + cartridgeType);
+ }
+ } catch (RemoteException e) {
+ throw new ADCException(e);
+ }
+ }
+ }
+
+ // if any sub groups are specified in the group, they should be already deployed
+ if (serviceGroupDefinition.getSubGroups() != null) {
+ List<String> subGroupNames = serviceGroupDefinition.getSubGroups();
+ for (String subGroupName : subGroupNames) {
+ if (getServiceGroupDefinition(subGroupName) == null) {
+ // sub group not deployed, can't continue
+ throw new InvalidServiceGroupException("No Service Group Definition found with name " + subGroupName);
+ }
+ }
+ }
+
+ try {
+ dataInsertionAndRetrievalMgr.peristServiceGroupDefinition(serviceGroupDefinition);
+
+ } catch (PersistenceManagerException e) {
+ throw new InvalidServiceGroupException(e);
+ }
+ }
+
+ public ServiceGroupDefinition getServiceGroupDefinition (String serviceGroupDefinitionName) throws ServiceGroupDefinitioException {
+
+ try {
+ return dataInsertionAndRetrievalMgr.getServiceGroupDefinition(serviceGroupDefinitionName);
+
+ } catch (PersistenceManagerException e) {
+ throw new ServiceGroupDefinitioException(e);
+ }
+ }
+
+ public void undeployServiceGroupDefinition (String serviceGroupDefinitionName) throws ServiceGroupDefinitioException {
+
+ try {
+ dataInsertionAndRetrievalMgr.removeServiceGroupDefinition(serviceGroupDefinitionName);
+
+ } catch (PersistenceManagerException e) {
+ throw new ServiceGroupDefinitioException(e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/62dc96e9/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/deployer/ServiceGroupDeployer.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/deployer/ServiceGroupDeployer.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/deployer/ServiceGroupDeployer.java
new file mode 100644
index 0000000..da8ff53
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/deployer/ServiceGroupDeployer.java
@@ -0,0 +1,36 @@
+/*
+ * 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.manager.grouping.deployer;
+
+import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException;
+import org.apache.stratos.manager.exception.ADCException;
+import org.apache.stratos.manager.exception.InvalidServiceGroupException;
+import org.apache.stratos.manager.exception.ServiceGroupDefinitioException;
+import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition;
+
+public interface ServiceGroupDeployer {
+
+ public void deployServiceGroupDefinition (Object serviceGroupObj) throws InvalidServiceGroupException, ServiceGroupDefinitioException,
+ ADCException, CloudControllerServiceUnregisteredCartridgeExceptionException;
+
+ public ServiceGroupDefinition getServiceGroupDefinition (String serviceGroupDefinitionName) throws ServiceGroupDefinitioException;
+
+ public void undeployServiceGroupDefinition (String serviceGroupDefinitionName) throws ServiceGroupDefinitioException;
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/62dc96e9/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/manager/ServiceGroupingManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/manager/ServiceGroupingManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/manager/ServiceGroupingManager.java
index 49565fe..3c42e01 100644
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/manager/ServiceGroupingManager.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/manager/ServiceGroupingManager.java
@@ -19,96 +19,39 @@
package org.apache.stratos.manager.grouping.manager;
-import org.apache.axis2.AxisFault;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException;
-import org.apache.stratos.manager.client.CloudControllerServiceClient;
import org.apache.stratos.manager.exception.ADCException;
import org.apache.stratos.manager.exception.InvalidServiceGroupException;
-import org.apache.stratos.manager.exception.PersistenceManagerException;
import org.apache.stratos.manager.exception.ServiceGroupDefinitioException;
import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition;
-import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager;
+import org.apache.stratos.manager.grouping.deployer.DefaultServiceGroupDeployer;
+import org.apache.stratos.manager.grouping.deployer.ServiceGroupDeployer;
-import java.rmi.RemoteException;
-import java.util.List;
public class ServiceGroupingManager {
- private static Log log = LogFactory.getLog(ServiceGroupingManager.class);
-
- private DataInsertionAndRetrievalManager dataInsertionAndRetrievalMgr;
+ //private static Log log = LogFactory.getLog(ServiceGroupingManager.class);
+ private ServiceGroupDeployer serviceGroupDeployer;
public ServiceGroupingManager () {
- dataInsertionAndRetrievalMgr = new DataInsertionAndRetrievalManager();
+ serviceGroupDeployer = new DefaultServiceGroupDeployer();
}
public void deployServiceGroupDefinition (ServiceGroupDefinition serviceGroupDefinition) throws InvalidServiceGroupException,
CloudControllerServiceUnregisteredCartridgeExceptionException, ServiceGroupDefinitioException, ADCException {
-
- // if any cartridges are specified in the group, they should be already deployed
- if (serviceGroupDefinition.getCartridges() != null) {
- List<String> cartridgeTypes = serviceGroupDefinition.getCartridges();
-
- CloudControllerServiceClient ccServiceClient = null;
-
- try {
- ccServiceClient = CloudControllerServiceClient.getServiceClient();
-
- } catch (AxisFault axisFault) {
- throw new ADCException(axisFault);
- }
-
- for (String cartridgeType : cartridgeTypes) {
- try {
- if(ccServiceClient.getCartridgeInfo(cartridgeType) == null) {
- // cartridge is not deployed, can't continue
- throw new InvalidServiceGroupException("No Cartridge Definition found with type " + cartridgeType);
- }
- } catch (RemoteException e) {
- throw new ADCException(e);
- }
- }
- }
-
- // if any sub groups are specified in the group, they should be already deployed
- if (serviceGroupDefinition.getSubGroups() != null) {
- List<String> subGroupNames = serviceGroupDefinition.getSubGroups();
- for (String subGroupName : subGroupNames) {
- if (getServiceGroupDefinition(subGroupName) == null) {
- // sub group not deployed, can't continue
- throw new InvalidServiceGroupException("No Service Group Definition found with name " + subGroupName);
- }
- }
- }
-
- try {
- dataInsertionAndRetrievalMgr.peristServiceGroupDefinition(serviceGroupDefinition);
-
- } catch (PersistenceManagerException e) {
- throw new InvalidServiceGroupException(e);
- }
+ serviceGroupDeployer.deployServiceGroupDefinition(serviceGroupDefinition);
}
public ServiceGroupDefinition getServiceGroupDefinition (String serviceGroupDefinitionName) throws ServiceGroupDefinitioException {
- try {
- return dataInsertionAndRetrievalMgr.getServiceGroupDefinition(serviceGroupDefinitionName);
-
- } catch (PersistenceManagerException e) {
- throw new ServiceGroupDefinitioException(e);
- }
+ return serviceGroupDeployer.getServiceGroupDefinition(serviceGroupDefinitionName);
}
public void undeployServiceGroupDefinition (String serviceGroupDefinitionName) throws ServiceGroupDefinitioException {
- try {
- dataInsertionAndRetrievalMgr.removeServiceGroupDefinition(serviceGroupDefinitionName);
-
- } catch (PersistenceManagerException e) {
- throw new ServiceGroupDefinitioException(e);
- }
+ serviceGroupDeployer.undeployServiceGroupDefinition(serviceGroupDefinitionName);
}
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/62dc96e9/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/ADCManagementServerComponent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/ADCManagementServerComponent.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/ADCManagementServerComponent.java
index 68f6a6e..c408eac 100644
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/ADCManagementServerComponent.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/ADCManagementServerComponent.java
@@ -20,8 +20,6 @@ package org.apache.stratos.manager.internal;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.manager.application.CompositeApplicationManager;
-import org.apache.stratos.manager.exception.ADCException;
import org.apache.stratos.manager.listener.InstanceStatusListener;
import org.apache.stratos.manager.publisher.TenantEventPublisher;
import org.apache.stratos.manager.publisher.TenantSynchronizerTaskScheduler;
http://git-wip-us.apache.org/repos/asf/stratos/blob/62dc96e9/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java
index 84ddfbf..6a771aa 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java
@@ -22,10 +22,8 @@ package org.apache.stratos.rest.endpoint.bean.util.converter;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.lang.StringUtils;
import org.apache.stratos.cloud.controller.stub.pojo.*;
-import org.apache.stratos.manager.application.utils.ApplicationUtils;
import org.apache.stratos.manager.deploy.service.Service;
import org.apache.stratos.messaging.domain.topology.Cluster;
-import org.apache.stratos.messaging.domain.topology.CompositeApplication;
import org.apache.stratos.rest.endpoint.bean.autoscaler.partition.Partition;
import org.apache.stratos.rest.endpoint.bean.autoscaler.partition.PartitionGroup;
import org.apache.stratos.rest.endpoint.bean.autoscaler.policy.autoscale.*;
@@ -36,13 +34,7 @@ import org.apache.stratos.rest.endpoint.bean.compositeapplication.definition.Con
import org.apache.stratos.rest.endpoint.bean.compositeapplication.definition.ConfigDependencies;
import org.apache.stratos.rest.endpoint.bean.compositeapplication.definition.ConfigGroup;
import org.apache.stratos.rest.endpoint.bean.topology.Member;
-import org.apache.stratos.messaging.domain.topology.Cartridge;
-import org.apache.stratos.messaging.domain.topology.Composite;
import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication;
-import org.apache.stratos.messaging.domain.topology.Dependencies;
-import org.apache.stratos.messaging.domain.topology.Group;
-import org.apache.stratos.messaging.domain.topology.Scalable;
-import org.apache.stratos.messaging.domain.topology.util.CompositeApplicationBuilder;
import org.apache.commons.logging.Log;
import java.util.ArrayList;
http://git-wip-us.apache.org/repos/asf/stratos/blob/62dc96e9/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
index c3781f8..b357eed 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
@@ -34,7 +34,8 @@ import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidCar
import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidCartridgeTypeExceptionException;
import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidCompositeApplicationDefinitionExceptionException;
import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidIaasProviderExceptionException;
-import org.apache.stratos.manager.application.CompositeApplicationManager;
+import org.apache.stratos.manager.composite.application.beans.CompositeAppDefinition;
+import org.apache.stratos.manager.composite.application.CompositeApplicationManager;
import org.apache.stratos.manager.client.AutoscalerServiceClient;
import org.apache.stratos.manager.client.CloudControllerServiceClient;
import org.apache.stratos.manager.deploy.service.Service;
@@ -87,6 +88,7 @@ public class ServiceUtils {
private static CartridgeSubscriptionManager cartridgeSubsciptionManager = new CartridgeSubscriptionManager();
private static ServiceGroupingManager serviceGropingManager = new ServiceGroupingManager();
private static ServiceDeploymentManager serviceDeploymentManager = new ServiceDeploymentManager();
+ private static CompositeApplicationManager compositeApplicationManager = new CompositeApplicationManager();
static StratosAdminResponse deployCartridge (CartridgeDefinitionBean cartridgeDefinitionBean, ConfigurationContext ctxt,
String userName, String tenantDomain) throws RestAPIException {
@@ -250,6 +252,22 @@ public class ServiceUtils {
stratosAdminResponse.setMessage("Successfully composite application to cloud controller");
return stratosAdminResponse;
}
+
+ static StratosAdminResponse deployCompositeApplicationDefintion (CompositeAppDefinition compositeAppDefinition)
+ throws RestAPIException {
+
+ try {
+ compositeApplicationManager.deployCompositeApplication(compositeAppDefinition);
+
+ } catch (CompositeApplicationDefinitionException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+
+ StratosAdminResponse stratosAdminResponse = new StratosAdminResponse();
+ stratosAdminResponse.setMessage("Successfully deployed Composite Application [ Id: " + compositeAppDefinition.getApplicationId()
+ + " , alias: " + compositeAppDefinition.getAlias() + " ]");
+ return stratosAdminResponse;
+ }
static StratosAdminResponse unDeployApplication(String configCompositeApplicationAlias, ConfigurationContext ctxt,
String userName, String tenantDomain) throws RestAPIException {
http://git-wip-us.apache.org/repos/asf/stratos/blob/62dc96e9/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
index b43f04d..dd30f09 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
@@ -24,6 +24,7 @@ import org.apache.stratos.common.beans.TenantInfoBean;
import org.apache.stratos.common.exception.StratosException;
import org.apache.stratos.common.util.ClaimsMgtUtil;
import org.apache.stratos.common.util.CommonUtil;
+import org.apache.stratos.manager.composite.application.beans.CompositeAppDefinition;
import org.apache.stratos.manager.dto.Cartridge;
import org.apache.stratos.manager.dto.SubscriptionInfo;
import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition;
@@ -106,7 +107,7 @@ public class StratosAdmin extends AbstractAdmin {
return Response.ok().header("WWW-Authenticate", "Basic").type(MediaType.APPLICATION_JSON).
entity(Utils.buildAuthenticationSuccessMessage(sessionId)).build();
}
-
+
@POST
@Path("/application/definition/")
@Produces("application/json")
@@ -124,6 +125,20 @@ public class StratosAdmin extends AbstractAdmin {
getTenantDomain());
}
+
+ /* @POST
+ @Path("/application/definition/")
+ @Produces("application/json")
+ @Consumes("application/json")
+ @AuthorizationAction("/permission/protected/manage/monitor/tenants")
+ @SuperTenantService(true)
+ // Grouping
+ public StratosAdminResponse deployApplicationDefinition(CompositeAppDefinition compositeAppDefinition)
+ throws RestAPIException {
+
+ return ServiceUtils.deployCompositeApplicationDefintion(compositeAppDefinition);
+ } */
+
@POST
@Path("/application/definition/undeploy")