Package org.apache.stratos.cloud.controller.util.xsd

Examples of org.apache.stratos.cloud.controller.util.xsd.CartridgeInfo


   
    // Assign auto scaling only when necessary.
    // Muti-tenant cartridge may not need a policy.
    Policy autoScalingPolicy = null;
   
    CartridgeInfo cartridgeInfo;
    try {
      cartridgeInfo = getServiceClient().getCartridgeInfo(cartridgeType);
    } catch (UnregisteredCartridgeException e) {
      String message = cartridgeType
          + " is not a valid cartridge type. Please try again with a valid cartridge type.";
      log.error(message);
      throw e;
    } catch (Exception e) {
      String message = "Error getting info for " + cartridgeType;
      log.error(message, e);
      throw new ADCException(message, e);
    }

    validateCartridgeAlias(cartName, cartridgeType);
   

        if (cartridgeType.equals(CartridgeConstants.MYSQL_CARTRIDGE_NAME)) {
         
          autoScalingPolicy = PolicyHolder.getInstance().getDefaultPolicy();
         
          if (autoScalingPolicy == null) {
            throw new PolicyException("Could not load default auto-scaling policy.");
          }
          if (log.isDebugEnabled()) {
          log.debug("Selected Policy: " + new Gson().toJson(autoScalingPolicy));
        }
         
            dataCartridge = new DataCartridge();
            mysqlPassword = generatePassword();
            dataCartridge.setPassword(mysqlPassword);
            dataCartridge.setDataCartridgeType(cartridgeType);
            dataCartridge.setUserName(CartridgeConstants.MYSQL_DEFAULT_USER);
            clusterDomain = getDynamicClusterDomain(cartridgeType, cartName, cartridgeInfo);

            registerService(cartridgeType,
                    clusterDomain,
                    clusterSubDomain,
                    createPayload(cartridgeInfo, cartName, autoScalingPolicy, repoURL, mysqlPassword, "localhost", payloadZipFileName, tenantId, tenantDomain),
                    "*",
                    cartName + "." + cartridgeInfo.getHostName(),
                    setRegisterServiceProperties(autoScalingPolicy, tenantId,cartName));
            deletePayloadFile(payloadZipFileName);
        } else {
         
      if (!new Boolean(System.getProperty(CartridgeConstants.FEATURE_INTERNAL_REPO_ENABLED))) {
        if (log.isDebugEnabled()) {
          log.debug("Internal repo feature is not enabled.");
        }

        if (repoURL == null || repoURL.trim().length() == 0) {
          throw new RepositoryRequiredException("External repository required for subscription");
        }
      }

      if (repoURL != null && repoURL.trim().length() > 0) {
        if (log.isDebugEnabled()) {
          log.debug("Repo URL entered: " + repoURL);
        }
        // Validate Remote Repository.
        validateRepository(repoURL, repoUsername, repoPassword, privateRepo,
            new Boolean(System.getProperty(CartridgeConstants.FEATURE_EXTERNAL_REPO_VAIDATION_ENABLED)));
      }

            try {
                repository = manageRepository(repoURL, repoUsername, repoPassword, cartName, cartridgeInfo, username,
                        tenantDomain);
            } catch (Exception e) {
                log.error(e.getMessage());
                throw new ADCException(e);
            }
         
            // TODO: Check logic here
            if (!cartridgeInfo.getMultiTenant()) {
             
            if (policy != null && policy.trim().length() > 0) {
              autoScalingPolicy = PolicyHolder.getInstance().getPolicy(policy);
            } else {
              autoScalingPolicy = PolicyHolder.getInstance().getDefaultPolicy();
            }
            if (autoScalingPolicy == null) {
              throw new PolicyException("Could not load auto-scaling policy.");
            }
            if (log.isDebugEnabled()) {
              log.debug("Selected Policy: " + new Gson().toJson(autoScalingPolicy));
            }

                if (cartridgeInfo.getProvider().equalsIgnoreCase(CartridgeConstants.PROVIDER_NAME_WSO2)) { //carbon cartridge private jet mode

                    clusterDomain = getDynamicClusterDomain(cartridgeType, cartName, cartridgeInfo);
                    registerService(cartridgeType,
                            clusterDomain,
                            clusterSubDomain,
                            createCarbonPayload(cartridgeInfo, cartName, alias, payloadZipFileName, tenantDomain, false),
                            Integer.toString(tenantId),
                            cartName + "." + cartridgeInfo.getHostName(),
                            setRegisterServiceProperties(autoScalingPolicy,tenantId,cartName));
                    deletePayloadFile(payloadZipFileName);

                } else {
                    clusterDomain = getDynamicClusterDomain(cartridgeType, cartName, cartridgeInfo);

                    String mySQLPassword = null;
                    String mySQLHostName = null;

                    if (dataCartridgeType != null && dataCartridgeType.trim().length() > 0 && dataCartridgeAlias != null
                            && dataCartridgeAlias.trim().length() > 0) {
                        if (log.isInfoEnabled()) {
                            log.info("Retrieving Data Cartridge info for connect ... Alias : " + dataCartridgeAlias
                                    + ", Type: " + dataCartridgeType);
                        }

                        //TODO: Optimize following logic. Same logic is used in MySQLPasswordConfigurer
                        int maxAttempts = Integer.parseInt(System.getProperty(CartridgeConstants.MAX_ATTEMPTS, "50"));
                        int i = 0;

                        while (i < maxAttempts) {
                            i++;
                            Cartridge c = null;
                            try {
                                c = getCartridgeInfo(dataCartridgeAlias, tenantDomain);
                            } catch (NotSubscribedException e) {
                                // This cannot happen here.
                            }
                            if (c != null) {
                                if (!c.getStatus().equals("ACTIVE")) {
                                    try {
                                        Thread.sleep(3000);
                                    } catch (InterruptedException ignore) {
                                    }
                                } else {
                                    mySQLPassword = c.getPassword();
                                    mySQLHostName = c.getIp();
                                    break;
                                }
                            }
                        }
                        log.info(" MYSQL Cartridge info retrieved ");
                    }

                    registerService(cartridgeType,
                            clusterDomain,
                            clusterSubDomain,
                            createPayload(cartridgeInfo, cartName, autoScalingPolicy, repoURL, mySQLPassword,
                                    mySQLHostName, payloadZipFileName, tenantId, tenantDomain), "*",
                            cartName + "." + cartridgeInfo.getHostName(),
                            setRegisterServiceProperties(autoScalingPolicy,tenantId,cartName));
                    deletePayloadFile(payloadZipFileName);
                }

            } else {
View Full Code Here


            throw new NotSubscribedException("You have not subscribed for " + alias, alias);
        }

        log.info("Cluster domain : " + sub.getClusterDomain() + " cartridge: " + sub.getCartridge());
       
        CartridgeInfo cartridgeInfo = null;
        try {
            cartridgeInfo = getServiceClient().getCartridgeInfo(sub.getCartridge());
        } catch (Exception e) {
            throw new ADCException("Cannot get cartridge info: " + sub.getCartridge(), e);
        }
View Full Code Here

      String[] availableCartridges = ApplicationManagementUtil.getServiceClient().getRegisteredCartridges();

      if (availableCartridges != null) {
        for (String cartridgeType : availableCartridges) {
          CartridgeInfo cartridgeInfo = null;
          try {
            cartridgeInfo = ApplicationManagementUtil.getServiceClient().getCartridgeInfo(cartridgeType);
          } catch (Exception e) {
            if (log.isWarnEnabled()) {
              log.warn("Error when calling getCartridgeInfo for " + cartridgeType + ", Error: "
                  + e.getMessage());
            }
          }
          if (cartridgeInfo == null) {
            // This cannot happen. But continue
            if (log.isDebugEnabled()) {
              log.debug("Cartridge Info not found: " + cartridgeType);
            }
            continue;
          }
         
          if (multiTenant != null && !multiTenant && cartridgeInfo.getMultiTenant()) {
            // Need only Single-Tenant cartridges
            continue;
          } else if (multiTenant != null && multiTenant && !cartridgeInfo.getMultiTenant()) {
            // Need only Multi-Tenant cartridges
            continue;
          }
         
          if (!cartridgeMatches(cartridgeInfo, searchPattern)) {
            continue;
          }
         
          Cartridge cartridge = new Cartridge();
          cartridge.setCartridgeType(cartridgeType);
          cartridge.setProvider(cartridgeInfo.getProvider());
          cartridge.setDisplayName(cartridgeInfo.getDisplayName());
          cartridge.setDescription(cartridgeInfo.getDescription());
          cartridge.setVersion(cartridgeInfo.getVersion());
          cartridge.setMultiTenant(cartridgeInfo.getMultiTenant());
          cartridge.setStatus(CartridgeConstants.NOT_SUBSCRIBED);
          cartridge.setCartridgeAlias("-");
          cartridge.setActiveInstances(0);
          cartridges.add(cartridge);
         
          if (cartridgeInfo.getMultiTenant() && !allowMultipleSubscription) {
            // If the cartridge is multi-tenant. We should not let users
            // subscribe twice.
            if (PersistenceManager.isAlreadySubscribed(cartridgeType,
                ApplicationManagementUtil.getTenantId(getConfigContext()))) {
              if (log.isDebugEnabled()) {
View Full Code Here

      List<CartridgeSubscription> subscriptionList = PersistenceManager
          .retrieveSubscribedCartridges(ApplicationManagementUtil.getTenantId(getConfigContext()));

      if (subscriptionList != null && !subscriptionList.isEmpty()) {
        for (CartridgeSubscription subscription : subscriptionList) {
          CartridgeInfo cartridgeInfo = null;
          try {
            cartridgeInfo = ApplicationManagementUtil.getServiceClient().getCartridgeInfo(
                subscription.getCartridge());
          } catch (Exception e) {
            if (log.isWarnEnabled()) {
View Full Code Here

            String clusterSubDomain = subscription.getClusterSubdomain();

            if (log.isDebugEnabled()) {
                log.debug("Finding cartridge information for " + subscription.getCartridge());
            }
            CartridgeInfo cartridgeInfo = ApplicationManagementUtil.getServiceClient().getCartridgeInfo(subscription.getCartridge());
            if (log.isDebugEnabled()) {
                log.debug("Found " + cartridgeInfo.getDisplayName() + " for " + subscription.getCartridge());
            }
            if (!cartridgeInfo.getMultiTenant()) {
                log.info("Terminating all instances of " + clusterDomain + " " + clusterSubDomain);
                ApplicationManagementUtil.getServiceClient().terminateAllInstances(clusterDomain, clusterSubDomain);
                log.info("All instances terminated.");
                log.info("Unregistering services...");
                ApplicationManagementUtil.getServiceClient().unregisterService(clusterDomain, clusterSubDomain);
View Full Code Here

TOP

Related Classes of org.apache.stratos.cloud.controller.util.xsd.CartridgeInfo

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.