Package org.apache.stratos.cloud.controller.deployment.partition

Examples of org.apache.stratos.cloud.controller.deployment.partition.Partition


        @Override
        public void run() {


            String clusterId = memberContext.getClusterId();
            Partition partition = memberContext.getPartition();
            String publicIp = null;

            try{

                String autoAssignIpProp =
                                          iaasProvider.getProperty(CloudControllerConstants.AUTO_ASSIGN_IP_PROPERTY);
               
                String pre_defined_ip =
                        iaasProvider.getProperty(CloudControllerConstants.FLOATING_IP_PROPERTY);
                   
                  // reset ip
                  String ip = "";
                   
                    // default behavior is autoIpAssign=false
                    if (autoAssignIpProp == null ||
                        (autoAssignIpProp != null && autoAssignIpProp.equals("false"))) {
                     
                      // check if floating ip is well defined in cartridge definition
                      if (pre_defined_ip != null) {
                        if (isValidIpAddress(pre_defined_ip)) {
                          if(log.isDebugEnabled()) {
                            log.debug("CloudControllerServiceImpl:IpAllocator:pre_defined_ip: invoking associatePredefinedAddress" + pre_defined_ip);
                          }
                          Iaas iaas = iaasProvider.getIaas();
                          ip = iaas.associatePredefinedAddress(node, pre_defined_ip);
              
                          if (ip == null || "".equals(ip) || !pre_defined_ip.equals(ip)) {
                            // throw exception and stop instance creation
                               String msg = "Error occurred while allocating predefined floating ip address: " + pre_defined_ip +
                                      " / allocated ip:" + ip +
                                        " - terminating node:"  + memberContext.toString();
                                log.error(msg);
                            // terminate instance
                                terminate(iaasProvider,
                                  node.getId(), memberContext);
                                throw new CloudControllerException(msg);
                          }
                        } else {
                          String msg = "Invalid floating ip address configured: " + pre_defined_ip + 
                                 " - terminating node:"  + memberContext.toString();
                          log.error(msg);
                          // terminate instance
                          terminate(iaasProvider,
                            node.getId(), memberContext);
                          throw new CloudControllerException(msg);
                        }
                         
                        } else {
                          if(log.isDebugEnabled()) {
                            log.debug("CloudControllerServiceImpl:IpAllocator:no (valid) predefined floating ip configured, " + pre_defined_ip
                              + ", selecting available one from pool");
                          }
                          Iaas iaas = iaasProvider.getIaas();
                            // allocate an IP address - manual IP assigning mode
                            ip = iaas.associateAddress(node);
                           
                if (ip != null) {
                  memberContext.setAllocatedIpAddress(ip);
                  log.info("Allocated an ip address: "
                      + memberContext.toString());
                }
                        }      
                     
                      // build the node with the new ip
                      node = NodeMetadataBuilder.fromNodeMetadata(node)
                        .publicAddresses(ImmutableSet.of(ip)).build();
                    }
                   

                    // public ip
                    if (node.getPublicAddresses() != null &&
                        node.getPublicAddresses().iterator().hasNext()) {
                        ip = node.getPublicAddresses().iterator().next();
                        publicIp = ip;
                        memberContext.setPublicIpAddress(ip);
                        log.info("Retrieving Public IP Address : " + memberContext.toString());
                    }

                    // private IP
                    if (node.getPrivateAddresses() != null &&
                        node.getPrivateAddresses().iterator().hasNext()) {
                        ip = node.getPrivateAddresses().iterator().next();
                        memberContext.setPrivateIpAddress(ip);
                        log.info("Retrieving Private IP Address. " + memberContext.toString());
                    }

                    dataHolder.addMemberContext(memberContext);

                    // persist in registry
                    persist();

                    String memberID = memberContext.getMemberId();

                    // trigger topology
                    TopologyBuilder.handleMemberSpawned(memberID, cartridgeType, clusterId, memberContext.getNetworkPartitionId(),
                            partition.getId(), ip, memberContext.getLbClusterId(),publicIp);

                    // update the topology with the newly spawned member
                    // publish data
                    CartridgeInstanceDataPublisher.publish(memberID,
                                                        memberContext.getPartition().getId(),
View Full Code Here


            log.error(msg);
            throw new IllegalArgumentException(msg);
        }

        String clusterId = memberContext.getClusterId();
        Partition partition = memberContext.getPartition();

        if(log.isDebugEnabled()) {
          log.debug("Received an instance spawn request : " + memberContext.toString());
        }

        ComputeService computeService = null;
        Template template = null;

        if (partition == null) {
            String msg =
                         "Instance start-up failed. Specified Partition is null. " +
                                 memberContext.toString();
            log.error(msg);
            throw new IllegalArgumentException(msg);
        }

        String partitionId = partition.getId();
        ClusterContext ctxt = dataHolder.getClusterContext(clusterId);

        if (ctxt == null) {
            String msg = "Instance start-up failed. Invalid cluster id. " + memberContext.toString();
            log.error(msg);
View Full Code Here

TOP

Related Classes of org.apache.stratos.cloud.controller.deployment.partition.Partition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.