Package org.apache.stratos.cloud.controller.stub.pojo

Examples of org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo


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

            if (availableCartridges != null) {
                for (String cartridgeType : availableCartridges) {
                    CartridgeInfo cartridgeInfo = null;
                    try {
                        cartridgeInfo = CloudControllerServiceClient.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 (!ServiceUtils.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.setHostName(cartridgeInfo.getHostName());
                    cartridge.setDefaultAutoscalingPolicy(cartridgeInfo.getDefaultAutoscalingPolicy());
                    cartridge.setDefaultDeploymentPolicy(cartridgeInfo.getDefaultDeploymentPolicy());
                    //cartridge.setStatus(CartridgeConstants.NOT_SUBSCRIBED);
                    cartridge.setCartridgeAlias("-");
                    cartridge.setPersistence(cartridgeInfo.getPersistence());

                    if(cartridgeInfo.getLbConfig() != null && cartridgeInfo.getProperties() != null) {
                        for(Property property: cartridgeInfo.getProperties()) {
                        if(property.getName().equals("load.balancer")) {
                            cartridge.setLoadBalancer(true);
                        }
                        }
                    }
                    //cartridge.setActiveInstances(0);
                    cartridges.add(cartridge);


                    if (cartridgeInfo.getMultiTenant() && !allowMultipleSubscription) {
                        // If the cartridge is multi-tenant. We should not let users
                        // createSubscription twice.
                        if (isAlreadySubscribed(cartridgeType,
                                ApplicationManagementUtil.getTenantId(configurationContext))) {
                            if (log.isDebugEnabled()) {
View Full Code Here


        }
    }

    public void testCarbonCartridgeSubscription() {

        CartridgeInfo cartridgeInfo1 = new CartridgeInfo();
        cartridgeInfo1.setProvider("carbon");
        cartridgeInfo1.setMultiTenant(true);
        cartridgeInfo1.setType("esb");
        CartridgeSubscription cartridgeSubscription1 = getCartridgeInstance(cartridgeInfo1);
        assertNotNull(cartridgeSubscription1);


        CartridgeInfo cartridgeInfo2 = new CartridgeInfo();
        cartridgeInfo2.setProvider("carbon");
        cartridgeInfo2.setMultiTenant(false);
        cartridgeInfo2.setType("as");
        CartridgeSubscription cartridgeSubscription2 = getCartridgeInstance(cartridgeInfo2);
        assertNotNull(cartridgeSubscription2);
    }
View Full Code Here

        assertNotNull(cartridgeSubscription2);
    }

    public void testPhpCartridgeSubscription() {

        CartridgeInfo cartridgeInfo = new CartridgeInfo();
        cartridgeInfo.setProvider("php-provider");
        cartridgeInfo.setMultiTenant(false);
        cartridgeInfo.setType("php");
        CartridgeSubscription cartridgeSubscription = getCartridgeInstance(cartridgeInfo);
        assertNotNull(cartridgeSubscription);
    }
View Full Code Here

        assertNotNull(cartridgeSubscription);
    }

    public void testMySqlCartridgeSubscription() {

        CartridgeInfo cartridgeInfo = new CartridgeInfo();
        cartridgeInfo.setProvider("data");
        cartridgeInfo.setMultiTenant(false);
        cartridgeInfo.setType("mysql");
        CartridgeSubscription cartridgeSubscription = getCartridgeInstance(cartridgeInfo);
        assertNotNull(cartridgeSubscription);
    }
View Full Code Here

        assertNotNull(cartridgeSubscription);
    }

    public void testTomcatCartridgeSubscription() {

        CartridgeInfo cartridgeInfo = new CartridgeInfo();
        cartridgeInfo.setProvider("tomcat-provider");
        cartridgeInfo.setMultiTenant(false);
        cartridgeInfo.setType("tomcat");
        CartridgeSubscription cartridgeSubscription = getCartridgeInstance(cartridgeInfo);
        assertNotNull(cartridgeSubscription);
    }
View Full Code Here

        setUpCsrtridgeSubscriptions();
    }

    private void setUpCsrtridgeSubscriptions() {

        CartridgeInfo cartridgeInfo1 = getCartridgeInfo("carbon", "esb", true);
        CartridgeSubscription cartridgeSubscription1 = getCartridgeInstance(cartridgeInfo1);
        assertNotNull(cartridgeSubscription1);
        Subscriber subscriber1 = getSubscriber("admin", 1, "a.com");
        cartridgeSubscription1.setSubscriber(subscriber1);
        cartridgeSubscription1.setClusterDomain("esb.domain");
        cartridgeSubscription1.setAlias("esba");
        cartridgeSubscriptions.add(cartridgeSubscription1);

        CartridgeInfo cartridgeInfo2 = getCartridgeInfo("carbon", "esb", true);
        CartridgeSubscription cartridgeSubscription2 = getCartridgeInstance(cartridgeInfo2);
        assertNotNull(cartridgeSubscription2);
        Subscriber subscriber2 = getSubscriber("admin", 2, "b.com");
        cartridgeSubscription2.setSubscriber(subscriber2);
        cartridgeSubscription2.setClusterDomain("esb.domain");
        cartridgeSubscription2.setAlias("esbb");
        cartridgeSubscriptions.add(cartridgeSubscription2);

        CartridgeInfo cartridgeInfo3 = getCartridgeInfo("carbon", "esb.privatejet", false);
        CartridgeSubscription cartridgeSubscription3 = getCartridgeInstance(cartridgeInfo3);
        assertNotNull(cartridgeSubscription3);
        Subscriber subscriber3 = getSubscriber("admin", 1, "a.com");
        cartridgeSubscription3.setSubscriber(subscriber3);
        cartridgeSubscription3.setClusterDomain("a.esb.domain");
        cartridgeSubscription3.setAlias("esba1");
        cartridgeSubscriptions.add(cartridgeSubscription3);

        CartridgeInfo cartridgeInfo4 = getCartridgeInfo("php-provider", "php", false);
        CartridgeSubscription cartridgeSubscription4 = getCartridgeInstance(cartridgeInfo4);
        assertNotNull(cartridgeSubscription4);
        Subscriber subscriber4 = getSubscriber("admin", 3, "c.com");
        cartridgeSubscription4.setSubscriber(subscriber4);
        cartridgeSubscription4.setClusterDomain("a.php.domain");
        cartridgeSubscription4.setAlias("phpa");
        cartridgeSubscriptions.add(cartridgeSubscription4);

        CartridgeInfo cartridgeInfo5 = getCartridgeInfo("mysql-provider", "mysql", false);
        CartridgeSubscription cartridgeSubscription5 = getCartridgeInstance(cartridgeInfo5);
        assertNotNull(cartridgeSubscription5);
        Subscriber subscriber5 = getSubscriber("admin", 3, "c.com");
        cartridgeSubscription5.setSubscriber(subscriber5);
        cartridgeSubscription5.setClusterDomain("a.mysql.domain");
View Full Code Here

        dataInsertionAndRetrievalManager.cacheSubscriptionsWithoutPersisting(cartridgeSubscriptions);
    }

    private CartridgeInfo getCartridgeInfo (String provider, String type, boolean multitenant) {

        CartridgeInfo cartridgeInfo = new CartridgeInfo();
        cartridgeInfo.setProvider(provider);
        cartridgeInfo.setType(type);
        cartridgeInfo.setMultiTenant(multitenant);
        return cartridgeInfo;
    }
View Full Code Here

                                                                                            InvalidRepositoryException {

        // validate cartridge alias
        CartridgeSubscriptionUtils.validateCartridgeAlias(subscriptionData.getTenantId(), subscriptionData.getCartridgeType(), subscriptionData.getCartridgeAlias());

        CartridgeInfo cartridgeInfo;
        try {
            cartridgeInfo = CloudControllerServiceClient.getServiceClient().getCartridgeInfo(subscriptionData.getCartridgeType());

        } catch (CloudControllerServiceUnregisteredCartridgeExceptionException e) {
            String message = subscriptionData.getCartridgeType() + " is not a valid cartridgeSubscription type. Please try again with a valid cartridgeSubscription type.";
            log.error(message);
            throw new ADCException(message, e);

        } catch (Exception e) {
            String message = "Error getting info for " + subscriptionData.getCartridgeType();
            log.error(message, e);
            throw new ADCException(message, e);
        }

        // For MT subscriptions check whether there are active instances
        if(cartridgeInfo.getMultiTenant() && !activeInstancesAvailable(subscriptionData)) {
          String msg = "No active instances are found for cartridge [" + subscriptionData.getCartridgeType() + "]";
          log.error(msg);
          throw new ADCException(msg);
        }
       
        // check if this subscription requires Persistence Mapping, and its supported by the cartridge definition
        Properties persistenceMappingProperties = null;
        if (subscriptionData.getPersistanceContext() != null) {
            persistenceMappingProperties = getPersistenceMappingProperties(subscriptionData.getPersistanceContext(), cartridgeInfo);
        }

        Properties serviceCartridgeSubscriptionProperties = null;
        LBDataContext lbDataCtxt = null;
        CartridgeSubscription lbCartridgeSubscription = null;
        Properties lbCartridgeSubscriptionProperties = null;
        String lbClusterId = null;

        // get lb config reference
        LoadbalancerConfig lbConfig = cartridgeInfo.getLbConfig();
        if (lbConfig == null || lbConfig.getProperties() == null) {
            // no LB ref
            if (log.isDebugEnabled()) {
                log.debug("This Service does not require a load balancer. " + "[Service Name] " +
                        subscriptionData.getCartridgeType());
View Full Code Here

            log.error(errorMsg);
            throw new ServiceAlreadyDeployedException(errorMsg, type);
        }

        //get deployed Cartridge Definition information
        CartridgeInfo cartridgeInfo;
        try {
            cartridgeInfo = CloudControllerServiceClient.getServiceClient().getCartridgeInfo(type);

        } catch (CloudControllerServiceUnregisteredCartridgeExceptionException e) {
            String message = type + " is not a valid cartridgeSubscription type. Please try again with a valid cartridgeSubscription type.";
            log.error(message);
            throw new ADCException(message, e);

        } catch (Exception e) {
            String message = "Error getting info for " + type;
            log.error(message, e);
            throw new ADCException(message, e);
        }

        if (!cartridgeInfo.getMultiTenant()) {
            String errorMsg = "Cartridge definition with type " + type + " is not multitenant";
            log.error(errorMsg);
            throw new ADCException(errorMsg);
        }


//        // TODO - LB cartridge.... ??
//
//        List<Property> lbRefProp = new ArrayList<Property>();
//
//        // get lb config reference
//        LoadbalancerConfig lbConfig = cartridgeInfo.getLbConfig();
//
//        if (lbConfig == null || lbConfig.getProperties() == null) {
//
//            if (log.isDebugEnabled()) {
//                log.debug("This Service does not require a load balancer. " + "[Service Name] " +
//                          type);
//            }
//        } else {
//
//            Service lbService;
//
//            Properties lbReferenceProperties = lbConfig.getProperties();
//
//            Property property = new Property();
//            property.setName(org.apache.stratos.messaging.util.Constants.LOAD_BALANCER_REF);
//
//            for (org.apache.stratos.cloud.controller.pojo.Property prop : lbReferenceProperties.getProperties()) {
//
//                String name = prop.getName();
//                String value = prop.getValue();
//
//                // TODO make following a chain of responsibility pattern
//                if (Constants.NO_LOAD_BALANCER.equals(name)) {
//                    if ("true".equals(value)) {
//                        if (log.isDebugEnabled()) {
//                            log.debug("This cartridge does not require a load balancer. " +
//                                      "[Type] " + type);
//                        }
//                        property.setValue(name);
//                        lbRefProp.add(property);
//                        break;
//                    }
//                } else if (Constants.EXISTING_LOAD_BALANCERS.equals(name)) {
//                    String clusterIdsVal = value;
//                    if (log.isDebugEnabled()) {
//                        log.debug("This cartridge refers to existing load balancers. " + "[Type] " +
//                                  type + "[Referenced Cluster Ids] " + clusterIdsVal);
//                    }
//
//                    String[] clusterIds = clusterIdsVal.split(",");
//
//                    for (String clusterId : clusterIds) {
//
//                            try {
//                              AutoscalerServiceClient.getServiceClient().checkLBExistenceAgainstPolicy(clusterId,
//                                  deploymentPolicyName);
//                            } catch (Exception ex) {
//                                // we don't need to throw the error here.
//                                log.error(ex.getMessage(), ex);
//                            }
//
//                    }
//
//                    property.setValue(name);
//                    lbRefProp.add(property);
//                    break;
//
//                } else if (Constants.DEFAULT_LOAD_BALANCER.equals(name)) {
//
//                    if ("true".equals(value)) {
//
//                        CartridgeInfo lbCartridgeInfo;
//                        String lbCartridgeType = lbConfig.getType();
//                        try {
//                            // retrieve lb Cartridge info
//                            lbCartridgeInfo = CloudControllerServiceClient.getServiceClient().getCartridgeInfo(lbCartridgeType);
//                        } catch (Exception e) {
//                            String msg = "Cannot get cartridge info: " + type;
//                            log.error(msg, e);
//                            throw new ADCException(msg, e);
//                        }
//
//                        property.setValue(name);
//                        if (log.isDebugEnabled()) {
//                            log.debug("This cartridge uses default load balancer. " + "[Type] " +
//                                      type);
//                        }
//
//                            try {
//                                // get the valid policies for lb cartridge
//                                DeploymentPolicy[] lbCartridgeDepPolicies =
//                                  AutoscalerServiceClient.getServiceClient().getDeploymentPolicies(lbCartridgeType);
//                                // traverse deployment policies of lb cartridge
//                                for (DeploymentPolicy policy : lbCartridgeDepPolicies) {
//                                    // check existence of the subscribed policy
//                                    if (deploymentPolicyName.equals(policy.getId())) {
//
//                                        if (!AutoscalerServiceClient.getServiceClient().checkDefaultLBExistenceAgainstPolicy(deploymentPolicyName)) {
//
//                                            // if lb cluster doesn't exist
//                                            lbService = new MultiTenantLBService(lbCartridgeType,
//                                                    lbCartridgeInfo.getDefaultAutoscalingPolicy(),
//                                                    deploymentPolicyName, tenantId,
//                                                    lbCartridgeInfo,
//                                                    tenantRange);
//
//                                            Properties lbDeploymentProperties = new Properties();
//
//                                            // check if there are properties in LB cartridge info
//                                            Property [] cartridgeInfoProps = lbCartridgeInfo.getProperties();
//                                            if (cartridgeInfoProps != null && cartridgeInfoProps.length > 0) {
//                                                lbDeploymentProperties.setProperties(combine(lbCartridgeInfo.getProperties(), new Property[]{property}));
//                                            } else {
//                                                lbDeploymentProperties.setProperties(new Property[]{property});
//                                            }
//
//                                            lbService.deploy(lbDeploymentProperties);
//
//                                            // persist
//                                            persist(lbService);
//                                        }
//                                    }
//                                }
//
//                            } catch (Exception ex) {
//                                // we don't need to throw the error here.
//                                log.error(ex.getMessage(), ex);
//                            }
//
//
//                        lbRefProp.add(property);
//                        break;
//                    }
//                } else if (Constants.SERVICE_AWARE_LOAD_BALANCER.equals(name)) {
//
//                    if ("true".equals(value)) {
//
//                        CartridgeInfo lbCartridgeInfo;
//                        String lbCartridgeType = lbConfig.getType();
//                        try {
//                            // retrieve lb Cartridge info
//                            lbCartridgeInfo = CloudControllerServiceClient.getServiceClient().getCartridgeInfo(lbCartridgeType);
//                        } catch (Exception e) {
//                            String msg = "Cannot get cartridge info: " + type;
//                            log.error(msg, e);
//                            throw new ADCException(msg, e);
//                        }
//
//                        property.setValue(name);
//                        if (log.isDebugEnabled()) {
//                            log.debug("This cartridge uses a service aware load balancer. " +
//                                    "[Type] " + type);
//                        }
//
//                        // add a property for the service type
//                        Property loadBalancedServiceTypeProperty = new Property();
//                        loadBalancedServiceTypeProperty.setName(Constants.LOAD_BALANCED_SERVICE_TYPE);
//                        loadBalancedServiceTypeProperty.setValue(type);
//
//                        try {
//
//                            // get the valid policies for lb cartridge
//                            DeploymentPolicy[] lbCartridgeDepPolicies =
//                                    AutoscalerServiceClient.getServiceClient().getDeploymentPolicies(lbCartridgeType);
//                            // traverse deployment policies of lb cartridge
//                            for (DeploymentPolicy policy : lbCartridgeDepPolicies) {
//
//                                // check existence of the subscribed policy
//                                if (deploymentPolicyName.equals(policy.getId())) {
//
//                                    if (!AutoscalerServiceClient.getServiceClient().checkServiceLBExistenceAgainstPolicy(type,
//                                            deploymentPolicyName)) {
//
//                                        lbCartridgeInfo.addProperties(property);
//                                        lbCartridgeInfo.addProperties(loadBalancedServiceTypeProperty);
//
//                                        lbService = new MultiTenantLBService(lbCartridgeType,
//                                                lbCartridgeInfo.getDefaultAutoscalingPolicy(),
//                                                deploymentPolicyName, tenantId,
//                                                lbCartridgeInfo,
//                                                tenantRange);
//
//                                        Properties lbDeploymentProperties = new Properties();
//
//                                        // check if there are properties in LB cartridge info
//                                        Property [] cartridgeInfoProps = lbCartridgeInfo.getProperties();
//                                        if (cartridgeInfoProps != null && cartridgeInfoProps.length > 0) {
//                                            lbDeploymentProperties.setProperties(combine(lbCartridgeInfo.getProperties(), new Property[]{property, loadBalancedServiceTypeProperty}));
//                                        } else {
//                                            lbDeploymentProperties.setProperties(new Property[]{property, loadBalancedServiceTypeProperty});
//                                        }
//
//                                        lbService.deploy(lbDeploymentProperties);
//
//                                        // persist
//                                        persist(lbService);
//                                    }
//                                }
//                            }
//
//                        } catch (Exception ex) {
//                            // we don't need to throw the error here.
//                            log.error(ex.getMessage(), ex);
//                        }
//
//
//                        lbRefProp.add(property);
//                        break;
//                    }
//                }
//            }
//        }

        LBDataContext lbDataCtxt = null;

        // get lb config reference
        LoadbalancerConfig lbConfig = cartridgeInfo.getLbConfig();
        if (lbConfig == null || lbConfig.getProperties() == null) {
            // no LB ref
            if (log.isDebugEnabled()) {
                log.debug("This Service does not require a load balancer. " + "[Service Name] " + type);
            }
View Full Code Here

TOP

Related Classes of org.apache.stratos.cloud.controller.stub.pojo.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.