Package com.leansoft.bigqueue.page

Examples of com.leansoft.bigqueue.page.MappedPageFactoryImpl


            int gcPeriodInSec,
            SerDe<E> serDe,
            long sizeLimit) throws IOException {
        innerArray = new BigArrayImpl(path, name);
        // the ttl does not matter here since queue front index page is always cached
        this.queueFrontIndexPageFactory = new MappedPageFactoryImpl(QUEUE_FRONT_INDEX_PAGE_SIZE,
                ((BigArrayImpl)innerArray).getArrayDirectory() + QUEUE_FRONT_INDEX_PAGE_FOLDER,
                10 * 1000/*does not matter*/);
        IMappedPage queueFrontIndexPage = this.queueFrontIndexPageFactory.acquirePage(QUEUE_FRONT_PAGE_INDEX);

        ByteBuffer queueFrontIndexBuffer = queueFrontIndexPage.getLocal(0);
View Full Code Here


  }
 
 
  void commonInit() throws IOException {
    // initialize page factories
    this.indexPageFactory = new MappedPageFactoryImpl(INDEX_PAGE_SIZE,
        this.arrayDirectory + INDEX_PAGE_FOLDER,
        INDEX_PAGE_CACHE_TTL);
    this.dataPageFactory = new MappedPageFactoryImpl(DATA_PAGE_SIZE,
        this.arrayDirectory + DATA_PAGE_FOLDER,
        DATA_PAGE_CACHE_TTL);
    // the ttl does not matter here since meta data page is always cached
    this.metaPageFactory = new MappedPageFactoryImpl(META_DATA_PAGE_SIZE,
        this.arrayDirectory + META_DATA_PAGE_FOLDER,
        10 * 1000/*does not matter*/);
   
    // initialize array indexes
    initArrayIndex();
View Full Code Here

     */
    public BigQueueImpl(String queueDir, String queueName, int pageSize) throws IOException {
        innerArray = new BigArrayImpl(queueDir, queueName, pageSize);

        // the ttl does not matter here since queue front index page is always cached
        this.queueFrontIndexPageFactory = new MappedPageFactoryImpl(QUEUE_FRONT_INDEX_PAGE_SIZE,
                ((BigArrayImpl) innerArray).getArrayDirectory() + QUEUE_FRONT_INDEX_PAGE_FOLDER,
                10 * 1000/*does not matter*/);
        IMappedPage queueFrontIndexPage = this.queueFrontIndexPageFactory.acquirePage(QUEUE_FRONT_PAGE_INDEX);

        ByteBuffer queueFrontIndexBuffer = queueFrontIndexPage.getLocal(0);
View Full Code Here

  private String testDir = TestUtil.TEST_BASE_DIR + "bigqueue/unit/mapped_page_factory_test";
 
 
  @Test
  public void testGetBackPageFileSet() throws IOException {
    mappedPageFactory = new MappedPageFactoryImpl(1024, testDir + "/test_get_backpage_fileset", 2 * 1000);
   
    for(int i = 0; i < 10; i++ ) {
      mappedPageFactory.acquirePage(i);
    }
   
View Full Code Here

    }
  }
 
  @Test
  public void testGetBackPageFileSize() throws IOException {
    mappedPageFactory = new MappedPageFactoryImpl(1024 * 1024, testDir + "/test_get_backpage_filesize", 2 * 1000);
   
    for(int i = 0; i < 100; i++ ) {
      mappedPageFactory.acquirePage(i);
    }
   
View Full Code Here

 
 
  @Test
  public void testSingleThread() throws IOException {
 
    mappedPageFactory = new MappedPageFactoryImpl(1024 * 1024 * 128, testDir + "/test_single_thread", 2 * 1000);
   
    IMappedPage mappedPage = mappedPageFactory.acquirePage(0); // first acquire
    assertNotNull(mappedPage);
    IMappedPage mappedPage0 = mappedPageFactory.acquirePage(0); // second acquire
    assertSame(mappedPage, mappedPage0);
View Full Code Here

    FileUtil.deleteDirectory(new File(testDir));
  }
 
  @Test
  public void testMultiThreads() throws IOException {
    mappedPageFactory = new MappedPageFactoryImpl(1024 * 1024 * 128, testDir + "/test_multi_threads", 2 * 1000);
   
    int pageNumLimit = 200;
    int threadNum = 1000;
   
    Map<Integer, IMappedPage[]> sharedMap1 = this.testAndGetSharedMap(mappedPageFactory, threadNum, pageNumLimit);
View Full Code Here

  private String testDir = TestUtil.TEST_BASE_DIR + "bigqueue/unit/mapped_page_test";

  @Test
  public void testSingleThread() throws IOException {
    int pageSize = 1024 * 1024 * 32;
    mappedPageFactory = new MappedPageFactoryImpl(pageSize, testDir + "/test_single_thread", 2 * 1000);
   
    IMappedPage mappedPage = this.mappedPageFactory.acquirePage(0);
    assertNotNull(mappedPage);
   
    ByteBuffer buffer = mappedPage.getLocal(0);
View Full Code Here

  }
 
  @Test
  public void testMultiThreads() {
    int pageSize = 1024 * 1024 * 32;
    mappedPageFactory = new MappedPageFactoryImpl(pageSize, testDir + "/test_multi_threads", 2 * 1000);
   
    int threadNum = 100;
    int pageNumLimit = 50;
   
    Set<IMappedPage> pageSet = Collections.newSetFromMap(new ConcurrentHashMap<IMappedPage, Boolean>());
View Full Code Here

      } catch (IllegalArgumentException ex) {
        throw new IllegalArgumentException("invalid fanout identifier", ex);
      }
      this.fanoutId = fanoutId;
      // the ttl does not matter here since queue front index page is always cached
      this.indexPageFactory = new MappedPageFactoryImpl(QUEUE_FRONT_INDEX_PAGE_SIZE,
          innerArray.arrayDirectory + QUEUE_FRONT_INDEX_PAGE_FOLDER_PREFIX + fanoutId,
          10 * 1000/*does not matter*/);
     
      IMappedPage indexPage = this.indexPageFactory.acquirePage(QUEUE_FRONT_PAGE_INDEX);
     
View Full Code Here

TOP

Related Classes of com.leansoft.bigqueue.page.MappedPageFactoryImpl

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.