コード例 #1
0
  private void openNewPage() throws Exception {
    lock.writeLock().lock();

    try {
      numberOfPages++;

      int tmpCurrentPageId = currentPageId + 1;

      if (currentPage != null) {
        currentPage.close();
      }

      currentPage = createPage(tmpCurrentPageId);

      LivePageCache pageCache = new LivePageCacheImpl(currentPage);

      currentPage.setLiveCache(pageCache);

      cursorProvider.addPageCache(pageCache);

      currentPageSize.set(0);

      currentPage.open();

      currentPageId = tmpCurrentPageId;

      if (currentPageId < firstPageId) {
        firstPageId = currentPageId;
      }
    } finally {
      lock.writeLock().unlock();
    }
  }
コード例 #2
0
  @Override
  public void flushExecutors() {
    cursorProvider.flushExecutors();

    FutureLatch future = new FutureLatch();

    executor.execute(future);

    if (!future.await(60000)) {
      ActiveMQServerLogger.LOGGER.pageStoreTimeout(address);
    }
  }
コード例 #3
0
  /** @param addressSettings */
  @Override
  public void applySetting(final AddressSettings addressSettings) {
    maxSize = addressSettings.getMaxSizeBytes();

    pageSize = addressSettings.getPageSizeBytes();

    addressFullMessagePolicy = addressSettings.getAddressFullMessagePolicy();

    if (cursorProvider != null) {
      cursorProvider.setCacheMaxSize(addressSettings.getPageCacheMaxSize());
    }
  }
コード例 #4
0
  @Override
  public synchronized void stop() throws Exception {
    if (running) {
      cursorProvider.stop();

      running = false;

      flushExecutors();

      if (currentPage != null) {
        currentPage.close();
        currentPage = null;
      }
    }
  }
コード例 #5
0
  @Override
  public void start() throws Exception {
    lock.writeLock().lock();

    try {

      if (running) {
        // don't throw an exception.
        // You could have two threads adding PagingStore to a
        // ConcurrentHashMap,
        // and having both threads calling init. One of the calls should just
        // need to be ignored
        return;
      } else {
        running = true;
        firstPageId = Integer.MAX_VALUE;

        // There are no files yet on this Storage. We will just return it empty
        if (fileFactory != null) {

          currentPageId = 0;
          if (currentPage != null) {
            currentPage.close();
          }
          currentPage = null;

          List<String> files = fileFactory.listFiles("page");

          numberOfPages = files.size();

          for (String fileName : files) {
            final int fileId = PagingStoreImpl.getPageIdFromFileName(fileName);

            if (fileId > currentPageId) {
              currentPageId = fileId;
            }

            if (fileId < firstPageId) {
              firstPageId = fileId;
            }
          }

          if (currentPageId != 0) {
            currentPage = createPage(currentPageId);
            currentPage.open();

            List<PagedMessage> messages = currentPage.read(storageManager);

            LivePageCache pageCache = new LivePageCacheImpl(currentPage);

            for (PagedMessage msg : messages) {
              pageCache.addLiveMessage(msg);
              if (msg.getMessage().isLargeMessage()) {
                // We have to do this since addLIveMessage will increment an extra one
                ((LargeServerMessage) msg.getMessage()).decrementDelayDeletionCount();
              }
            }

            currentPage.setLiveCache(pageCache);

            currentPageSize.set(currentPage.getSize());

            cursorProvider.addPageCache(pageCache);
          }

          // We will not mark it for paging if there's only a single empty file
          if (currentPage != null && !(numberOfPages == 1 && currentPage.getSize() == 0)) {
            startPaging();
          }
        }
      }

    } finally {
      lock.writeLock().unlock();
    }
  }
コード例 #6
0
 @Override
 public void processReload() throws Exception {
   cursorProvider.processReload();
 }