本文整理汇总了Java中org.apache.lucene.store.SimpleFSLockFactory类的典型用法代码示例。如果您正苦于以下问题:Java SimpleFSLockFactory类的具体用法?Java SimpleFSLockFactory怎么用?Java SimpleFSLockFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SimpleFSLockFactory类属于org.apache.lucene.store包,在下文中一共展示了SimpleFSLockFactory类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: SnapShooter
import org.apache.lucene.store.SimpleFSLockFactory; //导入依赖的package包/类
public SnapShooter(SolrCore core, String location, String snapshotName) {
solrCore = core;
if (location == null) snapDir = core.getDataDir();
else {
File base = new File(core.getCoreDescriptor().getRawInstanceDir());
snapDir = org.apache.solr.util.FileUtils.resolvePath(base, location).getAbsolutePath();
File dir = new File(snapDir);
if (!dir.exists()) dir.mkdirs();
}
lockFactory = new SimpleFSLockFactory(snapDir);
this.snapshotName = snapshotName;
if(snapshotName != null) {
directoryName = "snapshot." + snapshotName;
} else {
SimpleDateFormat fmt = new SimpleDateFormat(DATE_FMT, Locale.ROOT);
directoryName = "snapshot." + fmt.format(new Date());
}
}
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:SnapShooter.java
示例2: testSimpleLockErrorOnStartup
import org.apache.lucene.store.SimpleFSLockFactory; //导入依赖的package包/类
@Test
public void testSimpleLockErrorOnStartup() throws Exception {
Directory directory = newFSDirectory(new File(initCoreDataDir, "index"), new SimpleFSLockFactory());
//creates a new IndexWriter without releasing the lock yet
IndexWriter indexWriter = new IndexWriter(directory, new IndexWriterConfig(TEST_VERSION_CURRENT, null));
ignoreException("locked");
try {
System.setProperty("solr.tests.lockType","simple");
//opening a new core on the same index
initCore("solrconfig-basic.xml", "schema.xml");
if (checkForCoreInitException(LockObtainFailedException.class))
return;
fail("Expected " + LockObtainFailedException.class.getSimpleName());
} finally {
System.clearProperty("solr.tests.lockType");
unIgnoreException("locked");
indexWriter.close();
directory.close();
deleteCore();
}
}
开发者ID:europeana,项目名称:search,代码行数:24,代码来源:SolrCoreCheckLockOnStartupTest.java
示例3: testWhetherDeleteAllDeletesWriteLock
import org.apache.lucene.store.SimpleFSLockFactory; //导入依赖的package包/类
public void testWhetherDeleteAllDeletesWriteLock() throws Exception {
Directory d = newFSDirectory(_TestUtil.getTempDir("TestIndexWriter.testWhetherDeleteAllDeletesWriteLock"));
// Must use SimpleFSLockFactory... NativeFSLockFactory
// somehow "knows" a lock is held against write.lock
// even if you remove that file:
d.setLockFactory(new SimpleFSLockFactory());
RandomIndexWriter w1 = new RandomIndexWriter(random(), d);
w1.deleteAll();
try {
new RandomIndexWriter(random(), d, newIndexWriterConfig(TEST_VERSION_CURRENT, null).setWriteLockTimeout(100));
fail("should not be able to create another writer");
} catch (LockObtainFailedException lofe) {
// expected
}
w1.close();
d.close();
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:18,代码来源:TestIndexWriter.java
示例4: testSimpleLockErrorOnStartup
import org.apache.lucene.store.SimpleFSLockFactory; //导入依赖的package包/类
@Test
public void testSimpleLockErrorOnStartup() throws Exception {
Directory directory = newFSDirectory(new File(dataDir, "index"), new SimpleFSLockFactory());
//creates a new IndexWriter without releasing the lock yet
IndexWriter indexWriter = new IndexWriter(directory, new IndexWriterConfig(Version.LUCENE_40, null));
try {
//opening a new core on the same index
initCore("solrconfig-simplelock.xml", "schema.xml");
fail("Expected " + LockObtainFailedException.class.getSimpleName());
} catch (Throwable t) {
assertTrue(t instanceof RuntimeException);
assertNotNull(t.getCause());
assertTrue(t.getCause() instanceof RuntimeException);
assertNotNull(t.getCause().getCause());
assertTrue(t.getCause().getCause().toString(), t.getCause().getCause() instanceof LockObtainFailedException);
} finally {
indexWriter.close();
directory.close();
deleteCore();
}
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:24,代码来源:SolrCoreCheckLockOnStartupTest.java
示例5: SnapShooter
import org.apache.lucene.store.SimpleFSLockFactory; //导入依赖的package包/类
public SnapShooter(SolrCore core, String location) {
solrCore = core;
if (location == null) snapDir = core.getDataDir();
else {
File base = new File(core.getCoreDescriptor().getRawInstanceDir());
snapDir = org.apache.solr.util.FileUtils.resolvePath(base, location).getAbsolutePath();
File dir = new File(snapDir);
if (!dir.exists()) dir.mkdirs();
}
lockFactory = new SimpleFSLockFactory(snapDir);
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:12,代码来源:SnapShooter.java
示例6: injectLockFactory
import org.apache.lucene.store.SimpleFSLockFactory; //导入依赖的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
示例7: testWhetherDeleteAllDeletesWriteLock
import org.apache.lucene.store.SimpleFSLockFactory; //导入依赖的package包/类
public void testWhetherDeleteAllDeletesWriteLock() throws Exception {
Directory d = newFSDirectory(createTempDir("TestIndexWriter.testWhetherDeleteAllDeletesWriteLock"));
// Must use SimpleFSLockFactory... NativeFSLockFactory
// somehow "knows" a lock is held against write.lock
// even if you remove that file:
d.setLockFactory(new SimpleFSLockFactory());
RandomIndexWriter w1 = new RandomIndexWriter(random(), d);
w1.deleteAll();
try {
new RandomIndexWriter(random(), d, newIndexWriterConfig(null)
.setWriteLockTimeout(100));
fail("should not be able to create another writer");
} catch (LockObtainFailedException lofe) {
// expected
}
w1.close();
d.close();
}
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:TestIndexWriter.java
示例8: injectLockFactory
import org.apache.lucene.store.SimpleFSLockFactory; //导入依赖的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
示例9: getDirectory
import org.apache.lucene.store.SimpleFSLockFactory; //导入依赖的package包/类
private Directory getDirectory(String path) throws IOException {
return FSDirectory.open(new File(path), new SimpleFSLockFactory());
}
开发者ID:astralbat,项目名称:gitcommitviewer,代码行数:4,代码来源:DefaultLuceneIndexAccessor.java
注:本文中的org.apache.lucene.store.SimpleFSLockFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论