Package org.hornetq.core.paging

Examples of org.hornetq.core.paging.Page


    */
   private void handlePageWrite(final ReplicationPageWriteMessage packet) throws Exception
   {
      PagedMessage pgdMessage = packet.getPagedMessage();
      ServerMessage msg = pgdMessage.getMessage(storage);
      Page page = getPage(msg.getAddress(), packet.getPageNumber());
      page.write(pgdMessage);
   }
View Full Code Here


   private Page getPage(final SimpleString storeName, final int pageId) throws Exception
   {
      ConcurrentMap<Integer, Page> map = getPageMap(storeName);

      Page page = map.get(pageId);

      if (page == null)
      {
         page = newPage(pageId, storeName, map);
      }
View Full Code Here

    */
   private synchronized Page newPage(final int pageId,
                                     final SimpleString storeName,
                                     final ConcurrentMap<Integer, Page> map) throws Exception
   {
      Page page = map.get(pageId);

      if (page == null)
      {
         page = pageManager.getPageStore(storeName).createPage(pageId);
         page.open();
         map.put(pageId, page);
      }

      return page;
   }
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)
               {
                  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

    * @return
    * @throws Exception
    */
   private boolean readPage() throws Exception
   {
      Page page = depage();

      if (page == null)
      {
         return false;
      }

      page.open();

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

      if (onDepage(page.getPageId(), storeName, messages))
      {
         page.delete();

         return true;
      }
      else
      {
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

                  log.info("Address " + pagingStore.getAddress() +
                           " is leaving page mode as all messages are consumed and acknowledged from the page store");
                  pagingStore.forceAnotherPage();

                  Page currentPage = pagingStore.getCurrentPage();

                  try
                  {
                     // First step: Move every cursor to the next bookmarked page (that was just created)
                     for (PageSubscription cursor : cursorList)
                     {
                        cursor.confirmPosition(new PagePositionImpl(currentPage.getPageId(), -1));
                     }

                     storageManager.waitOnOperations();
                  }
                  finally
                  {
                     for (PageSubscription cursor : cursorList)
                     {
                        cursor.enableAutoCleanup();
                     }
                  }

                  pagingStore.stopPaging();

                  // This has to be called after we stopped paging
                  for (PageSubscription cursor : cursorList)
                  {
                     cursor.scheduleCleanupCheck();
                  }

               }
            }

            for (long i = pagingStore.getFirstPage(); i < minPage; i++)
            {
               Page page = pagingStore.depage();
               if (page == null)
               {
                  break;
               }
               depagedPages.add(page);
View Full Code Here

         // Reading is done outside of the synchronized block, however
         // the page stays locked until the entire reading is finished
         if (needToRead)
         {
            Page page = null;
            try
            {
               page = pagingStore.createPage((int)pageId);

               page.open();

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

               for (PagedMessage pdgMessage : pgdMessages)
               {
                  pdgMessage.initMessage(storageManager);
               }

               cache.setMessages(pgdMessages.toArray(new PagedMessage[pgdMessages.size()]));

            }
            finally
            {
               try
               {
                  if (page != null)
                  {
                     page.close();
                  }
               }
               catch (Throwable ignored)
               {
               }
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();

                  // 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

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.