changes to messaging component after CC refactoring
Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/41521508 Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/41521508 Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/41521508 Branch: refs/heads/master Commit: 41521508d8cf83efe2a83d865759da00dba9e157 Parents: e4df27d Author: Nirmal Fernando <[email protected]> Authored: Wed Nov 27 09:43:58 2013 +0530 Committer: Nirmal Fernando <[email protected]> Committed: Wed Nov 27 09:43:58 2013 +0530 ---------------------------------------------------------------------- components/org.apache.stratos.messaging/pom.xml | 6 ++ .../domain/policy/DeploymentPolicy.java | 6 +- .../messaging/domain/policy/Partition.java | 36 +++++++++- .../messaging/domain/policy/PartitionGroup.java | 2 +- .../messaging/domain/topology/Member.java | 2 + .../messaging/domain/topology/Partition.java | 69 -------------------- .../messaging/domain/topology/Scope.java | 2 +- .../messaging/domain/topology/Service.java | 2 + .../messaging/domain/topology/Topology.java | 2 + .../event/topology/InstanceSpawnedEvent.java | 3 +- .../event/topology/PartitionCreatedEvent.java | 49 +++----------- .../stratos/messaging/util/Properties.java | 37 +++++++++++ .../apache/stratos/messaging/util/Property.java | 54 +++++++++++++++ 13 files changed, 154 insertions(+), 116 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/41521508/components/org.apache.stratos.messaging/pom.xml ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.messaging/pom.xml b/components/org.apache.stratos.messaging/pom.xml index 7530175..57e558b 100644 --- a/components/org.apache.stratos.messaging/pom.xml +++ b/components/org.apache.stratos.messaging/pom.xml @@ -59,6 +59,12 @@ <artifactId>org.wso2.carbon.logging</artifactId> <version>${wso2carbon.version}</version> </dependency> + <dependency> + <groupId>com.jamesmurty.utils</groupId> + <artifactId>java-xmlbuilder</artifactId> + <version>0.6</version> + </dependency> + </dependencies> <build> http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/41521508/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/policy/DeploymentPolicy.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/policy/DeploymentPolicy.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/policy/DeploymentPolicy.java index 50f9006..53e8006 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/policy/DeploymentPolicy.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/policy/DeploymentPolicy.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.stratos.autoscaler.policy.model; +package org.apache.stratos.messaging.domain.policy; import java.util.ArrayList; import java.util.List; @@ -63,5 +63,9 @@ public class DeploymentPolicy { } return this.partitionGroups; } + + public String toString() { + return "Deployment Policy: "+this.id; + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/41521508/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/policy/Partition.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/policy/Partition.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/policy/Partition.java index e65dd05..e33899f 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/policy/Partition.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/policy/Partition.java @@ -17,15 +17,25 @@ * under the License. */ -package org.apache.stratos.autoscaler.policy.model; +package org.apache.stratos.messaging.domain.policy; + +import java.io.Serializable; + +import org.apache.stratos.messaging.util.Properties; /** * The model class for Partition definition. */ -public class Partition { +public class Partition implements Serializable{ - private int partitionMax; + private static final long serialVersionUID = 3725971214092010720L; + private int partitionMax; private int partitionMin; + /** + * provider should match with an IaasProvider type. + */ + private String provider; + private Properties properties = new Properties(); private String id; @@ -83,5 +93,25 @@ public class Partition { public void setId(String id) { this.id = id; } + + public Properties getProperties() { + return properties; + } + + public void setProperties(Properties properties) { + this.properties = properties; + } + + public String getProvider() { + return provider; + } + + public void setProvider(String provider) { + this.provider = provider; + } + + public String toString() { + return "Partition Id: "+this.id+", Partition Provider: "+this.provider; + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/41521508/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/policy/PartitionGroup.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/policy/PartitionGroup.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/policy/PartitionGroup.java index 2db5e67..06ce872 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/policy/PartitionGroup.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/policy/PartitionGroup.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.stratos.autoscaler.policy.model; +package org.apache.stratos.messaging.domain.policy; import java.util.ArrayList; import java.util.List; http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/41521508/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java index 12374d4..ce6c620 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java @@ -25,6 +25,8 @@ import java.util.HashMap; import java.util.Map; import java.util.Properties; +import org.apache.stratos.messaging.domain.policy.Partition; + /** * Defines a member node in a cluster. * Key: serviceName, clusterId, memberId http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/41521508/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Partition.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Partition.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Partition.java deleted file mode 100644 index c31090d..0000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Partition.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.stratos.messaging.domain.topology; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -public class Partition implements Serializable{ - private static final long serialVersionUID = 4827628468577123048L; - private String id; - private Scope scope; - /** - * key - type of scope - * value - name of the scope - */ - private Map<String, String> properties = new HashMap(); - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - - public Scope getScope() { - return scope; - } - - public void setScope(Scope scope) { - this.scope = scope; - } - - public Map<String, String> getProperties() { - return properties; - } - - public void setProperties(Map<String, String> properties) { - this.properties = properties; - } - - public void setProperty(String key, String value) { - if (key != null && value != null) { - getProperties().put(key, value); - } - } - - public String getProperty(String key) { - return getProperties().get(key); - } -} http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/41521508/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Scope.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Scope.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Scope.java index fc05745..c111957 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Scope.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Scope.java @@ -22,5 +22,5 @@ package org.apache.stratos.messaging.domain.topology; * represents the scope of each partition which can be configured in stratos. */ public enum Scope { - PROVIDER, REGION, ZONE, HOST + provider, region, zone, host } http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/41521508/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Service.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Service.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Service.java index bcf59f2..7140d33 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Service.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Service.java @@ -21,6 +21,7 @@ package org.apache.stratos.messaging.domain.topology; import java.io.Serializable; import java.util.*; +import com.jamesmurty.utils.XMLBuilder; /** * Defines a service in the topology. A service represents a cartridge type. @@ -107,4 +108,5 @@ public class Service implements Serializable{ public void setProperties(Properties properties) { this.properties = properties; } + } http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/41521508/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java index b598827..4e6552f 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java @@ -24,6 +24,8 @@ import java.util.Collection; import java.util.HashMap; import java.util.Map; +import org.apache.stratos.messaging.domain.policy.Partition; + /** * Defines a topology of serviceMap in Stratos. */ http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/41521508/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/InstanceSpawnedEvent.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/InstanceSpawnedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/InstanceSpawnedEvent.java index a809624..b5bc434 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/InstanceSpawnedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/InstanceSpawnedEvent.java @@ -18,10 +18,11 @@ */ package org.apache.stratos.messaging.event.topology; -import org.apache.stratos.messaging.domain.topology.Partition; import java.io.Serializable; +import org.apache.stratos.messaging.domain.policy.Partition; + /** * This event is fired by Cloud Controller when a member is spawned by the IaaS in a given cluster. */ http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/41521508/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/PartitionCreatedEvent.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/PartitionCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/PartitionCreatedEvent.java index 38aacbc..604dc6e 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/PartitionCreatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/PartitionCreatedEvent.java @@ -18,54 +18,23 @@ */ package org.apache.stratos.messaging.event.topology; -import org.apache.stratos.messaging.domain.topology.Scope; - +import org.apache.stratos.messaging.domain.policy.Partition; import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; public class PartitionCreatedEvent extends TopologyEvent implements Serializable { - private String id; - private Scope scope; - private Map<String, String> properties = new HashMap<String, String>(); - - public PartitionCreatedEvent(String id, Scope scope) { - this.id = id; - this.scope = scope; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } + private static final long serialVersionUID = -312209596940292730L; + private Partition partition; - public Scope getScope() { - return scope; + public PartitionCreatedEvent(Partition partition) { + this.setPartition(partition); } - public void setScope(Scope scope) { - this.scope = scope; + public Partition getPartition() { + return partition; } - public Map<String, String> getProperties() { - return properties; + public void setPartition(Partition partition) { + this.partition = partition; } - public void setProperties(Map<String, String> properties) { - this.properties = properties; - } - - public void setProperty(String key, String value) { - - if (key != null && value != null) { - getProperties().put(key, value); - } - } - - public String getProperty(String key) { - return getProperties().get(key); - } } http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/41521508/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Properties.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Properties.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Properties.java new file mode 100644 index 0000000..f32b91c --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Properties.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.stratos.messaging.util; + +/** + * Had to wrap {@link Property} array using a class, since there's a bug in current + * stub generation. + */ +public class Properties { + + private Property[] properties; + + public Property[] getProperties() { + return properties; + } + + public void setProperties(Property[] properties) { + this.properties = properties; + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/41521508/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Property.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Property.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Property.java new file mode 100644 index 0000000..644b532 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Property.java @@ -0,0 +1,54 @@ +/* + * 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.messaging.util; + +/** + * Holds a property + */ +public class Property { + + private String name; + private String value; + + public Property(){ + + } + + public Property(String name, String value){ + this.setName(name); + this.setValue(value); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + +}
