当前位置: 首页>>代码示例>>Java>>正文


Java SingleInstanceLockFactory类代码示例

本文整理汇总了Java中org.apache.lucene.store.SingleInstanceLockFactory的典型用法代码示例。如果您正苦于以下问题:Java SingleInstanceLockFactory类的具体用法?Java SingleInstanceLockFactory怎么用?Java SingleInstanceLockFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SingleInstanceLockFactory类属于org.apache.lucene.store包,在下文中一共展示了SingleInstanceLockFactory类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: open

import org.apache.lucene.store.SingleInstanceLockFactory; //导入依赖的package包/类
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);
}
 
开发者ID:dcos,项目名称:exhibitor,代码行数:13,代码来源:IndexBuilder.java

示例2: HazelcastDirectory

import org.apache.lucene.store.SingleInstanceLockFactory; //导入依赖的package包/类
public HazelcastDirectory() {
    // TODO: develop Hazelcast Lock Factory
    super(new SingleInstanceLockFactory());

    Config config = new Config("lucene-hazelcastDirectory-1.0");

    // near cache config
    /*NearCacheConfig nearCacheConfig = new NearCacheConfig();
    nearCacheConfig.setCacheLocalEntries(true);
    nearCacheConfig.setInvalidateOnChange(true);
    config.getMapConfig(MAP_NAME).setNearCacheConfig(nearCacheConfig);*/
    //config.getMapConfig(MAP_NAME).setInMemoryFormat(InMemoryFormat.BINARY);

    // serialization
    config.getSerializationConfig().addDataSerializableFactory(
            HFile.HazelcastDataSerializableFactory.FACTORY_ID,
            new HFile.HazelcastDataSerializableFactory());

    // network config
    config.getNetworkConfig().setPort(8085);
    config.getNetworkConfig().setPortCount(2);
    config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
    config.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(true);
    config.getNetworkConfig().getJoin().getTcpIpConfig().addMember(members);

    // group config
    config.getGroupConfig().setName("lucene-hazelcast");
    config.getGroupConfig().setPassword("password");

    HazelcastInstance instance = Hazelcast.newHazelcastInstance(config);
    fileMap = instance.getMap(MAP_NAME);
}
 
开发者ID:Marza,项目名称:lucene-hazelcast,代码行数:33,代码来源:HazelcastDirectory.java

示例3: makeDirectory

import org.apache.lucene.store.SingleInstanceLockFactory; //导入依赖的package包/类
private Directory makeDirectory() throws ServerException {
  try {
    Files.createDirectories(indexDirectory.toPath());
    return FSDirectory.open(indexDirectory.toPath(), new SingleInstanceLockFactory());
  } catch (IOException e) {
    throw new ServerException(e);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:9,代码来源:LuceneSearcher.java

示例4: injectLockFactory

import org.apache.lucene.store.SingleInstanceLockFactory; //导入依赖的package包/类
private static Directory injectLockFactory(Directory dir, String lockPath,
    String rawLockType) throws IOException {
  if (null == rawLockType) {
    // we default to "simple" for backwards compatibility
    log.warn("No lockType configured for " + dir + " assuming 'simple'");
    rawLockType = "simple";
  }
  final String lockType = rawLockType.toLowerCase(Locale.ROOT).trim();
  
  if ("simple".equals(lockType)) {
    // multiple SimpleFSLockFactory instances should be OK
    dir.setLockFactory(new SimpleFSLockFactory(lockPath));
  } else if ("native".equals(lockType)) {
    dir.setLockFactory(new NativeFSLockFactory(lockPath));
  } else if ("single".equals(lockType)) {
    if (!(dir.getLockFactory() instanceof SingleInstanceLockFactory)) dir
        .setLockFactory(new SingleInstanceLockFactory());
  } else if ("none".equals(lockType)) {
    // Recipe for disaster
    log.error("CONFIGURATION WARNING: locks are disabled on " + dir);
    dir.setLockFactory(NoLockFactory.getNoLockFactory());
  } else {
    throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
        "Unrecognized lockType: " + rawLockType);
  }
  return dir;
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:28,代码来源:CachingDirectoryFactory.java

示例5: injectLockFactory

import org.apache.lucene.store.SingleInstanceLockFactory; //导入依赖的package包/类
private static Directory injectLockFactory(Directory dir, String lockPath,
    String rawLockType) throws IOException {
  if (null == rawLockType) {
    // we default to "simple" for backwards compatibility
    log.warn("No lockType configured for " + dir + " assuming 'simple'");
    rawLockType = "simple";
  }
  final String lockType = rawLockType.toLowerCase(Locale.ROOT).trim();
  
  if ("simple".equals(lockType)) {
    // multiple SimpleFSLockFactory instances should be OK
    dir.setLockFactory(new SimpleFSLockFactory(lockPath));
  } else if ("native".equals(lockType)) {
    dir.setLockFactory(new NativeFSLockFactory(lockPath));
  } else if ("single".equals(lockType)) {
    if (!(dir.getLockFactory() instanceof SingleInstanceLockFactory)) dir
        .setLockFactory(new SingleInstanceLockFactory());
  } else if ("hdfs".equals(lockType)) {
    Directory del = dir;
    
    if (dir instanceof NRTCachingDirectory) {
      del = ((NRTCachingDirectory) del).getDelegate();
    }
    
    if (del instanceof BlockDirectory) {
      del = ((BlockDirectory) del).getDirectory();
    }
    
    if (!(del instanceof HdfsDirectory)) {
      throw new SolrException(ErrorCode.FORBIDDEN, "Directory: "
          + del.getClass().getName()
          + ", but hdfs lock factory can only be used with HdfsDirectory");
    }

    dir.setLockFactory(new HdfsLockFactory(((HdfsDirectory)del).getHdfsDirPath(), ((HdfsDirectory)del).getConfiguration()));
  } else if ("none".equals(lockType)) {
    // Recipe for disaster
    log.error("CONFIGURATION WARNING: locks are disabled on " + dir);
    dir.setLockFactory(NoLockFactory.getNoLockFactory());
  } else {
    throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
        "Unrecognized lockType: " + rawLockType);
  }
  return dir;
}
 
开发者ID:europeana,项目名称:search,代码行数:46,代码来源:CachingDirectoryFactory.java

示例6: retrieveDirectory

import org.apache.lucene.store.SingleInstanceLockFactory; //导入依赖的package包/类
@Override
public Directory retrieveDirectory(String name) throws IOException {
    return (location != null) ?
            FSDirectory.open(new File(location, name), new SingleInstanceLockFactory()) :
            new RAMDirectory();
}
 
开发者ID:hflabs,项目名称:perecoder,代码行数:7,代码来源:LuceneFileDirectoryFactory.java

示例7: DistributedDirectory

import org.apache.lucene.store.SingleInstanceLockFactory; //导入依赖的package包/类
public DistributedDirectory(NosqlDirectory nosqlDirectory) throws IOException {
	this(nosqlDirectory, new SingleInstanceLockFactory());
}
 
开发者ID:lumongo,项目名称:lumongo,代码行数:4,代码来源:DistributedDirectory.java

示例8: BfsDirectory

import org.apache.lucene.store.SingleInstanceLockFactory; //导入依赖的package包/类
public BfsDirectory()
{
  super(new SingleInstanceLockFactory());

  Services manager = Services.current();

  int pod = 0;//manager.getNode().getNodeIndex();

  String path = String.format("bfs:///usr/lib/lucene/index/node-%1$s", pod);

  _root = manager.service(path).as(BfsFileSync.class);
}
 
开发者ID:baratine,项目名称:lucene-plugin,代码行数:13,代码来源:BfsDirectory.java


注:本文中的org.apache.lucene.store.SingleInstanceLockFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。