org.xcmis.search.lucene.index
Class ReadWriteDirectoryFactory

java.lang.Object
  extended by org.xcmis.search.lucene.index.ReadWriteDirectoryFactory
All Implemented Interfaces:
ConcurrentDirectoryFactory

public class ReadWriteDirectoryFactory
extends Object
implements ConcurrentDirectoryFactory

Created by The eXo Platform SAS.
Date:

Version:
$Id: DirectoryReadWriteLockFactory.java 111 2008-11-11 11:11:11Z serg $
Author:
Karpenko Sergiy

Constructor Summary
ReadWriteDirectoryFactory()
          Constructor.
 
Method Summary
 File createFile(File dir, String fileName, int dirCount)
          Create file with locking of dirCount parent directories.
 void lock(String dir)
          
 void lockRead(String dir)
          
 void removeDirectory(File dir, int dirCount)
          Try remove directory and parent directories.
 boolean tryLock(String dir)
          
 void unlock(String dir)
          
 void unlockRead(String dir)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReadWriteDirectoryFactory

public ReadWriteDirectoryFactory()
Constructor.

Method Detail

createFile

public File createFile(File dir,
                       String fileName,
                       int dirCount)
                throws IOException,
                       TransactionLogException
Create file with locking of dirCount parent directories.

Specified by:
createFile in interface ConcurrentDirectoryFactory
Parameters:
dir - - parent directory of file
fileName - - name of file
dirCount - - count of parent directories that will be locked during create file execution
Returns:
File - created file
Throws:
IOException - - I/O Exception
TransactionLogException - - if file already exist, or file or it's parent directory was not created (or not exist)

lock

public void lock(String dir)


lockRead

public void lockRead(String dir)


removeDirectory

public void removeDirectory(File dir,
                            int dirCount)
                     throws TransactionLogException
Try remove directory and parent directories. Maximum count of removed directories is dirCount.

Specified by:
removeDirectory in interface ConcurrentDirectoryFactory
Parameters:
dir - - directory to remove.
dirCount - - maximum count of removed directories. dir counted to.
Throws:
TransactionLogException - - if directory do not contain subfiles, but was not removed.

tryLock

public boolean tryLock(String dir)


unlock

public void unlock(String dir)


unlockRead

public void unlockRead(String dir)



Copyright © 2011 eXo Platform SAS. All Rights Reserved.