Package org.hornetq.core.paging

Examples of org.hornetq.core.paging.Page


         }
         else
         {
            numberOfPages--;

            final Page returnPage;

            // We are out of old pages, all that is left now is the current page.
            // On that case we need to replace it by a new empty page, and return the current page immediately
            if (currentPageId == firstPageId)
            {
               firstPageId = Integer.MAX_VALUE;

               if (currentPage == null)
               {
                  // sanity check... it shouldn't happen!
                  throw new IllegalStateException("CurrentPage is null");
               }

               returnPage = currentPage;
               returnPage.close();
               currentPage = null;

               // The current page is empty... which means we reached the end of the pages
               if (returnPage.getNumberOfMessages() == 0)
               {
                  stopPaging();
                  returnPage.open();
                  returnPage.delete();

                  // This will trigger this address to exit the page mode,
                  // and this will make HornetQ start using the journal again
                  return null;
               }
View Full Code Here


         fileFactory = storeFactory.newFileFactory(getStoreName());
      }

      SequentialFile file = fileFactory.createSequentialFile(fileName, 1000);

      Page page = new PageImpl(storeName, storageManager, fileFactory, file, pageNumber);

      // To create the file
      file.open();

      file.position(0);
View Full Code Here

         }
         else
         {
            numberOfPages--;

            final Page returnPage;

            // We are out of old pages, all that is left now is the current page.
            // On that case we need to replace it by a new empty page, and return the current page immediately
            if (currentPageId == firstPageId)
            {
               firstPageId = Integer.MAX_VALUE;

               if (currentPage == null)
               {
                  // sanity check... it shouldn't happen!
                  throw new IllegalStateException("CurrentPage is null");
               }

               returnPage = currentPage;
               returnPage.close();
               currentPage = null;

               // The current page is empty... which means we reached the end of the pages
               if (returnPage.getNumberOfMessages() == 0)
               {
                  stopPaging();
                  returnPage.open();
                  returnPage.delete(null);

                  // This will trigger this address to exit the page mode,
                  // and this will make HornetQ start using the journal again
                  return null;
               }
View Full Code Here

               // Wait every producer to produce at least one message
               latchStart.await();

               while (aliveProducers.get() > 0)
               {
                  Page page = storeImpl.depage();
                  if (page != null)
                  {
                     readPages.add(page);
                  }
               }
View Full Code Here

               long msgsRead = 0;

               while (msgsRead < NUMBER_OF_MESSAGES)
               {
                  Page page = storeImpl.depage();
                  if (page != null)
                  {
                     page.open();
                     List<PagedMessage> messages = page.read(new NullStorageManager());

                     for (PagedMessage pgmsg : messages)
                     {
                        ServerMessage msg = pgmsg.getMessage();

                        assertEquals(msgsRead++, msg.getMessageID());

                        assertEquals(msg.getMessageID(), msg.getLongProperty("count").longValue());
                     }

                     page.close();
                     page.delete(null);
                  }
                  else
                  {
                     System.out.println("Depaged!!!! numerOfMessages = " + msgsRead + " of " + NUMBER_OF_MESSAGES);
                     Thread.sleep(500);
View Full Code Here

                            PagingTest.PAGE_MAX,
                            new HashMap<String, AddressSettings>());

      server.start();

      Page pg = server.getPagingManager().getPageStore(ADDRESS).getCurrentPage();

      pg.open();

      List<PagedMessage> msgs = pg.read(server.getStorageManager());

      assertTrue(msgs.size() > 0);

      pg.close();

      long queues[] = new long[] { server.locateQueue(new SimpleString("q1")).getID(),
                                  server.locateQueue(new SimpleString("q2")).getID() };

      for (long q : queues)
      {
         for (int i = 0; i < msgs.size(); i++)
         {
            server.getStorageManager().storeCursorAcknowledge(q, new PagePositionImpl(pg.getPageId(), i));
         }
      }

      server.stop();
View Full Code Here

            @Override
            public Page createPage(final int page) throws Exception
            {

               Page originalPage = super.createPage(page);

               return new FailingPage(originalPage);
            }
View Full Code Here

               // Wait every producer to produce at least one message
               latchStart.await();

               while (aliveProducers.get() > 0)
               {
                  Page page = storeImpl.depage();
                  if (page != null)
                  {
                     readPages.add(page);
                  }
               }
View Full Code Here

      Assert.assertEquals(1, storeImpl.getNumberOfPages());

      storeImpl.sync();

      Page page = storeImpl.depage();

      page.open();

      List<PagedMessage> msg = page.read();

      Assert.assertEquals(numMessages, msg.size());
      Assert.assertEquals(1, storeImpl.getNumberOfPages());

      page = storeImpl.depage();
View Full Code Here

      int sequence = 0;

      for (int pageNr = 0; pageNr < 2; pageNr++)
      {
         Page page = storeImpl.depage();

         page.open();

         List<PagedMessage> msg = page.read();

         page.close();

         Assert.assertEquals(5, msg.size());

         for (int i = 0; i < 5; i++)
         {
            Assert.assertEquals(sequence++, msg.get(i).getMessage(null).getMessageID());
            UnitTestCase.assertEqualsBuffers(18, buffers.get(pageNr * 5 + i), msg.get(i)
                                                                                 .getMessage(null)
                                                                                 .getBodyBuffer());
         }
      }

      Assert.assertEquals(1, storeImpl.getNumberOfPages());

      Assert.assertTrue(storeImpl.isPaging());

      ServerMessage msg = createMessage(1, storeImpl, destination, buffers.get(0));

      Assert.assertTrue(storeImpl.page(msg));

      Page newPage = storeImpl.depage();

      newPage.open();

      Assert.assertEquals(1, newPage.read().size());

      newPage.delete();

      Assert.assertEquals(1, storeImpl.getNumberOfPages());

      Assert.assertTrue(storeImpl.isPaging());

      Assert.assertNull(storeImpl.depage());

      Assert.assertFalse(storeImpl.isPaging());

      Assert.assertFalse(storeImpl.page(msg));

      storeImpl.startPaging();

      Assert.assertTrue(storeImpl.page(msg));

      Page page = storeImpl.depage();

      page.open();

      List<PagedMessage> msgs = page.read();

      Assert.assertEquals(1, msgs.size());

      Assert.assertEquals(1l, msgs.get(0).getMessage(null).getMessageID());

      UnitTestCase.assertEqualsBuffers(18, buffers.get(0), msgs.get(0).getMessage(null).getBodyBuffer());

      Assert.assertEquals(1, storeImpl.getNumberOfPages());

      Assert.assertTrue(storeImpl.isPaging());

      Assert.assertNull(storeImpl.depage());

      Assert.assertEquals(0, storeImpl.getNumberOfPages());

      page.open();

   }
View Full Code Here

TOP

Related Classes of org.hornetq.core.paging.Page

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.