org.apache.lucene.store.LockFactory Java Examples
The following examples show how to use
org.apache.lucene.store.LockFactory.
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: LuceneIndex.java From netbeans with Apache License 2.0 | 6 votes |
private static FSDirectory createFSDirectory ( final File indexFolder, final LockFactory lockFactory) throws IOException { assert indexFolder != null; assert lockFactory != null; final FSDirectory directory; final String dirType = System.getProperty(PROP_DIR_TYPE); if(DIR_TYPE_MMAP.equals(dirType)) { directory = new MMapDirectory(indexFolder, lockFactory); } else if (DIR_TYPE_NIO.equals(dirType)) { directory = new NIOFSDirectory(indexFolder, lockFactory); } else if (DIR_TYPE_IO.equals(dirType)) { directory = new SimpleFSDirectory(indexFolder, lockFactory); } else { directory = FSDirectory.open(indexFolder, lockFactory); } return directory; }
Example #2
Source File: FsDirectoryService.java From crate with Apache License 2.0 | 6 votes |
private static Directory setPreload(Directory directory, Path location, LockFactory lockFactory, Set<String> preLoadExtensions) throws IOException { if (preLoadExtensions.isEmpty() == false && directory instanceof MMapDirectory && ((MMapDirectory) directory).getPreload() == false) { if (preLoadExtensions.contains("*")) { ((MMapDirectory) directory).setPreload(true); return directory; } MMapDirectory primary = new MMapDirectory(location, lockFactory); primary.setPreload(true); return new FileSwitchDirectory(preLoadExtensions, primary, directory, true) { @Override public String[] listAll() throws IOException { // avoid listing twice return primary.listAll(); } }; } return directory; }
Example #3
Source File: StandardDirectoryFactory.java From lucene-solr with Apache License 2.0 | 6 votes |
@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 #4
Source File: MockFSDirectoryFactory.java From lucene-solr with Apache License 2.0 | 6 votes |
@Override public Directory create(String path, LockFactory lockFactory, DirContext dirContext) throws IOException { // we pass NoLockFactory, because the real lock factory is set later by injectLockFactory: Directory dir = LuceneTestCase.newFSDirectory(new File(path).toPath(), lockFactory); // we can't currently do this check because of how // Solr has to reboot a new Directory sometimes when replicating // or rolling back - the old directory is closed and the following // test assumes it can open an IndexWriter when that happens - we // have a new Directory for the same dir and still an open IW at // this point Directory cdir = reduce(dir); cdir = reduce(cdir); cdir = reduce(cdir); if (cdir instanceof MockDirectoryWrapper) { ((MockDirectoryWrapper)cdir).setAssertNoUnrefencedFilesOnClose(false); } return dir; }
Example #5
Source File: HdfsDirectoryFactory.java From lucene-solr with Apache License 2.0 | 6 votes |
@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 #6
Source File: RAMDirectoryFactory.java From lucene-solr with Apache License 2.0 | 5 votes |
@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 #7
Source File: FsDirectoryService.java From crate with Apache License 2.0 | 5 votes |
protected Directory newFSDirectory(Path location, LockFactory lockFactory) throws IOException { final String storeType = indexSettings.getSettings() .get(IndexModule.INDEX_STORE_TYPE_SETTING.getKey(), IndexModule.Type.FS.getSettingsKey()); IndexModule.Type type; if (IndexModule.Type.FS.match(storeType)) { type = IndexModule.defaultStoreType( IndexModule.NODE_STORE_ALLOW_MMAP.getWithFallback(indexSettings.getNodeSettings())); } else { type = IndexModule.Type.fromSettingsKey(storeType); } switch (type) { case HYBRIDFS: // Use Lucene defaults final FSDirectory primaryDirectory = FSDirectory.open(location, lockFactory); if (primaryDirectory instanceof MMapDirectory) { MMapDirectory mMapDirectory = (MMapDirectory) primaryDirectory; return new HybridDirectory(lockFactory, mMapDirectory); } else { return primaryDirectory; } case MMAPFS: return new MMapDirectory(location, lockFactory); case SIMPLEFS: return new SimpleFSDirectory(location, lockFactory); case NIOFS: return new NIOFSDirectory(location, lockFactory); default: throw new AssertionError("unexpected built-in store type [" + type + "]"); } }
Example #8
Source File: FsDirectoryService.java From crate with Apache License 2.0 | 5 votes |
@Override public Directory newDirectory() throws IOException { final Path location = path.resolveIndex(); final LockFactory lockFactory = indexSettings.getValue(INDEX_LOCK_FACTOR_SETTING); Files.createDirectories(location); Directory wrapped = newFSDirectory(location, lockFactory); Set<String> preLoadExtensions = new HashSet<>( indexSettings.getValue(IndexModule.INDEX_STORE_PRE_LOAD_SETTING)); wrapped = setPreload(wrapped, location, lockFactory, preLoadExtensions); return wrapped; }
Example #9
Source File: InfinispanSingletonCacheManagerDirectoryProvider.java From wallride with Apache License 2.0 | 5 votes |
private LockFactory getLockFactory(Path indexDir, Properties properties) { try { return serviceManager.requestService(LockFactoryCreator.class).createLockFactory(indexDir, properties); } finally { serviceManager.releaseService(LockFactoryCreator.class); } }
Example #10
Source File: AlternateDirectoryTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public Directory create(String path, LockFactory lockFactory, DirContext dirContext) throws IOException { openCalled = true; // we pass NoLockFactory, because the real lock factory is set later by injectLockFactory: return dir = newFSDirectory(new File(path).toPath(), lockFactory); }
Example #11
Source File: CoreMergeIndexesAdminHandlerTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public Directory create(String path, LockFactory lockFactory, DirContext dirContext) throws IOException { if (fail) { throw new FailingDirectoryFactoryException(); } else { return super.create(path, lockFactory, dirContext); } }
Example #12
Source File: ByteBuffersDirectoryFactory.java From lucene-solr with Apache License 2.0 | 5 votes |
@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 #13
Source File: RecordOwnerLockFactory.java From netbeans with Apache License 2.0 | 5 votes |
private static <T extends Exception> T annotateException( @NonNull final T e, @NullAllowed File indexDir, @NullAllowed Map<Thread,StackTraceElement[]> threads, @NullAllowed LockFactory lockFactory) { final StringBuilder message = new StringBuilder(); if (indexDir != null) { final File[] children = indexDir.listFiles(); if (children == null) { message.append("Non existing index folder"); //NOI18N } else { for (File c : children) { message.append(c.getName()).append(" f: ").append(c.isFile()). append(" r: ").append(c.canRead()). append(" w: ").append(c.canWrite()).append("\n"); //NOI18N } } } if (threads != null) { final Thread ct = Thread.currentThread(); message.append("current thread: ").append(ct).append('(').append(ct.getId()).append(')'); //NOI18N message.append("threads: \n"); //NOI18N //NOI18N stackTraces(threads, message); } if (lockFactory != null) { message.append("lockFactory: ").append(lockFactory); //NOI18N } return Exceptions.attachMessage(e, message.toString()); }
Example #14
Source File: MMapDirectoryFactory.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override protected Directory create(String path, LockFactory lockFactory, DirContext dirContext) throws IOException { // we pass NoLockFactory, because the real lock factory is set later by injectLockFactory: MMapDirectory mapDirectory = new MMapDirectory(new File(path).toPath(), lockFactory, maxChunk); try { mapDirectory.setUseUnmap(unmapHack); } catch (IllegalArgumentException e) { log.warn("Unmap not supported on this JVM, continuing on without setting unmap", e); } mapDirectory.setPreload(preload); return mapDirectory; }
Example #15
Source File: MockDirectoryFactory.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override protected Directory create(String path, LockFactory lockFactory, DirContext dirContext) throws IOException { Directory dir; if (useMockDirectoryWrapper) dir = LuceneTestCase.newMockDirectory(); else dir = LuceneTestCase.newDirectory(); // we ignore the given lock factory Directory cdir = reduce(dir); cdir = reduce(cdir); cdir = reduce(cdir); if (cdir instanceof MockDirectoryWrapper) { MockDirectoryWrapper mockDirWrapper = (MockDirectoryWrapper) cdir; // we can't currently do this check because of how // Solr has to reboot a new Directory sometimes when replicating // or rolling back - the old directory is closed and the following // test assumes it can open an IndexWriter when that happens - we // have a new Directory for the same dir and still an open IW at // this point mockDirWrapper.setAssertNoUnrefencedFilesOnClose(false); // ram dirs in cores that are restarted end up empty // and check index fails mockDirWrapper.setCheckIndexOnClose(false); if (allowReadingFilesStillOpenForWrite) { mockDirWrapper.setAllowReadingFilesStillOpenForWrite(true); } } return dir; }
Example #16
Source File: LuceneTestCase.java From lucene-solr with Apache License 2.0 | 5 votes |
private static Directory newFSDirectoryImpl(Class<? extends FSDirectory> clazz, Path path, LockFactory lf) throws IOException { FSDirectory d = null; try { d = CommandLineUtil.newFSDirectory(clazz, path, lf); } catch (ReflectiveOperationException e) { Rethrow.rethrow(e); } return d; }
Example #17
Source File: FencedDirectory.java From incubator-retired-blur with Apache License 2.0 | 4 votes |
public void setLockFactory(LockFactory lockFactory) throws IOException { _directory.setLockFactory(lockFactory); }
Example #18
Source File: MockFSDirectoryService.java From crate with Apache License 2.0 | 4 votes |
@Override protected synchronized Directory newFSDirectory(Path location, LockFactory lockFactory) throws IOException { throw new UnsupportedOperationException(); }
Example #19
Source File: FsDirectoryService.java From crate with Apache License 2.0 | 4 votes |
HybridDirectory(LockFactory lockFactory, MMapDirectory delegate) throws IOException { super(delegate.getDirectory(), lockFactory); this.delegate = delegate; }
Example #20
Source File: FileSystemDirectory.java From linden with Apache License 2.0 | 4 votes |
@Override public LockFactory getLockFactory() { return null; }
Example #21
Source File: DistributedDirectory.java From lumongo with Apache License 2.0 | 4 votes |
public DistributedDirectory(NosqlDirectory nosqlDirectory, LockFactory lockFactory) throws IOException { super(lockFactory); this.nosqlDirectory = nosqlDirectory; }
Example #22
Source File: ProgressableDirectory.java From incubator-retired-blur with Apache License 2.0 | 4 votes |
@Override public void setLockFactory(LockFactory lockFactory) throws IOException { _directory.setLockFactory(lockFactory); }
Example #23
Source File: ProgressableDirectory.java From incubator-retired-blur with Apache License 2.0 | 4 votes |
@Override public LockFactory getLockFactory() { return _directory.getLockFactory(); }
Example #24
Source File: BaseDirectoryTestSuite.java From incubator-retired-blur with Apache License 2.0 | 4 votes |
@Override public LockFactory getLockFactory() { return _directory.getLockFactory(); }
Example #25
Source File: BaseDirectoryTestSuite.java From incubator-retired-blur with Apache License 2.0 | 4 votes |
@Override public void setLockFactory(LockFactory lockFactory) throws IOException { _directory.setLockFactory(lockFactory); }
Example #26
Source File: CacheDirectory.java From incubator-retired-blur with Apache License 2.0 | 4 votes |
public LockFactory getLockFactory() { return _internal.getLockFactory(); }
Example #27
Source File: CacheDirectory.java From incubator-retired-blur with Apache License 2.0 | 4 votes |
public void setLockFactory(LockFactory lockFactory) throws IOException { _internal.setLockFactory(lockFactory); }
Example #28
Source File: BlockDirectory.java From incubator-retired-blur with Apache License 2.0 | 4 votes |
@Override public void setLockFactory(LockFactory lockFactory) throws IOException { _directory.setLockFactory(lockFactory); }
Example #29
Source File: BlockDirectory.java From incubator-retired-blur with Apache License 2.0 | 4 votes |
@Override public LockFactory getLockFactory() { return _directory.getLockFactory(); }
Example #30
Source File: FencedDirectory.java From incubator-retired-blur with Apache License 2.0 | 4 votes |
public LockFactory getLockFactory() { return _directory.getLockFactory(); }