Package org.apache.lucene.store

Examples of org.apache.lucene.store.LockFactory


         resumeTx(tx);
      }
   }

   private void forceLockClearInternal() {
      LockFactory lockFactory = getLockFactory();
      try {
         log.warn("Forcing clear of index lock");
         lockFactory.clearLock(IndexWriter.WRITE_LOCK_NAME);
      } catch (IOException e) {
         log.error(e);
      }
   }
View Full Code Here


   * @return the created {@code FSDirectory} instance
   *
   * @throws IOException if an error
   */
  public static FSDirectory createFSIndex(File indexDir, Properties properties) throws IOException {
    LockFactory lockFactory = createLockFactory( indexDir, properties );
    FSDirectoryType fsDirectoryType = FSDirectoryType.getType( properties );
    FSDirectory fsDirectory = fsDirectoryType.getDirectory( indexDir, null );

    // must use the setter (instead of using the constructor) to set the lockFactory, or Lucene will
    // throw an exception if it's different than a previous setting.
View Full Code Here

      return TransactionMode.NON_TRANSACTIONAL;
   }

   public void testLuceneIndexLocking() throws IOException {
      final String commonIndexName = "myIndex";
      LockFactory lockManagerA = makeLockFactory(cache(0,"lucene"), commonIndexName);
      LockFactory lockManagerB = makeLockFactory(cache(1, "lucene"), commonIndexName);
      LockFactory isolatedLockManager = makeLockFactory(cache(0, "lucene"), "anotherIndex");
      Lock luceneLockA = lockManagerA.makeLock(IndexWriter.WRITE_LOCK_NAME);
      Lock luceneLockB = lockManagerB.makeLock(IndexWriter.WRITE_LOCK_NAME);
      Lock anotherLock = isolatedLockManager.makeLock(IndexWriter.WRITE_LOCK_NAME);
     
      assert luceneLockA.obtain();
      assert luceneLockB.isLocked();
      assert ! anotherLock.isLocked();
      assert ! luceneLockA.obtain();
View Full Code Here

   }

   @Test(dataProvider = "writeLockNameProvider")
   public void testLuceneIndexLocking(final String writeLockProvider) throws IOException {
      final String commonIndexName = "myIndex";
      LockFactory lockManagerA = makeLockFactory(cache(0,"lucene"), commonIndexName);
      LockFactory lockManagerB = makeLockFactory(cache(1, "lucene"), commonIndexName);
      LockFactory isolatedLockManager = makeLockFactory(cache(0, "lucene"), "anotherIndex");
      Lock luceneLockA = lockManagerA.makeLock(writeLockProvider);
      Lock luceneLockB = lockManagerB.makeLock(writeLockProvider);
      Lock anotherLock = isolatedLockManager.makeLock(writeLockProvider);

      assert luceneLockA.obtain();
      assert luceneLockB.isLocked();
      assert ! anotherLock.isLocked();
      assert ! luceneLockA.obtain();
View Full Code Here

   }

   @Test(dataProvider = "writeLockNameProvider")
   public void testLuceneIndexLocking(final String writeLockProvider) throws IOException {
      final String commonIndexName = "myIndex";
      LockFactory lockManagerA = makeLockFactory(cache(0,"lucene"), commonIndexName);
      LockFactory lockManagerB = makeLockFactory(cache(1, "lucene"), commonIndexName);
      LockFactory isolatedLockManager = makeLockFactory(cache(0, "lucene"), "anotherIndex");
      Lock luceneLockA = lockManagerA.makeLock(writeLockProvider);
      Lock luceneLockB = lockManagerB.makeLock(writeLockProvider);
      Lock anotherLock = isolatedLockManager.makeLock(writeLockProvider);
     
      assert luceneLockA.obtain();
      assert luceneLockB.isLocked();
      assert ! anotherLock.isLocked();
      assert ! luceneLockA.obtain();
View Full Code Here

   public void testOverrideWriteLocker() throws IOException {
      Directory dir = null;
      try {
         dir = DirectoryBuilder.newDirectoryInstance(cache, cache, cache, INDEX_NAME).chunkSize(BUFFER_SIZE)
               .overrideWriteLocker(new LockFactory() {
                  @Override
                  public Lock makeLock(String lockName) {
                     return null;
                  }
View Full Code Here

            Activator.getDefault().logError(e.getMessage(), e);
          }
        }

        /* Create Directory */
        LockFactory lockFactory = new NativeFSLockFactory(path);
        fDirectory = FSDirectory.getDirectory(path, lockFactory);
      }

      if (fIndexer == null)
        fIndexer = new Indexer(this, fDirectory);
View Full Code Here

   public void testOverrideWriteLocker() throws IOException {
      Directory dir = null;
      try {
         dir = DirectoryBuilder.newDirectoryInstance(cache, cache, cache, INDEX_NAME).chunkSize(BUFFER_SIZE)
               .overrideWriteLocker(new LockFactory() {
                  @Override
                  public Lock makeLock(String lockName) {
                     return null;
                  }
View Full Code Here

   @Test(expectedExceptions = IllegalArgumentException.class)
   public void testInitWithInvalidSegmentReadLocker() {
      Cache cache = cacheManager.getCache();

      InfinispanDirectory dir = new InfinispanDirectory(cache, cache, "indexName", new LockFactory() {
         @Override
         public Lock makeLock(String lockName) {
            return null;
         }
View Full Code Here

   }

   @Test(dataProvider = "writeLockNameProvider")
   public void testLuceneIndexLocking(final String writeLockProvider) throws IOException {
      final String commonIndexName = "myIndex";
      LockFactory lockManagerA = makeLockFactory(cache(0,"lucene"), commonIndexName);
      LockFactory lockManagerB = makeLockFactory(cache(1, "lucene"), commonIndexName);
      LockFactory isolatedLockManager = makeLockFactory(cache(0, "lucene"), "anotherIndex");
      Lock luceneLockA = lockManagerA.makeLock(writeLockProvider);
      Lock luceneLockB = lockManagerB.makeLock(writeLockProvider);
      Lock anotherLock = isolatedLockManager.makeLock(writeLockProvider);

      assert luceneLockA.obtain();
      assert luceneLockB.isLocked();
      assert ! anotherLock.isLocked();
      assert ! luceneLockA.obtain();
View Full Code Here

TOP

Related Classes of org.apache.lucene.store.LockFactory

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.