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/03 18:38:35 UTC
git commit: persisting Service Groups - initial impl.
Repository: stratos
Updated Branches:
refs/heads/4.0.0-grouping 991d7856d -> f8b27de43
persisting Service Groups - initial impl.
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/f8b27de4
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/f8b27de4
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/f8b27de4
Branch: refs/heads/4.0.0-grouping
Commit: f8b27de43b5defc567f2961ec3d840cf4a923ce3
Parents: 991d785
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Thu Jul 3 19:53:33 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Thu Jul 3 19:53:33 2014 +0530
----------------------------------------------------------------------
.../exception/InvalidServiceGroupException.java | 47 ++++++++
.../ServiceGroupDefinitioException.java | 47 ++++++++
.../definitions/DependencyDefinitions.java | 48 ++++++++
.../definitions/ServiceGroupDefinition.java | 68 +++++++++++
.../definitions/StartupOrderDefinition.java | 47 ++++++++
.../manager/ServiceGroupingManager.java | 114 +++++++++++++++++++
.../manager/persistence/PersistenceManager.java | 7 ++
.../RegistryBasedPersistenceManager.java | 73 ++++++++++++
.../DataInsertionAndRetrievalManager.java | 14 +++
.../stratos/manager/utils/Serializer.java | 20 ++++
.../rest/endpoint/services/ServiceUtils.java | 58 ++++++++--
.../rest/endpoint/services/StratosAdmin.java | 37 +++++-
12 files changed, 572 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/f8b27de4/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/InvalidServiceGroupException.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/InvalidServiceGroupException.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/InvalidServiceGroupException.java
new file mode 100644
index 0000000..063cebb
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/InvalidServiceGroupException.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 InvalidServiceGroupException extends Exception {
+
+ private String message;
+
+ public InvalidServiceGroupException () {
+ super();
+ }
+
+ public InvalidServiceGroupException (String message, Throwable cause) {
+ super(message, cause);
+ this.message = message;
+ }
+
+ public InvalidServiceGroupException (String message) {
+ super(message);
+ this.message = message;
+ }
+
+ public InvalidServiceGroupException (Throwable cause) {
+ super(cause);
+ }
+
+ public String getMessage() {
+ return message;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/f8b27de4/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/ServiceGroupDefinitioException.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/ServiceGroupDefinitioException.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/ServiceGroupDefinitioException.java
new file mode 100644
index 0000000..5644ddb
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/ServiceGroupDefinitioException.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 ServiceGroupDefinitioException extends Exception {
+
+ private String message;
+
+ public ServiceGroupDefinitioException () {
+ super();
+ }
+
+ public ServiceGroupDefinitioException (String message, Throwable cause) {
+ super(message, cause);
+ this.message = message;
+ }
+
+ public ServiceGroupDefinitioException (String message) {
+ super(message);
+ this.message = message;
+ }
+
+ public ServiceGroupDefinitioException (Throwable cause) {
+ super(cause);
+ }
+
+ public String getMessage() {
+ return message;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/f8b27de4/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/DependencyDefinitions.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/DependencyDefinitions.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/DependencyDefinitions.java
new file mode 100644
index 0000000..eee4634
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/DependencyDefinitions.java
@@ -0,0 +1,48 @@
+/*
+ * 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.definitions;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+import java.util.List;
+
+@XmlRootElement(name = "dependencies")
+public class DependencyDefinitions implements Serializable {
+
+ private List<StartupOrderDefinition> startupOrder;
+
+ private String killBehaviour;
+
+ public List<StartupOrderDefinition> getStartupOrder() {
+ return startupOrder;
+ }
+
+ public void setStartupOrder(List<StartupOrderDefinition> startupOrder) {
+ this.startupOrder = startupOrder;
+ }
+
+ public String getKillBehaviour() {
+ return killBehaviour;
+ }
+
+ public void setKillBehaviour(String killBehaviour) {
+ this.killBehaviour = killBehaviour;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/f8b27de4/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/ServiceGroupDefinition.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/ServiceGroupDefinition.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/ServiceGroupDefinition.java
new file mode 100644
index 0000000..ac8321f
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/ServiceGroupDefinition.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.grouping.definitions;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+import java.util.List;
+
+@XmlRootElement(name = "serviceGroup")
+public class ServiceGroupDefinition implements Serializable {
+
+ private String name;
+
+ private List<String> subGroups;
+
+ private List<String> cartridges;
+
+ private DependencyDefinitions dependencies;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public List<String> getSubGroups() {
+ return subGroups;
+ }
+
+ public void setSubGroups(List<String> subGroups) {
+ this.subGroups = subGroups;
+ }
+
+ public List<String> getCartridges() {
+ return cartridges;
+ }
+
+ public void setCartridges(List<String> cartridges) {
+ this.cartridges = cartridges;
+ }
+
+ public DependencyDefinitions getDependencies() {
+ return dependencies;
+ }
+
+ public void setDependencies(DependencyDefinitions dependencies) {
+ this.dependencies = dependencies;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/f8b27de4/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/StartupOrderDefinition.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/StartupOrderDefinition.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/StartupOrderDefinition.java
new file mode 100644
index 0000000..522e3a2
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/StartupOrderDefinition.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.grouping.definitions;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+
+@XmlRootElement(name = "startupOrder")
+public class StartupOrderDefinition implements Serializable {
+
+ private String start;
+
+ private String after;
+
+ public String getStart() {
+ return start;
+ }
+
+ public void setStart(String start) {
+ this.start = start;
+ }
+
+ public String getAfter() {
+ return after;
+ }
+
+ public void setAfter(String after) {
+ this.after = after;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/f8b27de4/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
new file mode 100644
index 0000000..49565fe
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/manager/ServiceGroupingManager.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.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 java.rmi.RemoteException;
+import java.util.List;
+
+public class ServiceGroupingManager {
+
+ private static Log log = LogFactory.getLog(ServiceGroupingManager.class);
+
+ private DataInsertionAndRetrievalManager dataInsertionAndRetrievalMgr;
+
+ public ServiceGroupingManager () {
+ dataInsertionAndRetrievalMgr = new DataInsertionAndRetrievalManager();
+ }
+
+ 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);
+ }
+ }
+
+ 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/f8b27de4/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/persistence/PersistenceManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/persistence/PersistenceManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/persistence/PersistenceManager.java
index d5712c3..65b31c4 100644
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/persistence/PersistenceManager.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/persistence/PersistenceManager.java
@@ -21,6 +21,7 @@ package org.apache.stratos.manager.persistence;
import org.apache.stratos.manager.deploy.service.Service;
import org.apache.stratos.manager.exception.PersistenceManagerException;
+import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition;
import org.apache.stratos.manager.subscription.CartridgeSubscription;
import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication;
@@ -47,6 +48,12 @@ public abstract class PersistenceManager {
public abstract Service getService (String cartridgeType) throws PersistenceManagerException;
public abstract void removeService (String cartridgeType) throws PersistenceManagerException;
+
+ public abstract void persistServiceGroupDefinition (ServiceGroupDefinition serviceGroupDefinition) throws PersistenceManagerException;
+
+ public abstract ServiceGroupDefinition getServiceGroupDefinition (String serviceGroupDefinitionName) throws PersistenceManagerException;
+
+ public abstract void removeServiceGroupDefinition (String serviceGroupDefinitionName) throws PersistenceManagerException;
//Grouping
public abstract void persistDeployedCompositeApplication(ConfigCompositeApplication configCompositeApplication) throws PersistenceManagerException;
http://git-wip-us.apache.org/repos/asf/stratos/blob/f8b27de4/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/persistence/RegistryBasedPersistenceManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/persistence/RegistryBasedPersistenceManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/persistence/RegistryBasedPersistenceManager.java
index 408c1bb..f4eb8ba 100644
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/persistence/RegistryBasedPersistenceManager.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/persistence/RegistryBasedPersistenceManager.java
@@ -23,6 +23,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.manager.deploy.service.Service;
import org.apache.stratos.manager.exception.PersistenceManagerException;
+import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition;
import org.apache.stratos.manager.registry.RegistryManager;
import org.apache.stratos.manager.subscription.CartridgeSubscription;
import org.apache.stratos.manager.utils.Deserializer;
@@ -47,6 +48,8 @@ public class RegistryBasedPersistenceManager extends PersistenceManager {
private static final String INACTIVE_SUBSCRIPTIONS = "/subscriptions/inactive";
private static final String SERVICES = "/services";
private static final String COMPOSITE_APPLICATION = "/composite_applications";
+ private static final String SERVICE_GROUPING = "/service.grouping";
+ private static final String SERVICE_GROUPING_DEFINITIONS = SERVICE_GROUPING + "/definitions";
@Override
public void persistCartridgeSubscription (CartridgeSubscription cartridgeSubscription) throws PersistenceManagerException {
@@ -668,4 +671,74 @@ public class RegistryBasedPersistenceManager extends PersistenceManager {
}
}
+ @Override
+ public void persistServiceGroupDefinition(ServiceGroupDefinition serviceGroupDefinition) throws PersistenceManagerException {
+
+ // persist Service Group Definition
+ try {
+ RegistryManager.getInstance().persist(STRATOS_MANAGER_REOSURCE + SERVICE_GROUPING_DEFINITIONS + "/" +
+ serviceGroupDefinition.getName(),
+ Serializer.serializeServiceGroupDefinitionToByteArray(serviceGroupDefinition), null);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Persisted Service Group Definition successfully: [ " + serviceGroupDefinition.getName() + " ]");
+ }
+
+ } catch (RegistryException e) {
+ throw new PersistenceManagerException(e);
+
+ } catch (IOException e) {
+ throw new PersistenceManagerException(e);
+ }
+ }
+
+ @Override
+ public ServiceGroupDefinition getServiceGroupDefinition(String serviceGroupDefinitionName) throws PersistenceManagerException {
+
+ Object byteObj;
+
+ try {
+ byteObj = RegistryManager.getInstance().retrieve(STRATOS_MANAGER_REOSURCE + SERVICE_GROUPING_DEFINITIONS + "/" +
+ serviceGroupDefinitionName);
+
+ } catch (RegistryException e) {
+ throw new PersistenceManagerException(e);
+ }
+
+ if (byteObj == null) {
+ return null;
+ }
+
+ Object serviceGroupDefinitionObj;
+
+ try {
+ serviceGroupDefinitionObj = Deserializer.deserializeFromByteArray((byte[]) byteObj);
+
+ } catch (Exception e) {
+ throw new PersistenceManagerException(e);
+ }
+
+ if (serviceGroupDefinitionObj instanceof ServiceGroupDefinition) {
+ return (ServiceGroupDefinition) serviceGroupDefinitionObj;
+ }
+
+ return null;
+ }
+
+ @Override
+ public void removeServiceGroupDefinition(String serviceGroupDefinitionName) throws PersistenceManagerException {
+
+ String resourcePath = STRATOS_MANAGER_REOSURCE + SERVICE_GROUPING_DEFINITIONS + "/" + serviceGroupDefinitionName;
+
+ try {
+ RegistryManager.getInstance().delete(resourcePath);
+ if (log.isDebugEnabled()) {
+ log.debug("Deleted Service Group Definition on path " + resourcePath + " successfully");
+ }
+
+ } catch (RegistryException e) {
+ throw new PersistenceManagerException(e);
+ }
+ }
+
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/f8b27de4/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/retriever/DataInsertionAndRetrievalManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/retriever/DataInsertionAndRetrievalManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/retriever/DataInsertionAndRetrievalManager.java
index 8250b3f..4dd61fb 100644
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/retriever/DataInsertionAndRetrievalManager.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/retriever/DataInsertionAndRetrievalManager.java
@@ -23,6 +23,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.manager.deploy.service.Service;
import org.apache.stratos.manager.exception.PersistenceManagerException;
+import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition;
import org.apache.stratos.manager.lookup.LookupDataHolder;
import org.apache.stratos.manager.persistence.PersistenceManager;
import org.apache.stratos.manager.persistence.RegistryBasedPersistenceManager;
@@ -400,5 +401,18 @@ public class DataInsertionAndRetrievalManager {
return persistenceManager.getDeployedCompositeApplications();
}
+ public void peristServiceGroupDefinition (ServiceGroupDefinition serviceGroupDefinition) throws PersistenceManagerException {
+ persistenceManager.persistServiceGroupDefinition(serviceGroupDefinition);
+ }
+
+ public ServiceGroupDefinition getServiceGroupDefinition (String serviceGroupDefinitionName) throws PersistenceManagerException {
+
+ return persistenceManager.getServiceGroupDefinition(serviceGroupDefinitionName);
+ }
+
+ public void removeServiceGroupDefinition (String serviceGroupName) throws PersistenceManagerException {
+
+ persistenceManager.removeServiceGroupDefinition(serviceGroupName);
+ }
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/f8b27de4/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/Serializer.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/Serializer.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/Serializer.java
index d31b1a1..5de1213 100644
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/Serializer.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/Serializer.java
@@ -20,6 +20,7 @@
package org.apache.stratos.manager.utils;
import org.apache.stratos.manager.deploy.service.Service;
+import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition;
import org.apache.stratos.manager.lookup.ClusterIdToSubscription;
import org.apache.stratos.manager.subscription.CartridgeSubscription;
import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication;
@@ -123,4 +124,23 @@ public class Serializer {
}
}
+
+ public static byte [] serializeServiceGroupDefinitionToByteArray (ServiceGroupDefinition serviceGroupDefinition)
+ throws IOException {
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ ObjectOutput out = null;
+ try {
+ out = new ObjectOutputStream(bos);
+ out.writeObject(serviceGroupDefinition);
+
+ return bos.toByteArray();
+
+ } finally {
+ if (out != null) {
+ out.close();
+ }
+ bos.close();
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/f8b27de4/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 c88acf1..c3781f8 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
@@ -23,7 +23,7 @@ import org.apache.axis2.context.ConfigurationContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
-import org.apache.stratos.cloud.controller.stub.pojo.*;
+import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException;
import org.apache.stratos.cloud.controller.stub.pojo.CartridgeConfig;
import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo;
import org.apache.stratos.cloud.controller.stub.pojo.CompositeApplicationDefinition;
@@ -35,7 +35,6 @@ import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidCar
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.application.utils.ApplicationUtils;
import org.apache.stratos.manager.client.AutoscalerServiceClient;
import org.apache.stratos.manager.client.CloudControllerServiceClient;
import org.apache.stratos.manager.deploy.service.Service;
@@ -43,17 +42,17 @@ import org.apache.stratos.manager.deploy.service.ServiceDeploymentManager;
import org.apache.stratos.manager.dto.Cartridge;
import org.apache.stratos.manager.dto.SubscriptionInfo;
import org.apache.stratos.manager.exception.*;
+import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition;
+import org.apache.stratos.manager.grouping.manager.ServiceGroupingManager;
import org.apache.stratos.manager.manager.CartridgeSubscriptionManager;
import org.apache.stratos.manager.repository.RepositoryNotification;
import org.apache.stratos.manager.subscription.CartridgeSubscription;
import org.apache.stratos.manager.subscription.DataCartridgeSubscription;
-import org.apache.stratos.manager.subscription.PersistenceContext;
import org.apache.stratos.manager.subscription.SubscriptionData;
import org.apache.stratos.manager.topology.model.TopologyClusterInformationModel;
import org.apache.stratos.manager.utils.ApplicationManagementUtil;
import org.apache.stratos.manager.utils.CartridgeConstants;
import org.apache.stratos.messaging.domain.topology.Cluster;
-import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication;
import org.apache.stratos.messaging.domain.topology.Member;
import org.apache.stratos.messaging.domain.topology.MemberStatus;
import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
@@ -67,12 +66,9 @@ import org.apache.stratos.rest.endpoint.bean.cartridge.definition.CartridgeDefin
import org.apache.stratos.rest.endpoint.bean.cartridge.definition.PersistenceBean;
import org.apache.stratos.rest.endpoint.bean.cartridge.definition.ServiceDefinitionBean;
import org.apache.stratos.rest.endpoint.bean.compositeapplication.definition.CompositeApplicationDefinitionBean;
-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.repositoryNotificationInfoBean.Payload;
import org.apache.stratos.rest.endpoint.bean.util.converter.PojoConverter;
import org.apache.stratos.rest.endpoint.exception.RestAPIException;
-import org.apache.stratos.messaging.domain.topology.CompositeApplication;
import javax.ws.rs.core.Response;
@@ -89,6 +85,7 @@ public class ServiceUtils {
private static Log log = LogFactory.getLog(ServiceUtils.class);
private static CartridgeSubscriptionManager cartridgeSubsciptionManager = new CartridgeSubscriptionManager();
+ private static ServiceGroupingManager serviceGropingManager = new ServiceGroupingManager();
private static ServiceDeploymentManager serviceDeploymentManager = new ServiceDeploymentManager();
static StratosAdminResponse deployCartridge (CartridgeDefinitionBean cartridgeDefinitionBean, ConfigurationContext ctxt,
@@ -1408,4 +1405,51 @@ public class ServiceUtils {
return stratosAdminResponse;
}
+ static StratosAdminResponse deployServiceGroupDefinition (ServiceGroupDefinition serviceGroupDefinition) throws RestAPIException {
+
+ try {
+ serviceGropingManager.deployServiceGroupDefinition(serviceGroupDefinition);
+
+ } catch (InvalidServiceGroupException e) {
+ throw new RestAPIException(e);
+ } catch (ServiceGroupDefinitioException e) {
+ throw new RestAPIException(e);
+ } catch (ADCException e) {
+ throw new RestAPIException(e);
+ } catch (CloudControllerServiceUnregisteredCartridgeExceptionException e) {
+ throw new RestAPIException(e);
+ }
+
+ log.info("Successfully deployed the Service Group Definition with name " + serviceGroupDefinition.getName());
+
+ StratosAdminResponse stratosAdminResponse = new StratosAdminResponse();
+ stratosAdminResponse.setMessage("Successfully deplpoyed Service Group Definition with name " + serviceGroupDefinition.getName());
+ return stratosAdminResponse;
+ }
+
+ static ServiceGroupDefinition getServiceGroupDefinition (String serviceGroupDefinitionName) throws RestAPIException {
+
+ try {
+ return serviceGropingManager.getServiceGroupDefinition(serviceGroupDefinitionName);
+
+ } catch (ServiceGroupDefinitioException e) {
+ throw new RestAPIException(e);
+ }
+ }
+
+ static StratosAdminResponse undeployServiceGroupDefinition (String serviceGroupDefinitionName) throws RestAPIException {
+
+ try {
+ serviceGropingManager.undeployServiceGroupDefinition(serviceGroupDefinitionName);
+
+ } catch (ServiceGroupDefinitioException e) {
+ throw new RestAPIException(e);
+ }
+
+ log.info("Successfully undeployed the Service Group Definition with name " + serviceGroupDefinitionName);
+
+ StratosAdminResponse stratosAdminResponse = new StratosAdminResponse();
+ stratosAdminResponse.setMessage("Successfully undeplpoyed Service Group Definition with name " + serviceGroupDefinitionName);
+ return stratosAdminResponse;
+ }
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/f8b27de4/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 a836fb7..b43f04d 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
@@ -26,6 +26,7 @@ import org.apache.stratos.common.util.ClaimsMgtUtil;
import org.apache.stratos.common.util.CommonUtil;
import org.apache.stratos.manager.dto.Cartridge;
import org.apache.stratos.manager.dto.SubscriptionInfo;
+import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition;
import org.apache.stratos.manager.subscription.CartridgeSubscription;
import org.apache.stratos.rest.endpoint.ServiceHolder;
import org.apache.stratos.rest.endpoint.Utils;
@@ -41,7 +42,6 @@ import org.apache.stratos.rest.endpoint.bean.cartridge.definition.CartridgeDefin
import org.apache.stratos.rest.endpoint.bean.cartridge.definition.ServiceDefinitionBean;
import org.apache.stratos.rest.endpoint.bean.compositeapplication.definition.CompositeApplicationDefinitionBean;
import org.apache.stratos.rest.endpoint.bean.repositoryNotificationInfoBean.Payload;
-import org.apache.stratos.rest.endpoint.bean.repositoryNotificationInfoBean.Repository;
import org.apache.stratos.rest.endpoint.bean.topology.Cluster;
import org.apache.stratos.rest.endpoint.exception.RestAPIException;
import org.apache.stratos.tenant.mgt.core.TenantPersistor;
@@ -202,6 +202,41 @@ public class StratosAdmin extends AbstractAdmin {
}
@POST
+ @Path("/group/definition/")
+ @Produces("application/json")
+ @Consumes("application/json")
+ @AuthorizationAction("/permission/protected/manage/monitor/tenants")
+ @SuperTenantService(true)
+ public StratosAdminResponse deployServiceGroupDefinition (ServiceGroupDefinition serviceGroupDefinition)
+ throws RestAPIException {
+
+ return ServiceUtils.deployServiceGroupDefinition(serviceGroupDefinition);
+ }
+
+ @GET
+ @Path("/group/definition/{groupDefinitionName}")
+ @Produces("application/json")
+ @Consumes("application/json")
+ @AuthorizationAction("/permission/protected/manage/monitor/tenants")
+ public ServiceGroupDefinition dgetServiceGroupDefinition (@PathParam("groupDefinitionName") String groupDefinitionName)
+ throws RestAPIException {
+
+ return ServiceUtils.getServiceGroupDefinition(groupDefinitionName);
+ }
+
+ @DELETE
+ @Path("/group/definition/{groupDefinitionName}")
+ @Produces("application/json")
+ @Consumes("application/json")
+ @AuthorizationAction("/permission/protected/manage/monitor/tenants")
+ @SuperTenantService(true)
+ public StratosAdminResponse undeployServiceGroupDefinition (@PathParam("groupDefinitionName") String groupDefinitionName)
+ throws RestAPIException {
+
+ return ServiceUtils.undeployServiceGroupDefinition(groupDefinitionName);
+ }
+
+ @POST
@Path("/policy/deployment/partition")
@Produces("application/json")
@Consumes("application/json")