Package com.nokia.dempsy.config

Examples of com.nokia.dempsy.config.ClusterId


            try
            {
               // start things and verify that the init method was called
               Dempsy dempsy = (Dempsy)context.getBean("dempsy");
               TestMp mp = (TestMp) getMp(dempsy, "test-app","test-cluster1");
               final ClusterId clusterId = new ClusterId("test-app","test-cluster1");

               // verify we haven't called it again, not that there's really
               // a way to given the code
               assertEquals(1, mp.startCalls.get());

               // make sure that there are no Mps
               MetricGetters statsCollector = (MetricGetters)dempsy.getCluster(new ClusterId("test-app","test-cluster1")).getNodes().get(0).getStatsCollector();

               assertTrue(poll(baseTimeoutMillis, statsCollector,
                     new Condition<MetricGetters>() { @Override public boolean conditionMet(MetricGetters sc)
                     {  return 100000 == sc.getMessageProcessorCount(); } }));
              
               // now there's 100000 mps in the container created from the KeySource. So we steal the
               // shard and force if offline but continuously disrupt it while it tries to come
               // back up.

               // now push the cluster into backup node.
               ClusterInfoSession originalSession = dempsy.getCluster(new ClusterId("test-app","test-cluster1")).getNodes().get(0).retouRteg().getClusterSession();
               ClusterInfoSessionFactory factory = dempsy.getClusterSessionFactory();

               String path = clusterId.asPath() + "/" + String.valueOf(0);
               session = TestUtils.stealShard(originalSession, factory, path,baseTimeoutMillis);
               DefaultRouterSlotInfo si = (DefaultRouterSlotInfo)session.getData(path, null);
               assertTrue(si.getDestination() instanceof JunkDestination); // checks to see who actually has the slot.

               // we will keep disrupting the session but we should still end up with zero mps.
View Full Code Here


      return ret;
   }
  
   public static StatsCollector getStatsCollector(Dempsy dempsy, String appName, String clusterName)
   {
      Dempsy.Application.Cluster cluster = dempsy.getCluster(new ClusterId(appName,clusterName));
      Dempsy.Application.Cluster.Node node = cluster.getNodes().get(0); // currently there is one node per cluster.
      return node.statsCollector;
   }
View Full Code Here

         for (Dempsy.Application app : dempsy.applications)
         {
            for (Dempsy.Application.Cluster cluster : app.appClusters)
            {
               if (!cluster.clusterDefinition.isRouteAdaptorType())
                  clusters.add(new ClusterId(cluster.clusterDefinition.getClusterId()));
              
               List<Dempsy.Application.Cluster.Node> nodes = cluster.getNodes();
               for (Dempsy.Application.Cluster.Node node : nodes)
                  routers.add(node.retouRteg());
            }
View Full Code Here

//----------------------------------------------------------------------------
  
   public MpContainer setupContainer(Object prototype) throws ContainerException
   {
      DummyDispatcher dispatcher = new DummyDispatcher();
      StatsCollector stats = new StatsCollectorCoda(new ClusterId("test", "test"), new StatsCollectorFactoryCoda().getNamingStrategy());
      JavaSerializer<Object> serializer = new JavaSerializer<Object>();

      manager = new MpContainer(new ClusterId("test","test"));
      manager.setDispatcher(dispatcher);
      manager.setStatCollector(stats);
      manager.setSerializer(serializer);
      manager.setPrototype(prototype);
      return manager;
View Full Code Here

   {
      tearDown();
      System.setProperty(StatsCollectorFactoryCoda.environmentPrefixSystemPropertyName,"Hello.");
      setUp();
      StatsCollectorFactoryCoda.MetricNamingStrategy strategy = statsCollectorFactory.getNamingStrategy();
      ClusterId clusterId = new ClusterId("app","cluster");
      MetricName name = strategy.createName(clusterId, "metric");

      assertEquals("metric", name.getName());
      assertEquals("app-cluster", name.getGroup());
      assertTrue(strategy.buildPrefix(clusterId, new Destination() { @Override public String toString() { return "destination"; } }).startsWith("Hello."));
View Full Code Here

   private int sequence = 0;
  
   @Before
   public void setUp() throws Exception
   {
      ClusterId cid = new ClusterId("TestMpContainerLoadHandling", "test" + sequence++);
      dispatcher = new MockDispatcher();

      StatsCollectorCoda sc = new StatsCollectorCoda(cid, new StatsCollectorFactoryCoda().getNamingStrategy());
      stats = sc;
      JavaSerializer<Object> serializer = new JavaSerializer<Object>();
View Full Code Here

         // the createExpireSessionClient actually results in a Disconnected/SyncConnected rotating events.
         // ... so we need to filter those out since it will result in a callback.
         session =  new ZookeeperSession("127.0.0.1:" + port,5000);

         final ClusterId clusterId = new ClusterId(appname,"testSessionExpired");
         createClusterLevel(clusterId,session);
         TestWatcher callback = new TestWatcher(session)
         {
            @Override
            public void process()
            {
               try
               {
                  called.set(true);
                  logger.trace("process called on TestWatcher.");
                  session.exists(clusterId.asPath(), this);
                  session.getSubdirs(clusterId.asPath(), this);
               }
               catch (ClusterInfoException cie)
               {
                  throw new RuntimeException(cie);
               }
            }
         };
        
         // now see if the cluster works.
         callback.process(); // this registers the session with the callback as the Watcher
        
         // now reset the condition
         callback.called.set(false);
        
         ZookeeperTestServer.forceSessionExpiration(session.zkref.get());

         // we should see the session expiration in a callback
         assertTrue(poll(5000,callback,new Condition<TestWatcher>() {  @Override public boolean conditionMet(TestWatcher o) {  return o.called.get(); } }));
        
         // and eventually a reconnect
         assertTrue(poll(5000,callback,new Condition<TestWatcher>()
         { 
            @Override public boolean conditionMet(TestWatcher o)
            {
               try
               {
                  o.process();
                  return true;
               }
               catch (Throwable th)
               {
                  return false;
               }
            }
         }));
        
         createClusterLevel(clusterId,session);
         assertTrue(session.exists(clusterId.asPath(), callback));
      }
      finally
      {
         if (server != null)
            server.shutdown();
View Full Code Here

         final FullApplication app = new FullApplication();
         ApplicationDefinition ad = app.getTopology();

         assertEquals(0,processCount.intValue()); // no calls yet

         dempsy[0] = getDempsyFor(new ClusterId(FullApplication.class.getSimpleName(),FullApplication.MyAdaptor.class.getSimpleName()),ad);
         dempsy[0].setClusterSessionFactory(new ZookeeperSessionFactory("127.0.0.1:" + port,5000));

         dempsy[1] = getDempsyFor(new ClusterId(FullApplication.class.getSimpleName(),FullApplication.MyMp.class.getSimpleName()),ad);
         dempsy[1].setClusterSessionFactory(new ZookeeperSessionFactory("127.0.0.1:" + port,5000));

         dempsy[2] = getDempsyFor(new ClusterId(FullApplication.class.getSimpleName(),FullApplication.MyRankMp.class.getSimpleName()),ad);
//         dempsy[2].setClusterSessionFactory(new ZookeeperSessionFactory<ClusterInformation, SlotInformation>("127.0.0.1:" + port,5000));
        
         dempsy[2].setClusterSessionFactory(new ClusterInfoSessionFactory()
         {
           
View Full Code Here

               return super.makeZooKeeperClient(connectString, sessionTimeout);
            }
         };
         sessiong = session;
        
         final ClusterId clusterId = new ClusterId(appname,"testRecoverWithIOException");
         TestUtils.createClusterLevel(clusterId, session);
         TestWatcher callback = new TestWatcher(session)
         {
            @Override public void process()
            {
               try {
                  session.getSubdirs(clusterId.asPath(),this);
                  called.set(true);
               }
               catch (ClusterInfoException cie) { throw new RuntimeException(cie); }
            }
         };
        
         callback.process();
        
         // force the ioexception to happen
         forceIOException.set(true);
        
         ZookeeperTestServer.forceSessionExpiration(session.zkref.get());
        
         // now in the background it should be retrying but hosed.
         assertTrue(forceIOExceptionLatch.await(baseTimeoutMillis * 3, TimeUnit.MILLISECONDS));

         // now the getActiveSlots call should fail since i'm preventing the recovery by throwing IOExceptions
         assertTrue(TestUtils.poll(baseTimeoutMillis, clusterId, new Condition<ClusterId>()
         {
            @Override
            public boolean conditionMet(ClusterId o) throws Throwable {
               try { session.mkdir(o.asPath() + "/join-1", null, DirMode.EPHEMERAL); return false; } catch (ClusterInfoException e) { return true; }
            }
         }));
        
         callback.called.set(false); // reset the callbacker ...
        
         // now we should allow the code to proceed.
         forceIOException.set(false);
        
         // wait for the callback
         assertTrue(poll(baseTimeoutMillis,callback,new Condition<TestWatcher>() { @Override public boolean conditionMet(TestWatcher o) { return o.called.get(); } }));
        
         // this should eventually recover.
         assertTrue(TestUtils.poll(baseTimeoutMillis, clusterId, new Condition<ClusterId>()
         {
            @Override
            public boolean conditionMet(ClusterId o) throws Throwable {
               try { TestUtils.createClusterLevel(o, session); session.mkdir(o.asPath() + "/join-1", null, DirMode.EPHEMERAL); return true; } catch (ClusterInfoException e) { return false; }
            }
         }));
        
         session.getSubdirs(clusterId.asPath(),callback);
        
         // And join should work
         // And join should work
         assertTrue(TestUtils.poll(baseTimeoutMillis,clusterId , new Condition<ClusterId>()
         {
View Full Code Here

   public void init() throws Throwable
   {
      onodes = System.setProperty("min_nodes_for_cluster", "1");
      oslots = System.setProperty("total_slots_for_cluster", "20");

      final ClusterId clusterId = new ClusterId("test", "test-slot");
      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();
View Full Code Here

TOP

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

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.