Package com.nokia.dempsy.monitoring.coda

Examples of com.nokia.dempsy.monitoring.coda.MetricGetters


            // 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();
            Thread.sleep(10);
            assertEquals(0,statsCollector.getMessageProcessorsCreated());
           
            mp.failActivation.set("test1");
            TestAdaptor adaptor = (TestAdaptor)context.getBean("adaptor");
            adaptor.pushMessage(new TestMessage("test1")); // this causes the container to clone the Mp

            assertTrue(poll(baseTimeoutMillis,mp,new Condition<TestMp>() { @Override public boolean conditionMet(TestMp mp) {  return mp.cloneCalls.get()==1; } }));
            Thread.sleep(100);
            assertEquals(0,statsCollector.getMessageProcessorsCreated());
           
            mp.failActivation.set(null);
            KeySourceImpl.pause.countDown();

            // instead of the latch we are going to poll for the correct result
            // wait for it to be received.
            assertTrue(poll(baseTimeoutMillis,mp,new Condition<TestMp>() { @Override public boolean conditionMet(TestMp mp) {  return mp.cloneCalls.get()==3; } }));
           
            assertTrue(poll(baseTimeoutMillis,statsCollector,new Condition<MetricGetters>() { @Override public boolean conditionMet(MetricGetters mg) {  return mg.getMessageProcessorsCreated()==2; } }));
            adaptor.pushMessage(new TestMessage("test1"));
            assertTrue(poll(baseTimeoutMillis,mp,new Condition<TestMp>() { @Override public boolean conditionMet(TestMp mp) {  return mp.handleCalls.get()==1; } }));
            adaptor.pushMessage(new TestMessage("test2"));
            assertTrue(poll(baseTimeoutMillis,mp,new Condition<TestMp>() { @Override public boolean conditionMet(TestMp mp) {  return mp.handleCalls.get()==2; } }));
            adaptor.pushMessage(new TestMessage("test1"));
            assertTrue(poll(baseTimeoutMillis,mp,new Condition<TestMp>() { @Override public boolean conditionMet(TestMp mp) {  return mp.handleCalls.get()==3; } }));
            adaptor.pushMessage(new TestMessage("test2"));
            assertTrue(poll(baseTimeoutMillis,mp,new Condition<TestMp>() { @Override public boolean conditionMet(TestMp mp) {  return mp.handleCalls.get()==4; } }));
            adaptor.pushMessage(new TestMessage("test1"));
            assertTrue(poll(baseTimeoutMillis,mp,new Condition<TestMp>() { @Override public boolean conditionMet(TestMp mp) {  return mp.handleCalls.get()==5; } }));
            adaptor.pushMessage(new TestMessage("test2"));

            // instead of the latch we are going to poll for the correct result
            // wait for it to be received.
            assertTrue(poll(baseTimeoutMillis,mp,new Condition<TestMp>() { @Override public boolean conditionMet(TestMp mp) {  return mp.handleCalls.get()==6; } }));
            Thread.sleep(100);
            assertEquals(6,mp.handleCalls.get());
            assertEquals(3,mp.cloneCalls.get());
            assertEquals(2,statsCollector.getMessageProcessorsCreated());
           
            // prepare for the next run
            KeySourceImpl.pause = new CountDownLatch(1);
         }
        
View Full Code Here


               // 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();

               // This will wait until the keySpace is up to the maxcount which is set (in the setup, below) to 100000
               assertTrue(poll(baseTimeoutMillis, statsCollector,
                     new Condition<MetricGetters>() { @Override public boolean conditionMet(MetricGetters sc)
                     {  return 100000 == sc.getMessageProcessorCount(); } }));

               // 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();

               session = TestUtils.stealShard(originalSession, factory, clusterId.asPath() + "/" + String.valueOf(0),baseTimeoutMillis);

               // If we got here then the MpContainer is on standby and the number of Mps should
               // drop to zero.
               assertTrue(poll(baseTimeoutMillis, statsCollector,
                     new Condition<MetricGetters>() { @Override public boolean conditionMet(MetricGetters sc)
                     { return 0 == sc.getMessageProcessorCount(); } }));
               Thread.sleep(10);
               assertEquals(0,statsCollector.getMessageProcessorCount());

               session.stop(); // this should give control back over to the original session.
               session = null;

               // If we got here then the MpContainer is no longer on standby and the number of Mps should
               // go back to the original amount.
               assertTrue(poll(baseTimeoutMillis, statsCollector,
                     new Condition<MetricGetters>() { @Override public boolean conditionMet(MetricGetters sc)
                     { return 100000 == sc.getMessageProcessorCount(); } }));
               Thread.sleep(10);
               assertEquals(100000,statsCollector.getMessageProcessorCount());
            }
            finally
            {
               if (session != null)
                  session.stop();
View Full Code Here

               // 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.
               for (int i = 0; i < 100; i++)
               {
                  ((DisruptibleSession)originalSession).disrupt();
                  Thread.sleep(1);
               }
              
               // now wait until we get to zero.
               assertTrue(poll(baseTimeoutMillis, statsCollector,
                     new Condition<MetricGetters>() { @Override public boolean conditionMet(MetricGetters sc)
                     { return 0 == sc.getMessageProcessorCount(); } }));
               Thread.sleep(10);
               assertEquals(0,statsCollector.getMessageProcessorCount());
              
               // ok. Now we will close the session that's holding the shard and allow the container
               // to re-establish control of that shard. During the KeyStore reinstantiation of the
               // MPs we will be disrupting the session.
               session.stop();
               for (int i = 0; i < 100; i++)
               {
                  ((DisruptibleSession)originalSession).disrupt();
                  Thread.sleep(1);
               }

               // Now we should get back to 100000 Mps.
               poll(baseTimeoutMillis, statsCollector,
                     new Condition<MetricGetters>() { @Override public boolean conditionMet(MetricGetters sc)
                     { return 100000 == sc.getMessageProcessorCount(); } });

               assertEquals(100000,statsCollector.getMessageProcessorCount());
            }
            finally
            {
               if (session != null)
                  session.stop();
View Full Code Here

      thread.start();
     
      Thread.sleep(50); //let it get going.
      assertFalse(evictIsComplete.get()); // check to see we're hung.

      final MetricGetters sc = (MetricGetters)container.getStatsCollector();
      assertEquals(0,sc.getMessageCollisionCount());
     
      // sending it a message will now cause it to have the collision tick up
      inputQueue.add(serializer.serialize(new ContainerTestMessage("foo")));
     
      assertTrue(TestUtils.poll(baseTimeoutMillis, sc, new TestUtils.Condition<MetricGetters>()
View Full Code Here

      thread.start();
     
      Thread.sleep(500); //let it get going.
      assertFalse(evictIsComplete.get()); // check to see we're hung.

      final MetricGetters sc = (MetricGetters)container.getStatsCollector();
      assertEquals(0,sc.getMessageCollisionCount());
     
      // sending it a message will now cause it to have the collision tick up
      inputQueue.add(serializer.serialize(new ContainerTestMessage("foo")));
     
      // give it some time.
      Thread.sleep(100);
     
      // make sure there's no collision
      assertEquals(0,sc.getMessageCollisionCount());
     
      // make sure the message didn't get through
      assertNull(outputQueue.peek());
     
      // make sure no message got handled
View Full Code Here

TOP

Related Classes of com.nokia.dempsy.monitoring.coda.MetricGetters

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.