org.elasticsearch.common.lucene.store
Class SwitchDirectory

java.lang.Object
  extended by org.apache.lucene.store.Directory
      extended by org.elasticsearch.common.lucene.store.SwitchDirectory
All Implemented Interfaces:
Closeable, ForceSyncDirectory

public class SwitchDirectory
extends org.apache.lucene.store.Directory
implements ForceSyncDirectory

A Directory instance that switches files between two other Directory instances.

Files with the specified extensions are placed in the primary directory; others are placed in the secondary directory.


Field Summary
 
Fields inherited from class org.apache.lucene.store.Directory
isOpen, lockFactory
 
Constructor Summary
SwitchDirectory(Set<String> primaryExtensions, org.apache.lucene.store.Directory primaryDir, org.apache.lucene.store.Directory secondaryDir, boolean doClose)
           
 
Method Summary
 void close()
           
 org.apache.lucene.store.IndexOutput createOutput(String name)
           
 void deleteFile(String name)
           
 boolean fileExists(String name)
           
 long fileLength(String name)
           
 long fileModified(String name)
           
 void forceSync(String name)
          Similar to Directory.sync(String) but forces it even if its disabled.
static String getExtension(String name)
          Utility method to return a file's extension.
 String[] listAll()
           
 org.apache.lucene.store.IndexInput openInput(String name)
           
 org.apache.lucene.store.Directory primaryDir()
          Return the primary directory
 com.google.common.collect.ImmutableSet<String> primaryExtensions()
           
 org.apache.lucene.store.Directory secondaryDir()
          Return the secondary directory
 void sync(Collection<String> names)
           
 void sync(String name)
           
 void touchFile(String name)
           
 
Methods inherited from class org.apache.lucene.store.Directory
clearLock, copy, copy, ensureOpen, getLockFactory, getLockID, makeLock, openInput, setLockFactory, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SwitchDirectory

public SwitchDirectory(Set<String> primaryExtensions,
                       org.apache.lucene.store.Directory primaryDir,
                       org.apache.lucene.store.Directory secondaryDir,
                       boolean doClose)
Method Detail

primaryExtensions

public com.google.common.collect.ImmutableSet<String> primaryExtensions()

primaryDir

public org.apache.lucene.store.Directory primaryDir()
Return the primary directory


secondaryDir

public org.apache.lucene.store.Directory secondaryDir()
Return the secondary directory


close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Specified by:
close in class org.apache.lucene.store.Directory
Throws:
IOException

listAll

public String[] listAll()
                 throws IOException
Specified by:
listAll in class org.apache.lucene.store.Directory
Throws:
IOException

getExtension

public static String getExtension(String name)
Utility method to return a file's extension.


fileExists

public boolean fileExists(String name)
                   throws IOException
Specified by:
fileExists in class org.apache.lucene.store.Directory
Throws:
IOException

fileModified

public long fileModified(String name)
                  throws IOException
Specified by:
fileModified in class org.apache.lucene.store.Directory
Throws:
IOException

touchFile

public void touchFile(String name)
               throws IOException
Specified by:
touchFile in class org.apache.lucene.store.Directory
Throws:
IOException

deleteFile

public void deleteFile(String name)
                throws IOException
Specified by:
deleteFile in class org.apache.lucene.store.Directory
Throws:
IOException

fileLength

public long fileLength(String name)
                throws IOException
Specified by:
fileLength in class org.apache.lucene.store.Directory
Throws:
IOException

createOutput

public org.apache.lucene.store.IndexOutput createOutput(String name)
                                                 throws IOException
Specified by:
createOutput in class org.apache.lucene.store.Directory
Throws:
IOException

sync

public void sync(Collection<String> names)
          throws IOException
Overrides:
sync in class org.apache.lucene.store.Directory
Throws:
IOException

sync

public void sync(String name)
          throws IOException
Overrides:
sync in class org.apache.lucene.store.Directory
Throws:
IOException

forceSync

public void forceSync(String name)
               throws IOException
Description copied from interface: ForceSyncDirectory
Similar to Directory.sync(String) but forces it even if its disabled.

Specified by:
forceSync in interface ForceSyncDirectory
Throws:
IOException

openInput

public org.apache.lucene.store.IndexInput openInput(String name)
                                             throws IOException
Specified by:
openInput in class org.apache.lucene.store.Directory
Throws:
IOException


Copyright © 2009-2012. All Rights Reserved.