Package org.hornetq.core.paging.cursor

Examples of org.hornetq.core.paging.cursor.PagedReference


         msg.getBodyBuffer().writeBytes(buffer, 0, buffer.writerIndex());

         Assert.assertTrue(pageStore.page(msg, ctx, ctx.getContextListing(ADDRESS)));

         PagedReference readMessage = iterator.next();

         assertNotNull(readMessage);

         assertEquals(i, readMessage.getMessage().getIntProperty("key").intValue());

         assertNull(iterator.next());
      }

      OperationContextImpl.clearContext();
     
      ctx = generateCTX();

      pageStore = lookupPageStore(ADDRESS);

      cursor = this.server.getPagingManager().getPageStore(ADDRESS).getCursorProvier().getSubscription(queue.getID());
      iterator = cursor.iterator();

      for (int i = 0; i < NUM_MESSAGES * 2; i++)
      {
         if (i % 100 == 0)
            System.out.println("Paged " + i);

         if (i >= NUM_MESSAGES)
         {

            HornetQBuffer buffer = RandomUtil.randomBuffer(messageSize, i + 1l);

            ServerMessage msg = new ServerMessageImpl(i, buffer.writerIndex());
            msg.putIntProperty("key", i);

            msg.getBodyBuffer().writeBytes(buffer, 0, buffer.writerIndex());

            Assert.assertTrue(pageStore.page(msg, ctx, ctx.getContextListing(ADDRESS)));
         }

         PagedReference readMessage = iterator.next();

         assertNotNull(readMessage);

         assertEquals(i, readMessage.getMessage().getIntProperty("key").intValue());
      }

      OperationContextImpl.clearContext();

      pageStore = lookupPageStore(ADDRESS);

      cursor = this.server.getPagingManager().getPageStore(ADDRESS).getCursorProvier().getSubscription(queue.getID());
      iterator = cursor.iterator();

      for (int i = 0; i < NUM_MESSAGES * 3; i++)
      {
         if (i % 100 == 0)
            System.out.println("Paged " + i);

         if (i >= NUM_MESSAGES * 2 - 1)
         {

            HornetQBuffer buffer = RandomUtil.randomBuffer(messageSize, i + 1l);

            ServerMessage msg = new ServerMessageImpl(i, buffer.writerIndex());
            msg.putIntProperty("key", i + 1);

            msg.getBodyBuffer().writeBytes(buffer, 0, buffer.writerIndex());

            Assert.assertTrue(pageStore.page(msg, ctx, ctx.getContextListing(ADDRESS)));
         }

         PagedReference readMessage = iterator.next();

         assertNotNull(readMessage);

         cursor.ack(readMessage);

         assertEquals(i, readMessage.getMessage().getIntProperty("key").intValue());
      }

      PagedReference readMessage = iterator.next();

      assertEquals(NUM_MESSAGES * 3, readMessage.getMessage().getIntProperty("key").intValue());

      cursor.ack(readMessage);

      server.getStorageManager().waitOnOperations();

View Full Code Here


      LinkedListIterator<PagedReference> iterator = cursor.iterator();
     
      for (int i = 0 ; i < TOTAL_MSG; i++ )
      {
         assertEquals(0, exceptions.get());
         PagedReference ref = null;
         for (int repeat = 0 ; repeat < 5; repeat++)
         {
            ref = iterator.next();
            if (ref == null)
            {
               Thread.sleep(1000);
            }
            else
            {
               break;
            }
         }
         assertNotNull(ref);
        
         ref.acknowledge();
         assertNotNull(ref);
        
         System.out.println("Consuming " + ref.getMessage().getIntProperty("key"));
         //assertEquals(i, ref.getMessage().getIntProperty("key").intValue());
      }

      assertEquals(0, exceptions.get());
   }
View Full Code Here

      System.out.println("Number of pages - " + pageStore.getNumberOfPages());

      // First consume what's already there without any tx as nothing was committed
      for (int i = 300; i < 400; i++)
      {
         PagedReference pos = iterator.next();
         assertNotNull("Null at position " + i, pos);
         assertEquals(i, pos.getMessage().getIntProperty("key").intValue());
         cursor.ack(pos);
      }

      assertNull(iterator.next());

      cursor.printDebug();
      txCommit.commit();

      txRollback.rollback();
     
      storage.waitOnOperations();

      // Second:after pgtxCommit was done
      for (int i = 200; i < 300; i++)
      {
         PagedReference pos = iterator.next();
         assertNotNull(pos);
         assertEquals(i, pos.getMessage().getIntProperty("key").intValue());
         cursor.ack(pos);
      }

      assertNull(iterator.next());
     
View Full Code Here

      System.out.println("Number of pages - " + pageStore.getNumberOfPages());

      // First consume what's already there without any tx as nothing was committed
      for (int i = 100; i < 200; i++)
      {
         PagedReference pos = iterator.next();
         assertNotNull("Null at position " + i, pos);
         assertEquals(i, pos.getMessage().getIntProperty("key").intValue());
         cursor.ack(pos);
      }

      assertNull(iterator.next());
     
      txLazy.commit();
     
      storage.waitOnOperations();

      for (int i = 0; i < 100; i++)
      {
         PagedReference pos = iterator.next();
         assertNotNull("Null at position " + i, pos);
         assertEquals(i, pos.getMessage().getIntProperty("key").intValue());
         cursor.ack(pos);
      }

      assertNull(iterator.next());
View Full Code Here

      cache = null;

      LinkedListIterator<PagedReference> iterator = cursor.iterator();

      PagedReference msgCursor = null;
      while ((msgCursor = iterator.next()) != null)
      {
         assertEquals(key++, msgCursor.getMessage().getIntProperty("key").intValue());
      }
      assertEquals(NUM_MESSAGES, key);

      server.stop();

      OperationContextImpl.clearContext();

      createServer();

      cursorProvider = lookupCursorProvider();
      cursor = cursorProvider.getSubscription(queue.getID());
      key = initialKey;
      iterator = cursor.iterator();
      while ((msgCursor = iterator.next()) != null)
      {
         assertEquals(key++, msgCursor.getMessage().getIntProperty("key").intValue());
         cursor.ack(msgCursor);
      }

      forceGC();
View Full Code Here

     
      LinkedListIterator<PagedReference> iter2 = cursor.iterator();
     
      assertTrue(iter.hasNext());
     
      PagedReference msg1 = iter.next();
     
      PagedReference msg2 = iter2.next();
     
      assertEquals(tstProperty(msg1.getMessage()), tstProperty(msg2.getMessage()));
     
      System.out.println("property = " + tstProperty(msg1.getMessage()));

      msg1 = iter.next();
     
      assertEquals(1, tstProperty(msg1.getMessage()));
     
      iter.remove();
     
      msg2 = iter2.next();
     
      assertEquals(2, tstProperty(msg2.getMessage()));
     
      iter2.repeat();
     
      msg2 = iter2.next();
     
      assertEquals(2, tstProperty(msg2.getMessage()));
     
      iter2.repeat();
     
      assertEquals(2, tstProperty(msg2.getMessage()));
     
      msg1 = iter.next();
     
      assertEquals(2, tstProperty(msg1.getMessage()));
     
View Full Code Here

      public synchronized PagedReference next()
      {

         if (cachedNext != null)
         {
            PagedReference retPos = cachedNext;
            cachedNext = null;
            return retPos;
         }

         try
View Full Code Here

      {
         synchronized (PageSubscriptionImpl.this)
         {
            boolean match = false;

            PagedReference message = null;

            PagePosition lastPosition = position;
            PagePosition tmpPosition = position;

            do
            {
               synchronized (redeliveries)
               {
                  PagePosition redelivery = redeliveries.poll();

                  if (redelivery != null)
                  {
                     // There's a redelivery pending, we will get it out of that pool instead
                     isredelivery = true;
                     PagedReference redeliveredMsg = getReference(redelivery);
                     lastRedelivery = redeliveredMsg;

                     return redeliveredMsg;
                  }
                  else
View Full Code Here

         if (pageIterator != null && !queueDestroyed)
         {
            // System.out.println("QueueMemorySize before depage = " + queueMemorySize.get());
            while (pageIterator.hasNext())
            {
               PagedReference reference = pageIterator.next();
               pageIterator.remove();

               if (filter1 == null || filter1.match(reference.getMessage()))
               {
                  count++;
                  txCount++;
                  messageAction.actMessage(tx, reference);
               }
View Full Code Here

      int depaged = 0;
      while (timeout > System.currentTimeMillis() && queueMemorySize.get() < maxSize && pageIterator.hasNext())
      {
         depaged++;
         PagedReference reference = pageIterator.next();
         if (isTrace)
         {
            HornetQServerLogger.LOGGER.trace("Depaging reference " + reference + " on queue " + this.getName());
         }
         addTail(reference, false);
View Full Code Here

TOP

Related Classes of org.hornetq.core.paging.cursor.PagedReference

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.