You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by re...@apache.org on 2013/11/11 07:19:37 UTC
git commit: fixing parsing issue for the zone and region,
partition removed event added
Updated Branches:
refs/heads/master 39b936982 -> 23a17cb20
fixing parsing issue for the zone and region, partition removed event added
Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/23a17cb2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/23a17cb2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/23a17cb2
Branch: refs/heads/master
Commit: 23a17cb20660c8373cdb5464d1cbd8e78e2f9ee4
Parents: 39b9369
Author: rekathiru <rt...@gmail.com>
Authored: Mon Nov 11 11:49:22 2013 +0530
Committer: rekathiru <rt...@gmail.com>
Committed: Mon Nov 11 11:49:22 2013 +0530
----------------------------------------------------------------------
.../controller/axiom/AxiomXpathParser.java | 52 +++++++++++++-------
.../impl/CloudControllerServiceImpl.java | 2 +-
.../controller/topology/TopologyBuilder.java | 3 ++
.../util/CloudControllerConstants.java | 6 +--
4 files changed, 42 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/23a17cb2/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/axiom/AxiomXpathParser.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/axiom/AxiomXpathParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/axiom/AxiomXpathParser.java
index 31abf60..7f36ddb 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/axiom/AxiomXpathParser.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/axiom/AxiomXpathParser.java
@@ -31,6 +31,7 @@ import org.apache.commons.logging.LogFactory;
import org.apache.stratos.cloud.controller.exception.CloudControllerException;
import org.apache.stratos.cloud.controller.exception.MalformedConfigurationFileException;
import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder;
+import org.apache.stratos.cloud.controller.topology.TopologyBuilder;
import org.apache.stratos.cloud.controller.topology.TopologyManager;
import org.apache.stratos.cloud.controller.util.*;
import org.apache.stratos.messaging.domain.topology.Partition;
@@ -412,8 +413,9 @@ public class AxiomXpathParser {
return iaas;
}
- private Partition getPartition(final OMNode item, Collection<Partition> partitions) {
+ private Partition getPartition(final OMNode item) {
Partition partition = null;
+ Partition oldPartition = null;
String id = null;
String type = null;
@@ -439,7 +441,7 @@ public class AxiomXpathParser {
"has not specified in " + xmlSource;
handleException(msg);
}
-
+ oldPartition = TopologyManager.getInstance().getTopology().getPartition(id);
Iterator<?> it1 =
iaasElt.getChildrenWithName(new QName(CloudControllerConstants.SCOPE_ELEMENT));
@@ -461,14 +463,10 @@ public class AxiomXpathParser {
}
- if (partitions != null) {
- // check whether this is a reference to a predefined Region.
- for (Partition partition1 : partitions) {
- //load region id
- if (partition1.getId().equals(id)) {
- partition = partition1;
- break;
- }
+ if (oldPartition != null) {
+ //load region id
+ if (oldPartition.getId().equals(id)) {
+ partition = oldPartition;
}
}
@@ -478,6 +476,8 @@ public class AxiomXpathParser {
partition.setScope(type);
loadProperties(iaasElt, partition.getProperties());
//handle partition created event
+ TopologyBuilder.handlePartitionCreated(partition);
+
} else {
Partition partition1 = new Partition();
partition1.setId(id);
@@ -487,10 +487,11 @@ public class AxiomXpathParser {
String partitionS = gson.toJson(partition);
String partition1S = gson.toJson(partition1);
if (!partitionS.endsWith(partition1S)) {
- //handle update partition
partition.setId(id);
partition.setScope(type);
loadProperties(iaasElt, partition.getProperties());
+ //handle update partition event
+ TopologyBuilder.handlePartitionUpdated(partition, oldPartition);
}
@@ -607,8 +608,8 @@ public class AxiomXpathParser {
OMElement providerElt = (OMElement) it2.next();
typeRegion = providerElt.getText();
}
- if(!region.getType().equals(typeRegion)) {
- return zone;
+ if (!region.getType().equals(typeRegion)) {
+ return zone;
}
Iterator<?> it =
zoneElm.getChildrenWithName(new QName(CloudControllerConstants.TYPE_ELEMENT));
@@ -692,8 +693,8 @@ public class AxiomXpathParser {
OMElement providerElt = (OMElement) it2.next();
typeZone = providerElt.getText();
}
- if(!zone.getType().equals(typeZone)) {
- return host;
+ if (!zone.getType().equals(typeZone)) {
+ return host;
}
Iterator<?> it =
hostElt.getChildrenWithName(new QName(CloudControllerConstants.TYPE_ELEMENT));
@@ -1676,7 +1677,8 @@ public class AxiomXpathParser {
}
public void setPartitionsList() {
- Collection<Partition> partitions = TopologyManager.getInstance().getTopology().getPartitions();
+ Set<String> partitionIds = TopologyManager.getInstance().getTopology().getPartitionMap().keySet();
+ List<String> ids = new ArrayList<String>();
List<OMNode> nodeList = getMatchingNodes(CloudControllerConstants.PARTITION_XPATH);
@@ -1687,7 +1689,23 @@ public class AxiomXpathParser {
}
for (OMNode node : nodeList) {
- partitions.add(getPartition(node, partitions));
+ ids.add(getPartition(node).getId());
+
+ }
+ //have to remove the non existing partition from the map
+ boolean isFound;
+ for (String parId : partitionIds) {
+ isFound = false;
+ for (String id : ids) {
+ if (parId.equals(id)) {
+ isFound = true;
+ break;
+ }
+ }
+ if (!isFound) {
+ //have to remove the partition id from the Topology
+ TopologyBuilder.handlePartitionRemoved(TopologyManager.getInstance().getTopology().getPartition(parId));
+ }
}
}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/23a17cb2/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
index cb1dd23..293b0ec 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
@@ -265,7 +265,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
}
}
- @Override
+ @Override()
public String startInstance(String clusterId, LocationScope locationScope) {
ComputeService computeService;
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/23a17cb2/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
index c525acc..cae793c 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
@@ -70,6 +70,7 @@ public class TopologyBuilder {
try {
TopologyManager.getInstance().acquireWriteLock();
topology.addPartition(partition);
+ TopologyManager.getInstance().updateTopology(topology);
} finally {
TopologyManager.getInstance().releaseWriteLock();
}
@@ -87,6 +88,7 @@ public class TopologyBuilder {
TopologyManager.getInstance().acquireWriteLock();
topology.removePartition(oldPartition);
topology.addPartition(newPartition);
+ TopologyManager.getInstance().updateTopology(topology);
} finally {
TopologyManager.getInstance().releaseWriteLock();
}
@@ -103,6 +105,7 @@ public class TopologyBuilder {
try {
TopologyManager.getInstance().acquireWriteLock();
topology.removePartition(partition);
+ TopologyManager.getInstance().updateTopology(topology);
} finally {
TopologyManager.getInstance().releaseWriteLock();
}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/23a17cb2/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerConstants.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerConstants.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerConstants.java
index 25d6793..bc91670 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerConstants.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerConstants.java
@@ -65,7 +65,7 @@ public final class CloudControllerConstants {
public static final String PROVIDER_ELEMENT = "provider";
public static final String IDENTITY_ELEMENT = "identity";
public static final String TYPE_ELEMENT = "type";
- public static final String SCOPE_ELEMENT = "type";
+ public static final String SCOPE_ELEMENT = "scope";
public static final String ID_ELEMENT = "id";
public static final String CREDENTIAL_ELEMENT = "credential";
public static final String DEFAULT_SERVICE_ELEMENT = "default";
@@ -149,9 +149,9 @@ public final class CloudControllerConstants {
public static final String REGION_XPATH = "/"+CLOUD_CONTROLLER_ELEMENT+"/"+
IAAS_PROVIDERS_ELEMENT+"/"+IAAS_PROVIDER_ELEMENT + "/" + REGION_ELEMENT;
public static final String ZONE_XPATH = "/"+CLOUD_CONTROLLER_ELEMENT+"/"+
- IAAS_PROVIDERS_ELEMENT+"/"+IAAS_PROVIDER_ELEMENT + REGION_ELEMENT + "/" + ZONE_ELEMENT;
+ IAAS_PROVIDERS_ELEMENT+"/"+IAAS_PROVIDER_ELEMENT + "/" + REGION_ELEMENT + "/" + ZONE_ELEMENT;
public static final String HOST_XPATH = "/"+CLOUD_CONTROLLER_ELEMENT+"/"+
- IAAS_PROVIDERS_ELEMENT+"/"+IAAS_PROVIDER_ELEMENT + REGION_ELEMENT + "/" + ZONE_ELEMENT
+ IAAS_PROVIDERS_ELEMENT+"/"+IAAS_PROVIDER_ELEMENT + "/" + REGION_ELEMENT + "/" + ZONE_ELEMENT
+ "/" + HOST_ELEMENT ;
public static final String PROPERTY_ELEMENT_XPATH = "/"+PROPERTY_ELEMENT;
public static final String IMAGE_ID_ELEMENT_XPATH = "/"+IMAGE_ID_ELEMENT;