Package org.apache.lucene.store

Examples of org.apache.lucene.store.NativeFSLockFactory


   * @return the directory
   * @throws IOException if an I/O exception occurs
   */
  protected Directory getDirectory() throws IOException {
    File fDir = new File(this.getIndexReference().getIndexLocation());
    NativeFSLockFactory nativeLockFactory = this.getNativeLockFactory();
    if (nativeLockFactory != null) {
      return FSDirectory.open(fDir,nativeLockFactory);
    } else {
      return FSDirectory.open(fDir);
    }
View Full Code Here


   * Gets the native lock factory if it has been configured for use.
   * @return the native lock factory (null if not configured for use)
   * @throws IOException if an I/O exception occurs
   */
  protected synchronized NativeFSLockFactory getNativeLockFactory() throws IOException {
    NativeFSLockFactory factory = null;
    if (this.getIndexReference().getUseNativeFSLockFactory()) {
      File dir = new File(this.getIndexReference().getIndexLocation());
      String path = dir.getCanonicalPath();
      synchronized (NATIVEFSLOCKFACTORIES) {
        factory = NATIVEFSLOCKFACTORIES.get(path);
        if (factory == null) {
          factory = new NativeFSLockFactory(dir);
          NATIVEFSLOCKFACTORIES.put(path,factory);
        }
      }
    }
    return factory;
View Full Code Here

   * Gets the native lock factory if it has been configured for use.
   * @return the native lock factory (null if not configured for use)
   * @throws IOException if an exception occurs
   */
  private synchronized NativeFSLockFactory getNativeLockFactory() throws IOException {
    NativeFSLockFactory factory = null;
    if (this.luceneConfig.getUseNativeFSLockFactory()) {
      File dir = new File(this.luceneConfig.getIndexLocation());
      String path = dir.getCanonicalPath();
      synchronized (NATIVEFSLOCKFACTORIES) {
        factory = NATIVEFSLOCKFACTORIES.get(path);
        if (factory == null) {
          factory = new NativeFSLockFactory(dir);
          NATIVEFSLOCKFACTORIES.put(path,factory);
        }
      }
      //if (NATIVEFSLOCKFACTORY == null) {
      //  File lDir = new File(this.luceneConfig.getIndexLocation());
View Full Code Here

   * @return the directory
   * @throws IOException if an exception occurs
   */
  private Directory newDirectory() throws IOException {
    File fDir = new File(this.luceneConfig.getIndexLocation());
    NativeFSLockFactory nativeLockFactory = this.getNativeLockFactory();
    if (nativeLockFactory != null) {
      return FSDirectory.open(fDir,nativeLockFactory);
    } else {
      return FSDirectory.open(fDir);
    }
View Full Code Here

  public synchronized Lock obtainBackgroundLock() throws LockObtainFailedException {
    Lock lock = null;
    String pfx = "Unable to obtain background lock.";
    if (this.luceneConfig.getUseNativeFSLockFactory()) {
      try {
        NativeFSLockFactory nativeLockFactory = this.getNativeLockFactory();
        lock = nativeLockFactory.makeLock(BACKGROUND_LOCKNAME);
      } catch (IOException e) {
        String msg = pfx+" "+e.getMessage();
        getLogger().log(Level.WARNING,pfx,e);
        throw new LockObtainFailedException(msg);
      }
View Full Code Here

            }
            else
            {
               dir = new File(baseDir, name);
            }
            return FSDirectory.getDirectory(dir, new NativeFSLockFactory(dir));
         }
      });
   }
View Full Code Here

         spellIndexDirectory = null;
         SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<Object>()
         {
            public Object run() throws Exception
            {
               spellIndexDirectory = FSDirectory.getDirectory(path, new NativeFSLockFactory(path));
               if (IndexReader.indexExists(spellIndexDirectory))
               {
                  lastRefresh = System.currentTimeMillis();
               }
               return null;
View Full Code Here

    }
    else if ( "native".equals( lockFactoryName ) ) {
      if ( indexDir == null ) {
        throw new SearchException( "To use \"native\" as a LockFactory strategy an indexBase path must be set" );
      }
      return new NativeFSLockFactory( indexDir );
    }
    else if ( "single".equals( lockFactoryName ) ) {
      return new SingleInstanceLockFactory();
    }
    else if ( "none".equals( lockFactoryName ) ) {
View Full Code Here

               {
                  throw new IOException("Cannot create directory: " + dir);
               }
            }
            LockFactory lockFactory =
               (LOCK_FACTORY_CLASS == null) ? new NativeFSLockFactory() : (LockFactory)LOCK_FACTORY_CLASS.newInstance();

            if (FS_DIRECTORY_CLASS == null)
            {
               return FSDirectory.open(dir, lockFactory);
            }
View Full Code Here

    else if ( "native".equals( lockFactoryName ) ) {
      if ( indexDir == null ) {
        throw new SearchException( "To use \"native\" as a LockFactory strategy an indexBase path must be set" );
      }
      try {
        return new NativeFSLockFactory( indexDir );
      }
      catch ( IOException e ) {
        throw new SearchException( "Could not initialize NativeFSLockFactory", e );
      }
    }
View Full Code Here

TOP

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

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.