Java Code Examples for org.apache.lucene.store.SingleInstanceLockFactory

The following examples show how to use org.apache.lucene.store.SingleInstanceLockFactory. These examples are extracted from open source projects. 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 Project: lucene-solr   Source File: HdfsDirectoryFactory.java    License: 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 Project: lucene-solr   Source File: StandardDirectoryFactory.java    License: 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 Project: lucene-solr   Source File: RAMDirectoryFactory.java    License: 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 Project: lucene-solr   Source File: ByteBuffersDirectoryFactory.java    License: 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 Project: exhibitor   Source File: IndexBuilder.java    License: 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 Project: lumongo   Source File: DistributedDirectory.java    License: Apache License 2.0 4 votes vote down vote up
public DistributedDirectory(NosqlDirectory nosqlDirectory) throws IOException {
	this(nosqlDirectory, new SingleInstanceLockFactory());
}