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

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


                        event.getClusterId(),
                        event.getMemberId()));
            }

            // 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;
            }
            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()));
                }
View Full Code Here


                    log.warn(String.format("Service already created: [service] %s", event.getServiceName()));
                }
            } else {
             
              // Apply changes to the topology
              Service service = new Service(event.getServiceName(), event.getServiceType());
              service.addPorts(event.getPorts());
              topology.addService(service);
             
              if (log.isInfoEnabled()) {
                log.info(String.format("Service created: [service] %s", event.getServiceName()));
              }
View Full Code Here

                    return false;
                }
            }

            // 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 does not exist: [service] %s [cluster] %s",
                            event.getServiceName(),
                            event.getClusterId()));
                }
            } else {
             
              // Apply changes to the topology
              service.removeCluster(event.getClusterId());
             
              if (log.isInfoEnabled()) {
                log.info(String.format("Cluster removed from service: [service] %s [cluster] %s",
                    event.getServiceName(), event.getClusterId()));
              }
View Full Code Here

                    return false;
                }
            }

            // 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;
            }
            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()));
                }
View Full Code Here

                    return false;
                }
            }

            // 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()));
                }
View Full Code Here

                    return false;
                }
            }

            // 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;
            }
            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()));
                }
View Full Code Here

            }
            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()));
        }
      }
View Full Code Here

                    return false;
                }
            }

            // 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;
            }
            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()));
                }
View Full Code Here

            protected void onEvent(Event event) {
                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

                                    memberActivatedEvent.getServiceName(), memberActivatedEvent.getClusterId()));
                        }
                        return;
                    }
                    // Cluster not found in load balancer context, add it
                    Service service = TopologyManager.getTopology().getService(memberActivatedEvent.getServiceName());
                    if (service != null) {
                        Cluster cluster = service.getCluster(memberActivatedEvent.getClusterId());
                        if (cluster != null) {
                            LoadBalancerContextUtil.addClusterToLbContext(cluster);
                        } else {
                            if (log.isErrorEnabled()) {
                                log.error(String.format("Cluster not found in topology: [service] %s [cluster] %s",
                                        memberActivatedEvent.getServiceName(), memberActivatedEvent.getClusterId()));
                            }
                        }
                    } else {
                        if (log.isErrorEnabled()) {
                            log.error(String.format("Service not found in topology: [service] %s", memberActivatedEvent.getServiceName()));
                        }
                    }
                } catch (Exception e) {
                    log.error("Error processing event", e);
                } finally {
                    TopologyManager.releaseReadLock();
                }
            }
        });
        topologyEventReceiver.addEventListener(new ClusterRemovedEventListener() {
            @Override
            protected void onEvent(Event event) {
                try {
                    TopologyManager.acquireReadLock();

                    // Remove cluster from context
                    ClusterRemovedEvent clusterRemovedEvent = (ClusterRemovedEvent) event;
                    Cluster cluster = LoadBalancerContext.getInstance().getClusterIdClusterMap().getCluster(clusterRemovedEvent.getClusterId());
                    if (cluster != null) {
                        LoadBalancerContextUtil.removeClusterFromLbContext(cluster.getClusterId());
                    } else {
                        if (log.isWarnEnabled()) {
                            log.warn(String.format("Cluster not found in load balancer context: [service] %s [cluster] %s",
                                    clusterRemovedEvent.getServiceName(), clusterRemovedEvent.getClusterId()));
                        }
                    }
                } catch (Exception e) {
                    log.error("Error processing event", e);
                } finally {
                    TopologyManager.releaseReadLock();
                }
            }
        });
        topologyEventReceiver.addEventListener(new ServiceRemovedEventListener() {
            @Override
            protected void onEvent(Event event) {
                try {
                    TopologyManager.acquireReadLock();

                    // Remove all clusters of given service from context
                    ServiceRemovedEvent serviceRemovedEvent = (ServiceRemovedEvent) event;
                    Service service = TopologyManager.getTopology().getService(serviceRemovedEvent.getServiceName());
                    if (service != null) {
                        for (Cluster cluster : service.getClusters()) {
                            LoadBalancerContextUtil.removeClusterFromLbContext(cluster.getClusterId());
                        }
                    } else {
                        if (log.isWarnEnabled()) {
                            log.warn(String.format("Service not found in topology: [service] %s", serviceRemovedEvent.getServiceName()));
View Full Code Here

TOP

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

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.