Package org.apache.stratos.cloud.controller.exception

Examples of org.apache.stratos.cloud.controller.exception.CloudControllerException


  private void buildTemplate(IaasProvider iaas) {
    if (iaas.getComputeService() == null) {
      String msg = "Compute service is null for IaaS provider: "
          + iaas.getName();
      log.fatal(msg);
      throw new CloudControllerException(msg);
    }

    TemplateBuilder templateBuilder = iaas.getComputeService()
        .templateBuilder();
View Full Code Here


          tm.deleteTask(CloudControllerConstants.TOPOLOGY_SYNC_TASK_NAME);
        } catch (TaskException e1) {
          log.error(e1);
        }
      }
      throw new CloudControllerException(msg, e);
    }
  }
View Full Code Here

          tm.deleteTask(CloudControllerConstants.DATA_PUB_TASK_NAME);
        } catch (TaskException e1) {
          log.error(e1);
        }
      }
      throw new CloudControllerException(msg, e);
    }
    return tm;
  }
View Full Code Here

    if (serviceCtxt == null) {
      String msg = "Not a registered service: domain - " + domainName
          + ", sub domain - " + subDomainName;
      log.fatal(msg);
      throw new CloudControllerException(msg);
    }

    // load Cartridge
    serviceCtxt.setCartridge(loadCartridge(serviceCtxt.getCartridgeType(),
        serviceCtxt.getPayload(), dataHolder
            .getCartridges()));

    if (serviceCtxt.getCartridge() == null) {
      String msg = "There's no registered Cartridge found. Domain - "
          + domainName + ", sub domain - " + subDomainName;
      log.fatal(msg);
      throw new CloudControllerException(msg);
    }

    if (serviceCtxt.getCartridge().getIaases().isEmpty()) {
      String msg = "There's no registered IaaSes found for Cartridge type: "
          + serviceCtxt.getCartridge().getType();
      log.fatal(msg);
      throw new CloudControllerException(msg);
    }

    // sort the IaasProviders according to scale up order
    Collections.sort(serviceCtxt.getCartridge().getIaases(),
        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);
View Full Code Here

          dataHolder);
    } catch (RegistryException e) {

      String msg = "Failed to persist the Cloud Controller data in registry. Further, transaction roll back also failed.";
      log.fatal(msg);
      throw new CloudControllerException(msg, e);
    }
  }
View Full Code Here

    if (serviceCtxt == null) {
      String msg = "Not a registered service: domain - " + domainName
          + ", sub domain - " + subDomainName;
      log.fatal(msg);
      throw new CloudControllerException(msg);
    }

    // load Cartridge, if null
    if (serviceCtxt.getCartridge() == null) {
      serviceCtxt.setCartridge(loadCartridge(
          serviceCtxt.getCartridgeType(), serviceCtxt.getPayload(),
          dataHolder.getCartridges()));
    }

    // if still, Cartridge is null
    if (serviceCtxt.getCartridge() == null) {
      String msg = "There's no registered Cartridge found. Domain - "
          + domainName + ", sub domain - " + subDomainName;
      log.fatal(msg);
      throw new CloudControllerException(msg);
    }

    // sort the IaasProviders according to scale down order
    Collections
        .sort(serviceCtxt.getCartridge().getIaases(),
View Full Code Here

    if (serviceCtxt == null) {
      String msg = "Not a registered service: domain - " + domainName
          + ", sub domain - " + subDomainName;
      log.fatal(msg);
      throw new CloudControllerException(msg);
    }

    // load Cartridge, if null
    if (serviceCtxt.getCartridge() == null) {
      serviceCtxt.setCartridge(loadCartridge(
          serviceCtxt.getCartridgeType(), serviceCtxt.getPayload(),
          dataHolder.getCartridges()));
    }

    if (serviceCtxt.getCartridge() == null) {
      String msg = "There's no registered Cartridge found. Domain - "
          + domainName + ", sub domain - " + subDomainName;
      log.fatal(msg);
      throw new CloudControllerException(msg);
    }

    IaasProvider iaas = serviceCtxt.getCartridge().getLastlyUsedIaas();
    // this is required since, we need to find the correct reference.
    // caz if the lastly used iaas retrieved from registry, it is not a
View Full Code Here

    if (serviceCtxt == null) {
      String msg = "Not a registered service: domain - " + domainName
          + ", sub domain - " + subDomainName;
      log.fatal(msg);
      throw new CloudControllerException(msg);
    }

    // load Cartridge, if null
    if (serviceCtxt.getCartridge() == null) {
      serviceCtxt.setCartridge(loadCartridge(
          serviceCtxt.getCartridgeType(), serviceCtxt.getPayload(),
          dataHolder.getCartridges()));
    }

    if (serviceCtxt.getCartridge() == null) {
      String msg = "There's no registered Cartridge found. Domain - "
          + domainName + ", sub domain - " + subDomainName;
      log.fatal(msg);
      throw new CloudControllerException(msg);
    }

    // sort the IaasProviders according to scale down order
    Collections
        .sort(serviceCtxt.getCartridge().getIaases(),
View Full Code Here

    // this is just to be safe
    if (iaasTemp.getComputeService() == null) {
      String msg = "Unexpeced error occured! IaasContext's ComputeService is null!";
      log.error(msg);
      throw new CloudControllerException(msg);
    }

    // destroy the node
    iaasTemp.getComputeService().destroyNode(nodeId);
View Full Code Here

      } catch (IOException e) {
        String msg = "Failed while persisting the payload of domain : "
            + domain + ", sub domain : " + subDomain;
        log.error(msg, e);
        throw new CloudControllerException(msg, e);
      }

    } else {
      log.debug("Payload is null or empty for :\n "
          + newServiceCtxt.toNode().toString());
    }

    // persist
    try {
      String uniqueName = domain + "-" + subDomain + "-"
          + UUID.randomUUID() + ".xml";
      FileUtils.writeStringToFile(new File(
          CloudControllerConstants.SERVICES_DIR + uniqueName),
          newServiceCtxt.toXml());
    } catch (IOException e) {
      String msg = "Failed while persisting the service configuration - domain : "
          + domain
          + ", sub domain : "
          + subDomain
          + ", tenant range: "
          + tenantRange
          + ", cartridge type: "
          + cartridgeType;
      log.error(msg, e);
      throw new CloudControllerException(msg, e);
    }

    log.info("Service successfully registered! Domain - " + domain
        + ", Sub domain - " + newServiceCtxt.getSubDomainName()
        + ", Cartridge type - " + cartridgeType);
View Full Code Here

TOP

Related Classes of org.apache.stratos.cloud.controller.exception.CloudControllerException

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.