Package com.nokia.dempsy.config

Examples of com.nokia.dempsy.config.ClusterDefinition


      Map<ClusterId, ClusterDefinition> defs = new HashMap<ClusterId, ClusterDefinition>();
      for (ClusterDefinition clusterDef : applicationDefinition.getClusterDefinitions())
         defs.put(clusterDef.getClusterId(), clusterDef);
     
      // now see about the one that we are.
      ClusterDefinition currentClusterDef = null;
      if (currentCluster != null)
      {
         currentClusterDef = defs.get(currentCluster);
         if (currentClusterDef == null)
            throw new DempsyException("This Dempsy instance seems to be misconfigured. While this VM thinks it's an instance of " +
                  currentCluster + " the application it's configured with doesn't contain this cluster definition. The application configuration consists of: " +
                  applicationDefinition);
      }

      // get the set of explicit destinations if they exist
      Set<ClusterId> explicitClusterDestinations =
            (currentClusterDef != null && currentClusterDef.hasExplicitDestinations()) ? new HashSet<ClusterId>() : null;
      if (explicitClusterDestinations != null)
         explicitClusterDestinations.addAll(Arrays.asList(currentClusterDef.getDestinations()));

      //-------------------------------------------------------------------------------------
      // TODO: This loop will eventually be replaced when the instantiation of the Outbound
      // is driven from cluster information management events (Zookeeper callbacks).
      //-------------------------------------------------------------------------------------
View Full Code Here


        
         ClusterId clusterId = outbound.getClusterId();
         if (classes != null && classes.size() > 0)
         {
            // find the appropriate ClusterDefinition
            ClusterDefinition curClusterDef = applicationDefinition.getClusterDefinition(clusterId);
           
            if (curClusterDef != null)
            {
               // create a corresponding ClusterRouter
               @SuppressWarnings("unchecked")
               ClusterRouter clusterRouter = new ClusterRouter((Serializer<Object>)curClusterDef.getSerializer(),outbound);
           
               for (Class<?> clazz : classes)
               {
                  Set<ClusterRouter> cur = Collections.newSetFromMap(new ConcurrentHashMap<ClusterRouter, Boolean>()); // potential
                  Set<ClusterRouter> tmp = routerMap.putIfAbsent(clazz, cur);
View Full Code Here

      Destination destination = new Destination() {};
      ApplicationDefinition app = new ApplicationDefinition(clusterId.getApplicationName());
      DecentralizedRoutingStrategy strategy = new DecentralizedRoutingStrategy(1, 1);
      app.setRoutingStrategy(strategy);
      app.setSerializer(new JavaSerializer<Object>());
      ClusterDefinition cd = new ClusterDefinition(clusterId.getMpClusterName());
      cd.setMessageProcessorPrototype(new GoodTestMp());
      app.add(cd);
      app.initialize();
     
      LocalClusterSessionFactory mpfactory = new LocalClusterSessionFactory();
      ClusterInfoSession session = mpfactory.createSession();
View Full Code Here

         ad.initialize();

         List<ClusterDefinition> clusters = ad.getClusterDefinitions();
         for (int i = clusters.size() - 1; i >= 0; i--)
         {
            ClusterDefinition cluster = clusters.get(i);
            CheckCluster.toCheckAgainst = cluster.getClusterId();

            DempsyHolder cur = new DempsyHolder();
            cur.clusterid = cluster.getClusterId();
            cur.actx = new ClassPathXmlApplicationContext(ctx);
            cur.actx.registerShutdownHook();
            cur.dempsy =  (Dempsy)cur.actx.getBean("dempsy");
            cur.dempsy.start();
            dempsys.put(cluster.getClusterId(), cur);
         }

         // get the last FullApplication in the processing chain.
         ClassPathXmlApplicationContext actx = dempsys.get(new ClusterId(FullApplication.class.getSimpleName(),MyRankMp.class.getSimpleName())).actx;
         final FullApplication app = (FullApplication)actx.getBean("app");
View Full Code Here

         ad.initialize();

         List<ClusterDefinition> clusters = ad.getClusterDefinitions();
         for (int i = clusters.size() - 1; i >= 0; i--)
         {
            ClusterDefinition cluster = clusters.get(i);
            CheckCluster.toCheckAgainst = cluster.getClusterId();

            DempsyHolder cur = new DempsyHolder();
            cur.clusterid = cluster.getClusterId();
            cur.actx = new ClassPathXmlApplicationContext(ctx);
            cur.actx.registerShutdownHook();
            cur.dempsy =  (Dempsy)cur.actx.getBean("dempsy");
            cur.dempsy.start();
            dempsys.put(cluster.getClusterId(), cur);
         }
        
         // get the last FullApplication in the processing chain.
         ClassPathXmlApplicationContext actx = dempsys.get(new ClusterId(FullApplication.class.getSimpleName(),MyRankMp.class.getSimpleName())).actx;
         final FullApplication app = (FullApplication)actx.getBean("app");

         // this checks that the throughput works.
         assertTrue(poll(baseTimeoutMillis * 5, app, new Condition<Object>()
         {
            @Override
            public boolean conditionMet(Object o)
            {
               return app.finalMessageCount.get() > 100;
            }
         }));
        
         // now start another MyMp cluster.
         spare = new DempsyHolder();
         spare.clusterid = new ClusterId(FullApplication.class.getSimpleName(),MyMp.class.getSimpleName());
         CheckCluster.toCheckAgainst = spare.clusterid;
         spare.actx = new ClassPathXmlApplicationContext(ctx);
         spare.dempsy = (Dempsy)spare.actx.getBean("dempsy");
         spare.dempsy.start();

         Dempsy.Application.Cluster cluster = spare.dempsy.getCluster(spare.clusterid);
         Dempsy.Application.Cluster.Node node = cluster.getNodes().get(0);
         final StatsCollector collector = node.getStatsCollector();
        
         // we are going to create another node of the MyMp via a test hack
         cluster = spare.dempsy.getCluster(new ClusterId(FullApplication.class.getSimpleName(),MyMp.class.getSimpleName()));
         node = cluster.getNodes().get(0);
         final MyMp spareprototype = (MyMp)node.getMpContainer().getPrototype();

         // TODO, see if we really need that check, and if so, implement
         // an alternate way to get it, since with the stats collector rework
         // we no longer use an independent MetricsRegistry per StatsCollector
View Full Code Here

   }
  
   public ApplicationDefinition getTopology() throws DempsyException
   {
      ApplicationDefinition ret = new ApplicationDefinition(FullApplication.class.getSimpleName()).
            add(new ClusterDefinition(MyAdaptor.class.getSimpleName()).setAdaptor(new MyAdaptor())).
            add(new ClusterDefinition(MyMp.class.getSimpleName()).setMessageProcessorPrototype(new MyMp()).setOutputExecuter(new RelativeOutputSchedule(1, TimeUnit.SECONDS))).
            add(new ClusterDefinition(MyRankMp.class.getSimpleName()).setMessageProcessorPrototype(new MyRankMp()));
     
      return ret;
   }
View Full Code Here

TOP

Related Classes of com.nokia.dempsy.config.ClusterDefinition

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.