Repository: stratos
Updated Branches:
  refs/heads/stratos-4.1.x 0606f844f -> adab632d8


Moving label names to constants


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/adab632d
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/adab632d
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/adab632d

Branch: refs/heads/stratos-4.1.x
Commit: adab632d8d872b1dc02b078d001260f60c4f51d3
Parents: 0606f84
Author: Akila Perera <[email protected]>
Authored: Sun Sep 20 22:00:09 2015 +0530
Committer: Akila Perera <[email protected]>
Committed: Sun Sep 20 22:00:09 2015 +0530

----------------------------------------------------------------------
 .../iaases/kubernetes/KubernetesIaas.java       | 45 +++++++++------
 .../publisher/BAMUsageDataPublisher.java        | 42 +++++++-------
 .../util/CloudControllerConstants.java          | 61 +++++++++++---------
 .../kubernetes/client/KubernetesApiClient.java  |  2 +
 .../KubernetesAPIClientInterface.java           | 20 ++++---
 5 files changed, 96 insertions(+), 74 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/adab632d/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaas.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaas.java
 
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaas.java
index d4a0e6c..d231932 100644
--- 
a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaas.java
+++ 
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaas.java
@@ -35,6 +35,7 @@ import 
org.apache.stratos.cloud.controller.domain.kubernetes.PortRange;
 import org.apache.stratos.cloud.controller.exception.*;
 import org.apache.stratos.cloud.controller.iaases.Iaas;
 import org.apache.stratos.cloud.controller.iaases.PartitionValidator;
+import org.apache.stratos.cloud.controller.util.CloudControllerConstants;
 import org.apache.stratos.cloud.controller.util.CloudControllerUtil;
 import org.apache.stratos.common.Property;
 import org.apache.stratos.common.constants.StratosConstants;
@@ -433,14 +434,15 @@ public class KubernetesIaas extends Iaas {
                 memberContext.getMemberId(), cpu, memory));
 
         Map<String, String> podLabels = new HashMap<>();
-        podLabels.put("md5Hex-memberId", 
DigestUtils.md5Hex(memberContext.getMemberId()));
+        podLabels
+                .put(CloudControllerConstants.MD5_HEX_MEMBER_ID_LABEL, 
DigestUtils.md5Hex(memberContext.getMemberId()));
 
         Map<String, String> podAnnotations = new HashMap<>();
-        podAnnotations.put("memberId", memberContext.getMemberId());
-        podAnnotations.put("cartridgeType", memberContext.getCartridgeType());
-        podAnnotations.put("applicationId", memberContext.getApplicationId());
-        podAnnotations.put("clusterId", memberContext.getClusterId());
-        podAnnotations.put("clusterInstanceId", 
memberContext.getClusterInstanceId());
+        podAnnotations.put(CloudControllerConstants.MEMBER_ID_LABEL, 
memberContext.getMemberId());
+        podAnnotations.put(CloudControllerConstants.CARTRIDGE_TYPE_LABEL, 
memberContext.getCartridgeType());
+        podAnnotations.put(CloudControllerConstants.APPLICATION_ID_LABEL, 
memberContext.getApplicationId());
+        podAnnotations.put(CloudControllerConstants.CLUSTER_ID_LABEL, 
memberContext.getClusterId());
+        podAnnotations.put(CloudControllerConstants.CLUSTER_INSTANCE_ID_LABEL, 
memberContext.getClusterInstanceId());
 
         kubernetesApi.createPod(podId, podName, podLabels, podAnnotations, 
dockerImage, cpu, memory, ports,
                 environmentVariables);
@@ -547,19 +549,26 @@ public class KubernetesIaas extends Iaas {
                 String containerPortName = 
KubernetesIaasUtil.preparePortNameFromPortMapping(clusterPortMapping);
 
                 Map<String, String> serviceLabels = new HashMap<>();
-                serviceLabels.put("applicationId", 
DigestUtils.md5Hex(clusterContext.getApplicationId()));
-                serviceLabels.put("clusterId", 
DigestUtils.md5Hex(clusterContext.getClusterId()));
+                
serviceLabels.put(CloudControllerConstants.MD5_HEX_APPLICATION_ID_LABEL,
+                        DigestUtils.md5Hex(clusterContext.getApplicationId()));
+                
serviceLabels.put(CloudControllerConstants.MD5_HEX_CLUSTER_ID_LABEL,
+                        DigestUtils.md5Hex(clusterContext.getClusterId()));
 
                 Map<String, String> serviceAnnotations = new HashMap<>();
-                serviceAnnotations.put("applicationId", 
clusterContext.getApplicationId());
-                serviceAnnotations.put("clusterId", 
clusterContext.getClusterId());
-                serviceAnnotations.put("name", clusterPortMapping.getName());
-                serviceAnnotations.put("protocol", 
clusterPortMapping.getProtocol());
-                serviceAnnotations.put("serviceType", 
clusterPortMapping.getKubernetesServiceType());
-                serviceAnnotations.put("portType", 
clusterPortMapping.getKubernetesPortType());
-                serviceAnnotations.put("servicePort", 
String.valueOf(clusterPortMapping.getKubernetesServicePort()));
-                serviceAnnotations.put("port", 
String.valueOf(clusterPortMapping.getPort()));
-                serviceAnnotations.put("proxyPort", 
String.valueOf(clusterPortMapping.getProxyPort()));
+                serviceAnnotations
+                        .put(CloudControllerConstants.APPLICATION_ID_LABEL, 
clusterContext.getApplicationId());
+                
serviceAnnotations.put(CloudControllerConstants.CLUSTER_ID_LABEL, 
clusterContext.getClusterId());
+                
serviceAnnotations.put(CloudControllerConstants.PROTOCOL_LABEL, 
clusterPortMapping.getProtocol());
+                
serviceAnnotations.put(CloudControllerConstants.SERVICE_TYPE_LABEL,
+                        clusterPortMapping.getKubernetesServiceType());
+                serviceAnnotations
+                        .put(CloudControllerConstants.PORT_TYPE_LABEL, 
clusterPortMapping.getKubernetesPortType());
+                
serviceAnnotations.put(CloudControllerConstants.SERVICE_PORT_LABEL, 
String.valueOf(clusterPortMapping
+                        .getKubernetesServicePort()));
+                serviceAnnotations
+                        .put(CloudControllerConstants.PORT_LABEL, 
String.valueOf(clusterPortMapping.getPort()));
+                
serviceAnnotations.put(CloudControllerConstants.PROXY_PORT_LABEL,
+                        String.valueOf(clusterPortMapping.getProxyPort()));
 
                 kubernetesApi.createService(serviceId, serviceName, 
serviceLabels, serviceAnnotations, servicePort,
                         serviceType, containerPortName, containerPort, 
sessionAffinity);
@@ -1028,7 +1037,7 @@ public class KubernetesIaas extends Iaas {
                 }
                 catch (KubernetesClientException e) {
                     log.error(String.format("Could not delete kubernetes 
service: [application-id] %s " +
-                            "[service-id] %s", 
clusterContext.getApplicationId(), serviceId));
+                            "[service-id] %s", 
clusterContext.getApplicationId(), serviceId), e);
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/stratos/blob/adab632d/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 d5aabbd..56c5f87 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
@@ -151,27 +151,27 @@ public class BAMUsageDataPublisher {
         streamDefinition.setDescription("Instances booted up by the Cloud 
Controller");
         // Payload definition
         List<Attribute> payloadData = new ArrayList<Attribute>();
-        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.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.IS_MULTI_TENANT_COL, AttributeType.STRING));
-        payloadData.add(new Attribute(CloudControllerConstants.IAAS_COL, 
AttributeType.STRING));
-        payloadData.add(new Attribute(CloudControllerConstants.STATUS_COL, 
AttributeType.STRING));
-        payloadData.add(new Attribute(CloudControllerConstants.HOST_NAME_COL, 
AttributeType.STRING));
-        payloadData.add(new Attribute(CloudControllerConstants.HYPERVISOR_COL, 
AttributeType.STRING));
-        payloadData.add(new Attribute(CloudControllerConstants.RAM_COL, 
AttributeType.STRING));
-        payloadData.add(new Attribute(CloudControllerConstants.IMAGE_ID_COL, 
AttributeType.STRING));
-        payloadData.add(new Attribute(CloudControllerConstants.LOGIN_PORT_COL, 
AttributeType.INT));
-        payloadData.add(new Attribute(CloudControllerConstants.OS_NAME_COL, 
AttributeType.STRING));
-        payloadData.add(new Attribute(CloudControllerConstants.OS_VERSION_COL, 
AttributeType.STRING));
-        payloadData.add(new Attribute(CloudControllerConstants.OS_ARCH_COL, 
AttributeType.STRING));
-        payloadData.add(new Attribute(CloudControllerConstants.OS_BIT_COL, 
AttributeType.STRING));
-        payloadData.add(new Attribute(CloudControllerConstants.PRIV_IP_COL, 
AttributeType.STRING));
-        payloadData.add(new Attribute(CloudControllerConstants.PUB_IP_COL, 
AttributeType.STRING));
-        payloadData.add(new 
Attribute(CloudControllerConstants.ALLOCATE_IP_COL, AttributeType.STRING));
+        payloadData.add(new 
Attribute(CloudControllerConstants.MEMBER_ID_LABEL, AttributeType.STRING));
+        payloadData.add(new 
Attribute(CloudControllerConstants.CARTRIDGE_TYPE_LABEL, AttributeType.STRING));
+        payloadData.add(new 
Attribute(CloudControllerConstants.CLUSTER_ID_LABEL, AttributeType.STRING));
+        payloadData.add(new 
Attribute(CloudControllerConstants.LB_CLUSTER_ID_LABEL, AttributeType.STRING));
+        payloadData.add(new 
Attribute(CloudControllerConstants.PARTITION_ID_LABEL, AttributeType.STRING));
+        payloadData.add(new 
Attribute(CloudControllerConstants.NETWORK_ID_LABEL, AttributeType.STRING));
+        payloadData.add(new 
Attribute(CloudControllerConstants.IS_MULTI_TENANT_LABEL, 
AttributeType.STRING));
+        payloadData.add(new Attribute(CloudControllerConstants.IAAS_LABEL, 
AttributeType.STRING));
+        payloadData.add(new Attribute(CloudControllerConstants.STATUS_LABEL, 
AttributeType.STRING));
+        payloadData.add(new 
Attribute(CloudControllerConstants.HOST_NAME_LABEL, AttributeType.STRING));
+        payloadData.add(new 
Attribute(CloudControllerConstants.HYPERVISOR_LABEL, AttributeType.STRING));
+        payloadData.add(new Attribute(CloudControllerConstants.RAM_LABEL, 
AttributeType.STRING));
+        payloadData.add(new Attribute(CloudControllerConstants.IMAGE_ID_LABEL, 
AttributeType.STRING));
+        payloadData.add(new 
Attribute(CloudControllerConstants.LOGIN_PORT_LABEL, AttributeType.INT));
+        payloadData.add(new Attribute(CloudControllerConstants.OS_NAME_LABEL, 
AttributeType.STRING));
+        payloadData.add(new 
Attribute(CloudControllerConstants.OS_VERSION_LABEL, AttributeType.STRING));
+        payloadData.add(new Attribute(CloudControllerConstants.OS_ARCH_LABEL, 
AttributeType.STRING));
+        payloadData.add(new Attribute(CloudControllerConstants.OS_BIT_LABEL, 
AttributeType.STRING));
+        payloadData.add(new Attribute(CloudControllerConstants.PRIV_IP_LABEL, 
AttributeType.STRING));
+        payloadData.add(new Attribute(CloudControllerConstants.PUB_IP_LABEL, 
AttributeType.STRING));
+        payloadData.add(new 
Attribute(CloudControllerConstants.ALLOCATE_IP_LABEL, AttributeType.STRING));
         streamDefinition.setPayloadData(payloadData);
         return streamDefinition;
     }

http://git-wip-us.apache.org/repos/asf/stratos/blob/adab632d/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 5e6115f..483283b 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,35 +93,44 @@ 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("[/.]", "_");
 
     /**
-     * column names
+     * domain attribute names
      */
     public static final String PAYLOAD_PREFIX = "payload_";
-    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 PARTITION_ID_COL = "partitionId";
-    public static final String NETWORK_ID_COL = "networkId";
-    public static final String ALIAS_COL = "alias";
-    public static final String TENANT_RANGE_COL = "tenantRange";
-    public static final String IS_MULTI_TENANT_COL = "isMultiTenant";
-    public static final String IAAS_COL = "iaas";
-    public static final String STATUS_COL = "status";
-    public static final String HOST_NAME_COL = "hostName";
-    public static final String HYPERVISOR_COL = "hypervisor";
-    public static final String RAM_COL = "ram";
-    public static final String IMAGE_ID_COL = "imageId";
-    public static final String LOGIN_PORT_COL = "loginPort";
-    public static final String OS_NAME_COL = "osName";
-    public static final String OS_VERSION_COL = "osVersion";
-    public static final String OS_ARCH_COL = "osArch";
-    public static final String OS_BIT_COL = "is64bitOS";
-    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 APPLICATION_ID_LABEL = "applicationId";
+    public static final String MEMBER_ID_LABEL = "memberId";
+    public static final String MD5_HEX_APPLICATION_ID_LABEL = 
"md5Hex-applicationId";
+    public static final String MD5_HEX_MEMBER_ID_LABEL = "md5Hex-memberId";
+    public static final String CARTRIDGE_TYPE_LABEL = "cartridgeType";
+    public static final String SERVICE_TYPE_LABEL = "serviceType";
+    public static final String MD5_HEX_CLUSTER_ID_LABEL = "md5Hex-clusterId";
+    public static final String CLUSTER_ID_LABEL = "clusterId";
+    public static final String CLUSTER_INSTANCE_ID_LABEL = "clusterInstanceId";
+    public static final String PARTITION_ID_LABEL = "partitionId";
+    public static final String NETWORK_ID_LABEL = "networkId";
+    public static final String ALIAS_LABEL = "alias";
+    public static final String TENANT_RANGE_LABEL = "tenantRange";
+    public static final String IS_MULTI_TENANT_LABEL = "isMultiTenant";
+    public static final String IAAS_LABEL = "iaas";
+    public static final String STATUS_LABEL = "status";
+    public static final String HOST_NAME_LABEL = "hostName";
+    public static final String HYPERVISOR_LABEL = "hypervisor";
+    public static final String RAM_LABEL = "ram";
+    public static final String IMAGE_ID_LABEL = "imageId";
+    public static final String LOGIN_PORT_LABEL = "loginPort";
+    public static final String OS_NAME_LABEL = "osName";
+    public static final String OS_VERSION_LABEL = "osVersion";
+    public static final String OS_ARCH_LABEL = "osArch";
+    public static final String OS_BIT_LABEL = "is64bitOS";
+    public static final String PRIV_IP_LABEL = "privateIPAddresses";
+    public static final String PUB_IP_LABEL = "publicIPAddresses";
+    public static final String ALLOCATE_IP_LABEL = "allocateIPAddresses";
+    public static final String PORT_LABEL = "port";
+    public static final String PROTOCOL_LABEL = "protocol";
+    public static final String SERVICE_PORT_LABEL = "servicePort";
+    public static final String PROXY_PORT_LABEL = "proxyPort";
+    public static final String PORT_TYPE_LABEL = "portType";
 
     /**
      * Properties
@@ -273,7 +282,7 @@ public final class CloudControllerConstants {
     public static final String BLOCK_UNTIL_RUNNING = "blockUntilRunning";
     public static final String INSTANCE_TYPE = "instanceType";
     public static final String ASSOCIATE_PUBLIC_IP_ADDRESS = 
"associatePublicIpAddress";
-    public static final String LB_CLUSTER_ID_COL = "lbclusterId";
+    public static final String LB_CLUSTER_ID_LABEL = "lbclusterId";
     public static final String NETWORK_INTERFACES = "networkInterfaces";
     public static final String NETWORK_FIXED_IP = "fixedIp";
     public static final String NETWORK_PORT = "portUuid";

http://git-wip-us.apache.org/repos/asf/stratos/blob/adab632d/components/org.apache.stratos.kubernetes.client/src/main/java/org/apache/stratos/kubernetes/client/KubernetesApiClient.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.kubernetes.client/src/main/java/org/apache/stratos/kubernetes/client/KubernetesApiClient.java
 
b/components/org.apache.stratos.kubernetes.client/src/main/java/org/apache/stratos/kubernetes/client/KubernetesApiClient.java
index fe94d39..978273c 100644
--- 
a/components/org.apache.stratos.kubernetes.client/src/main/java/org/apache/stratos/kubernetes/client/KubernetesApiClient.java
+++ 
b/components/org.apache.stratos.kubernetes.client/src/main/java/org/apache/stratos/kubernetes/client/KubernetesApiClient.java
@@ -48,6 +48,7 @@ public class KubernetesApiClient implements 
KubernetesAPIClientInterface {
      * @param podId                Identifier of the pod
      * @param podName              Pod name to be used by the pod label
      * @param podLabels            Map of labels to be applied to the pod
+     * @param annotations          Map of annotations to be applied to the pod
      * @param dockerImage          Docker image to be used by the pod
      * @param cpu                  Number of cpu cores
      * @param memory               Memory allocation in megabytes
@@ -157,6 +158,7 @@ public class KubernetesApiClient implements 
KubernetesAPIClientInterface {
      * @param serviceId         Service id
      * @param serviceName       Service name to be used by the label name
      * @param serviceLabels     Service labels map
+     * @param annotations       Map of annotations to be applied to the service
      * @param servicePort       Port to be exposed by the kubernetes node
      * @param containerPortName Container port name defined in the port label
      * @param containerPort     Container port

http://git-wip-us.apache.org/repos/asf/stratos/blob/adab632d/components/org.apache.stratos.kubernetes.client/src/main/java/org/apache/stratos/kubernetes/client/interfaces/KubernetesAPIClientInterface.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.kubernetes.client/src/main/java/org/apache/stratos/kubernetes/client/interfaces/KubernetesAPIClientInterface.java
 
b/components/org.apache.stratos.kubernetes.client/src/main/java/org/apache/stratos/kubernetes/client/interfaces/KubernetesAPIClientInterface.java
index f1d6566..9b42966 100644
--- 
a/components/org.apache.stratos.kubernetes.client/src/main/java/org/apache/stratos/kubernetes/client/interfaces/KubernetesAPIClientInterface.java
+++ 
b/components/org.apache.stratos.kubernetes.client/src/main/java/org/apache/stratos/kubernetes/client/interfaces/KubernetesAPIClientInterface.java
@@ -38,6 +38,7 @@ public interface KubernetesAPIClientInterface {
      * @param podId                id of the pod
      * @param podName              pod label
      * @param podLabels            Map of labels to be applied to the pod
+     * @param annotations          Map of annotations to be applied to the pod
      * @param dockerImage          docker image name
      * @param cpu                  number of cpu cores
      * @param memory               memory allocation in mega bytes
@@ -78,17 +79,18 @@ public interface KubernetesAPIClientInterface {
     /**
      * Create service.
      *
-     * @param serviceId
-     * @param serviceName
-     * @param podLabels
-     * @param servicePort
-     * @param serviceType
-     * @param containerPortName
-     * @param containerPort
-     * @param sessionAffinity
+     * @param serviceId         id of the service
+     * @param serviceName       service name
+     * @param serviceLabels     labels to be applied to the service
+     * @param annotations       Map of annotations to be applied to the service
+     * @param servicePort       port to be used in the node
+     * @param serviceType       port type to be used when creating the service
+     * @param containerPortName port name
+     * @param containerPort     port to be used in the container
+     * @param sessionAffinity   session affinity policy to be used when 
routing requests to this service
      * @throws KubernetesClientException
      */
-    public void createService(String serviceId, String serviceName, 
Map<String, String> podLabels, Map<String,
+    public void createService(String serviceId, String serviceName, 
Map<String, String> serviceLabels, Map<String,
             String> annotations, int servicePort, String serviceType, String 
containerPortName, int containerPort,
                               String sessionAffinity)
             throws KubernetesClientException;

Reply via email to