You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by im...@apache.org on 2015/07/23 15:38:34 UTC
[3/4] stratos git commit: Reverting last set of commits which were
merged from pr/403 to master branch by mistake
http://git-wip-us.apache.org/repos/asf/stratos/blob/2ff059db/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java
index d7a5916..4d51cc1 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java
@@ -68,8 +68,8 @@ public class CloudControllerServiceImpl implements CloudControllerService {
}
- public boolean addCartridge(Cartridge cartridgeConfig)
- throws InvalidCartridgeDefinitionException, InvalidIaasProviderException, CartridgeAlreadyExistsException {
+ public boolean addCartridge(Cartridge cartridgeConfig) throws InvalidCartridgeDefinitionException,
+ InvalidIaasProviderException, CartridgeAlreadyExistsException {
handleNullObject(cartridgeConfig, "Cartridge definition is null");
@@ -111,8 +111,8 @@ public class CloudControllerServiceImpl implements CloudControllerService {
}
@Override
- public boolean updateCartridge(Cartridge cartridge)
- throws InvalidCartridgeDefinitionException, InvalidIaasProviderException,
+ public boolean updateCartridge(Cartridge cartridge) throws InvalidCartridgeDefinitionException,
+ InvalidIaasProviderException,
CartridgeDefinitionNotExistsException {
handleNullObject(cartridge, "Cartridge definition is null");
@@ -155,13 +155,12 @@ public class CloudControllerServiceImpl implements CloudControllerService {
return true;
}
- private void copyIaasProviders(Cartridge destCartridge, Cartridge sourceCartridge) {
+ private void copyIaasProviders(Cartridge destCartridge,
+ Cartridge sourceCartridge) {
- List<IaasProvider> newIaasProviders =
- CloudControllerContext.getInstance().getIaasProviders(destCartridge.getType());
+ List<IaasProvider> newIaasProviders = CloudControllerContext.getInstance().getIaasProviders(destCartridge.getType());
- Map<String, IaasProvider> iaasProviderMap =
- CloudControllerContext.getInstance().getPartitionToIaasProvider(sourceCartridge.getType());
+ Map<String, IaasProvider> iaasProviderMap = CloudControllerContext.getInstance().getPartitionToIaasProvider(sourceCartridge.getType());
if (iaasProviderMap != null) {
for (Entry<String, IaasProvider> entry : iaasProviderMap.entrySet()) {
@@ -172,12 +171,11 @@ public class CloudControllerServiceImpl implements CloudControllerService {
IaasProvider iaasProvider = entry.getValue();
if (newIaasProviders.contains(iaasProvider)) {
if (log.isDebugEnabled()) {
- log.debug("Copying partition from the cartridge that is undeployed, to the new cartridge: " +
- "[partition-id] " + partitionId + " [cartridge-type] " + destCartridge.getType());
+ log.debug("Copying partition from the cartridge that is undeployed, to the new cartridge: "
+ + "[partition-id] " + partitionId + " [cartridge-type] " + destCartridge.getType());
}
CloudControllerContext.getInstance().addIaasProvider(destCartridge.getType(), partitionId,
- newIaasProviders.get(newIaasProviders.indexOf(
- iaasProvider)));
+ newIaasProviders.get(newIaasProviders.indexOf(iaasProvider)));
}
}
}
@@ -332,8 +330,8 @@ public class CloudControllerServiceImpl implements CloudControllerService {
return memberContextsArray;
}
- public MemberContext startInstance(InstanceContext instanceContext)
- throws CartridgeNotFoundException, InvalidIaasProviderException, CloudControllerException {
+ public MemberContext startInstance(InstanceContext instanceContext) throws
+ CartridgeNotFoundException, InvalidIaasProviderException, CloudControllerException {
try {
// Validate instance context
@@ -350,8 +348,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
String partitionId = partition.getId();
String clusterId = instanceContext.getClusterId();
ClusterContext clusterContext = CloudControllerContext.getInstance().getClusterContext(clusterId);
- handleNullObject(clusterContext,
- "Could not start instance, cluster context not found: [cluster-id] " + clusterId);
+ handleNullObject(clusterContext, "Could not start instance, cluster context not found: [cluster-id] " + clusterId);
// Validate cartridge
String cartridgeType = clusterContext.getCartridgeType();
@@ -363,15 +360,12 @@ public class CloudControllerServiceImpl implements CloudControllerService {
}
// Validate iaas provider
- IaasProvider iaasProvider =
- CloudControllerContext.getInstance().getIaasProviderOfPartition(cartridge.getType(), partitionId);
+ IaasProvider iaasProvider = CloudControllerContext.getInstance().getIaasProviderOfPartition(cartridge.getType(), partitionId);
if (iaasProvider == null) {
String msg = String.format("Could not start instance, " +
"IaaS provider not found in cartridge %s for partition %s, " +
"partitions found: %s ", cartridgeType, partitionId,
- CloudControllerContext.getInstance()
- .getPartitionToIaasProvider(cartridge.getType())
- .keySet().toString());
+ CloudControllerContext.getInstance().getPartitionToIaasProvider(cartridge.getType()).keySet().toString());
log.error(msg);
throw new InvalidIaasProviderException(msg);
}
@@ -382,9 +376,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
// Create member context
String applicationId = clusterContext.getApplicationId();
MemberContext memberContext = createMemberContext(applicationId, cartridgeType, memberId,
- CloudControllerUtil.getLoadBalancingIPTypeEnumFromString(
- cartridge.getLoadBalancingIPType()),
- instanceContext);
+ CloudControllerUtil.getLoadBalancingIPTypeEnumFromString(cartridge.getLoadBalancingIPType()), instanceContext);
// Prepare payload
StringBuilder payload = new StringBuilder(clusterContext.getPayload());
@@ -408,6 +400,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
NetworkPartition networkPartition =
CloudControllerContext.getInstance().getNetworkPartition(memberContext.getNetworkPartitionId());
+
if (networkPartition.getProperties() != null) {
if (networkPartition.getProperties().getProperties() != null) {
for (Property property : networkPartition.getProperties().getProperties()) {
@@ -454,13 +447,13 @@ public class CloudControllerServiceImpl implements CloudControllerService {
clusterContext.setVolumes(volumes);
}
+ // Handle member created event
+ TopologyBuilder.handleMemberCreatedEvent(memberContext);
+
// Persist member context
CloudControllerContext.getInstance().addMemberContext(memberContext);
CloudControllerContext.getInstance().persist();
- // Handle member created event
- TopologyBuilder.handleMemberCreatedEvent(memberContext);
-
// Start instance in a new thread
if (log.isDebugEnabled()) {
log.debug(String.format("Starting instance creator thread: [cluster] %s [cluster-instance] %s " +
@@ -479,10 +472,9 @@ public class CloudControllerServiceImpl implements CloudControllerService {
}
private MemberContext createMemberContext(String applicationId, String cartridgeType, String memberId,
- LoadBalancingIPType loadBalancingIPType,
- InstanceContext instanceContext) {
- MemberContext memberContext =
- new MemberContext(applicationId, cartridgeType, instanceContext.getClusterId(), memberId);
+ LoadBalancingIPType loadBalancingIPType, InstanceContext instanceContext) {
+ MemberContext memberContext = new MemberContext(
+ applicationId, cartridgeType, instanceContext.getClusterId(), memberId);
memberContext.setClusterInstanceId(instanceContext.getClusterInstanceId());
memberContext.setNetworkPartitionId(instanceContext.getNetworkPartitionId());
@@ -497,7 +489,8 @@ public class CloudControllerServiceImpl implements CloudControllerService {
return memberContext;
}
- private Volume createVolumeAndSetInClusterContext(Volume volume, IaasProvider iaasProvider) {
+ private Volume createVolumeAndSetInClusterContext(Volume volume,
+ IaasProvider iaasProvider) {
// iaas cannot be null at this state #startInstance method
Iaas iaas = iaasProvider.getIaas();
int sizeGB = volume.getSize();
@@ -505,8 +498,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
if (StringUtils.isNotEmpty(volume.getVolumeId())) {
// volumeID is specified, so not creating additional volumes
if (log.isDebugEnabled()) {
- log.debug("Volume creation is skipping since a volume ID is specified. [Volume ID] " +
- volume.getVolumeId());
+ log.debug("Volume creation is skipping since a volume ID is specified. [Volume ID] " + volume.getVolumeId());
}
volume.setId(volume.getVolumeId());
} else {
@@ -519,6 +511,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
return volume;
}
+
private StringBuilder getPersistencePayload(ClusterContext ctx, Iaas iaas) {
StringBuilder persistencePayload = new StringBuilder();
if (isPersistenceMappingAvailable(ctx)) {
@@ -581,8 +574,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
log.info(String.format("Member terminated [member-id] %s ", memberId));
} else {
log.warn(String.format("Stratos could not terminate the member [member-id] %s. This may due to a issue " +
- "in the underlying IaaS, Please terminate the member manually if it is available",
- memberId));
+ "in the underlying IaaS, Please terminate the member manually if it is available", memberId));
MemberContext memberContext = CloudControllerContext.getInstance().getMemberContextOfMemberId(memberId);
CloudControllerServiceUtil.executeMemberTerminationPostProcess(memberContext);
}
@@ -590,8 +582,8 @@ public class CloudControllerServiceImpl implements CloudControllerService {
}
@Override
- public boolean terminateInstance(String memberId)
- throws InvalidMemberException, InvalidCartridgeTypeException, CloudControllerException {
+ public boolean terminateInstance(String memberId) throws InvalidMemberException,
+ InvalidCartridgeTypeException, CloudControllerException {
try {
handleNullObject(memberId, "Could not terminate instance, member id is null.");
@@ -605,8 +597,10 @@ public class CloudControllerServiceImpl implements CloudControllerService {
if (StringUtils.isBlank(memberContext.getInstanceId())) {
if (log.isErrorEnabled()) {
- log.error(String.format("Could not terminate instance, instance id is blank: [member-id] %s " +
- ", removing member from topology...", memberContext.getMemberId()));
+ log.error(String.format(
+ "Could not terminate instance, instance id is blank: [member-id] %s " +
+ ", removing member from topology...",
+ memberContext.getMemberId()));
}
CloudControllerServiceUtil.executeMemberTerminationPostProcess(memberContext);
}
@@ -614,8 +608,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
// check if status == active, if true, then this is a termination on member faulty
TopologyManager.acquireWriteLock();
Topology topology = TopologyManager.getTopology();
- org.apache.stratos.messaging.domain.topology.Service service =
- topology.getService(memberContext.getCartridgeType());
+ org.apache.stratos.messaging.domain.topology.Service service = topology.getService(memberContext.getCartridgeType());
if (service != null) {
Cluster cluster = service.getCluster(memberContext.getClusterId());
@@ -625,8 +618,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
// check if ready to shutdown member is expired and send
// member terminated if it is.
- if (isMemberExpired(member, memberContext.getObsoleteInitTime(),
- memberContext.getObsoleteExpiryTime())) {
+ if (isMemberExpired(member, memberContext.getObsoleteInitTime(), memberContext.getObsoleteExpiryTime())) {
if (log.isInfoEnabled()) {
log.info(String.format(
"Member pending termination in ReadyToShutdown state exceeded expiry time. " +
@@ -682,12 +674,12 @@ public class CloudControllerServiceImpl implements CloudControllerService {
@Override
public boolean terminateInstances(String clusterId) throws InvalidClusterException {
- log.info("Starting to terminate all instances of cluster : " + clusterId);
+ log.info("Starting to terminate all instances of cluster : "
+ + clusterId);
handleNullObject(clusterId, "Instance termination failed. Cluster id is null.");
- List<MemberContext> memberContexts =
- CloudControllerContext.getInstance().getMemberContextsOfClusterId(clusterId);
+ List<MemberContext> memberContexts = CloudControllerContext.getInstance().getMemberContextsOfClusterId(clusterId);
if (memberContexts == null) {
String msg = "Instance termination failed. No members found for cluster id: " + clusterId;
log.warn(msg);
@@ -701,7 +693,8 @@ public class CloudControllerServiceImpl implements CloudControllerService {
}
@Override
- public boolean registerService(Registrant registrant) throws CartridgeNotFoundException {
+ public boolean registerService(Registrant registrant)
+ throws CartridgeNotFoundException {
String cartridgeType = registrant.getCartridgeType();
handleNullObject(cartridgeType, "Service registration failed, cartridge Type is null.");
@@ -778,8 +771,8 @@ public class CloudControllerServiceImpl implements CloudControllerService {
Cartridge cartridge = CloudControllerContext.getInstance().getCartridge(cartridgeType);
if (cartridge == null) {
- String msg = String.format(
- "Service unregistration failed. No matching cartridge found: [cartridge-type] %s " +
+ String msg =
+ String.format("Service unregistration failed. No matching cartridge found: [cartridge-type] %s " +
"[application-id] %s", cartridgeType, ctxt.getApplicationId());
log.error(msg);
throw new UnregisteredClusterException(msg);
@@ -820,9 +813,8 @@ public class CloudControllerServiceImpl implements CloudControllerService {
terminateInstance(member.getMemberId());
} catch (Exception e) {
// we are not gonna stop the execution due to errors.
- log.warn((String.format(
- "Instance termination failed of member [member-id] %s " + "[application-id] %s",
- member.getMemberId(), ctxt.getApplicationId())), e);
+ log.warn((String.format("Instance termination failed of member [member-id] %s " +
+ "[application-id] %s", member.getMemberId(), ctxt.getApplicationId())), e);
}
}
@@ -836,9 +828,8 @@ public class CloudControllerServiceImpl implements CloudControllerService {
lock = CloudControllerContext.getInstance().acquireClusterContextWriteLock();
ClusterContext ctxt = CloudControllerContext.getInstance().getClusterContext(clusterId_);
if (ctxt == null) {
- String msg = String.format(
- "Service unregistration failed. Cluster not found: [cluster-id] %s " +
- "[application-id] %s ", clusterId_, ctxt.getApplicationId());
+ String msg = String.format("Service unregistration failed. Cluster not found: [cluster-id] %s " +
+ "[application-id] %s ", clusterId_, ctxt.getApplicationId());
log.error(msg);
return;
}
@@ -867,17 +858,12 @@ public class CloudControllerServiceImpl implements CloudControllerService {
try {
lock = CloudControllerContext.getInstance().acquireCartridgesWriteLock();
- Cartridge cartridge =
- CloudControllerContext.getInstance().getCartridge(ctxt.getCartridgeType());
- if (cartridge != null &&
- CloudControllerContext.getInstance().getIaasProviders(cartridge.getType()) != null &&
- ctxt.getVolumes() != null) {
+ Cartridge cartridge = CloudControllerContext.getInstance().getCartridge(ctxt.getCartridgeType());
+ if (cartridge != null && CloudControllerContext.getInstance().getIaasProviders(cartridge.getType()) != null && ctxt.getVolumes() != null) {
for (Volume volume : ctxt.getVolumes()) {
if (volume.getId() != null) {
String iaasType = volume.getIaasType();
- Iaas iaas = CloudControllerContext.getInstance()
- .getIaasProvider(cartridge.getType(), iaasType)
- .getIaas();
+ Iaas iaas = CloudControllerContext.getInstance().getIaasProvider(cartridge.getType(), iaasType).getIaas();
if (iaas != null) {
try {
// delete the volumes if remove on unsubscription is true.
@@ -888,8 +874,8 @@ public class CloudControllerServiceImpl implements CloudControllerService {
} catch (Exception ignore) {
if (log.isErrorEnabled()) {
log.error((String.format("Error while deleting volume [id] %s " +
- "[application-id]", volume.getId(),
- ctxt.getApplicationId())), ignore);
+ "[application-id]", volume.getId(), ctxt.getApplicationId())),
+ ignore);
}
}
}
@@ -917,8 +903,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
public boolean validateDeploymentPolicyNetworkPartition(String cartridgeType, String networkPartitionId)
throws InvalidPartitionException, InvalidCartridgeTypeException {
- NetworkPartition networkPartition =
- CloudControllerContext.getInstance().getNetworkPartition(networkPartitionId);
+ NetworkPartition networkPartition = CloudControllerContext.getInstance().getNetworkPartition(networkPartitionId);
Lock lock = null;
try {
lock = CloudControllerContext.getInstance().acquireCartridgesWriteLock();
@@ -950,14 +935,15 @@ public class CloudControllerServiceImpl implements CloudControllerService {
if (validatedPartitions != null && validatedPartitions.contains(partition.getId())) {
// partition cache hit
String provider = partition.getProvider();
- IaasProvider iaasProvider =
- CloudControllerContext.getInstance().getIaasProvider(cartridge.getType(), provider);
+ IaasProvider iaasProvider = CloudControllerContext.getInstance()
+ .getIaasProvider(cartridge.getType(), provider);
partitionToIaasProviders.put(partition.getId(), iaasProvider);
continue;
}
Callable<IaasProvider> worker = new PartitionValidatorCallable(partition, cartridge);
- Future<IaasProvider> job = CloudControllerContext.getInstance().getExecutorService().submit(worker);
+ Future<IaasProvider> job = CloudControllerContext.getInstance()
+ .getExecutorService().submit(worker);
jobList.put(partition.getId(), job);
}
@@ -983,8 +969,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
"[cartridge-type] " + cartridgeType);
}
} catch (Exception e) {
- String message =
- "Could not cache partitions against the cartridge: [cartridge-type] " + cartridgeType;
+ String message = "Could not cache partitions against the cartridge: [cartridge-type] " + cartridgeType;
log.error(message, e);
throw new InvalidPartitionException(message, e);
}
@@ -1034,8 +1019,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
}
@Override
- public boolean updateClusterStatus(String serviceName, String clusterId, String instanceId,
- ClusterStatus status) {
+ public boolean updateClusterStatus(String serviceName, String clusterId, String instanceId, ClusterStatus status) {
//TODO
return true;
}
@@ -1048,8 +1032,8 @@ public class CloudControllerServiceImpl implements CloudControllerService {
}
@Override
- public boolean createApplicationClusters(String appId, ApplicationClusterContext[] appClustersContexts)
- throws ApplicationClusterRegistrationException {
+ public boolean createApplicationClusters(String appId, ApplicationClusterContext[] appClustersContexts) throws
+ ApplicationClusterRegistrationException {
if (appClustersContexts == null || appClustersContexts.length == 0) {
String errorMsg = "No application cluster information found, unable to create clusters: " +
"[application-id] " + appId;
@@ -1079,14 +1063,12 @@ public class CloudControllerServiceImpl implements CloudControllerService {
for (ClusterPortMapping clusterPortMapping : clusterPortMappings) {
try {
if (clusterPortMapping.isKubernetes()) {
- URL accessUrl =
- new URL(clusterPortMapping.getProtocol(), appClusterCtxt.getHostName(),
- clusterPortMapping.getKubernetesServicePort(), "");
+ URL accessUrl = new URL(clusterPortMapping.getProtocol(), appClusterCtxt.getHostName(),
+ clusterPortMapping.getKubernetesServicePort(), "");
accessUrlPerCluster.add(accessUrl.toString());
} else {
- URL accessUrl =
- new URL(clusterPortMapping.getProtocol(), appClusterCtxt.getHostName(),
- clusterPortMapping.getProxyPort(), "");
+ URL accessUrl = new URL(clusterPortMapping.getProtocol(), appClusterCtxt.getHostName(),
+ clusterPortMapping.getProxyPort(), "");
accessUrlPerCluster.add(accessUrl.toString());
}
} catch (MalformedURLException e) {
@@ -1102,10 +1084,10 @@ public class CloudControllerServiceImpl implements CloudControllerService {
}
for (ApplicationClusterContext appClusterCtxt : appClustersContexts) {
- ClusterContext clusterContext =
- new ClusterContext(appId, appClusterCtxt.getCartridgeType(), appClusterCtxt.getClusterId(),
- appClusterCtxt.getTextPayload(), appClusterCtxt.getHostName(),
- appClusterCtxt.isLbCluster(), appClusterCtxt.getProperties());
+ ClusterContext clusterContext = new ClusterContext(
+ appId, appClusterCtxt.getCartridgeType(), appClusterCtxt.getClusterId(),
+ appClusterCtxt.getTextPayload(), appClusterCtxt.getHostName(),
+ appClusterCtxt.isLbCluster(), appClusterCtxt.getProperties());
if (appClusterCtxt.isVolumeRequired()) {
clusterContext.setVolumeRequired(true);
@@ -1115,8 +1097,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
// Create cluster object
Cluster cluster = new Cluster(appClusterCtxt.getCartridgeType(), appClusterCtxt.getClusterId(),
- appClusterCtxt.getDeploymentPolicyName(),
- appClusterCtxt.getAutoscalePolicyName(), appId);
+ appClusterCtxt.getDeploymentPolicyName(), appClusterCtxt.getAutoscalePolicyName(), appId);
cluster.setLbCluster(false);
cluster.setTenantRange(appClusterCtxt.getTenantRange());
cluster.setHostNames(Arrays.asList(appClusterCtxt.getHostName()));
@@ -1139,14 +1120,14 @@ public class CloudControllerServiceImpl implements CloudControllerService {
return true;
}
- public boolean createClusterInstance(String serviceType, String clusterId, String alias, String instanceId,
- String partitionId, String networkPartitionId)
- throws ClusterInstanceCreationException {
+ public boolean createClusterInstance(String serviceType, String clusterId,
+ String alias, String instanceId, String partitionId,
+ String networkPartitionId) throws ClusterInstanceCreationException {
Lock lock = null;
try {
lock = CloudControllerContext.getInstance().acquireClusterContextWriteLock();
- TopologyBuilder.handleClusterInstanceCreated(serviceType, clusterId, alias, instanceId, partitionId,
- networkPartitionId);
+ TopologyBuilder.handleClusterInstanceCreated(serviceType, clusterId, alias,
+ instanceId, partitionId, networkPartitionId);
CloudControllerContext.getInstance().persist();
} finally {
@@ -1163,26 +1144,27 @@ public class CloudControllerServiceImpl implements CloudControllerService {
}
@Override
- public KubernetesCluster getKubernetesCluster(String kubernetesClusterId)
- throws NonExistingKubernetesClusterException {
+ public KubernetesCluster getKubernetesCluster(String kubernetesClusterId) throws
+ NonExistingKubernetesClusterException {
return CloudControllerContext.getInstance().getKubernetesCluster(kubernetesClusterId);
}
@Override
- public KubernetesMaster getMasterForKubernetesCluster(String kubernetesClusterId)
- throws NonExistingKubernetesClusterException {
+ public KubernetesMaster getMasterForKubernetesCluster(String kubernetesClusterId) throws
+ NonExistingKubernetesClusterException {
return CloudControllerContext.getInstance().getKubernetesMasterInGroup(kubernetesClusterId);
}
@Override
- public KubernetesHost[] getHostsForKubernetesCluster(String kubernetesClusterId)
- throws NonExistingKubernetesClusterException {
+ public KubernetesHost[] getHostsForKubernetesCluster(String kubernetesClusterId) throws
+ NonExistingKubernetesClusterException {
return CloudControllerContext.getInstance().getKubernetesHostsInGroup(kubernetesClusterId);
}
+
@Override
- public boolean addKubernetesCluster(KubernetesCluster kubernetesCluster)
- throws InvalidKubernetesClusterException, KubernetesClusterAlreadyExistsException {
+ public boolean addKubernetesCluster(KubernetesCluster kubernetesCluster) throws InvalidKubernetesClusterException,
+ KubernetesClusterAlreadyExistsException {
if (kubernetesCluster == null) {
throw new InvalidKubernetesClusterException("Kubernetes cluster cannot be null");
}
@@ -1222,8 +1204,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
}
@Override
- public boolean updateKubernetesCluster(KubernetesCluster kubernetesCluster)
- throws InvalidKubernetesClusterException {
+ public boolean updateKubernetesCluster(KubernetesCluster kubernetesCluster) throws InvalidKubernetesClusterException {
if (kubernetesCluster == null) {
throw new InvalidKubernetesClusterException("Kubernetes cluster cannot be null");
}
@@ -1256,8 +1237,8 @@ public class CloudControllerServiceImpl implements CloudControllerService {
}
@Override
- public boolean addKubernetesHost(String kubernetesClusterId, KubernetesHost kubernetesHost)
- throws InvalidKubernetesHostException, NonExistingKubernetesClusterException {
+ public boolean addKubernetesHost(String kubernetesClusterId, KubernetesHost kubernetesHost) throws
+ InvalidKubernetesHostException, NonExistingKubernetesClusterException {
if (kubernetesHost == null) {
throw new InvalidKubernetesHostException("Kubernetes host cannot be null");
}
@@ -1270,9 +1251,8 @@ public class CloudControllerServiceImpl implements CloudControllerService {
lock = CloudControllerContext.getInstance().acquireKubernetesClusterWriteLock();
if (log.isInfoEnabled()) {
- log.info(String.format(
- "Adding kubernetes host for kubernetes cluster: [kubernetes-cluster-id] %s " + "[hostname] %s",
- kubernetesClusterId, kubernetesHost.getHostname()));
+ log.info(String.format("Adding kubernetes host for kubernetes cluster: [kubernetes-cluster-id] %s " +
+ "[hostname] %s", kubernetesClusterId, kubernetesHost.getHostname()));
}
CloudControllerUtil.validateKubernetesHost(kubernetesHost);
@@ -1283,23 +1263,21 @@ public class CloudControllerServiceImpl implements CloudControllerService {
kubernetesHostArrayList = new ArrayList<KubernetesHost>();
} else {
if (CloudControllerContext.getInstance().kubernetesHostExists(kubernetesHost.getHostId())) {
- throw new InvalidKubernetesHostException(
- "Kubernetes host already exists: [hostname] " + kubernetesHost.getHostId());
+ throw new InvalidKubernetesHostException("Kubernetes host already exists: [hostname] " +
+ kubernetesHost.getHostId());
}
- kubernetesHostArrayList =
- new ArrayList<KubernetesHost>(Arrays.asList(kubernetesCluster.getKubernetesHosts()));
+ kubernetesHostArrayList = new
+ ArrayList<KubernetesHost>(Arrays.asList(kubernetesCluster.getKubernetesHosts()));
}
kubernetesHostArrayList.add(kubernetesHost);
// Update information model
- kubernetesCluster.setKubernetesHosts(
- kubernetesHostArrayList.toArray(new KubernetesHost[kubernetesHostArrayList.size()]));
+ kubernetesCluster.setKubernetesHosts(kubernetesHostArrayList.toArray(new KubernetesHost[kubernetesHostArrayList.size()]));
CloudControllerContext.getInstance().updateKubernetesCluster(kubernetesCluster);
CloudControllerContext.getInstance().persist();
if (log.isInfoEnabled()) {
- log.info(
- String.format("Kubernetes host added successfully: [id] %s", kubernetesCluster.getClusterId()));
+ log.info(String.format("Kubernetes host added successfully: [id] %s", kubernetesCluster.getClusterId()));
}
return true;
@@ -1313,8 +1291,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
}
@Override
- public boolean removeKubernetesCluster(String kubernetesClusterId)
- throws NonExistingKubernetesClusterException {
+ public boolean removeKubernetesCluster(String kubernetesClusterId) throws NonExistingKubernetesClusterException {
if (StringUtils.isEmpty(kubernetesClusterId)) {
throw new NonExistingKubernetesClusterException("Kubernetes cluster id cannot be empty");
}
@@ -1357,13 +1334,11 @@ public class CloudControllerServiceImpl implements CloudControllerService {
log.info("Removing Kubernetes Host: " + kubernetesHostId);
}
try {
- KubernetesCluster kubernetesClusterStored =
- CloudControllerContext.getInstance().getKubernetesClusterContainingHost(kubernetesHostId);
+ KubernetesCluster kubernetesClusterStored = CloudControllerContext.getInstance().getKubernetesClusterContainingHost(kubernetesHostId);
// Kubernetes master cannot be removed
if (kubernetesClusterStored.getKubernetesMaster().getHostId().equals(kubernetesHostId)) {
- throw new NonExistingKubernetesHostException(
- "Kubernetes master is not allowed to be removed [id] " + kubernetesHostId);
+ throw new NonExistingKubernetesHostException("Kubernetes master is not allowed to be removed [id] " + kubernetesHostId);
}
List<KubernetesHost> kubernetesHostList = new ArrayList<KubernetesHost>();
@@ -1374,8 +1349,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
}
// member count will be equal only when host object was not found
if (kubernetesHostList.size() == kubernetesClusterStored.getKubernetesHosts().length) {
- throw new NonExistingKubernetesHostException(
- "Kubernetes host not found for [id] " + kubernetesHostId);
+ throw new NonExistingKubernetesHostException("Kubernetes host not found for [id] " + kubernetesHostId);
}
KubernetesHost[] kubernetesHostsArray = new KubernetesHost[kubernetesHostList.size()];
kubernetesHostList.toArray(kubernetesHostsArray);
@@ -1411,9 +1385,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
log.info("Updating Kubernetes master: " + kubernetesMaster);
}
try {
- KubernetesCluster kubernetesClusterStored = CloudControllerContext.getInstance()
- .getKubernetesClusterContainingHost(
- kubernetesMaster.getHostId());
+ KubernetesCluster kubernetesClusterStored = CloudControllerContext.getInstance().getKubernetesClusterContainingHost(kubernetesMaster.getHostId());
// Update information model
kubernetesClusterStored.setKubernetesMaster(kubernetesMaster);
@@ -1421,8 +1393,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
CloudControllerContext.getInstance().persist();
if (log.isInfoEnabled()) {
- log.info(String.format("Kubernetes master updated successfully: [id] %s",
- kubernetesMaster.getHostId()));
+ log.info(String.format("Kubernetes master updated successfully: [id] %s", kubernetesMaster.getHostId()));
}
return true;
@@ -1437,8 +1408,8 @@ public class CloudControllerServiceImpl implements CloudControllerService {
}
@Override
- public boolean updateKubernetesHost(KubernetesHost kubernetesHost)
- throws InvalidKubernetesHostException, NonExistingKubernetesHostException {
+ public boolean updateKubernetesHost(KubernetesHost kubernetesHost) throws
+ InvalidKubernetesHostException, NonExistingKubernetesHostException {
Lock lock = null;
try {
@@ -1449,9 +1420,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
}
try {
- KubernetesCluster kubernetesClusterStored = CloudControllerContext.getInstance()
- .getKubernetesClusterContainingHost(
- kubernetesHost.getHostId());
+ KubernetesCluster kubernetesClusterStored = CloudControllerContext.getInstance().getKubernetesClusterContainingHost(kubernetesHost.getHostId());
KubernetesHost[] kubernetesHosts = kubernetesClusterStored.getKubernetesHosts();
for (int i = 0; i < kubernetesHosts.length; i++) {
if (kubernetesHosts[i].getHostId().equals(kubernetesHost.getHostId())) {
@@ -1459,8 +1428,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
kubernetesHosts[i] = kubernetesHost;
if (log.isInfoEnabled()) {
- log.info(String.format("Kubernetes host updated successfully: [id] %s",
- kubernetesHost.getHostId()));
+ log.info(String.format("Kubernetes host updated successfully: [id] %s", kubernetesHost.getHostId()));
}
CloudControllerContext.getInstance().updateKubernetesCluster(kubernetesClusterStored);
@@ -1480,8 +1448,9 @@ public class CloudControllerServiceImpl implements CloudControllerService {
}
@Override
- public boolean addNetworkPartition(NetworkPartition networkPartition)
- throws NetworkPartitionAlreadyExistsException, InvalidNetworkPartitionException {
+ public boolean addNetworkPartition(NetworkPartition networkPartition) throws
+ NetworkPartitionAlreadyExistsException,
+ InvalidNetworkPartitionException {
handleNullObject(networkPartition, "Network Partition is null");
handleNullObject(networkPartition.getId(), "Network Partition ID is null");
@@ -1510,22 +1479,20 @@ public class CloudControllerServiceImpl implements CloudControllerService {
validatePartition(partition);
} catch (InvalidPartitionException e) {
//Following message is shown to the end user in all the the API clients(GUI/CLI/Rest API)
- throw new InvalidNetworkPartitionException(String.format(
- "Network partition " + " %s, is invalid since the partition %s is invalid",
+ throw new InvalidNetworkPartitionException(String.format("Network partition " +
+ " %s, is invalid since the partition %s is invalid",
networkPartition.getId(), partition.getId()), e);
}
if (log.isInfoEnabled()) {
- log.info(String.format(
- "Partition validated successfully: [network-partition-id] %s " + "[partition-id] %s",
- networkPartition.getId(), partition.getId()));
+ log.info(String.format("Partition validated successfully: [network-partition-id] %s " +
+ "[partition-id] %s", networkPartition.getId(), partition.getId()));
}
}
}
} else {
//Following message is shown to the end user in all the the API clients(GUI/CLI/Rest API)
- throw new InvalidNetworkPartitionException(
- String.format("Network partition: " + "%s doesn't not have any partitions ",
- networkPartition.getId()));
+ throw new InvalidNetworkPartitionException(String.format("Network partition: " +
+ "%s doesn't not have any partitions ", networkPartition.getId()));
}
// adding network partition to CC-Context
@@ -1540,8 +1507,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
}
@Override
- public boolean removeNetworkPartition(String networkPartitionId)
- throws NetworkPartitionNotExistsException {
+ public boolean removeNetworkPartition(String networkPartitionId) throws NetworkPartitionNotExistsException {
try {
if (log.isInfoEnabled()) {
@@ -1571,15 +1537,13 @@ public class CloudControllerServiceImpl implements CloudControllerService {
}
@Override
- public boolean updateNetworkPartition(NetworkPartition networkPartition)
- throws NetworkPartitionNotExistsException {
+ public boolean updateNetworkPartition(NetworkPartition networkPartition) throws NetworkPartitionNotExistsException {
try {
handleNullObject(networkPartition, "Network Partition is null");
handleNullObject(networkPartition.getId(), "Network Partition ID is null");
if (log.isInfoEnabled()) {
- log.info(String.format("Updating network partition: [network-partition-id] %s",
- networkPartition.getId()));
+ log.info(String.format("Updating network partition: [network-partition-id] %s", networkPartition.getId()));
}
String networkPartitionID = networkPartition.getId();
@@ -1640,8 +1604,8 @@ public class CloudControllerServiceImpl implements CloudControllerService {
try {
return CloudControllerContext.getInstance().getNetworkPartition(networkPartitionId);
} catch (Exception e) {
- String message =
- String.format("Could not get network partition: [network-partition-id] %s", networkPartitionId);
+ String message = String.format("Could not get network partition: [network-partition-id] %s",
+ networkPartitionId);
log.error(message);
throw new CloudControllerException(message, e);
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/2ff059db/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceUtil.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceUtil.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceUtil.java
index 3c6716c..37580eb 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceUtil.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceUtil.java
@@ -62,20 +62,21 @@ public class CloudControllerServiceUtil {
String partitionId = memberContext.getPartition() == null ? null : memberContext.getPartition().getId();
// Update the topology
- TopologyBuilder.handleMemberTerminated(memberContext.getCartridgeType(), memberContext.getClusterId(),
- memberContext.getNetworkPartitionId(), partitionId,
- memberContext.getMemberId());
+ TopologyBuilder.handleMemberTerminated(memberContext.getCartridgeType(),
+ memberContext.getClusterId(), memberContext.getNetworkPartitionId(),
+ partitionId, memberContext.getMemberId());
- Long timeStamp = System.currentTimeMillis();
// Publish statistics to BAM
- BAMUsageDataPublisher.publish(memberContext.getMemberId(), partitionId, memberContext.getNetworkPartitionId(),
- memberContext.getClusterId(), memberContext.getClusterInstanceId(),
- memberContext.getCartridgeType(), MemberStatus.Terminated.toString(), timeStamp,
- null, null, null);
+ BAMUsageDataPublisher.publish(memberContext.getMemberId(),
+ partitionId,
+ memberContext.getNetworkPartitionId(),
+ memberContext.getClusterId(),
+ memberContext.getCartridgeType(),
+ MemberStatus.Terminated.toString(),
+ null);
// Remove member context
- CloudControllerContext.getInstance()
- .removeMemberContext(memberContext.getClusterId(), memberContext.getMemberId());
+ CloudControllerContext.getInstance().removeMemberContext(memberContext.getClusterId(), memberContext.getMemberId());
// Persist cloud controller context
CloudControllerContext.getInstance().persist();
@@ -86,8 +87,7 @@ public class CloudControllerServiceUtil {
return isValid;
}
- public static IaasProvider validatePartitionAndGetIaasProvider(Partition partition, IaasProvider iaasProvider)
- throws InvalidPartitionException {
+ public static IaasProvider validatePartitionAndGetIaasProvider(Partition partition, IaasProvider iaasProvider) throws InvalidPartitionException {
if (iaasProvider != null) {
// if this is a IaaS based partition
Iaas iaas = iaasProvider.getIaas();
@@ -104,8 +104,7 @@ public class CloudControllerServiceUtil {
}
}
- public static boolean validatePartition(Partition partition, IaasProvider iaasProvider)
- throws InvalidPartitionException {
+ public static boolean validatePartition(Partition partition, IaasProvider iaasProvider) throws InvalidPartitionException {
validatePartitionAndGetIaasProvider(partition, iaasProvider);
return true;
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/2ff059db/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/InstanceCreator.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/InstanceCreator.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/InstanceCreator.java
index 35c8bb1..77cfea2 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/InstanceCreator.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/InstanceCreator.java
@@ -27,6 +27,8 @@ import org.apache.stratos.cloud.controller.domain.*;
import org.apache.stratos.cloud.controller.exception.CartridgeNotFoundException;
import org.apache.stratos.cloud.controller.iaases.Iaas;
import org.apache.stratos.cloud.controller.messaging.topology.TopologyBuilder;
+import org.apache.stratos.cloud.controller.statistics.publisher.BAMUsageDataPublisher;
+import org.apache.stratos.messaging.domain.topology.MemberStatus;
import java.util.concurrent.locks.Lock;
@@ -83,6 +85,15 @@ public class InstanceCreator implements Runnable {
// Update topology
TopologyBuilder.handleMemberInitializedEvent(memberContext);
+ // Publish instance creation statistics to BAM
+ BAMUsageDataPublisher.publish(
+ memberContext.getMemberId(),
+ memberContext.getPartition().getId(),
+ memberContext.getNetworkPartitionId(),
+ memberContext.getClusterId(),
+ memberContext.getCartridgeType(),
+ MemberStatus.Initialized.toString(),
+ memberContext.getInstanceMetadata());
} catch (Exception e) {
String message = String.format("Could not start instance: [cartridge-type] %s [cluster-id] %s",
memberContext.getCartridgeType(), memberContext.getClusterId());
http://git-wip-us.apache.org/repos/asf/stratos/blob/2ff059db/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/statistics/publisher/BAMUsageDataPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/statistics/publisher/BAMUsageDataPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/statistics/publisher/BAMUsageDataPublisher.java
index 675de25..d5aabbd 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/statistics/publisher/BAMUsageDataPublisher.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/statistics/publisher/BAMUsageDataPublisher.java
@@ -52,9 +52,13 @@ public class BAMUsageDataPublisher {
private static StreamDefinition streamDefinition;
private static final String cloudControllerEventStreamVersion = "1.0.0";
- public static void publish(String memberId, String partitionId, String networkId, String clusterId,
- String clusterInstanceId, String serviceName, String status, Long timeStamp,
- String autoscalingReason, Long scalingTime, InstanceMetadata metadata) {
+ public static void publish(String memberId,
+ String partitionId,
+ String networkId,
+ String clusterId,
+ String serviceName,
+ String status,
+ InstanceMetadata metadata) {
if (!CloudControllerConfig.getInstance().isBAMDataPublisherEnabled()) {
return;
}
@@ -75,24 +79,16 @@ public class BAMUsageDataPublisher {
MemberContext memberContext = CloudControllerContext.getInstance().getMemberContextOfMemberId(memberId);
String cartridgeType = memberContext.getCartridgeType();
Cartridge cartridge = CloudControllerContext.getInstance().getCartridge(cartridgeType);
- String instanceType =
- CloudControllerContext.getInstance().getIaasProviderOfPartition(cartridgeType, partitionId)
- .getProperty(CloudControllerConstants.INSTANCE_TYPE);
//Construct the data to be published
List<Object> payload = new ArrayList<Object>();
// Payload values
- payload.add(timeStamp);
payload.add(memberId);
payload.add(serviceName);
payload.add(clusterId);
- payload.add(clusterInstanceId);
payload.add(handleNull(memberContext.getLbClusterId()));
payload.add(handleNull(partitionId));
payload.add(handleNull(networkId));
- payload.add(handleNull(instanceType));
- payload.add(handleNull(autoscalingReason));
- payload.add(handleNull(scalingTime));
if (cartridge != null) {
payload.add(handleNull(String.valueOf(cartridge.isMultiTenant())));
} else {
@@ -133,14 +129,12 @@ public class BAMUsageDataPublisher {
try {
if (log.isDebugEnabled()) {
- log.debug(String.format("Publishing BAM event: [stream] %s [version] %s", streamDefinition.getName(),
- streamDefinition.getVersion()));
+ log.debug(String.format("Publishing BAM event: [stream] %s [version] %s", streamDefinition.getName(), streamDefinition.getVersion()));
}
dataPublisher.publish(streamDefinition.getName(), streamDefinition.getVersion(), event);
} catch (AgentException e) {
if (log.isErrorEnabled()) {
- log.error(String.format("Could not publish BAM event: [stream] %s [version] %s",
- streamDefinition.getName(), streamDefinition.getVersion()), e);
+ log.error(String.format("Could not publish BAM event: [stream] %s [version] %s", streamDefinition.getName(), streamDefinition.getVersion()), e);
}
}
}
@@ -150,23 +144,19 @@ public class BAMUsageDataPublisher {
}
private static StreamDefinition initializeStream() throws Exception {
- streamDefinition = new StreamDefinition(CloudControllerConstants.CLOUD_CONTROLLER_EVENT_STREAM,
+ streamDefinition = new StreamDefinition(
+ CloudControllerConstants.CLOUD_CONTROLLER_EVENT_STREAM,
cloudControllerEventStreamVersion);
streamDefinition.setNickName("cloud.controller");
streamDefinition.setDescription("Instances booted up by the Cloud Controller");
// Payload definition
List<Attribute> payloadData = new ArrayList<Attribute>();
- payloadData.add(new Attribute(CloudControllerConstants.TIME_STAMP, AttributeType.LONG));
payloadData.add(new Attribute(CloudControllerConstants.MEMBER_ID_COL, AttributeType.STRING));
payloadData.add(new Attribute(CloudControllerConstants.CARTRIDGE_TYPE_COL, AttributeType.STRING));
payloadData.add(new Attribute(CloudControllerConstants.CLUSTER_ID_COL, AttributeType.STRING));
- payloadData.add(new Attribute(CloudControllerConstants.CLUSTER_INSTANCE_ID_COL, AttributeType.STRING));
payloadData.add(new Attribute(CloudControllerConstants.LB_CLUSTER_ID_COL, AttributeType.STRING));
payloadData.add(new Attribute(CloudControllerConstants.PARTITION_ID_COL, AttributeType.STRING));
payloadData.add(new Attribute(CloudControllerConstants.NETWORK_ID_COL, AttributeType.STRING));
- payloadData.add(new Attribute(CloudControllerConstants.INSTANCE_TYPE, AttributeType.STRING));
- payloadData.add(new Attribute(CloudControllerConstants.SCALING_REASON, AttributeType.STRING));
- payloadData.add(new Attribute(CloudControllerConstants.SCALING_TIME, AttributeType.LONG));
payloadData.add(new Attribute(CloudControllerConstants.IS_MULTI_TENANT_COL, AttributeType.STRING));
payloadData.add(new Attribute(CloudControllerConstants.IAAS_COL, AttributeType.STRING));
payloadData.add(new Attribute(CloudControllerConstants.STATUS_COL, AttributeType.STRING));
@@ -186,6 +176,7 @@ public class BAMUsageDataPublisher {
return streamDefinition;
}
+
private static void createDataPublisher() {
//creating the agent
@@ -199,6 +190,7 @@ public class BAMUsageDataPublisher {
System.setProperty("javax.net.ssl.trustStore", trustStorePath);
System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);
+
try {
dataPublisher = new AsyncDataPublisher("tcp://" + bamServerUrl + "", adminUsername, adminPassword);
CloudControllerContext.getInstance().setDataPublisher(dataPublisher);
@@ -218,11 +210,4 @@ public class BAMUsageDataPublisher {
}
return val;
}
-
- private static Long handleNull(Long val) {
- if (val == null) {
- return -1L;
- }
- return val;
- }
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/2ff059db/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 41dd8f0..5e6115f 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
@@ -93,7 +93,8 @@ public final class CloudControllerConstants {
public static final String USER_NAME_ELEMENT = "userName";
public static final String PASSWORD_ELEMENT = "password";
public static final String CLOUD_CONTROLLER_EVENT_STREAM = "org.apache.stratos.cloud.controller";
- public static final String CLOUD_CONTROLLER_COL_FAMILY = CLOUD_CONTROLLER_EVENT_STREAM.replaceAll("[/.]", "_");
+ public static final String CLOUD_CONTROLLER_COL_FAMILY = CLOUD_CONTROLLER_EVENT_STREAM
+ .replaceAll("[/.]", "_");
/**
* column names
@@ -102,7 +103,6 @@ public final class CloudControllerConstants {
public static final String MEMBER_ID_COL = "memberId";
public static final String CARTRIDGE_TYPE_COL = "cartridgeType";
public static final String CLUSTER_ID_COL = "clusterId";
- public static final String CLUSTER_INSTANCE_ID_COL = "clusterInstanceId";
public static final String PARTITION_ID_COL = "partitionId";
public static final String NETWORK_ID_COL = "networkId";
public static final String ALIAS_COL = "alias";
@@ -122,9 +122,6 @@ public final class CloudControllerConstants {
public static final String PRIV_IP_COL = "privateIPAddresses";
public static final String PUB_IP_COL = "publicIPAddresses";
public static final String ALLOCATE_IP_COL = "allocateIPAddresses";
- public static final String TIME_STAMP = "timeStamp";
- public static final String SCALING_REASON = "scalingReason";
- public static final String SCALING_TIME = "scalingTime";
/**
* Properties
@@ -150,44 +147,66 @@ public final class CloudControllerConstants {
/**
* XPath expressions
*/
- public static final String IAAS_PROVIDER_XPATH =
- "/" + CLOUD_CONTROLLER_ELEMENT + "/" + IAAS_PROVIDERS_ELEMENT + "/" + IAAS_PROVIDER_ELEMENT;
- public static final String PARTITION_XPATH =
- "/" + CLOUD_CONTROLLER_ELEMENT + "/" + PARTITIONS_ELEMENT + "/" + PARTITION_ELEMENT;
- 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;
- public static final String HOST_XPATH =
- "/" + CLOUD_CONTROLLER_ELEMENT + "/" + IAAS_PROVIDERS_ELEMENT + "/" + IAAS_PROVIDER_ELEMENT + "/" +
- REGION_ELEMENT + "/" + ZONE_ELEMENT + "/" + HOST_ELEMENT;
+ public static final String IAAS_PROVIDER_XPATH = "/"
+ + CLOUD_CONTROLLER_ELEMENT + "/" + IAAS_PROVIDERS_ELEMENT + "/"
+ + IAAS_PROVIDER_ELEMENT;
+ public static final String PARTITION_XPATH = "/" + CLOUD_CONTROLLER_ELEMENT
+ + "/" + PARTITIONS_ELEMENT + "/" + PARTITION_ELEMENT;
+ 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;
+ public static final String HOST_XPATH = "/" + CLOUD_CONTROLLER_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;
- public static final String SCALE_UP_ORDER_ELEMENT_XPATH = "/" + SCALE_UP_ORDER_ELEMENT;
- public static final String SCALE_DOWN_ORDER_ELEMENT_XPATH = "/" + SCALE_DOWN_ORDER_ELEMENT;
+ public static final String SCALE_UP_ORDER_ELEMENT_XPATH = "/"
+ + SCALE_UP_ORDER_ELEMENT;
+ public static final String SCALE_DOWN_ORDER_ELEMENT_XPATH = "/"
+ + SCALE_DOWN_ORDER_ELEMENT;
public static final String PROVIDER_ELEMENT_XPATH = "/" + PROPERTY_ELEMENT;
public static final String IDENTITY_ELEMENT_XPATH = "/" + IDENTITY_ELEMENT;
- public static final String CREDENTIAL_ELEMENT_XPATH = "/" + CREDENTIAL_ELEMENT;
- public static final String SERVICES_ELEMENT_XPATH = "/" + SERVICES_ELEMENT + "/" + SERVICE_ELEMENT;
+ public static final String CREDENTIAL_ELEMENT_XPATH = "/"
+ + CREDENTIAL_ELEMENT;
+ public static final String SERVICES_ELEMENT_XPATH = "/" + SERVICES_ELEMENT
+ + "/" + SERVICE_ELEMENT;
public static final String SERVICE_ELEMENT_XPATH = "/" + SERVICE_ELEMENT;
- public static final String CARTRIDGE_ELEMENT_XPATH = "/" + CARTRIDGE_ELEMENT;
+ public static final String CARTRIDGE_ELEMENT_XPATH = "/"
+ + CARTRIDGE_ELEMENT;
public static final String PAYLOAD_ELEMENT_XPATH = "/" + PAYLOAD_ELEMENT;
public static final String HOST_ELEMENT_XPATH = "/" + HOST_ELEMENT;
- public static final String CARTRIDGES_ELEMENT_XPATH = "/" + CARTRIDGES_ELEMENT + "/" + CARTRIDGE_ELEMENT;
- public static final String IAAS_PROVIDER_ELEMENT_XPATH = "/" + IAAS_PROVIDER_ELEMENT;
- public static final String DEPLOYMENT_ELEMENT_XPATH = "/" + DEPLOYMENT_ELEMENT;
- public static final String PORT_MAPPING_ELEMENT_XPATH = "/" + PORT_MAPPING_ELEMENT;
- public static final String APP_TYPES_ELEMENT_XPATH = "/" + APP_TYPES_ELEMENT;
+ public static final String CARTRIDGES_ELEMENT_XPATH = "/"
+ + CARTRIDGES_ELEMENT + "/" + CARTRIDGE_ELEMENT;
+ public static final String IAAS_PROVIDER_ELEMENT_XPATH = "/"
+ + IAAS_PROVIDER_ELEMENT;
+ public static final String DEPLOYMENT_ELEMENT_XPATH = "/"
+ + DEPLOYMENT_ELEMENT;
+ public static final String PORT_MAPPING_ELEMENT_XPATH = "/"
+ + PORT_MAPPING_ELEMENT;
+ public static final String APP_TYPES_ELEMENT_XPATH = "/"
+ + APP_TYPES_ELEMENT;
- public static final String DATA_PUBLISHER_XPATH = "/" + CLOUD_CONTROLLER_ELEMENT + "/" + DATA_PUBLISHER_ELEMENT;
- public static final String TOPOLOGY_SYNC_XPATH = "/" + CLOUD_CONTROLLER_ELEMENT + "/" + TOPOLOGY_SYNC_ELEMENT;
- public static final String DATA_PUBLISHER_CRON_XPATH = "/" + CLOUD_CONTROLLER_ELEMENT + "/" + CRON_ELEMENT;
- public static final String BAM_SERVER_ADMIN_USERNAME_XPATH =
- "/" + CLOUD_CONTROLLER_ELEMENT + "/" + BAM_SERVER_ADMIN_USERNAME_ELEMENT;
- public static final String BAM_SERVER_ADMIN_PASSWORD_XPATH =
- "/" + CLOUD_CONTROLLER_ELEMENT + "/" + BAM_SERVER_ADMIN_PASSWORD_ELEMENT;
+ public static final String DATA_PUBLISHER_XPATH = "/"
+ + CLOUD_CONTROLLER_ELEMENT + "/" + DATA_PUBLISHER_ELEMENT;
+ public static final String TOPOLOGY_SYNC_XPATH = "/"
+ + CLOUD_CONTROLLER_ELEMENT + "/" + TOPOLOGY_SYNC_ELEMENT;
+ public static final String DATA_PUBLISHER_CRON_XPATH = "/"
+ + CLOUD_CONTROLLER_ELEMENT + "/" + CRON_ELEMENT;
+ public static final String BAM_SERVER_ADMIN_USERNAME_XPATH = "/"
+ + CLOUD_CONTROLLER_ELEMENT + "/"
+ + BAM_SERVER_ADMIN_USERNAME_ELEMENT;
+ public static final String BAM_SERVER_ADMIN_PASSWORD_XPATH = "/"
+ + CLOUD_CONTROLLER_ELEMENT + "/"
+ + BAM_SERVER_ADMIN_PASSWORD_ELEMENT;
+ // public static final String CASSANDRA_HOST_ADDRESS_XPATH =
+ // "/"+CLOUD_CONTROLLER_ELEMENT+
+ // "/"+CASSANDRA_HOST_ADDRESS;
+ // public static final String CASSANDRA_HOST_PORT_XPATH =
+ // "/"+CLOUD_CONTROLLER_ELEMENT+
+ // "/"+CASSANDRA_HOST_PORT;
/**
* Secret Manager related aliases.
@@ -220,19 +239,20 @@ public final class CloudControllerConstants {
/**
* Directories
*/
- public static final String SERVICES_DIR =
- CarbonUtils.getCarbonRepository() + File.separator + "services" + File.separator;
+ public static final String SERVICES_DIR = CarbonUtils.getCarbonRepository()
+ + File.separator + "services" + File.separator;
/**
* Topology sync related constants
*/
- public static final String TOPOLOGY_FILE_PATH =
- CarbonUtils.getCarbonConfigDirPath() + File.separator + "service-topology.conf";
+ public static final String TOPOLOGY_FILE_PATH = CarbonUtils
+ .getCarbonConfigDirPath()
+ + File.separator
+ + "service-topology.conf";
public static final String TOPOLOGY_SYNC_CRON = "1 * * * * ? *";
public static final String TOPOLOGY_SYNC_TASK_NAME = "TOPOLOGY_SYNC_TASK";
public static final String TOPOLOGY_SYNC_TASK_TYPE = "TOPOLOGY_SYNC_TASK_TYPE";
- public static final String AMQP_CONNECTION_URL =
- "amqp://admin:admin@clientID/carbon?brokerlist='tcp://localhost:5672'";
+ public static final String AMQP_CONNECTION_URL = "amqp://admin:admin@clientID/carbon?brokerlist='tcp://localhost:5672'";
public static final String AMQP_INITIAL_CONTEXT_FACTORY = "org.wso2.andes.jndi.PropertiesFileInitialContextFactory";
public static final String AMQP_TOPIC_CONNECTION_FACTORY = "qpidConnectionfactory";
http://git-wip-us.apache.org/repos/asf/stratos/blob/2ff059db/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/constants/StratosConstants.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/constants/StratosConstants.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/constants/StratosConstants.java
index 669a96a..1275f5c 100644
--- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/constants/StratosConstants.java
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/constants/StratosConstants.java
@@ -18,6 +18,7 @@
*/
package org.apache.stratos.common.constants;
+
public class StratosConstants {
public static final String CLOUD_SERVICE_IS_ACTIVE_PROP_KEY = "active";
@@ -25,7 +26,8 @@ public class StratosConstants {
public static final String CLOUD_SERVICE_INFO_STORE_PATH =
"/repository/components/org.apache.stratos/cloud-manager/cloud-services";
- public static final String TENANT_USER_VALIDATION_STORE_PATH = "/repository/components/org.wso2.carbon.validations";
+ public static final String TENANT_USER_VALIDATION_STORE_PATH =
+ "/repository/components/org.wso2.carbon.validations";
public static final String ADMIN_EMAIL_VERIFICATION_FLAG_PATH =
"/repository/components/org.wso2.carbon.email-confirmation-flag";
public static final String TENANT_DOMAIN_VERIFICATION_FLAG_PATH =
@@ -37,18 +39,23 @@ public class StratosConstants {
public static final String TENANT_CREATION_THEME_PAGE_TOKEN =
"/repository/components/org.wso2.carbon.theme-page-token";
- public static final String TENANT_PACKAGE_INFO_PATH = "/repository/components/org.wso2.carbon.package-info";
+ public static final String TENANT_PACKAGE_INFO_PATH =
+ "/repository/components/org.wso2.carbon.package-info";
- public static final String ALL_THEMES_PATH = "/repository/components/org.wso2.carbon.all-themes";
+ public static final String ALL_THEMES_PATH =
+ "/repository/components/org.wso2.carbon.all-themes";
- public static final String THROTTLING_RULES_PATH = "/repository/components/org.wso2.carbon.throttling-rules";
+ public static final String THROTTLING_RULES_PATH =
+ "/repository/components/org.wso2.carbon.throttling-rules";
- public static final String ORIGINATED_SERVICE_PATH = "/repository/components/org.wso2.carbon.originated-service";
+ public static final String ORIGINATED_SERVICE_PATH =
+ "/repository/components/org.wso2.carbon.originated-service";
public static final String PATH_SEPARATOR = "/";
public static final String CLOUD_SERVICE_ICONS_STORE_PATH =
- "/repository/components/org.wso2.carbon.cloud-manager/" + "cloud-services-icons";
+ "/repository/components/org.wso2.carbon.cloud-manager/" +
+ "cloud-services-icons";
public static final String VALIDATION_KEY_RESOURCE_NAME = "validation-key";
public static final String INCOMING_PATH_DIR = "incoming";
@@ -84,8 +91,7 @@ public class StratosConstants {
// metering constants
public static final String THROTTLING_ALL_ACTION = "all_actions";
- public static final String THROTTLING_IN_DATA_ACTION = "in_data_action";
- //this covers registry capacity + registry bandwidth
+ public static final String THROTTLING_IN_DATA_ACTION = "in_data_action"; //this covers registry capacity + registry bandwidth
public static final String THROTTLING_OUT_DATA_ACTION = "out_data_action"; //this covers registry bandwidth
public static final String THROTTLING_ADD_USER_ACTION = "add_user_action";
public static final String THROTTLING_SERVICE_IN_BANDWIDTH_ACTION = "service_in_bandwith_action";
@@ -123,8 +129,10 @@ public class StratosConstants {
" for privacy policy of WSO2 Stratos.";
// Web location of Terms of Usage and privacy policy
- public static final String STRATOS_TERMS_OF_USAGE = "http://wso2.com/cloud/services/terms-of-use/";
- public static final String STRATOS_PRIVACY_POLICY = "http://wso2.com/cloud/services/privacy-policy/";
+ public static final String STRATOS_TERMS_OF_USAGE =
+ "http://wso2.com/cloud/services/terms-of-use/";
+ public static final String STRATOS_PRIVACY_POLICY =
+ "http://wso2.com/cloud/services/privacy-policy/";
public static final String MULTITENANCY_FREE_PLAN = "Demo";
public static final String MULTITENANCY_SMALL_PLAN = "SMB";
public static final String MULTITENANCY_MEDIUM_PLAN = "Professional";
@@ -150,8 +158,6 @@ public class StratosConstants {
public static final String MAX_CHECK_DROOL_FILE = "maxcheck.drl";
public static final String OBSOLETE_CHECK_DROOL_FILE = "obsoletecheck.drl";
public static final String MIN_COUNT = "MIN_COUNT";
- public static final String SCALING_REASON = "SCALING_REASON";
- public static final String SCALING_TIME = "SCALING_TIME";
// Policy and definition related constants
public static final int PUBLIC_DEFINITION = 0;
@@ -159,8 +165,7 @@ public class StratosConstants {
// member expiry timeout constants
public static final String PENDING_MEMBER_EXPIRY_TIMEOUT = "autoscaler.member.pendingMemberExpiryTimeout";
public static final String OBSOLETED_MEMBER_EXPIRY_TIMEOUT = "autoscaler.member.obsoletedMemberExpiryTimeout";
- public static final String PENDING_TERMINATION_MEMBER_EXPIRY_TIMEOUT =
- "autoscaler.member.pendingTerminationMemberExpiryTimeout";
+ public static final String PENDING_TERMINATION_MEMBER_EXPIRY_TIMEOUT = "autoscaler.member.pendingTerminationMemberExpiryTimeout";
public static final String FILTER_VALUE_SEPARATOR = ",";
public static final String TOPOLOGY_APPLICATION_FILTER = "stratos.topology.application.filter";
http://git-wip-us.apache.org/repos/asf/stratos/blob/2ff059db/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py
index e44059f..ed64f6e 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py
@@ -508,6 +508,7 @@ class EventHandler:
try:
if self.__extension_executor is not None:
self.__log.debug("Executing extension for event [%s]" % event)
+ PluginExecutor(self.__extension_executor, extension_values).start()
extension_thread = PluginExecutor(self.__extension_executor, extension_values)
extension_thread.start()
http://git-wip-us.apache.org/repos/asf/stratos/blob/2ff059db/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/healthstatspublisher/healthstats.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/healthstatspublisher/healthstats.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/healthstatspublisher/healthstats.py
index 855f732..9753c3e 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/healthstatspublisher/healthstats.py
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/healthstatspublisher/healthstats.py
@@ -17,7 +17,7 @@
from threading import Thread
import multiprocessing
-import time
+
import psutil
from abstracthealthstatisticspublisher import *
@@ -124,8 +124,6 @@ class HealthStatisticsPublisher:
stream_def.description = HealthStatisticsPublisherManager.STREAM_DESCRIPTION
# stream_def.add_payloaddata_attribute()
-
- #stream_def.add_payloaddata_attribute("time_stamp", StreamDefinition.LONG)
stream_def.add_payloaddata_attribute("cluster_id", StreamDefinition.STRING)
stream_def.add_payloaddata_attribute("cluster_instance_id", StreamDefinition.STRING)
stream_def.add_payloaddata_attribute("network_partition_id", StreamDefinition.STRING)
@@ -143,7 +141,6 @@ class HealthStatisticsPublisher:
"""
event = ThriftEvent()
- #event.payloadData.append(int(round(time.time() * 1000)))
event.payloadData.append(self.cartridge_agent_config.cluster_id)
event.payloadData.append(self.cartridge_agent_config.cluster_instance_id)
event.payloadData.append(self.cartridge_agent_config.network_partition_id)
@@ -162,7 +159,6 @@ class HealthStatisticsPublisher:
"""
event = ThriftEvent()
- #event.payloadData.append(int(round(time.time() * 1000)))
event.payloadData.append(self.cartridge_agent_config.cluster_id)
event.payloadData.append(self.cartridge_agent_config.cluster_instance_id)
event.payloadData.append(self.cartridge_agent_config.network_partition_id)
http://git-wip-us.apache.org/repos/asf/stratos/blob/2ff059db/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
index a16a3e5..fa369f5 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
@@ -463,6 +463,7 @@ public class StratosApiV41 extends AbstractApi {
@Produces("application/json")
@Consumes("application/json")
@AuthorizationAction("/permission/admin/stratos/cartridgeGroups/manage")
+ @SuperTenantService(true)
public Response addCartridgeGroup(
CartridgeGroupBean cartridgeGroupBean) throws RestAPIException {
try {
@@ -579,6 +580,7 @@ public class StratosApiV41 extends AbstractApi {
@Produces("application/json")
@Consumes("application/json")
@AuthorizationAction("/permission/admin/stratos/cartridgeGroups/manage")
+ @SuperTenantService(true)
public Response removeServiceGroup(
@PathParam("name") String name) throws RestAPIException {
try {
@@ -1294,6 +1296,7 @@ public class StratosApiV41 extends AbstractApi {
@Produces("application/json")
@Consumes("application/json")
@AuthorizationAction("/permission/admin/stratos/applications/manage")
+ @SuperTenantService(true)
public Response removeApplication(
@PathParam("applicationId") String applicationId) throws RestAPIException {
ApplicationBean applicationDefinition = StratosApiV41Utils.getApplication(applicationId);