You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ni...@apache.org on 2013/11/30 07:42:28 UTC
[1/4] git commit: start instance method now takes a MemberContext as
the argument, fixed the Partition bean, removed file based persistence of CC
Updated Branches:
refs/heads/master d9ca9e3b0 -> faca01666
start instance method now takes a MemberContext as the argument, fixed the Partition bean, removed file based persistence of CC
Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/e7e52770
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/e7e52770
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/e7e52770
Branch: refs/heads/master
Commit: e7e5277032b7312d960e0cb4dd1d28648bc67326
Parents: 9f69444
Author: Nirmal Fernando <ni...@apache.org>
Authored: Sat Nov 30 11:58:05 2013 +0530
Committer: Nirmal Fernando <ni...@apache.org>
Committed: Sat Nov 30 11:58:05 2013 +0530
----------------------------------------------------------------------
.../deployment/partition/Partition.java | 4 +-
.../impl/CloudControllerServiceImpl.java | 186 ++++---------------
.../interfaces/CloudControllerService.java | 3 +-
.../cloud/controller/pojo/MemberContext.java | 66 +++++--
.../controller/topology/TopologyManager.java | 60 +++---
5 files changed, 118 insertions(+), 201 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/e7e52770/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployment/partition/Partition.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployment/partition/Partition.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployment/partition/Partition.java
index e434a86..99e0c10 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployment/partition/Partition.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployment/partition/Partition.java
@@ -43,7 +43,7 @@ public class Partition implements Serializable{
* Gets the value of the partitionMax property.
*
*/
- public int getPartitionMembersMax() {
+ public int getPartitionMax() {
return partitionMax;
}
@@ -59,7 +59,7 @@ public class Partition implements Serializable{
* Gets the value of the partitionMin property.
*
*/
- public int getPartitionMembersMin() {
+ public int getPartitionMin() {
return partitionMin;
}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/e7e52770/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 b6aed38..2785df0 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
@@ -285,13 +285,21 @@ public class CloudControllerServiceImpl implements CloudControllerService {
}
@Override
- public String startInstance(String clusterId, Partition partition) throws IllegalArgumentException, UnregisteredCartridgeException {
+ public MemberContext startInstance(MemberContext member) throws IllegalArgumentException, UnregisteredCartridgeException {
+ if (member == null) {
+ String msg = "Instance start-up failed. Member is null.";
+ log.error(msg);
+ throw new IllegalArgumentException(msg);
+ }
+
+ String clusterId = member.getClusterId();
+ Partition partition = member.getPartition();
+
log.info("Starting new instance of cluster : " + clusterId);
ComputeService computeService = null;
Template template = null;
- String ip;
if(partition == null) {
String msg = "Instance start-up failed. Specified Partition is null. Cluster id: "+clusterId;
@@ -318,44 +326,10 @@ public class CloudControllerServiceImpl implements CloudControllerService {
throw new UnregisteredCartridgeException(msg);
}
+ member.setCartridgeType(cartridgeType);
-// Partition partition_ = TopologyManager.getInstance().getTopology().getPartition(partitionId);
-// Scope scope = partition_.getScope();
-// String provider = partition_.getProperty("provider");
final Lock lock = new ReentrantLock();
- // get the subjected ServiceContext
-// ServiceContext serviceCtxt = dataHolder
-// .getServiceContextFromDomain(clusterId);
-//
-// if (serviceCtxt == null) {
-// String msg = "Not a registered service: domain - " + clusterId;
-// log.fatal(msg);
-// throw new CloudControllerException(msg);
-// }
-//
-// // load Cartridge
-// serviceCtxt.setCartridge(loadCartridge(serviceCtxt.getCartridgeType(),
-// dataHolder
-// .getCartridges()));
-//
-// if (serviceCtxt.getCartridge() == null) {
-// String msg = "There's no registered Cartridge found. Domain - "
-// + clusterId;
-// log.fatal(msg);
-// throw new CloudControllerException(msg);
-// }
-//
-// if (serviceCtxt.getCartridge().getIaases().isEmpty()) {
-// String msg = "There's no registered IaaSes found for Cartridge type: "
-// + serviceCtxt.getCartridge().getType();
-// log.fatal(msg);
-// throw new CloudControllerException(msg);
-// }
-
-
-// for (IaasProvider iaas : serviceCtxt.getCartridge().getIaases()) {
-
IaasProvider iaas = cartridge.getIaasProviderOfPartition(partitionId);
if(iaas == null) {
String msg = "Instance start-up failed for cluster: "+clusterId+". " +
@@ -364,13 +338,10 @@ public class CloudControllerServiceImpl implements CloudControllerService {
log.fatal(msg);
throw new CloudControllerException(msg);
}
-// IaasContext ctxt;
-// if ((ctxt = serviceCtxt.getIaasContext(iaas.getType())) == null) {
-// ctxt = serviceCtxt.addIaasContext(iaas.getType());
-// }
try {
//generating the Unique member ID...
String memberID = generateMemberId(clusterId);
+ member.setMemberId(memberID);
//have to add memberID to the payload
StringBuilder payload = new StringBuilder(ctxt.getPayload());
payload.append(",");
@@ -383,37 +354,6 @@ public class CloudControllerServiceImpl implements CloudControllerService {
computeService = iaas.getComputeService();
template = iaas.getTemplate();
-// if(scope == null || scope.name().equals(Scope.PROVIDER.name())) {
-// computeService = iaas.getComputeService();
-// template = iaas.getTemplate();
-// } else if(scope.name().equals(Scope.REGION.name())) {
-// for(Region region : iaas.getListOfRegions()) {
-// if(region.getId().equals(partitionId)) {
-// computeService = region.getComputeService();
-// template = region.getTemplate();
-// }
-// }
-// } else if(scope.name().equals(Scope.ZONE.name())) {
-// for(Region region : iaas.getListOfRegions()) {
-// for(Zone zone : region.getListOfZones()) {
-// if(zone.getId().equals(partitionId)) {
-// computeService = zone.getComputeService();
-// template = zone.getTemplate();
-// }
-// }
-// }
-// } else if(scope.name().equals(Scope.HOST.name())) {
-// for(Region region : iaas.getListOfRegions()) {
-// for(Zone zone : region.getListOfZones()) {
-// for(Host host: zone.getListOfHosts()) {
-// if(host.getId().equals(partitionId)) {
-// computeService = host.getComputeService();
-// template = host.getTemplate();
-// }
-// }
-// }
-// }
-// }
if (template == null) {
String msg = "Failed to start an instance in "
+ iaas.getType()
@@ -424,12 +364,6 @@ public class CloudControllerServiceImpl implements CloudControllerService {
throw new CloudControllerException(msg);
}
- // set instance name as the host name
- // template.getOptions().userMetadata("Name",
- // serviceCtxt.getHostName());
- // template.getOptions().as(TemplateOptions.class).userMetadata("Name",
- // serviceCtxt.getHostName());
-
// generate the group id from domain name and sub domain
// name.
// Should have lower-case ASCII letters, numbers, or dashes.
@@ -452,52 +386,42 @@ public class CloudControllerServiceImpl implements CloudControllerService {
lock.lock();
try {
+ // node id
+ String nodeId = node.getId();
+ if (nodeId == null) {
+ String msg = "Node id of the starting instance is null.\n" + node.toString();
+ log.fatal(msg);
+ throw new CloudControllerException(msg);
+ }
+
+ member.setNodeId(nodeId);
+
// reset ip
- ip = "";
+ String ip = "";
// default behavior is autoIpAssign=false
if (autoAssignIpProp == null || (autoAssignIpProp != null && autoAssignIpProp.equals("false"))) {
// allocate an IP address - manual IP assigning mode
ip = iaas.getIaas().associateAddress(iaas, node);
+ member.setAllocatedIpAddress(ip);
log.info("Allocated ip address: " + ip);
}
- if (ip.isEmpty() && node.getPublicAddresses() != null && node.getPublicAddresses().iterator().hasNext()) {
+ // public ip
+ if (node.getPublicAddresses() != null && node.getPublicAddresses().iterator().hasNext()) {
ip = node.getPublicAddresses().iterator().next();
+ member.setPublicIpAddress(ip);
log.info("Public ip address: " + ip);
}
- // if not public IP is assigned, we're using private IP
- if (ip.isEmpty() && node.getPrivateAddresses() != null && node.getPrivateAddresses().iterator().hasNext()) {
+ // private IP
+ if (node.getPrivateAddresses() != null && node.getPrivateAddresses().iterator().hasNext()) {
ip = node.getPrivateAddresses().iterator().next();
+ member.setPrivateIpAddress(ip);
log.info("Private ip address: " + ip);
}
- String nodeId = node.getId();
- if (nodeId == null) {
- String msg = "Node id of the starting instance is null.\n" + node.toString();
- log.fatal(msg);
- throw new CloudControllerException(msg);
- }
- MemberContext memberCtxt = new MemberContext(memberID, nodeId, clusterId, partitionId, cartridgeType, ip);
- dataHolder.addMemberContext(memberCtxt);
-
- // add node ID
-// ctxt.addNodeId(node.getId());
-// ctxt.addNodeToPublicIp(node.getId(), ip);
-
- // to faster look up
-// dataHolder.addNodeId(
-// node.getId(), serviceCtxt);
-//
-// dataHolder.addNodeId(memberID, node.getId());
-//
-// serviceCtxt.getCartridge().setLastlyUsedIaas(iaas);
-//
-// // add this ip to the topology
-// appendToPublicIpProperty(ip, serviceCtxt);
-//
-// dataHolder.updateActiveInstanceCount(iaas.getType(), 1);
+ dataHolder.addMemberContext(member);
// persist in registry
persist();
@@ -508,7 +432,6 @@ public class CloudControllerServiceImpl implements CloudControllerService {
//update the topology with the newly spawned member
// publish data
-// CartridgeInstanceDataPublisherTask.publish();
if (log.isDebugEnabled()) {
log.debug("Node details: \n" + node.toString()
+ "\n***************\n");
@@ -520,7 +443,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
+ ip
+ "\tNode Id: " + nodeId);
- return ip;
+ return member;
} finally {
// release the lock
@@ -651,7 +574,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
String memberId = ctxt.getMemberId();
String clusterId = ctxt.getClusterId();
- String partitionId = ctxt.getPartitionId();
+ String partitionId = ctxt.getPartition().getId();
String cartridgeType = ctxt.getCartridgeType();
String nodeId = ctxt.getNodeId();
@@ -1008,52 +931,11 @@ public class CloudControllerServiceImpl implements CloudControllerService {
*/
private IaasProvider terminate(IaasProvider iaasTemp,
String nodeId, MemberContext ctxt) {
-// Scope scope = partition.getScope();
-// String partitionId = partition.getId();
-// // this is just to be safe
-// if (iaasTemp.getComputeService() == null) {
-// String msg = "Unexpeced error occured! IaasContext's ComputeService is null!";
-// log.error(msg);
-// throw new CloudControllerException(msg);
-// }
-//
-// if(scope == null || scope.name().equals(Scope.PROVIDER.name())) {
-// iaasTemp.getComputeService().destroyNode(nodeId);
-// } else if(scope.name().equals(Scope.REGION.name())) {
-// for(Region region : iaasTemp.getListOfRegions()) {
-// if(region.getId().equals(partitionId)) {
-// region.getComputeService();
-// }
-// }
-// } else if(scope.name().equals(Scope.ZONE.name())) {
-// for(Region region : iaasTemp.getListOfRegions()) {
-// for(Zone zone : region.getListOfZones()) {
-// if(zone.getId().equals(partitionId)) {
-// zone.getComputeService().destroyNode(nodeId);
-// }
-// }
-// }
-// } else if(scope.name().equals(Scope.HOST.name())) {
-// for(Region region : iaasTemp.getListOfRegions()) {
-// for(Zone zone : region.getListOfZones()) {
-// for(Host host: zone.getListOfHosts()) {
-// if(host.getId().equals(partitionId)) {
-// host.getComputeService().destroyNode(nodeId);
-// }
-// }
-// }
-// }
-// }
// destroy the node
iaasTemp.getComputeService().destroyNode(nodeId);
- String autoAssignIpProp = iaasTemp
- .getProperty(CloudControllerConstants.AUTO_ASSIGN_IP_PROPERTY);
-
// release allocated IP address
- if (autoAssignIpProp == null
- || (autoAssignIpProp
- .equals("false"))) {
+ if (ctxt.getAllocatedIpAddress() != null) {
// allocate an IP address - manual IP assigning mode
iaasTemp.getIaas().releaseAddress(iaasTemp,
ctxt.getAllocatedIpAddress());
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/e7e52770/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java
index bae0922..ee71f62 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java
@@ -27,6 +27,7 @@ import org.apache.stratos.cloud.controller.exception.InvalidPartitionException;
import org.apache.stratos.cloud.controller.exception.UnregisteredCartridgeException;
import org.apache.stratos.cloud.controller.exception.UnregisteredClusterException;
import org.apache.stratos.cloud.controller.pojo.CartridgeInfo;
+import org.apache.stratos.cloud.controller.pojo.MemberContext;
import org.apache.stratos.cloud.controller.pojo.Registrant;
/**
@@ -84,7 +85,7 @@ public interface CloudControllerService {
* an instance need to be started.
* @return public IP which is associated with the newly started instance.
*/
- public String startInstance(String clusterId, Partition partition) throws IllegalArgumentException, UnregisteredCartridgeException;
+ public MemberContext startInstance(MemberContext member) throws IllegalArgumentException, UnregisteredCartridgeException;
/**
* Calling this method will spawn more than one ininstances in the
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/e7e52770/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/MemberContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/MemberContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/MemberContext.java
index 64fd3c2..11ebb8a 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/MemberContext.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/MemberContext.java
@@ -18,8 +18,10 @@
*/
package org.apache.stratos.cloud.controller.pojo;
+import org.apache.stratos.cloud.controller.deployment.partition.Partition;
+
/**
- * Holds runtime data of a Member.
+ * Holds information about a Member.
* @author nirmal
*
*/
@@ -31,21 +33,26 @@ public class MemberContext {
private String nodeId;
// cluster id of this member
private String clusterId;
- // partition id this member is in.
- private String partitionId;
+ // partition this member is in.
+ private Partition partition;
// cartridge type this member belongs to.
private String cartridgeType;
- // allocated ip
+ // private ip
+ private String privateIpAddress;
+ // public ip
+ private String publicIpAddress;
+ // manually allocated ip
private String allocatedIpAddress;
+ // member initiated time
+ private long initTime;
- public MemberContext(String id, String nodeId, String clusterId, String partitionId, String cartridgeType, String ip) {
+ public MemberContext(String id, String clusterId, Partition partition) {
this.memberId = id;
- this.nodeId = nodeId;
this.clusterId = clusterId;
- this.partitionId = partitionId;
- this.cartridgeType = cartridgeType;
- this.allocatedIpAddress = ip;
-
+ this.setPartition(partition);
+ }
+
+ public MemberContext() {
}
public String getMemberId() {
@@ -66,24 +73,51 @@ public class MemberContext {
public void setClusterId(String clusterId) {
this.clusterId = clusterId;
}
- public String getPartitionId() {
- return partitionId;
- }
- public void setPartitionId(String partitionId) {
- this.partitionId = partitionId;
- }
public String getCartridgeType() {
return cartridgeType;
}
public void setCartridgeType(String cartridgeType) {
this.cartridgeType = cartridgeType;
}
+ public Partition getPartition() {
+ return partition;
+ }
+
+ public void setPartition(Partition partition) {
+ this.partition = partition;
+ }
+
+ public String getPublicIpAddress() {
+ return publicIpAddress;
+ }
+
+ public void setPublicIpAddress(String publicIpAddress) {
+ this.publicIpAddress = publicIpAddress;
+ }
+
+ public String getPrivateIpAddress() {
+ return privateIpAddress;
+ }
+
+ public void setPrivateIpAddress(String privateIpAddress) {
+ this.privateIpAddress = privateIpAddress;
+ }
+
public String getAllocatedIpAddress() {
return allocatedIpAddress;
}
+
public void setAllocatedIpAddress(String allocatedIpAddress) {
this.allocatedIpAddress = allocatedIpAddress;
}
+
+ public long getInitTime() {
+ return initTime;
+ }
+
+ public void setInitTime(long initTime) {
+ this.initTime = initTime;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/e7e52770/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyManager.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyManager.java
index 8d8d58a..7c36613 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyManager.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyManager.java
@@ -80,24 +80,24 @@ public class TopologyManager {
synchronized (TopologyManager.class) {
if(this.topology == null) {
//need to initialize the topology
- if(this.topologyFile.exists()) {
- try {
- currentContent = FileUtils.readFileToString(this.topologyFile);
- Gson gson = new Gson();
- this.topology = gson.fromJson(currentContent, Topology.class);
- if(log.isDebugEnabled()) {
- log.debug("The current topology is: " + currentContent);
- }
- } catch (IOException e) {
- log.error(e.getMessage());
- throw new CloudControllerException(e.getMessage(), e);
- }
- } else {
+// if(this.topologyFile.exists()) {
+// try {
+// currentContent = FileUtils.readFileToString(this.topologyFile);
+// Gson gson = new Gson();
+// this.topology = gson.fromJson(currentContent, Topology.class);
+// if(log.isDebugEnabled()) {
+// log.debug("The current topology is: " + currentContent);
+// }
+// } catch (IOException e) {
+// log.error(e.getMessage());
+// throw new CloudControllerException(e.getMessage(), e);
+// }
+// } else {
if(log.isDebugEnabled()) {
log.debug("Creating new topology");
}
this.topology = new Topology();
- }
+// }
}
}
if(log.isDebugEnabled()) {
@@ -109,22 +109,22 @@ public class TopologyManager {
public synchronized void updateTopology(Topology topology) {
synchronized (TopologyManager.class) {
this.topology = topology;
- if (this.topologyFile.exists()) {
- this.backup.delete();
- this.topologyFile.renameTo(backup);
- }
- Gson gson = new Gson();
- String message = gson.toJson(topology);
- // overwrite the topology file
- try {
- FileUtils.writeStringToFile(this.topologyFile, message);
- if(log.isDebugEnabled()) {
- log.debug("The updated topology is: " + message);
- }
- } catch (IOException e) {
- log.error(e.getMessage());
- throw new CloudControllerException(e.getMessage(), e);
- }
+// if (this.topologyFile.exists()) {
+// this.backup.delete();
+// this.topologyFile.renameTo(backup);
+// }
+// Gson gson = new Gson();
+// String message = gson.toJson(topology);
+// // overwrite the topology file
+// try {
+// FileUtils.writeStringToFile(this.topologyFile, message);
+// if(log.isDebugEnabled()) {
+// log.debug("The updated topology is: " + message);
+// }
+// } catch (IOException e) {
+// log.error(e.getMessage());
+// throw new CloudControllerException(e.getMessage(), e);
+// }
}
}
[2/4] git commit: changes to WSDL based on CC change
Posted by ni...@apache.org.
changes to WSDL based on CC change
Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/5d8c064b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/5d8c064b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/5d8c064b
Branch: refs/heads/master
Commit: 5d8c064b6c1700a3b34ab97bfcaa6fc6d962be2b
Parents: e7e5277
Author: Nirmal Fernando <ni...@apache.org>
Authored: Sat Nov 30 11:58:50 2013 +0530
Committer: Nirmal Fernando <ni...@apache.org>
Committed: Sat Nov 30 11:58:50 2013 +0530
----------------------------------------------------------------------
.../main/resources/CloudControllerService.wsdl | 41 +++++++++++++-------
1 file changed, 26 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/5d8c064b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl
----------------------------------------------------------------------
diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl
index 61e2f5e..5d23869 100644
--- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl
+++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl
@@ -21,7 +21,7 @@
<xs:sequence/>
</xs:complexType>
</xs:schema>
- <xs:schema xmlns:ax212="http://pojo.controller.cloud.stratos.apache.org/xsd" xmlns:ax28="http://partition.deployment.controller.cloud.stratos.apache.org/xsd" xmlns:ax211="http://policy.deployment.controller.cloud.stratos.apache.org/xsd" xmlns:ax24="http://exception.controller.cloud.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://impl.controller.cloud.stratos.apache.org">
+ <xs:schema xmlns:ax213="http://pojo.controller.cloud.stratos.apache.org/xsd" xmlns:ax28="http://partition.deployment.controller.cloud.stratos.apache.org/xsd" xmlns:ax211="http://policy.deployment.controller.cloud.stratos.apache.org/xsd" xmlns:ax24="http://exception.controller.cloud.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://impl.controller.cloud.stratos.apache.org">
<xs:import namespace="http://exception.controller.cloud.stratos.apache.org/xsd"/>
<xs:import namespace="http://partition.deployment.controller.cloud.stratos.apache.org/xsd"/>
<xs:import namespace="http://policy.deployment.controller.cloud.stratos.apache.org/xsd"/>
@@ -128,22 +128,21 @@
<xs:element name="startInstance">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="clusterId" nillable="true" type="xs:string"/>
- <xs:element minOccurs="0" name="partition" nillable="true" type="ax28:Partition"/>
+ <xs:element minOccurs="0" name="member" nillable="true" type="ax213:MemberContext"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="startInstanceResponse">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
+ <xs:element minOccurs="0" name="return" nillable="true" type="ax213:MemberContext"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="registerService">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="registrant" nillable="true" type="ax212:Registrant"/>
+ <xs:element minOccurs="0" name="registrant" nillable="true" type="ax213:Registrant"/>
</xs:sequence>
</xs:complexType>
</xs:element>
@@ -190,7 +189,7 @@
<xs:element name="getCartridgeInfoResponse">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="return" nillable="true" type="ax212:CartridgeInfo"/>
+ <xs:element minOccurs="0" name="return" nillable="true" type="ax213:CartridgeInfo"/>
</xs:sequence>
</xs:complexType>
</xs:element>
@@ -206,7 +205,8 @@
</xs:sequence>
</xs:complexType>
</xs:schema>
- <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://pojo.controller.cloud.stratos.apache.org/xsd">
+ <xs:schema xmlns:ax212="http://partition.deployment.controller.cloud.stratos.apache.org/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://pojo.controller.cloud.stratos.apache.org/xsd">
+ <xs:import namespace="http://partition.deployment.controller.cloud.stratos.apache.org/xsd"/>
<xs:complexType name="Properties">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="properties" nillable="true" type="ax26:Property"/>
@@ -218,6 +218,19 @@
<xs:element minOccurs="0" name="value" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
+ <xs:complexType name="MemberContext">
+ <xs:sequence>
+ <xs:element minOccurs="0" name="allocatedIpAddress" nillable="true" type="xs:string"/>
+ <xs:element minOccurs="0" name="cartridgeType" nillable="true" type="xs:string"/>
+ <xs:element minOccurs="0" name="clusterId" nillable="true" type="xs:string"/>
+ <xs:element minOccurs="0" name="initTime" type="xs:long"/>
+ <xs:element minOccurs="0" name="memberId" nillable="true" type="xs:string"/>
+ <xs:element minOccurs="0" name="nodeId" nillable="true" type="xs:string"/>
+ <xs:element minOccurs="0" name="partition" nillable="true" type="ax212:Partition"/>
+ <xs:element minOccurs="0" name="privateIpAddress" nillable="true" type="xs:string"/>
+ <xs:element minOccurs="0" name="publicIpAddress" nillable="true" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
<xs:complexType name="Registrant">
<xs:sequence>
<xs:element minOccurs="0" name="autoScalerPolicyName" nillable="true" type="xs:string"/>
@@ -265,8 +278,6 @@
<xs:sequence>
<xs:element minOccurs="0" name="id" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="partitionMax" type="xs:int"/>
- <xs:element minOccurs="0" name="partitionMembersMax" type="xs:int"/>
- <xs:element minOccurs="0" name="partitionMembersMin" type="xs:int"/>
<xs:element minOccurs="0" name="partitionMin" type="xs:int"/>
<xs:element minOccurs="0" name="properties" nillable="true" type="ax27:Properties"/>
<xs:element minOccurs="0" name="provider" nillable="true" type="xs:string"/>
@@ -744,22 +755,22 @@
</wsdl:binding>
<wsdl:service name="CloudControllerService">
<wsdl:port name="CloudControllerServiceHttpSoap11Endpoint" binding="ns:CloudControllerServiceSoap11Binding">
- <soap:address location="http://192.168.1.2:9764/services/CloudControllerService.CloudControllerServiceHttpSoap11Endpoint/"/>
+ <soap:address location="http://10.100.1.154:9764/services/CloudControllerService.CloudControllerServiceHttpSoap11Endpoint/"/>
</wsdl:port>
<wsdl:port name="CloudControllerServiceHttpsSoap11Endpoint" binding="ns:CloudControllerServiceSoap11Binding">
- <soap:address location="https://192.168.1.2:9444/services/CloudControllerService.CloudControllerServiceHttpsSoap11Endpoint/"/>
+ <soap:address location="https://10.100.1.154:9444/services/CloudControllerService.CloudControllerServiceHttpsSoap11Endpoint/"/>
</wsdl:port>
<wsdl:port name="CloudControllerServiceHttpSoap12Endpoint" binding="ns:CloudControllerServiceSoap12Binding">
- <soap12:address location="http://192.168.1.2:9764/services/CloudControllerService.CloudControllerServiceHttpSoap12Endpoint/"/>
+ <soap12:address location="http://10.100.1.154:9764/services/CloudControllerService.CloudControllerServiceHttpSoap12Endpoint/"/>
</wsdl:port>
<wsdl:port name="CloudControllerServiceHttpsSoap12Endpoint" binding="ns:CloudControllerServiceSoap12Binding">
- <soap12:address location="https://192.168.1.2:9444/services/CloudControllerService.CloudControllerServiceHttpsSoap12Endpoint/"/>
+ <soap12:address location="https://10.100.1.154:9444/services/CloudControllerService.CloudControllerServiceHttpsSoap12Endpoint/"/>
</wsdl:port>
<wsdl:port name="CloudControllerServiceHttpEndpoint" binding="ns:CloudControllerServiceHttpBinding">
- <http:address location="http://192.168.1.2:9764/services/CloudControllerService.CloudControllerServiceHttpEndpoint/"/>
+ <http:address location="http://10.100.1.154:9764/services/CloudControllerService.CloudControllerServiceHttpEndpoint/"/>
</wsdl:port>
<wsdl:port name="CloudControllerServiceHttpsEndpoint" binding="ns:CloudControllerServiceHttpBinding">
- <http:address location="https://192.168.1.2:9444/services/CloudControllerService.CloudControllerServiceHttpsEndpoint/"/>
+ <http:address location="https://10.100.1.154:9444/services/CloudControllerService.CloudControllerServiceHttpsEndpoint/"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
\ No newline at end of file
[3/4] git commit: latest improvements to auto-scaler, minimum rule,
fail over from an instance creation
Posted by ni...@apache.org.
latest improvements to auto-scaler, minimum rule, fail over from an instance creation
Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/b3930ea7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/b3930ea7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/b3930ea7
Branch: refs/heads/master
Commit: b3930ea7c2434b294ba485e7b8d228b11728eef6
Parents: 5d8c064
Author: Nirmal Fernando <ni...@apache.org>
Authored: Sat Nov 30 12:08:49 2013 +0530
Committer: Nirmal Fernando <ni...@apache.org>
Committed: Sat Nov 30 12:08:49 2013 +0530
----------------------------------------------------------------------
.../stratos/autoscaler/ClusterContext.java | 10 +-
.../stratos/autoscaler/ClusterMonitor.java | 10 +-
.../stratos/autoscaler/MemberContext.java | 58 --------
.../stratos/autoscaler/MemberStatsContext.java | 58 ++++++++
.../stratos/autoscaler/PartitionContext.java | 131 +++++++++++++++++--
.../autoscaler/algorithm/OneAfterAnother.java | 4 +-
.../autoscaler/algorithm/RoundRobin.java | 4 +-
.../cloud/controller/CloudControllerClient.java | 10 +-
.../rule/AutoscalerRuleEvaluator.java | 27 ++--
.../stratos/autoscaler/TestKnowledgeBase.java | 4 +
.../resources/test-minimum-autoscaler-rule.drl | 21 +--
11 files changed, 228 insertions(+), 109 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b3930ea7/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ClusterContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ClusterContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ClusterContext.java
index 99711ee..c1bf519 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ClusterContext.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ClusterContext.java
@@ -61,7 +61,7 @@ public class ClusterContext {
private Properties properties;
- private Map<String, MemberContext> memberContextMap;
+ private Map<String, MemberStatsContext> memberContextMap;
private DeploymentPolicy deploymentPolicy;
@SuppressWarnings("unchecked")
@@ -78,7 +78,7 @@ public class ClusterContext {
}
}
}
- memberContextMap = new HashMap<String, MemberContext>();
+ memberContextMap = new HashMap<String, MemberStatsContext>();
partitionCountMap = new HashMap<String, Integer>();
for (Partition partition : partitionsOfThisCluster) {
@@ -135,13 +135,13 @@ public class ClusterContext {
*
* @param memberContext will be added to map
*/
- public void addMemberContext(MemberContext memberContext) {
+ public void addMemberContext(MemberStatsContext memberContext) {
memberContextMap.put(memberContext.getMemberId(), memberContext);
}
/**
- * {@link MemberContext} which carries memberId will be removed from map
+ * {@link MemberStatsContext} which carries memberId will be removed from map
* @param memberId
*/
public void removeMemberContext(String memberId){
@@ -188,7 +188,7 @@ public class ClusterContext {
return 0;
}
- public void setMemberContextMap(Map<String, MemberContext> memberContextMap) {
+ public void setMemberContextMap(Map<String, MemberStatsContext> memberContextMap) {
this.memberContextMap = memberContextMap;
}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b3930ea7/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ClusterMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ClusterMonitor.java
index 40758f7..ce12904 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ClusterMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ClusterMonitor.java
@@ -41,7 +41,7 @@ public class ClusterMonitor implements Runnable{
private static final Log log = LogFactory.getLog(ClusterMonitor.class);
private String clusterId;
private ClusterContext clusterCtxt;
- private List<MemberContext> memberCtxt;
+ private List<MemberStatsContext> memberCtxt;
private Map<String, PartitionContext> partitionCtxts;
private StatefulKnowledgeSession ksession;
private boolean isDestroyed;
@@ -71,11 +71,11 @@ public class ClusterMonitor implements Runnable{
this.clusterCtxt = clusterCtxt;
}
- public List<MemberContext> getMemberCtxt() {
+ public List<MemberStatsContext> getMemberCtxt() {
return memberCtxt;
}
- public void setMemberCtxt(List<MemberContext> memberCtxt) {
+ public void setMemberCtxt(List<MemberStatsContext> memberCtxt) {
this.memberCtxt = memberCtxt;
}
@@ -115,7 +115,7 @@ public class ClusterMonitor implements Runnable{
public void run() {
while (!isDestroyed()) {
- log.info("Cluster monitor is running..");
+ log.debug("Cluster monitor is running..");
try {
minInstanceCountCheck();
} catch (Exception e) {
@@ -143,7 +143,7 @@ public class ClusterMonitor implements Runnable{
}
ctxt.setMinimumMemberCount(partition.getPartitionMin());
- AutoscalerRuleEvaluator.evaluate(ksession, facthandle, ctxt);
+ facthandle = AutoscalerRuleEvaluator.evaluate(ksession, facthandle, ctxt);
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b3930ea7/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/MemberContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/MemberContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/MemberContext.java
deleted file mode 100644
index 32bb807..0000000
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/MemberContext.java
+++ /dev/null
@@ -1,58 +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.autoscaler;
-
-/**
- * This class will keep additional parameters such as load average and memory consumption
- */
-
-public class MemberContext {
- private float loadAverage;
- private float memoryConsumption;
- private String memberId;
-
- public MemberContext(String memberId){
- this.memberId = memberId;
- }
-
- public String getMemberId() {
- return memberId;
- }
-
- public void setMemberId(String memberId) {
- this.memberId = memberId;
- }
-
- public float getMemoryConsumption() {
- return memoryConsumption;
- }
-
- public void setMemoryConsumption(float memoryConsumption) {
- this.memoryConsumption = memoryConsumption;
- }
-
- public float getLoadAverage() {
- return loadAverage;
- }
-
- public void setLoadAverage(float loadAverage) {
- this.loadAverage = loadAverage;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b3930ea7/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/MemberStatsContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/MemberStatsContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/MemberStatsContext.java
new file mode 100644
index 0000000..da85cee
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/MemberStatsContext.java
@@ -0,0 +1,58 @@
+/*
+ * 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.autoscaler;
+
+/**
+ * This class will keep additional parameters such as load average and memory consumption
+ */
+
+public class MemberStatsContext {
+ private float loadAverage;
+ private float memoryConsumption;
+ private String memberId;
+
+ public MemberStatsContext(String memberId){
+ this.memberId = memberId;
+ }
+
+ public String getMemberId() {
+ return memberId;
+ }
+
+ public void setMemberId(String memberId) {
+ this.memberId = memberId;
+ }
+
+ public float getMemoryConsumption() {
+ return memoryConsumption;
+ }
+
+ public void setMemoryConsumption(float memoryConsumption) {
+ this.memoryConsumption = memoryConsumption;
+ }
+
+ public float getLoadAverage() {
+ return loadAverage;
+ }
+
+ public void setLoadAverage(float loadAverage) {
+ this.loadAverage = loadAverage;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b3930ea7/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/PartitionContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/PartitionContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/PartitionContext.java
index c76ac9f..1740363 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/PartitionContext.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/PartitionContext.java
@@ -19,26 +19,64 @@
package org.apache.stratos.autoscaler;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.stratos.cloud.controller.deployment.partition.Partition;
+import org.apache.stratos.cloud.controller.pojo.MemberContext;
/**
+ * This is an object that inserted to the rules engine.
+ * Holds information about a partition.
* @author nirmal
*
*/
public class PartitionContext {
+ private static final Log log = LogFactory.getLog(PartitionContext.class);
private String partitionId;
private Partition partition;
private int currentMemberCount = 0;
private int minimumMemberCount = 0;
- private List<String> memberIds = new ArrayList<String>();
+ // 5 mints as the default
+ private long expiryTime = 300000;
+ // pending members
+ private List<MemberContext> pendingMembers;
+
+ // members to be terminated
+ private List<String> obsoletedMembers;
+
+ // active members
+ private List<MemberContext> activeMembers;
public PartitionContext(Partition partition) {
this.setPartition(partition);
this.partitionId = partition.getId();
+ this.pendingMembers = new ArrayList<MemberContext>();
+ this.activeMembers = new ArrayList<MemberContext>();
+ this.obsoletedMembers = new CopyOnWriteArrayList<String>();
+ Thread th = new Thread(new PendingMemberWatcher(this));
+ th.start();
+ }
+
+ public List<MemberContext> getPendingMembers() {
+ return pendingMembers;
+ }
+
+ public void setPendingMembers(List<MemberContext> pendingMembers) {
+ this.pendingMembers = pendingMembers;
+ }
+
+ public List<MemberContext> getActiveMembers() {
+ return activeMembers;
+ }
+
+ public void setActiveMembers(List<MemberContext> activeMembers) {
+ this.activeMembers = activeMembers;
}
public String getPartitionId() {
@@ -48,17 +86,12 @@ public class PartitionContext {
this.partitionId = partitionId;
}
public int getCurrentMemberCount() {
- return currentMemberCount;
+ // live count + pending count
+ return currentMemberCount + pendingMembers.size();
}
public void incrementCurrentMemberCount(int count) {
this.currentMemberCount += count;
}
- public List<String> getMemberIds() {
- return memberIds;
- }
- public void setMemberIds(List<String> memberIds) {
- this.memberIds = memberIds;
- }
public int getMinimumMemberCount() {
return minimumMemberCount;
@@ -75,4 +108,86 @@ public class PartitionContext {
public void setPartition(Partition partition) {
this.partition = partition;
}
+
+ public void addPendingMember(MemberContext ctxt) {
+ this.pendingMembers.add(ctxt);
+ }
+
+ public void removePendingMember(MemberContext ctxt) {
+ this.pendingMembers.remove(ctxt);
+ }
+
+ public void addActiveMember(MemberContext ctxt) {
+ this.activeMembers.add(ctxt);
+ }
+
+ public void removeActiveMember(MemberContext ctxt) {
+ this.activeMembers.remove(ctxt);
+ }
+
+ public void addObsoleteMember(String memberId) {
+ this.obsoletedMembers.add(memberId);
+ }
+
+ public boolean removeObsoleteMember(String memberId) {
+ return this.obsoletedMembers.remove(memberId);
+ }
+
+ public long getExpiryTime() {
+ return expiryTime;
+ }
+
+ public void setExpiryTime(long expiryTime) {
+ this.expiryTime = expiryTime;
+ }
+
+ public List<String> getObsoletedMembers() {
+ return obsoletedMembers;
+ }
+
+ public void setObsoletedMembers(List<String> obsoletedMembers) {
+ this.obsoletedMembers = obsoletedMembers;
+ }
+
+ private class PendingMemberWatcher implements Runnable {
+ private PartitionContext ctxt;
+
+ public PendingMemberWatcher(PartitionContext ctxt) {
+ this.ctxt = ctxt;
+ }
+
+ @Override
+ public void run() {
+
+ while (true) {
+ long expiryTime = ctxt.getExpiryTime();
+ List<MemberContext> pendingMembers = ctxt.getPendingMembers();
+ synchronized (pendingMembers) {
+
+ for (Iterator<MemberContext> iterator = pendingMembers.listIterator(); iterator.hasNext();) {
+ MemberContext pendingMember = (MemberContext) iterator.next();
+
+ if (pendingMember == null) {
+ continue;
+ }
+ long pendingTime = System.currentTimeMillis() - pendingMember.getInitTime();
+ if (pendingTime >= expiryTime) {
+ iterator.remove();
+ log.info("Pending state of member: " + pendingMember.getMemberId() +
+ " is expired. " + "Adding as an obsoleted member.");
+ // member should be terminated
+ ctxt.addObsoleteMember(pendingMember.getMemberId());
+ }
+ }
+ }
+
+ try {
+ // TODO find a constant
+ Thread.sleep(15000);
+ } catch (InterruptedException ignore) {
+ }
+ }
+ }
+
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b3930ea7/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/OneAfterAnother.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/OneAfterAnother.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/OneAfterAnother.java
index bbc2438..5c33b99 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/OneAfterAnother.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/OneAfterAnother.java
@@ -55,7 +55,7 @@ public class OneAfterAnother implements AutoscaleAlgorithm {
clusterContext.addPartitionCount(currentPartitionId, 0);
}
- if (clusterContext.getMemberCount(currentPartitionId) < currentPartition.getPartitionMembersMax()) {
+ if (clusterContext.getMemberCount(currentPartitionId) < currentPartition.getPartitionMax()) {
// current partition is free
clusterContext.increaseMemberCountInPartitionBy(currentPartitionId, 1);
if (log.isDebugEnabled())
@@ -95,7 +95,7 @@ public class OneAfterAnother implements AutoscaleAlgorithm {
String currentPartitionId = currentPartition.getId();
// has more than minimum instances.
- if (clusterContext.getMemberCount(currentPartitionId) > currentPartition.getPartitionMembersMin()) {
+ if (clusterContext.getMemberCount(currentPartitionId) > currentPartition.getPartitionMin()) {
// current partition is free
clusterContext.decreaseMemberCountInPartitionBy(currentPartitionId, 1);
if (log.isDebugEnabled())
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b3930ea7/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/RoundRobin.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/RoundRobin.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/RoundRobin.java
index 78444f6..7de89cd 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/RoundRobin.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/RoundRobin.java
@@ -58,7 +58,7 @@ public class RoundRobin implements AutoscaleAlgorithm{
if(!clusterContext.partitionCountExists(currentPartitionId))
AutoscalerContext.getInstance().getClusterContext(clusterId).addPartitionCount(currentPartitionId, 0);
- if(clusterContext.getMemberCount(currentPartitionId) < currentPartition.getPartitionMembersMax()){
+ if(clusterContext.getMemberCount(currentPartitionId) < currentPartition.getPartitionMax()){
// current partition is free
clusterContext.increaseMemberCountInPartitionBy(currentPartitionId, 1);
if(log.isDebugEnabled())
@@ -112,7 +112,7 @@ public class RoundRobin implements AutoscaleAlgorithm{
AutoscalerContext.getInstance().getClusterContext(clusterId)
.addPartitionCount(currentPartitionId, 0);
// has more than minimum instances.
- if (clusterContext.getMemberCount(currentPartitionId) > currentPartition.getPartitionMembersMin()) {
+ if (clusterContext.getMemberCount(currentPartitionId) > currentPartition.getPartitionMin()) {
// current partition is free
clusterContext.decreaseMemberCountInPartitionBy(currentPartitionId, 1);
if (log.isDebugEnabled()) {
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b3930ea7/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java
index 17ad1c7..8564143 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java
@@ -37,6 +37,7 @@ import org.apache.stratos.cloud.controller.stub.CloudControllerServiceStub;
import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException;
import java.rmi.RemoteException;
+import java.util.UUID;
/**
@@ -102,9 +103,13 @@ public class CloudControllerClient {
}
}
- public void spawnAnInstance(Partition partition, String clusterId) throws SpawningException {
+ public org.apache.stratos.cloud.controller.pojo.MemberContext spawnAnInstance(Partition partition, String clusterId) throws SpawningException {
try {
- stub.startInstance(clusterId, partition);
+ org.apache.stratos.cloud.controller.pojo.MemberContext member = new org.apache.stratos.cloud.controller.pojo.MemberContext();
+ member.setClusterId(clusterId);
+ member.setPartition(partition);
+ member.setInitTime(System.currentTimeMillis());
+ return stub.startInstance(member);
} catch (CloudControllerServiceIllegalArgumentExceptionException e) {
log.error(e.getMessage());
throw new SpawningException(e);
@@ -117,6 +122,7 @@ public class CloudControllerClient {
throw new SpawningException(msg, e);
}
}
+
public void terminate(String memberId) throws TerminationException {
//call CC terminate method
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b3930ea7/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/AutoscalerRuleEvaluator.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/AutoscalerRuleEvaluator.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/AutoscalerRuleEvaluator.java
index a53040b..a81906e 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/AutoscalerRuleEvaluator.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/AutoscalerRuleEvaluator.java
@@ -25,14 +25,8 @@ import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.autoscaler.AutoscalerContext;
-import org.apache.stratos.autoscaler.ClusterContext;
import org.apache.stratos.autoscaler.ClusterMonitor;
-import org.apache.stratos.autoscaler.PartitionContext;
import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient;
-import org.apache.stratos.autoscaler.policy.PolicyManager;
-import org.apache.stratos.messaging.domain.topology.Service;
-import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseFactory;
import org.drools.builder.*;
@@ -44,10 +38,9 @@ import org.apache.stratos.autoscaler.Constants;
import org.apache.stratos.autoscaler.algorithm.AutoscaleAlgorithm;
import org.apache.stratos.autoscaler.algorithm.OneAfterAnother;
import org.apache.stratos.autoscaler.algorithm.RoundRobin;
-import org.apache.stratos.autoscaler.util.AutoscalerUtil;
-import org.apache.stratos.messaging.domain.topology.Cluster;
import org.apache.stratos.autoscaler.algorithm.PartitionGroupOneAfterAnother;
import org.apache.stratos.cloud.controller.deployment.partition.Partition;
+import org.apache.stratos.cloud.controller.pojo.MemberContext;
import org.drools.runtime.rule.FactHandle;
/**
@@ -73,7 +66,7 @@ public class AutoscalerRuleEvaluator {
}
- public static void evaluate(StatefulKnowledgeSession ksession, FactHandle handle, Object obj) {
+ public static FactHandle evaluate(StatefulKnowledgeSession ksession, FactHandle handle, Object obj) {
if (handle == null) {
@@ -83,7 +76,7 @@ public class AutoscalerRuleEvaluator {
}
ksession.fireAllRules();
log.info("fired all rules "+obj);
-
+ return handle;
}
public void addMonitor(ClusterMonitor monitor) {
@@ -111,21 +104,22 @@ public class AutoscalerRuleEvaluator {
// ksession.fireAllRules();
}
- public static boolean delegateSpawn(Partition partition, String clusterId) {
+ public static MemberContext delegateSpawn(Partition partition, String clusterId) {
try {
// int currentMemberCount = AutoscalerContext.getInstance().getClusterContext(clusterId).getMemberCount();
// if(currentMemberCount < partition.getPartitionMembersMax()) {
// AutoscalerContext.getInstance().getClusterContext(clusterId).increaseMemberCount(1);
- CloudControllerClient.getInstance().spawnAnInstance(partition, clusterId);
+ return CloudControllerClient.getInstance().spawnAnInstance(partition, clusterId);
} catch (Throwable e) {
- log.error("Cannot spawn an instance", e);
+ String message = "Cannot spawn an instance";
+ log.error(message, e);
+ throw new RuntimeException(message, e);
}
- return false;
}
- public boolean delegateTerminate(Partition partition, String clusterId) {
+ public static void delegateTerminate(String memberId) {
try {
// int currentMemberCount = AutoscalerContext.getInstance().getClusterContext(clusterId).getMemberCount();
@@ -135,11 +129,10 @@ public class AutoscalerRuleEvaluator {
//FIXME
// cloudControllerClient.terminate(partition, clusterId);
// }
- return true;
+ CloudControllerClient.getInstance().terminate(memberId);
} catch (Throwable e) {
log.error("Cannot terminate instance", e);
}
- return false;
}
// public boolean delegateSpawn(Partition partition, String clusterId, int memberCountToBeIncreased) {
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b3930ea7/components/org.apache.stratos.autoscaler/src/test/java/org/apache/stratos/autoscaler/TestKnowledgeBase.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/test/java/org/apache/stratos/autoscaler/TestKnowledgeBase.java b/components/org.apache.stratos.autoscaler/src/test/java/org/apache/stratos/autoscaler/TestKnowledgeBase.java
index 0895e44..c4fd401 100644
--- a/components/org.apache.stratos.autoscaler/src/test/java/org/apache/stratos/autoscaler/TestKnowledgeBase.java
+++ b/components/org.apache.stratos.autoscaler/src/test/java/org/apache/stratos/autoscaler/TestKnowledgeBase.java
@@ -99,4 +99,8 @@ public class TestKnowledgeBase {
// ksession.execute(p);
}
+
+ public static String get() {
+ return "null";
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b3930ea7/components/org.apache.stratos.autoscaler/src/test/resources/test-minimum-autoscaler-rule.drl
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/test/resources/test-minimum-autoscaler-rule.drl b/components/org.apache.stratos.autoscaler/src/test/resources/test-minimum-autoscaler-rule.drl
index ba3105c..a5c2fb1 100644
--- a/components/org.apache.stratos.autoscaler/src/test/resources/test-minimum-autoscaler-rule.drl
+++ b/components/org.apache.stratos.autoscaler/src/test/resources/test-minimum-autoscaler-rule.drl
@@ -19,16 +19,17 @@
package org.apache.stratos.autoscaler.rule;
+import function org.apache.stratos.autoscaler.TestKnowledgeBase.get;
+rule "Minimum Rule"
+dialect "mvel"
+ when
+ eval(true)
-#rule "Minimum Rule"
-#dialect "mvel"
-# when
-# $p : ArrayList()
-# $x : String() from $p
-# eval(true)
-#
- # then
-# System.out.println($x+ "SSsSS");
-#end
\ No newline at end of file
+ then
+ p = get();
+ if(p != null) {
+ System.out.println(p+ "SSsSS");
+ }
+end
\ No newline at end of file
[4/4] git commit: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/incubator-stratos
Posted by ni...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-stratos
Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/faca0166
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/faca0166
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/faca0166
Branch: refs/heads/master
Commit: faca0166609ee84ec7a89b1bf117d110d8375255
Parents: b3930ea d9ca9e3
Author: Nirmal Fernando <ni...@apache.org>
Authored: Sat Nov 30 12:10:21 2013 +0530
Committer: Nirmal Fernando <ni...@apache.org>
Committed: Sat Nov 30 12:10:21 2013 +0530
----------------------------------------------------------------------
.../pom.xml | 6 +
.../load/balancer/LoadBalancerContext.java | 28 +-
.../conf/LoadBalancerConfiguration.java | 1358 ++++--------------
.../load/balancer/conf/domain/Algorithm.java | 49 +
.../load/balancer/conf/structure/Node.java | 15 +-
.../balancer/conf/structure/NodeBuilder.java | 80 +-
.../load/balancer/conf/util/Constants.java | 46 +-
.../load/balancer/conf/util/HostContext.java | 161 ---
.../conf/util/LoadBalancerConfigUtil.java | 305 ----
.../balancer/conf/util/TenantDomainContext.java | 80 --
.../InvalidConfigurationException.java | 33 +
.../internal/LoadBalancerServiceComponent.java | 57 +-
.../test/LoadBalancerConfigUtilTest.java | 48 -
.../test/LoadBalancerConfigurationTest.java | 179 +--
.../load/balancer/test/NodeBuilderTest.java | 123 --
.../src/test/resources/loadbalancer.conf | 84 --
.../src/test/resources/loadbalancer1.conf | 60 -
.../src/test/resources/loadbalancer2.conf | 50 -
.../sample/configuration/loadbalancer1.conf | 66 +
.../sample/configuration/loadbalancer2.conf | 118 ++
.../sample/configuration/loadbalancer3.conf | 66 +
.../load-balancer/haproxy-extension/INSTALL.txt | 16 +-
products/load-balancer/README.txt | 19 +-
.../distribution/src/main/assembly/bin.xml | 1 +
.../distribution/src/main/bin/stratos.bat | 2 +-
.../distribution/src/main/bin/stratos.sh | 2 +-
.../src/main/conf/loadbalancer.conf | 45 +
27 files changed, 807 insertions(+), 2290 deletions(-)
----------------------------------------------------------------------