Examples of Dempsy


Examples of com.nokia.dempsy.Dempsy

            for (long endTime = System.currentTimeMillis() + 60000; endTime > System.currentTimeMillis() && SimpleAppForTesting.grabber.get() == null;) Thread.sleep(1);
            assertNotNull(SimpleAppForTesting.grabber.get());

            assertTrue(SimpleAppForTesting.grabber.get().waitForDempsy(60000));

            Dempsy dempsy = SimpleAppForTesting.grabber.get().dempsy.get();

            // wait for Dempsy to be running
            for (long endTime = System.currentTimeMillis() + 60000; endTime > System.currentTimeMillis() && !dempsy.isRunning();) Thread.sleep(1);
            assertTrue(dempsy.isRunning());

            Thread.sleep(500); // let the thing run for a bit.

            dempsy.stop();

            // wait for Dempsy to be stopped
            for (long endTime = System.currentTimeMillis() + 60000; endTime > System.currentTimeMillis() && dempsy.isRunning();) Thread.sleep(1);
            assertFalse(dempsy.isRunning());

            assertFalse(failed);
           
         }
        
View Full Code Here

Examples of com.nokia.dempsy.Dempsy

      assertNotNull(SimpleAppForTesting.grabber.get());

      assertTrue(SimpleAppForTesting.grabber.get().waitForDempsy(60000));
      assertTrue(SimpleAppForTesting.grabber.get().waitForContext(60000));

      Dempsy dempsy = SimpleAppForTesting.grabber.get().dempsy.get();

      // wait for Dempsy to be running
      for (long endTime = System.currentTimeMillis() + 60000; endTime > System.currentTimeMillis() && !dempsy.isRunning();) Thread.sleep(1);
      assertTrue(dempsy.isRunning());

      Thread.sleep(500); // let the thing run for a bit.
     
      assertTrue(dempsy.isRunning());

      dempsy.stop();

      // wait for Dempsy to be stopped
      for (long endTime = System.currentTimeMillis() + 60000; endTime > System.currentTimeMillis() && dempsy.isRunning();) Thread.sleep(1);
      assertFalse(dempsy.isRunning());

      assertFalse(failed);
   }
View Full Code Here

Examples of com.nokia.dempsy.Dempsy

  
   @Test
   public void testStartStop() throws Throwable
   {
      ClassPathXmlApplicationContext actx = null;
      Dempsy dempsy = null;

      try
      {  
         logger.debug("Starting up the appliction context ...");
         actx = new ClassPathXmlApplicationContext(ctx);
         actx.registerShutdownHook();

         dempsy = (Dempsy)actx.getBean("dempsy");
         dempsy.start();

         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;
            }
         }));
      }
      finally
      {
         if (dempsy != null)
            dempsy.stop();

         if (actx != null)
            actx.close();

         if (dempsy != null)
            assertTrue(dempsy.waitToBeStopped(baseTimeoutMillis));
      }
   }
View Full Code Here

Examples of com.nokia.dempsy.Dempsy

  
   @Test
   public void testStartForceMpDisconnectStop() throws Throwable
   {
      ClassPathXmlApplicationContext actx = null;
      Dempsy dempsy = null;

      try
      {  
         logger.debug("Starting up the appliction context ...");
         actx = new ClassPathXmlApplicationContext(ctx);
         actx.registerShutdownHook();

         final FullApplication app = (FullApplication)actx.getBean("app");

         dempsy = (Dempsy)actx.getBean("dempsy");

         // Override the cluster session factory to keep track of the sessions asked for.
         // This is so that I can grab the ZookeeperSession that's being instantiated by
         // the MyMp cluster.
         zookeeperCluster = null;
         dempsy.setClusterSessionFactory(
               new ZookeeperSessionFactory(System.getProperty("zk_connect"), 5000)
               {
                  int sessionCount = 0;

                  @Override
                  public synchronized ClusterInfoSession createSession() throws ClusterInfoException
                  {
                     sessionCount++;
                     ClusterInfoSession ret = super.createSession();

                     if (sessionCount == 2)
                        zookeeperCluster = (ZookeeperSession)ret;
                     return ret;
                  }
               });

         dempsy.start();

         Dempsy.Application.Cluster cluster = dempsy.getCluster(new ClusterId(FullApplication.class.getSimpleName(),MyAdaptor.class.getSimpleName()));
         Dempsy.Application.Cluster.Node node = cluster.getNodes().get(0);
         final StatsCollector collector = node.getStatsCollector();

         // this checks that the throughput works.
         assertTrue(poll(baseTimeoutMillis * 5, app, new Condition<Object>()
         {
            @Override
            public boolean conditionMet(Object o)
            {
               return app.finalMessageCount.get() > 10;
            }
         }));

         assertNotNull(zookeeperCluster);

         assertEquals(0,((MetricGetters)collector).getDiscardedMessageCount());
         assertEquals(0,((MetricGetters)collector).getMessageFailedCount());

         // ok ... so now we have stuff going all the way through. let's kick
         // the middle Mp's zookeeper cluster and see what happens.
         ZooKeeper origZk = zookeeperCluster.zkref.get();
         long sessionid = origZk.getSessionId();
         ZooKeeper killer = new ZooKeeper(System.getProperty("zk_connect"),5000, new Watcher() { @Override public void process(WatchedEvent arg0) { } }, sessionid, null);
         killer.close(); // tricks the server into expiring the other session

//         // we should be getting failures now ...
//         // but it's possible that it can reconnect prior to actually seeing an error so if this
//         //   fails frequently we need to remove this test.
//         assertTrue(poll(baseTimeoutMillis, app, new Condition()
//         {
//            @Override
//            public boolean conditionMet(Object o)
//            {
//               return collector.getMessageFailedCount() > 1;
//            }
//         }));

         //... and then recover.

         // get the MyMp prototype
         cluster = dempsy.getCluster(new ClusterId(FullApplication.class.getSimpleName(),MyMp.class.getSimpleName()));
         node = cluster.getNodes().get(0);
         final MyMp prototype = (MyMp)node.getMpContainer().getPrototype();

         // so let's see where we are
         final long interimMessageCount = prototype.myMpReceived.get();

         // and now we should eventually get more as the session recovers.
         assertTrue(poll(baseTimeoutMillis * 5, app, new Condition<Object>()
         {
            @Override
            public boolean conditionMet(Object o)
            {
               return prototype.myMpReceived.get() > interimMessageCount + 100;
            }
         }));
      }
      finally
      {
         if (dempsy != null)
            dempsy.stop();
        
         if (actx != null)
            actx.close();

         if (dempsy != null)
            assertTrue(dempsy.waitToBeStopped(baseTimeoutMillis));
      }
   }
View Full Code Here

Examples of com.nokia.dempsy.Dempsy

     
      TestUtils.createClusterLevel(clusterId, session);

      // fake the inbound side setup
      inbound = strategy.createInbound(session,clusterId,
            new Dempsy(){ public List<Class<?>> gm(ClusterDefinition clusterDef) { return super.getAcceptedMessages(clusterDef); }}.gm(cd),
         destination,new RoutingStrategy.Inbound.KeyspaceResponsibilityChangeListener()
         {
           
            @Override
            public void keyspaceResponsibilityChanged(Inbound inbound, boolean less, boolean more) { }
View Full Code Here

Examples of com.nokia.dempsy.Dempsy

   {
      // check that the message didn't go through.
      ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
            "testDempsy/Dempsy.xml", "testDempsy/ClusterInfo-LocalActx.xml", "testDempsy/Serializer-KryoActx.xml",
            "testDempsy/Transport-PassthroughActx.xml", "testDempsy/SimpleMultistageApplicationActx.xml" );
      Dempsy dempsy = (Dempsy)context.getBean("dempsy");
      ClusterInfoSessionFactory factory = dempsy.getClusterSessionFactory();
      ClusterInfoSession session = factory.createSession();
      ClusterId curCluster = new ClusterId("test-app", "test-cluster1");
      TestUtils.createClusterLevel(curCluster, session);
      session.setData(curCluster.asPath(), new DecentralizedRoutingStrategy.DefaultRouterClusterInfo(20,2));
      session.stop();
      dempsy.stop();
   }
View Full Code Here

Examples of com.nokia.dempsy.Dempsy

   @Test
   public void testStartForceMpDisconnectWithStandby() throws Throwable
   {
      ClassPathXmlApplicationContext actx = null;
      Dempsy dempsy = null;
     
      try
      {
         logger.debug("Starting up the appliction context ...");
         actx = new ClassPathXmlApplicationContext(ctx);
         actx.registerShutdownHook();

         final FullApplication app = (FullApplication)actx.getBean("app");

         dempsy = (Dempsy)actx.getBean("dempsy");

         // Override the cluster session factory to keep track of the sessions asked for.
         // This is so that I can grab the ZookeeperSession that's being instantiated by
         // the MyMp cluster.
         zookeeperCluster = null;
         dempsy.setClusterSessionFactory(
               new ZookeeperSessionFactory(System.getProperty("zk_connect"), 5000)
               {
                  int sessionCount = 0;

                  @Override
                  public synchronized ClusterInfoSession createSession() throws ClusterInfoException
                  {
                     sessionCount++;
                     ClusterInfoSession ret = super.createSession();

                     if (sessionCount == 2)
                        zookeeperCluster = (ZookeeperSession)ret;
                     return ret;
                  }
               });

         dempsy.start();

         Dempsy.Application.Cluster cluster = dempsy.getCluster(new ClusterId(FullApplication.class.getSimpleName(),MyAdaptor.class.getSimpleName()));
         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 = dempsy.getCluster(new ClusterId(FullApplication.class.getSimpleName(),MyMp.class.getSimpleName()));
         Dempsy.Application.Cluster.Node mpnode = cluster.getNodes().get(0);
         // this actually hoses the output schedule. It moves it to the new node due
         //  to a second call to setOutputInvoker.
         cluster.instantiateAndStartAnotherNodeForTesting(); // the code for start instantiates a new node

         assertNotNull(zookeeperCluster);

         assertEquals(0,((MetricGetters)collector).getDiscardedMessageCount());
         assertEquals(0,((MetricGetters)collector).getMessageFailedCount());

         // ok ... so now we have stuff going all the way through. let's kick
         // the middle Mp's zookeeper cluster and see what happens.
         ZooKeeper origZk = zookeeperCluster.zkref.get();
         origZk.close(); // this should kill it.
        
         // but just to be sure actually stop the node.
         mpnode.stop();

         // we should be getting failures now ... and then recover.

         // get the MyMp prototype
         cluster = dempsy.getCluster(new ClusterId(FullApplication.class.getSimpleName(),MyMp.class.getSimpleName()));
         node = cluster.getNodes().get(1); // notice, we're getting the SECOND node.
         final MyMp prototype = (MyMp)node.getMpContainer().getPrototype();

         // so let's see where we are
         final long interimMessageCount = prototype.myMpReceived.get();

         // and now we should eventually get more as the session recovers.
         assertTrue(poll(baseTimeoutMillis * 5, app, new Condition<Object>()
         {
            @Override
            public boolean conditionMet(Object o)
            {
               return prototype.myMpReceived.get() > interimMessageCount + 100;
            }
         }));

      }
      finally
      {
         if (dempsy != null)
            dempsy.stop();
        
         if (actx != null)
            actx.close();

         if (dempsy != null)
            assertTrue(dempsy.waitToBeStopped(baseTimeoutMillis));
      }

   }
View Full Code Here

Examples of com.nokia.dempsy.Dempsy

     
      if(context != null)
      {
         try
         {
            Dempsy dempsy = context.getBean(Dempsy.class);
            if (startUp)
            {
               dempsy.start();
               dempsy.waitToBeStopped();
            }
         }
         catch(InterruptedException e)
         {
            logger.error("Interrupted . . . ", e);
View Full Code Here

Examples of com.nokia.dempsy.Dempsy

      // here is a complete non-spring, non-DI Dempsy instantiation
      //------------------------------------------------------------------------------
      List<ApplicationDefinition> ads = new ArrayList<ApplicationDefinition>();
      ads.add(ad);
     
      Dempsy dempsy = new Dempsy();
      dempsy.setApplicationDefinitions(ads);
      dempsy.setClusterCheck(new SpecificClusterCheck(clusterId));
      dempsy.setDefaultRoutingStrategy(new DecentralizedRoutingStrategy(20, 1));
      dempsy.setDefaultSerializer(new JavaSerializer<Object>());
      dempsy.setDefaultStatsCollectorFactory(new StatsCollectorFactoryCoda());
      dempsy.setDefaultTransport(new TcpTransport());
      //------------------------------------------------------------------------------

      return dempsy;
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.