Examples of IaasContext


Examples of org.apache.stratos.cloud.controller.util.IaasContext

        if (serviceCtxt.getCartridge() != null) {
            instanceData.setMultiTenant(serviceCtxt.getCartridge().isMultiTenant());

            for (IaasProvider iaas : serviceCtxt.getCartridge().getIaases()) {

                IaasContext ctxt = null;
                if ((ctxt = serviceCtxt.getIaasContext(iaas.getType())) == null) {
                    ctxt = serviceCtxt.addIaasContext(iaas.getType());
                }

                if (ctxt.didISpawn(key)) {
                    instanceData.setIaas(iaas.getType());
                    instanceData.setMetaData(ctxt.getNode(key));

                    // clear to be removed data
                    ctxt.removeToBeRemovedNodeId(key);

                    // if the node is terminated
                    if (val.equals(NodeStatus.TERMINATED.toString())) {
                        // since this node is terminated
                        FasterLookUpDataHolder.getInstance().removeNodeId(key);

                        // remove node meta data
                        ctxt.removeNodeMetadata(ctxt.getNode(key));
                    }

                    break;
                }
            }
View Full Code Here

Examples of org.apache.stratos.cloud.controller.util.IaasContext

                       
                        if(computeService == null){
                            continue;
                        }
                       
                        IaasContext ctxt = null;
                        if((ctxt = subjectedSerCtxt.getIaasContext(iaas.getType())) == null){
                          ctxt = subjectedSerCtxt.addIaasContext(iaas.getType());
                        }

                        // get list of node Ids
                        List<String> nodeIds = ctxt.getAllNodeIds();

                        if (nodeIds.isEmpty()) {
                           
                            continue;
                        }
                       
                        try {

                            // get all the nodes spawned by this IaasContext
                            Set<? extends ComputeMetadata> set = computeService.listNodes();

                            Iterator<? extends ComputeMetadata> iterator = set.iterator();

                            // traverse through all nodes of this ComputeService object
                            while (iterator.hasNext()) {
                                NodeMetadata nodeMetadata = (NodeMetadataImpl) iterator.next();

                                // if this node belongs to the requested domain
                                if (nodeIds.contains(nodeMetadata.getId())) {

                                    statusMap.put(nodeMetadata.getId(), nodeMetadata.getStatus()
                                                                                    .toString());

                                    ctxt.addNodeMetadata(nodeMetadata);
                                }

                            }

                        }catch (Exception e) {
View Full Code Here

Examples of org.apache.stratos.cloud.controller.util.IaasContext

        IaasProviderComparator.ascending(IaasProviderComparator
            .getComparator(IaasProviderComparator.SCALE_UP_SORT)));

    for (IaasProvider iaas : serviceCtxt.getCartridge().getIaases()) {

      IaasContext ctxt = null;
      if ((ctxt = serviceCtxt.getIaasContext(iaas.getType())) == null) {
        ctxt = serviceCtxt.addIaasContext(iaas.getType());
      }

      if (iaas.getMaxInstanceLimit() > dataHolder.getActiveInstanceCount(iaas.getType())) {
        try {

          iaas.getIaas().setDynamicPayload(iaas);

          // get the ComputeService
          computeService = iaas.getComputeService();

          // corresponding Template
          template = iaas.getTemplate();

          if (template == null) {
            String msg = "Failed to start an instance in "
                + iaas.getType()
                + ". Reason : Template is null. You have not specify a matching service "
                + "element in the configuration file of Autoscaler.\n Hence, will try to "
                + "start in another IaaS if available.";
            log.error(msg);
            continue;
          }

          // set instance name as the host name
          // template.getOptions().userMetadata("Name",
          // serviceCtxt.getHostName());
          // template.getOptions().as(TemplateOptions.class).userMetadata("Name",
          // serviceCtxt.getHostName());

          // generate the group id from domain name and sub domain
          // name.
          // Should have lower-case ASCII letters, numbers, or dashes.
          // Should have a length between 3-15
          String str = domainName.concat("-" + subDomainName)
              .substring(0, 10);
          String group = str.replaceAll("[^a-z0-9-]", "");

          NodeMetadata node;

          // create and start a node
          Set<? extends NodeMetadata> nodes = computeService
              .createNodesInGroup(group, 1, template);

          node = nodes.iterator().next();

          String autoAssignIpProp = iaas
              .getProperty(CloudControllerConstants.AUTO_ASSIGN_IP_PROPERTY);

          // acquire the lock
          lock.lock();

          try {
            // reset ip
            ip = "";
            // default behavior is autoIpAssign=false
            if (autoAssignIpProp == null
                || (autoAssignIpProp != null && autoAssignIpProp
                    .equals("false"))) {
              // allocate an IP address - manual IP assigning mode
              ip = iaas.getIaas().associateAddress(iaas, node);
            }

            if (ip.isEmpty()
                && node.getPublicAddresses() != null
                && node.getPublicAddresses().iterator()
                    .hasNext()) {
              ip = node.getPublicAddresses().iterator().next();
            }

            // if not public IP is assigned, we're using private IP
            if (ip.isEmpty()
                && node.getPrivateAddresses() != null
                && node.getPrivateAddresses().iterator()
                    .hasNext()) {
              ip = node.getPrivateAddresses().iterator().next();
            }

            if (node.getId() == null) {
              String msg = "Node id of the starting instance is null.\n"
                  + node.toString();
              log.fatal(msg);
              throw new CloudControllerException(msg);
            }

            // add node ID
            ctxt.addNodeId(node.getId());
            ctxt.addNodeToPublicIp(node.getId(), ip);

            // to faster look up
            dataHolder.addNodeId(
                node.getId(), serviceCtxt);
View Full Code Here

Examples of org.apache.stratos.cloud.controller.util.IaasContext

          + iaas.getType()
          + ". Hence, will try to terminate an instance in another IaaS if possible.";

      String nodeId = null;

      IaasContext ctxt = serviceCtxt.getIaasContext(iaas.getType());

      // terminate the last instance first
      for (String id : Lists.reverse(ctxt.getNodeIds())) {
        if (id != null) {
          nodeId = id;
          break;
        }
      }
View Full Code Here

Examples of org.apache.stratos.cloud.controller.util.IaasContext

    iaas = serviceCtxt.getCartridge().getIaasProvider(iaas.getType());

    if (iaas != null) {

      String nodeId = null;
      IaasContext ctxt = serviceCtxt.getIaasContext(iaas.getType());

      int i = 0;
      for (i = ctxt.getNodeIds().size() - 1; i >= 0; i--) {
        String id = ctxt.getNodeIds().get(i);
        if (id != null) {
          nodeId = id;
          break;
        }
      }
View Full Code Here

Examples of org.apache.stratos.cloud.controller.util.IaasContext

                .getComparator(IaasProviderComparator.SCALE_DOWN_SORT)));

    // traverse in scale down order
    for (IaasProvider iaas : serviceCtxt.getCartridge().getIaases()) {

      IaasContext ctxt = serviceCtxt.getIaasContext(iaas.getType());

      if (ctxt == null) {
        log.error("Iaas Context for " + iaas.getType()
            + " not found. Cannot terminate instances");
        continue;
      }

      ArrayList<String> temp = new ArrayList<String>(ctxt.getNodeIds());
      for (String id : temp) {
        if (id != null) {
          // terminate it!
          terminate(iaas, ctxt, id);
View Full Code Here

Examples of org.apache.stratos.cloud.controller.util.IaasContext

      for (IaasProvider iaas : iaases) {

        ComputeService computeService = iaas.getComputeService();

        IaasContext ctxt = null;
        if ((ctxt = subjectedSerCtxt.getIaasContext(iaas.getType())) == null) {
          ctxt = subjectedSerCtxt.addIaasContext(iaas.getType());
        }

        // get list of node Ids which are belong to this domain- sub
        // domain
        List<String> nodeIds = ctxt.getNodeIds();

        if (nodeIds.isEmpty()) {
          log.debug("Zero nodes spawned in the IaaS "
              + iaas.getType() + " of domain: " + domainName
              + " and sub domain: " + subDomainName);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.