Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.infinispan.lucene.readlocks;
 
 
LocalLockMergingSegmentReadLockerTest represents a quick check on the functionality of org.infinispan.lucene.readlocks.LocalLockMergingSegmentReadLocker

Author(s):
Sanne Grinovero
Since:
4.1
@SuppressWarnings("unchecked")
@Test(groups = "functional", testName = "lucene.readlocks.LocalLockMergingSegmentReadLockerTest")
   
   @Test @Override
      prepareEnvironment(false);
      verifyBoth(,);
      IndexOutput indexOutput = .createOutput(.);
      indexOutput.writeString("no need to write, nobody ever will read this");
      indexOutput.flush();
      indexOutput.close();
      assertFileExistsHavingRLCount(, 1, true);
      IndexInput firstOpenOnB = .openInput(.);
      assertFileExistsHavingRLCount(, 2, true);
      .deleteFile();
      assertFileExistsHavingRLCount(, 1, false);
      //Lucene does use clone() - lock implementation ignores it as a clone is
      //cast on locked segments and released before the close on the parent object
      IndexInput cloneOfFirstOpenOnB = (IndexInputfirstOpenOnB.clone();
      assertFileExistsHavingRLCount(, 1, false);
      cloneOfFirstOpenOnB.close();
      assertFileExistsHavingRLCount(, 1, false);
      IndexInput firstOpenOnA = .openInput(.);
      assertFileExistsHavingRLCount(, 2, false);
      IndexInput secondOpenOnA = .openInput(.);
      assertFileExistsHavingRLCount(, 2, false);
      firstOpenOnA.close();
      assertFileExistsHavingRLCount(, 2, false);
      secondOpenOnA.close();
      assertFileExistsHavingRLCount(, 1, false);
      firstOpenOnB.close();
      .close();
      .close();
      verifyBoth();
   }
   @Test
      prepareEnvironment(true);
   }
   @Override
      return DirectoryBuilder.newDirectoryInstance(cachecachecache)
            .chunkSize()
            .create();
   }
      return DirectoryBuilder.newDirectoryInstance(cachecachecache)
            .chunkSize()
            .overrideSegmentReadLocker(new LocalLockMergingSegmentReadLocker(cachecachecache))
            .create();
   }
   private void prepareEnvironment(final boolean useDefConstructorthrows IOException {
       = cache(0, );
       = cache(1, );
      if (useDefConstructor) {
          = createDirectory();
          = createDirectory();
      } else {
          = createAdditionalDirectory();
          = createAdditionalDirectory();
      }
      CacheTestSupport.initializeDirectory();
   }
New to GrepCode? Check out our FAQ X