Package org.apache.stratos.messaging.domain.topology

Examples of org.apache.stratos.messaging.domain.topology.Cluster


                    log.warn(String.format("Service does not exist: [service] %s",
                            event.getServiceName()));
                }
                return false;
            }
            Cluster cluster = service.getCluster(event.getClusterId());
            if (cluster == null) {
                if (log.isWarnEnabled()) {
                    log.warn(String.format("Cluster does not exist: [service] %s [cluster] %s",
                            event.getServiceName(), event.getClusterId()));
                }
                return false;
            }
            Member member = cluster.getMember(event.getMemberId());
            if (member == null) {
                if (log.isWarnEnabled()) {
                    log.warn(String.format("Member does not exist: [service] %s [cluster] %s [member] %s",
                            event.getServiceName(),
                            event.getClusterId(),
View Full Code Here


                if (log.isWarnEnabled()) {
                    log.warn(String.format("Service does not exist: [service] %s", event.getServiceName()));
                }
                return false;
            }
            Cluster cluster = service.getCluster(event.getClusterId());
            if (cluster == null) {
                if (log.isWarnEnabled()) {
                    log.warn(String.format("Cluster does not exist: [service] %s [cluster] %s",
                            event.getServiceName(), event.getClusterId()));
                }
                return false;
            }
            Member member = cluster.getMember(event.getMemberId());
            if (member == null) {
                if (log.isWarnEnabled()) {
                    log.warn(String.format("Member does not exist: [service] %s [cluster] %s [member] %s",
                            event.getServiceName(),
                            event.getClusterId(),
View Full Code Here

                    log.warn(String.format("Service does not exist: [service] %s",
                            event.getServiceName()));
                }
                return false;
            }
            Cluster cluster = service.getCluster(event.getClusterId());
            if (cluster == null) {
                if (log.isWarnEnabled()) {
                    log.warn(String.format("Cluster does not exist: [service] %s [cluster] %s",
                            event.getServiceName(), event.getClusterId()));
                }
                return false;
            }
            Member member = cluster.getMember(event.getMemberId());
            if (member == null) {
                if (log.isWarnEnabled()) {
                    log.warn(String.format("Member does not exist: [service] %s [cluster] %s [member] %s",
                            event.getServiceName(),
                            event.getClusterId(),
View Full Code Here

                    return false;
                }
            }

            // Validate event properties
            Cluster cluster = event.getCluster();
            if(cluster == null) {
                String msg = "Cluster object of cluster created event is null.";
                log.error(msg);
                throw new RuntimeException(msg);
            }
            if (cluster.getHostNames().isEmpty()) {
                throw new RuntimeException("Host name/s not found in cluster created event");
            }
            // Validate event against the existing topology
            Service service = topology.getService(event.getServiceName());
            if (service == null) {
                if (log.isWarnEnabled()) {
                    log.warn(String.format("Service does not exist: [service] %s",
                            event.getServiceName()));
                }
                return false;
            }
            if (service.clusterExists(event.getClusterId())) {
                if (log.isWarnEnabled()) {
                    log.warn(String.format("Cluster already exists in service: [service] %s [cluster] %s", event.getServiceName(),
                            event.getClusterId()));
                }
      } else {

        // Apply changes to the topology
        service.addCluster(cluster);
        if (log.isInfoEnabled()) {
          log.info(String.format("Cluster created: %s",
              cluster.toString()));
        }
      }

            // Notify event listeners
            notifyEventListeners(event);
View Full Code Here

                if (log.isWarnEnabled()) {
                    log.warn(String.format("Service does not exist: [service] %s", event.getServiceName()));
                }
                return false;
            }
            Cluster cluster = service.getCluster(event.getClusterId());
            if (cluster == null) {
                if (log.isWarnEnabled()) {
                    log.warn(String.format("Cluster does not exist: [service] %s [cluster] %s",
                            event.getServiceName(), event.getClusterId()));
                }
                return false;
            }
            Member member = cluster.getMember(event.getMemberId());
            if(member != null) {
                // Apply member filter
                if(TopologyMemberFilter.getInstance().isActive()) {
                    if(TopologyMemberFilter.getInstance().lbClusterIdExcluded(member.getLbClusterId())) {
                        if (log.isDebugEnabled()) {
                            log.debug(String.format("Member is excluded: [lb-cluster-id] %s", member.getLbClusterId()));
                        }
                        return false;
                    }
                }
            }

            if (member == null) {
                if (log.isWarnEnabled()) {
                    log.warn(String.format("Member already terminated: [service] %s [cluster] %s [member] %s",
                            event.getServiceName(),
                            event.getClusterId(),
                            event.getMemberId()));
                }
            } else {
              // Remove member from the cluster
              cluster.removeMember(member);
             
              if (log.isInfoEnabled()) {
                log.info(String.format("Member terminated: [service] %s [cluster] %s [member] %s",
                    event.getServiceName(),
                    event.getClusterId(),
View Full Code Here

                try {
                    log.info("Event received: " + event);
                    ClusterCreatedEvent e = (ClusterCreatedEvent) event;
                    TopologyManager.acquireReadLock();
                    Service service = TopologyManager.getTopology().getService(e.getServiceName());
                    Cluster cluster = service.getCluster(e.getClusterId());
                    startClusterMonitor(cluster);
                } catch (Exception e) {
                    log.error("Error processing event", e);
                } finally {
                    TopologyManager.releaseReadLock();
View Full Code Here

        for(Service service : services) {
            String tenantRange = service.getTenantRange();
            if(tenantRange.equals(Constants.TENANT_RANGE_ALL)) {
                //check whether any active instances found for this service in the Topology

                Cluster cluster = TopologyManager.getTopology().getService(service.getType()).
                                        getCluster(service.getClusterId());
                boolean activeMemberFound = false;
                for(Member member : cluster.getMembers()) {
                    if(member.isActive()) {
                        activeMemberFound = true;
                        break;
                    }
                }
View Full Code Here

                    }
                    Cartridge cartridge = getCartridgeFromSubscription(subscription);
                    if (cartridge == null) {
                    continue;
                  }
                    Cluster cluster = TopologyClusterInformationModel.getInstance().getCluster(ApplicationManagementUtil.getTenantId(configurationContext)
                            ,cartridge.getCartridgeType(), cartridge.getCartridgeAlias());
                    String cartridgeStatus = "Inactive";
                    int activeMemberCount = 0;
          if (cluster != null) {
            Collection<Member> members = cluster.getMembers();
            for (Member member : members) {
              if (member.isActive()) {
                cartridgeStatus = "Active";
                activeMemberCount++;
              }
View Full Code Here

      if (cartridge == null) {
        String message = "Unregistered [alias]: "+cartridgeAlias+"! Please enter a valid alias.";
        log.error(message);
      throw new RestAPIException(Response.Status.NOT_FOUND, message);
      }
        Cluster cluster = TopologyClusterInformationModel.getInstance().getCluster(ApplicationManagementUtil.getTenantId(configurationContext)
                ,cartridge.getCartridgeType(), cartridge.getCartridgeAlias());
        String cartridgeStatus = "Inactive";
        int activeMemberCount = 0;

        // cluster might not be created yet, so need to check
        if (cluster != null) {
            Collection<Member> members = cluster.getMembers();
            if (members != null ) {
                for (Member member : members) {
                    if(member.isActive()) {
                        cartridgeStatus = "Active";
                        activeMemberCount++;
View Full Code Here

     
    }

    static int getActiveInstances(String cartridgeType, String cartridgeAlias, ConfigurationContext configurationContext) throws RestAPIException {
      int noOfActiveInstances = 0;
        Cluster cluster = TopologyClusterInformationModel.getInstance().getCluster(ApplicationManagementUtil.getTenantId(configurationContext)
                ,cartridgeType , cartridgeAlias);
       
        if(cluster == null) {
          String message = "No Cluster found for cartridge [type] "+cartridgeType+", [alias] "+cartridgeAlias;
      log.error(message);
      throw new RestAPIException(message);
        }
       
        for(Member member : cluster.getMembers()) {
            if(member.getStatus().toString().equals(MemberStatus.Activated)) {
                noOfActiveInstances ++;
            }
        }
    return noOfActiveInstances;
View Full Code Here

TOP

Related Classes of org.apache.stratos.messaging.domain.topology.Cluster

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.