Package org.jboss.messaging.core.impl

Examples of org.jboss.messaging.core.impl.DeliveringCounter


     
   }

   public void testDeliveringCounterNone() throws Exception
   {
      DeliveringCounter counter = new DeliveringCounter(DeliveringCounter.LEVEL_NONE);
     
      assertEquals(DeliveringCounter.LEVEL_NONE, counter.getLevel());
      Message[] mids = new Message[1000];
      for (int i = 0; i < 1000; i++)
      {
         Message m = CoreMessageFactory.createCoreMessage(i);
         counter.increment(m);
         mids[i] = m;
      }
      assertEquals(0, counter.get());
      for (int i = 0; i < 49; i++) {
         counter.decrement(mids[i]);
      }
      assertEquals(0, counter.get());
      counter.reset();
      assertEquals(0, counter.get());
   }
View Full Code Here


      assertEquals(0, counter.get());
   }

   public void testDeliveringCounterDefault() throws Exception
   {
      DeliveringCounter counter = new DeliveringCounter();
     
      assertEquals(DeliveringCounter.LEVEL_COUNTER, counter.getLevel());
      Message[] mids = new Message[1000];
      for (int i = 0; i < 1000; i++)
      {
         Message m = CoreMessageFactory.createCoreMessage(i);
         counter.increment(m);
         mids[i] = m;
      }
      assertEquals(1000, counter.get());
      for (int i = 0; i < 49; i++) {
         counter.decrement(mids[i]);
      }
      assertEquals(951, counter.get());
      counter.reset();
      assertEquals(0, counter.get());
   }
View Full Code Here

      assertEquals(0, counter.get());
   }

   public void testDeliveringCounterAll() throws Exception
   {
      DeliveringCounter counter = new DeliveringCounter(DeliveringCounter.LEVEL_ALL);
     
      assertEquals(DeliveringCounter.LEVEL_ALL, counter.getLevel());
      Message[] mids = new Message[1000];
     
      Map<Long, Message> msgs = new HashMap<Long, Message>();
     
      for (int i = 0; i < 1000; i++)
      {
         Message m = CoreMessageFactory.createCoreMessage(i);
         msgs.put(m.getMessageID(), m);
         counter.increment(m);
         mids[i] = m;
      }
      assertEquals(1000, counter.get());
      for (int i = 0; i < 49; i++) {
         counter.decrement(mids[i]);
         msgs.remove(mids[i].getMessageID());
      }
      assertEquals(951, counter.get());
      assertEquals(951, counter.getMessages().size());
     
      List inProcMsgs = counter.getMessages();
      for (Object o : inProcMsgs)
      {
         Message msg = (Message)o;
         msgs.remove(msg.getMessageID());
      }
      assertEquals(0, msgs.size());
     
      counter.reset();
      assertEquals(0, counter.get());
      assertEquals(0, counter.getMessages().size());
   }
View Full Code Here

    * When those threads finish, the counter should be empty.
    *
    */
   public void testDeliveringCounterConcurrent() throws Exception
   {
      DeliveringCounter counter = new DeliveringCounter(DeliveringCounter.LEVEL_ALL);
     
      assertEquals(DeliveringCounter.LEVEL_ALL, counter.getLevel());
      final int numMsg = 50000;
      Message[] mids = new Message[numMsg];
     
      final ConcurrentLinkedQueue<Message> msgs1 = new ConcurrentLinkedQueue<Message>();
      final ConcurrentLinkedQueue<Message> msgs2 = new ConcurrentLinkedQueue<Message>();
     
      for (int i = 0; i < numMsg; i++)
      {
         Message m = CoreMessageFactory.createCoreMessage(i);
         msgs1.add(m);
         msgs2.add(m);
      }
     
      final int numThr = 5;
      //create putter threads
      Thread[] putters = new PutterThread[numThr];
      Thread[] takers = new TakerThread[numThr];
     
      for (int i = 0; i < numThr; i++) {
         putters[i] = new PutterThread(counter, msgs1, i);
         takers[i] = new TakerThread(counter, msgs2, i);
         putters[i].start();
         takers[i].start();
      }
     
      for (int i = 0; i < numThr; i++) {
         putters[i].join();
         takers[i].join();
      }

      List msgs = counter.getMessages();
      assertEquals(0, msgs.size());
      assertEquals(0, counter.get());
   }
View Full Code Here

TOP

Related Classes of org.jboss.messaging.core.impl.DeliveringCounter

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.