org.apache.lucene.store.SingleInstanceLockFactory Java Examples

The following examples show how to use org.apache.lucene.store.SingleInstanceLockFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HdfsDirectoryFactory.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@Override
protected LockFactory createLockFactory(String rawLockType) throws IOException {
  if (null == rawLockType) {
    rawLockType = DirectoryFactory.LOCK_TYPE_HDFS;
    log.warn("No lockType configured, assuming '{}'.", rawLockType);
  }
  final String lockType = rawLockType.toLowerCase(Locale.ROOT).trim();
  switch (lockType) {
    case DirectoryFactory.LOCK_TYPE_HDFS:
      return HdfsLockFactory.INSTANCE;
    case DirectoryFactory.LOCK_TYPE_SINGLE:
      return new SingleInstanceLockFactory();
    case DirectoryFactory.LOCK_TYPE_NONE:
      return NoLockFactory.INSTANCE;
    default:
      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
          "Unrecognized lockType: " + rawLockType);
  }
}
 
Example #2
Source File: StandardDirectoryFactory.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@Override
protected LockFactory createLockFactory(String rawLockType) throws IOException {
  if (null == rawLockType) {
    rawLockType = DirectoryFactory.LOCK_TYPE_NATIVE;
    log.warn("No lockType configured, assuming '{}'.", rawLockType);
  }
  final String lockType = rawLockType.toLowerCase(Locale.ROOT).trim();
  switch (lockType) {
    case DirectoryFactory.LOCK_TYPE_SIMPLE:
      return SimpleFSLockFactory.INSTANCE;
    case DirectoryFactory.LOCK_TYPE_NATIVE:
      return NativeFSLockFactory.INSTANCE;
    case DirectoryFactory.LOCK_TYPE_SINGLE:
      return new SingleInstanceLockFactory();
    case DirectoryFactory.LOCK_TYPE_NONE:
      return NoLockFactory.INSTANCE;
    default:
      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
          "Unrecognized lockType: " + rawLockType);
  }
}
 
Example #3
Source File: RAMDirectoryFactory.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
protected LockFactory createLockFactory(String rawLockType) throws IOException {
  if (!(rawLockType == null || DirectoryFactory.LOCK_TYPE_SINGLE.equalsIgnoreCase(rawLockType.trim()))) {
    throw new SolrException(ErrorCode.FORBIDDEN,
        "RAMDirectory can only be used with the '" +
            DirectoryFactory.LOCK_TYPE_SINGLE+"' lock factory type.");
  }
  return new SingleInstanceLockFactory();
}
 
Example #4
Source File: ByteBuffersDirectoryFactory.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
protected LockFactory createLockFactory(String rawLockType) throws IOException {
  if (!(rawLockType == null || DirectoryFactory.LOCK_TYPE_SINGLE.equalsIgnoreCase(rawLockType.trim()))) {
    throw new SolrException(ErrorCode.FORBIDDEN,
        "ByteBuffersDirectory can only be used with the '"+DirectoryFactory.LOCK_TYPE_SINGLE+"' lock factory type.");
  }
  return new SingleInstanceLockFactory();
}
 
Example #5
Source File: IndexBuilder.java    From exhibitor with Apache License 2.0 5 votes vote down vote up
public void open() throws Exception
{
    if ( !directory.exists() && !directory.mkdirs() )
    {
        throw new IOException("Could not make: " + directory);
    }

    IndexWriterConfig conf = new IndexWriterConfig(Version.LUCENE_35, new KeywordAnalyzer()).setOpenMode(IndexWriterConfig.OpenMode.CREATE);

    niofsDirectory = new NIOFSDirectory(directory, new SingleInstanceLockFactory());
    writer = new IndexWriter(niofsDirectory, conf);
}
 
Example #6
Source File: DistributedDirectory.java    From lumongo with Apache License 2.0 4 votes vote down vote up
public DistributedDirectory(NosqlDirectory nosqlDirectory) throws IOException {
	this(nosqlDirectory, new SingleInstanceLockFactory());
}