Package org.apache.stratos.manager.subscription

Examples of org.apache.stratos.manager.subscription.CartridgeSubscription


  @AuthorizationAction("/permission/protected/manage/monitor/tenants")
  public StratosAdminResponse synchronizeRepository(String alias) throws RestAPIException {
    if (log.isDebugEnabled()) {
      log.debug(String.format("Synchronizing Git repository for alias '%s'", alias));
    }
    CartridgeSubscription cartridgeSubscription = ServiceUtils.getCartridgeSubscription(alias, getConfigContext());
    if (cartridgeSubscription != null && cartridgeSubscription.getRepository() != null && log.isDebugEnabled()) {
      log.debug(String.format("Found subscription for '%s'. Git repository: %s", alias, cartridgeSubscription
          .getRepository().getUrl()));
    }
    return ServiceUtils.synchronizeRepository(cartridgeSubscription);
  }
View Full Code Here


        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

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

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

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

    }

    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");
        cartridgeSubscription5.setAlias("mysqla");
        cartridgeSubscriptions.add(cartridgeSubscription5);

        dataInsertionAndRetrievalManager.cacheSubscriptionsWithoutPersisting(cartridgeSubscriptions);
    }
View Full Code Here

        // check for type 'mysql' and tenant 3
        cartridgeSubscriptions = dataInsertionAndRetrievalManager.getCartridgeSubscriptions(3, "mysql");
        assertEquals(1, cartridgeSubscriptions.size());

        // check for tenant 1 and alias 'esba'
        CartridgeSubscription subscription = dataInsertionAndRetrievalManager.getCartridgeSubscription(1, "esba");
        assertNotNull(subscription);

        // check for tenant 1 and alias 'esbb'
        subscription = dataInsertionAndRetrievalManager.getCartridgeSubscription(1, "esbb");
        assertNull(subscription);

        // check for tenant 2 and alias 'esba'
        subscription = dataInsertionAndRetrievalManager.getCartridgeSubscription(2, "esba");
        assertNull(subscription);

        // check for tenant 2 and alias 'esbb'
        subscription = dataInsertionAndRetrievalManager.getCartridgeSubscription(2, "esbb");
        assertNotNull(subscription);

        // check for tenant 1 and alias 'esba1'
        subscription = dataInsertionAndRetrievalManager.getCartridgeSubscription(1, "esba1");
        assertNotNull(subscription);

        // check for tenant 2 and alias 'esba1'
        subscription = dataInsertionAndRetrievalManager.getCartridgeSubscription(2, "esba1");
        assertNull(subscription);

        cartridgeSubscriptions = dataInsertionAndRetrievalManager.getCartridgeSubscriptionForCluster("esb.domain");
        assertNotNull(cartridgeSubscriptions);
        assertEquals(2, cartridgeSubscriptions.size());
        for (CartridgeSubscription cartridgeSubscription : cartridgeSubscriptions) {
            assertTrue(cartridgeSubscription.getAlias().equals("esba") || cartridgeSubscription.getAlias().equals("esbb"));
        }

        dataInsertionAndRetrievalManager.removeSubscriptionFromCache(1, "esba");

        cartridgeSubscriptions = dataInsertionAndRetrievalManager.getCartridgeSubscriptionForCluster("esb.domain");
        assertNotNull(cartridgeSubscriptions);
        assertEquals(1, cartridgeSubscriptions.size());
        for (CartridgeSubscription cartridgeSubscription : cartridgeSubscriptions) {
            assertTrue(cartridgeSubscription.getAlias().equals("esbb"));
        }

        dataInsertionAndRetrievalManager.removeSubscriptionFromCache(2, "esbb");
        assertNull(dataInsertionAndRetrievalManager.getCartridgeSubscriptionForCluster("esb.domain"));

        cartridgeSubscriptions = dataInsertionAndRetrievalManager.getCartridgeSubscriptionForCluster("a.esb.domain");
        assertNotNull(cartridgeSubscriptions);
        assertEquals(1, cartridgeSubscriptions.size());
        for (CartridgeSubscription cartridgeSubscription : cartridgeSubscriptions) {
            assertTrue(cartridgeSubscription.getAlias().equals("esba1"));
        }

        dataInsertionAndRetrievalManager.removeSubscriptionFromCache(1, "esba1");
        assertNull(dataInsertionAndRetrievalManager.getCartridgeSubscriptionForCluster("a.esb.domain"));

        // check for tenant 3 and alias 'phpa'
        subscription = dataInsertionAndRetrievalManager.getCartridgeSubscription(3, "phpa");
        assertNotNull(subscription);
        assertTrue(subscription.getAlias().equals("phpa"));

        dataInsertionAndRetrievalManager.removeSubscriptionFromCache(3, "phpa");
        subscription = dataInsertionAndRetrievalManager.getCartridgeSubscription(3, "phpa");
        assertNull(subscription);

        // check for tenant 3 and alias 'mysqla'
        subscription = dataInsertionAndRetrievalManager.getCartridgeSubscription(3, "mysqla");
        assertNotNull(subscription);
        assertTrue(subscription.getAlias().equals("mysqla"));

        dataInsertionAndRetrievalManager.removeSubscriptionFromCache(3, "mysqla");
        subscription = dataInsertionAndRetrievalManager.getCartridgeSubscription(3, "mysqla");
        assertNull(subscription);
View Full Code Here

            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());
            }

        } else {

            // LB ref found, get relevant LB Context data
            lbDataCtxt = CartridgeSubscriptionUtils.getLoadBalancerDataContext(subscriptionData.getTenantId(), subscriptionData.getCartridgeType(),
                    subscriptionData.getDeploymentPolicyName(), lbConfig);

            // subscribe to LB
            lbCartridgeSubscription = subscribeToLB (subscriptionData, lbDataCtxt, cartridgeInfo);

            // determine the LB cluster id, if available
            if (lbCartridgeSubscription != null) {
                lbClusterId = lbCartridgeSubscription.getClusterDomain();
            }

            lbCartridgeSubscriptionProperties =  new Properties();
            if (lbDataCtxt.getLbProperperties() != null && !lbDataCtxt.getLbProperperties().isEmpty()) {
                lbCartridgeSubscriptionProperties.setProperties(lbDataCtxt.getLbProperperties().toArray(new Property[0]));
            }
        }

        // subscribe to relevant service cartridge
        CartridgeSubscription serviceCartridgeSubscription = subscribe (subscriptionData, cartridgeInfo, lbClusterId);
        serviceCartridgeSubscriptionProperties = new Properties();

        // lb related properties
        if ((lbDataCtxt != null && lbDataCtxt.getLoadBalancedServiceProperties() != null) && !lbDataCtxt.getLoadBalancedServiceProperties().isEmpty()) {
            serviceCartridgeSubscriptionProperties.setProperties(lbDataCtxt.getLoadBalancedServiceProperties().toArray(new Property[0]));
View Full Code Here

        // set the relevant deployment policy
        loadBalancerCategory.setDeploymentPolicyName(lbDataContext.getDeploymentPolicy());

        // Create the CartridgeSubscription instance
        CartridgeSubscription cartridgeSubscription = CartridgeSubscriptionFactory.getLBCartridgeSubscriptionInstance(lbDataContext, loadBalancerCategory);

        // Generate and set the key
        String subscriptionKey = CartridgeSubscriptionUtils.generateSubscriptionKey();
        cartridgeSubscription.setSubscriptionKey(subscriptionKey);

        // Create repository
        Repository repository = cartridgeSubscription.manageRepository(null, """", false);

        // Create subscriber
        Subscriber subscriber = new Subscriber(subscriptionData.getTenantAdminUsername(), subscriptionData.getTenantId(), subscriptionData.getTenantDomain());

        // create subscription
        cartridgeSubscription.createSubscription(subscriber, lbAlias, lbDataContext.getAutoscalePolicy(),
                lbDataContext.getDeploymentPolicy(), repository);

        // add LB category to the payload
        if (cartridgeSubscription.getPayloadData() != null) {
            cartridgeSubscription.getPayloadData().add(CartridgeConstants.LB_CATEGORY, lbDataContext.getLbCategory());
        }

                // publishing to bam
               CartridgeSubscriptionDataPublisher.publish(subscriptionData.getTenantId(),
                     subscriptionData.getTenantAdminUsername(), lbAlias,
                     lbDataContext.getLbCartridgeInfo().getType(),
                     subscriptionData.getRepositoryURL(),
                     serviceCartridgeInfo.getMultiTenant(),
                     lbDataContext.getDeploymentPolicy(),
                     lbDataContext.getAutoscalePolicy(),
                     cartridgeSubscription.getCluster().getClusterDomain(),
                     cartridgeSubscription.getHostName(),
                     cartridgeSubscription.getMappedDomain(), "Subscribed");
       
        log.info("Tenant [" + subscriptionData.getTenantId() + "] with username [" + subscriptionData.getTenantAdminUsername() +
                " subscribed to " + "] Cartridge with Alias " + lbAlias + ", Cartridge Type: " + lbDataContext.getLbCartridgeInfo().getType() +
                ", Autoscale Policy: " + lbDataContext.getAutoscalePolicy() + ", Deployment Policy: " + lbDataContext.getDeploymentPolicy());
View Full Code Here

        } else {
            tenancyBehaviour = new SubscriptionSingleTenantBehaviour();
        }

        // Create the CartridgeSubscription instance
        CartridgeSubscription cartridgeSubscription = CartridgeSubscriptionFactory.getCartridgeSubscriptionInstance(cartridgeInfo, tenancyBehaviour);

        // Generate and set the key
        String subscriptionKey = CartridgeSubscriptionUtils.generateSubscriptionKey();
        cartridgeSubscription.setSubscriptionKey(subscriptionKey);
       
        String encryptedRepoPassword;
        String repositoryPassword = subscriptionData.getRepositoryPassword();
        if(repositoryPassword != null && !repositoryPassword.isEmpty()) {
          encryptedRepoPassword = RepoPasswordMgtUtil.encryptPassword(repositoryPassword, subscriptionKey);
        } else {
          encryptedRepoPassword = "";
        }

        // Create repository
        Repository repository = cartridgeSubscription.manageRepository(subscriptionData.getRepositoryURL(), subscriptionData.getRepositoryUsername(),
                encryptedRepoPassword,
                subscriptionData.isPrivateRepository());

        // Create subscriber
        Subscriber subscriber = new Subscriber(subscriptionData.getTenantAdminUsername(), subscriptionData.getTenantId(), subscriptionData.getTenantDomain());

        // set the LB cluster id relevant to this service cluster
        cartridgeSubscription.setLbClusterId(lbClusterId);

        //create subscription
        cartridgeSubscription.createSubscription(subscriber, subscriptionData.getCartridgeAlias(), subscriptionData.getAutoscalingPolicyName(),
                                                subscriptionData.getDeploymentPolicyName(), repository);

    // publishing to bam
    CartridgeSubscriptionDataPublisher.publish(
        subscriptionData.getTenantId(),
        subscriptionData.getTenantAdminUsername(),
        subscriptionData.getCartridgeAlias(),
        subscriptionData.getCartridgeType(),
        subscriptionData.getRepositoryURL(),
        cartridgeInfo.getMultiTenant(),
        subscriptionData.getAutoscalingPolicyName(),
        subscriptionData.getDeploymentPolicyName(),
        cartridgeSubscription.getCluster().getClusterDomain(),
        cartridgeSubscription.getHostName(),
        cartridgeSubscription.getMappedDomain(), "Subscribed");
       
        // Add whether the subscription is enabled upstream git commits
        if(cartridgeSubscription.getPayloadData() != null) {
            cartridgeSubscription.getPayloadData().add(CartridgeConstants.COMMIT_ENABLED, String.valueOf(subscriptionData.isCommitsEnabled()));
        }
       

        log.info("Tenant [" + subscriptionData.getTenantId() + "] with username [" + subscriptionData.getTenantAdminUsername() +
                " subscribed to " + "] Cartridge with Alias " + subscriptionData.getCartridgeAlias() + ", Cartridge Type: " +
View Full Code Here

TOP

Related Classes of org.apache.stratos.manager.subscription.CartridgeSubscription

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.