Package org.apache.stratos.adc.mgt.dao

Examples of org.apache.stratos.adc.mgt.dao.CartridgeSubscription


      if (log.isDebugEnabled()) {
        log.debug("Executing query: " + sql);
      }
      resultSet = statement.executeQuery();
      while (resultSet.next()) {
        CartridgeSubscription cartridge = new CartridgeSubscription();
        cartridge.setAlias(resultSet.getString("ALIAS"));
        cartridge.setCartridge(resultSet.getString("CARTRIDGE"));
        cartridge.setState(resultSet.getString("STATE"));
        cartridge.setClusterDomain(resultSet.getString("CLUSTER_DOMAIN"));
        cartridge.setClusterSubdomain(resultSet.getString("CLUSTER_SUBDOMAIN"));
        cartridge.setProvider(resultSet.getString("PROVIDER"));
        cartridge.setPolicy(resultSet.getString("POLICY"));
        cartridge.setMappedDomain(resultSet.getString("MAPPED_DOMAIN"));
        Repository repo = new Repository();
        repo.setRepoName(resultSet.getString("REPO_NAME"));
        cartridge.setRepository(repo);
        cartridge.setHostName(resultSet.getString("HOSTNAME"));
        int dataCartridgeId = resultSet.getInt("DATA_CARTRIDGE_ID");
        if (dataCartridgeId != 0) {
          DataCartridge dataCartridge = new DataCartridge();
          dataCartridge.setDataCartridgeType(resultSet.getString("TYPE"));
          dataCartridge.setPassword(resultSet.getString("PASSWORD"));
          dataCartridge.setUserName(resultSet.getString("USER_NAME"));
          cartridge.setDataCartridge(dataCartridge);
        }
        subscribedCartridgeList.add(cartridge);
      }
    } catch (Exception s) {
      String msg = "Error while sql connection :" + s.getMessage();
View Full Code Here


    return hostName;
  }

  public static CartridgeSubscription getSubscription(String tenantDomain, String alias) throws Exception {

    CartridgeSubscription cartridgeSubscription = null;
    Connection con = null;
    PreparedStatement statement = null;
    ResultSet resultSet = null;

    try {
      con = StratosDBUtils.getConnection();
      String sql = "SELECT * FROM CARTRIDGE_SUBSCRIPTION C left join REPOSITORY R on "
          + "C.REPO_ID=R.REPO_ID left join DATA_CARTRIDGE D on "
          + "D.DATA_CART_ID=C.DATA_CARTRIDGE_ID WHERE ALIAS=? AND TENANT_DOMAIN=? AND C.STATE != 'UNSUBSCRIBED'";
      statement = con.prepareStatement(sql);
      statement.setString(1, alias);
      statement.setString(2, tenantDomain);
      if (log.isDebugEnabled()) {
        log.debug("Executing query: " + sql);
      }
      resultSet = statement.executeQuery();
      if (resultSet.next()) {
        cartridgeSubscription = new CartridgeSubscription();
        populateSubscription(cartridgeSubscription, resultSet);
      }
    } catch (Exception s) {
      String msg = "Error while sql connection :" + s.getMessage();
      log.error(msg, s);
View Full Code Here

      if (log.isDebugEnabled()) {
        log.debug("Executing query: " + sql);
      }
      resultSet = statement.executeQuery();
      while (resultSet.next()) {
        CartridgeSubscription cartridgeSubscription = new CartridgeSubscription();
        populateSubscription(cartridgeSubscription, resultSet);
        subscriptionList.add(cartridgeSubscription);
      }
    } catch (Exception s) {
      String msg = "Error while sql connection :" + s.getMessage();
View Full Code Here

    String clusterDomain = "";
        String clusterSubDomain = CartridgeConstants.DEFAULT_SUBDOMAIN;
        String mgtClusterDomain = "";
        String mgtClusterSubDomain = CartridgeConstants.DEFAULT_MGT_SUBDOMAIN;
        CartridgeSubscription subscription = null;
        String mysqlPassword = null;
        Repository repository = null;
        DataCartridge dataCartridge = null;
        String cartName = (alias != null && alias.trim().length() > 0) ? alias : cartridgeType;
        String payloadZipFileName = "/tmp/" + UUID.randomUUID().toString() + ".zip";
View Full Code Here

                                                                     String clusterSubDomain,
                                                                     String mgtClusterDomain,
                                                                     String mgtClusterSubDomain,
                                                                     DataCartridge dataCartridge) {

        CartridgeSubscription cartridgeSubscription = new CartridgeSubscription();
        cartridgeSubscription.setCartridge(cartridgeType);
        cartridgeSubscription.setAlias(cartridgeName);
        cartridgeSubscription.setClusterDomain(clusterDomain);
        cartridgeSubscription.setClusterSubdomain(clusterSubDomain);
               cartridgeSubscription.setMgtClusterDomain(mgtClusterDomain);
                cartridgeSubscription.setMgtClusterSubDomain(mgtClusterSubDomain);
        String hostName = null;
        if (cartridgeInfo.getMultiTenant()) {
            hostName = cartridgeInfo.getHostName();
        } else {
            hostName = cartridgeName + "." + cartridgeInfo.getHostName();
        }
        cartridgeSubscription.setHostName(hostName);
        if (policy != null) {
          // Policy can be null for multi-tenant cartridge
          cartridgeSubscription.setPolicy(policy.getName());
        }
        cartridgeSubscription.setRepository(repository);
        cartridgeSubscription.setPortMappings(createPortMappings(cartridgeInfo));
        cartridgeSubscription.setProvider(cartridgeInfo.getProvider());
        cartridgeSubscription.setDataCartridge(dataCartridge);
        cartridgeSubscription.setTenantId(tenantId);
        cartridgeSubscription.setTenantDomain(tenantDomain);
        cartridgeSubscription.setBaseDirectory(cartridgeInfo.getBaseDir());
        cartridgeSubscription.setState("PENDING");
        return cartridgeSubscription;
    }
View Full Code Here

            String msg = "Provided alias is empty";
            log.error(msg);
            throw new ADCException("Alias you provided is empty.");
        }

        CartridgeSubscription sub;
        try {
            sub = PersistenceManager.getSubscription(tenantDomain, alias);
        } catch (Exception e) {
            String message = "Cannot get subscription info for " + tenantDomain + " and alias " + alias;
            log.error(message, e);
            throw new ADCException(message, e);
        }
        if (sub == null) {
            String msg = "Info request for not subscribed cartridge";
            log.error(msg);
            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);
        }

        TopologyManagementService topologyMgtService = DataHolder.getTopologyMgtService();

        String[] ips =
                topologyMgtService.getActiveIPs(sub.getCartridge(),
                        sub.getClusterDomain(),
                        sub.getClusterSubdomain());
        return populateCartridgeInfo(cartridgeInfo, sub, ips, tenantDomain);
    }
View Full Code Here

     *
     * @param alias name of the cartridge to be unsubscribed
     */
    public void unsubscribe(String alias) throws ADCException, NotSubscribedException {
      checkSuperTenant();
        CartridgeSubscription subscription = null;
       
        try {
      subscription = PersistenceManager.getSubscription(tenantDomain, alias);
    } catch (Exception e) {
      String msg = "Failed to get subscription for " + tenantDomain + " and alias " + alias;
            log.error(msg, e);
      throw new ADCException(msg, e);
    }

        if (subscription == null) {
            String msg = "Tenant " + tenantDomain + " is not subscribed for " + alias;
            log.error(msg);
            throw new NotSubscribedException("You have not subscribed for " + alias, alias);
        }
       
        try {
            String clusterDomain = subscription.getClusterDomain();
            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);
                log.info("Successfully terminated instances ..");
            } else {
                if (log.isInfoEnabled()) {
                    log.info("Cartridge "
                            + subscription.getCartridge()
                            + " is a multi-tenant cartridge and therefore will not terminate all instances and unregister services");
                }
            }

            new RepositoryFactory().destroyRepository(alias, tenantDomain, getUsername());
            log.info("Repo is destroyed successfully.. ");

            PersistenceManager.updateSubscriptionState(subscription.getSubscriptionId(), "UNSUBSCRIBED");
            new DNSManager().removeSubDomain(subscription.getHostName());
            registryManager.removeDomainMappingFromRegistry(subscription.getHostName());
            TopologyManagementService topologyMgtService = DataHolder.getTopologyMgtService();
     
            String[] ips = topologyMgtService.getActiveIPs(subscription.getCartridge(),
          subscription.getClusterDomain(), subscription.getClusterSubdomain());
            PersistenceManager.updateInstanceState("INACTIVE", ips, subscription.getClusterDomain(), subscription.getClusterSubdomain(), subscription.getCartridge());

        } catch (ADCException e) {
          log.error(e.getMessage(), e);
          throw e;
        } catch (Exception e1) {
View Full Code Here

      // TODO Following was in CLI. Fix this
    //    if (domain.indexOf('.') == -1) {
    //      System.out.println("\nOwn domain should include a '.' ");
    //    }

        CartridgeSubscription subscription = null;
        String actualHost = null;
       
        try {
      subscription = PersistenceManager.getSubscription(tenantDomain, cartridgeAlias);
    } catch (Exception e) {
View Full Code Here

        ApplicationManagementUtil.getTenantId(getConfigContext()), cartridgeName);
  }

    public void removeDomainMapping(String cartridgeAlias) throws ADCException, NotSubscribedException {
      checkSuperTenant();
        CartridgeSubscription subscription = null;
        String actualHost = null;
       
        try {
      subscription = PersistenceManager.getSubscription(tenantDomain, cartridgeAlias);
    } catch (Exception e) {
View Full Code Here

        }
    }

  public void synchronizeRepository(String cartridgeAlias) throws ADCException, NotSubscribedException {
    checkSuperTenant();
        CartridgeSubscription subscription = null;
       
        // Validating subscription
        try {
      subscription = PersistenceManager.getSubscription(tenantDomain, cartridgeAlias);
    } catch (Exception e) {
View Full Code Here

TOP

Related Classes of org.apache.stratos.adc.mgt.dao.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.