@Override public Lock obtainLock(String name) throws IOException { /* we do explicitly a no-lock instance since we hold an index commit from a SnapshotDeletionPolicy so we * can we certain that nobody messes with the files on disk. We also hold a ref on the store which means * no external source will delete files either.*/ return NoLockFactory.INSTANCE.obtainLock(in, name); }
/** Creates a new instance of LuceneIndex */ private LuceneIndex (final Language language, final File refCacheRoot) throws IOException { super(language); assert refCacheRoot != null; this.refCacheRoot = refCacheRoot; this.directory = FSDirectory.getDirectory(refCacheRoot, NoLockFactory.getNoLockFactory()); //Locking controlled by rwlock }
public static Directory getDirectory(String path, DirectoryFactory directoryFactory, SolrIndexConfig config) throws IOException { Directory d = directoryFactory.open(path); String rawLockType = (null == config) ? null : config.lockType; if (null == rawLockType) { // we default to "simple" for backwards compatibility log.warn("No lockType configured for " + path + " assuming 'simple'"); rawLockType = "simple"; } final String lockType = rawLockType.toLowerCase().trim(); if ("simple".equals(lockType)) { // multiple SimpleFSLockFactory instances should be OK d.setLockFactory(new SimpleFSLockFactory(path)); } else if ("native".equals(lockType)) { d.setLockFactory(new NativeFSLockFactory(path)); } else if ("single".equals(lockType)) { if (!(d.getLockFactory() instanceof SingleInstanceLockFactory)) d.setLockFactory(new SingleInstanceLockFactory()); } else if ("none".equals(lockType)) { // Recipe for disaster log.error("CONFIGURATION WARNING: locks are disabled on " + path); d.setLockFactory(new NoLockFactory()); } else { throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unrecognized lockType: " + rawLockType); } return d; }
/** * Override to use a different {@link Directory} implementation * * You may want to use {@link org.apache.lucene.store.FSDirectory#open} * which is supposed to select an appropriate * local FS implementation based on the current OS. However, we have seen cases * where using this leads to an implementation that hits {@link java.lang.OutOfMemoryError} * when building large indexes. */ protected Directory getDirectoryImplementation(File location) throws IOException { return new SimpleFSDirectory(location, NoLockFactory.getNoLockFactory()); }
} else if (lockFactoryType instanceof String && LuceneEnvironment.LockFactory.Type.NO_LOCKING.equalsIgnoreCase((String) lockFactoryType)) { lockFactory = new NoLockFactory(); } else { Object temp;
protected Directory createLocalDirForIndexWriter(LuceneIndexDefinition definition, String dirName) throws IOException { String indexPath = definition.getIndexPath(); File indexWriterDir = getIndexDir(definition, indexPath, dirName); //By design indexing in Oak is single threaded so Lucene locking //can be disabled Directory dir = FSDirectory.open(indexWriterDir, NoLockFactory.getNoLockFactory()); log.debug("IndexWriter would use {}", indexWriterDir); return dir; }
@Override public Lock obtainLock(String name) throws IOException { /* we do explicitly a no-lock instance since we hold an index commit from a SnapshotDeletionPolicy so we * can we certain that nobody messes with the files on disk. We also hold a ref on the store which means * no external source will delete files either.*/ return NoLockFactory.INSTANCE.obtainLock(in, name); }
protected Directory createLocalDirForIndexWriter(LuceneIndexDefinition definition, String dirName) throws IOException { String indexPath = definition.getIndexPath(); File indexWriterDir = getIndexDir(definition, indexPath, dirName); //By design indexing in Oak is single threaded so Lucene locking //can be disabled Directory dir = FSDirectory.open(indexWriterDir, NoLockFactory.getNoLockFactory()); log.debug("IndexWriter would use {}", indexWriterDir); return dir; }
@Override public Lock obtainLock(String name) throws IOException { /* we do explicitly a no-lock instance since we hold an index commit from a SnapshotDeletionPolicy so we * can we certain that nobody messes with the files on disk. We also hold a ref on the store which means * no external source will delete files either.*/ return NoLockFactory.INSTANCE.obtainLock(in, name); }
private DocumentSearcher(final ContextualEnvironment environment, final boolean withPrefixing) throws IOException { this.environment = environment; final StoreConfig config = withPrefixing ? StoreConfig.WITHOUT_DUPLICATES_WITH_PREFIXING : StoreConfig.WITHOUT_DUPLICATES; this.directory = new ExodusDirectory(environment, config, NoLockFactory.getNoLockFactory()); this.analyzer = createAnalyzer(); }
@Override public Lock obtainLock(String name) throws IOException { /* we do explicitly a no-lock instance since we hold an index commit from a SnapshotDeletionPolicy so we * can we certain that nobody messes with the files on disk. We also hold a ref on the store which means * no external source will delete files either.*/ return NoLockFactory.INSTANCE.obtainLock(in, name); }
public OakDirectory(NodeBuilder builder, String dataNodeName, LuceneIndexDefinition definition, boolean readOnly, BlobFactory blobFactory, @NotNull ActiveDeletedBlobCollectorFactory.BlobDeletionCallback blobDeletionCallback, boolean streamingWriteEnabled) { this.lockFactory = NoLockFactory.getNoLockFactory(); this.builder = builder; this.dataNodeName = dataNodeName; this.directoryBuilder = readOnly ? builder.getChildNode(dataNodeName) : builder.child(dataNodeName); this.definition = definition; this.readOnly = readOnly; this.fileNames.addAll(getListing()); this.fileNamesAtStart = ImmutableSet.copyOf(this.fileNames); this.indexName = definition.getIndexName(); this.blobFactory = blobFactory; this.blobDeletionCallback = blobDeletionCallback; this.streamingWriteEnabled = streamingWriteEnabled; }
public OakDirectory(NodeBuilder builder, String dataNodeName, LuceneIndexDefinition definition, boolean readOnly, BlobFactory blobFactory, @NotNull ActiveDeletedBlobCollectorFactory.BlobDeletionCallback blobDeletionCallback, boolean streamingWriteEnabled) { this.lockFactory = NoLockFactory.getNoLockFactory(); this.builder = builder; this.dataNodeName = dataNodeName; this.directoryBuilder = readOnly ? builder.getChildNode(dataNodeName) : builder.child(dataNodeName); this.definition = definition; this.readOnly = readOnly; this.fileNames.addAll(getListing()); this.fileNamesAtStart = ImmutableSet.copyOf(this.fileNames); this.indexName = definition.getIndexName(); this.blobFactory = blobFactory; this.blobDeletionCallback = blobDeletionCallback; this.streamingWriteEnabled = streamingWriteEnabled; }
Preconditions.checkArgument(maxMergeFactor > 0); Directory directory = new SimpleFSDirectory(tmpDirFile, NoLockFactory.getNoLockFactory()); IndexWriter writer = LuceneIndexOutputFormat.createIndexWriter( directory,
@Override public Directory newInstance(LuceneIndexDefinition definition, NodeBuilder builder, String dirName, boolean reindex) throws IOException { File indexDir = DirectoryUtils.createIndexDir(baseDir, definition.getIndexPath()); File readMe = new File(indexDir, INDEX_METADATA_FILE_NAME); File subDir = DirectoryUtils.createSubDir(indexDir, dirName); FileUtils.forceMkdir(subDir); IndexMeta meta; if (!readMe.exists()) { meta = new IndexMeta(definition.getIndexPath()); } else { meta = new IndexMeta(readMe); } meta.addDirectoryMapping(dirName, subDir.getName()); DirectoryUtils.writeMeta(indexDir, meta); return FSDirectory.open(subDir, NoLockFactory.getNoLockFactory()); }
lockFactory = NoLockFactory.getNoLockFactory(); } else { String lockClassName = System.getProperty("org.apache.lucene.store.FSDirectoryLockFactoryClass");
lockFactory = NoLockFactory.getNoLockFactory(); } else { String lockClassName = System.getProperty("org.apache.lucene.store.FSDirectoryLockFactoryClass");
private Directory newIndexDirectory(LuceneIndexDefinition indexDefinition, NodeBuilder definition, String dirName) throws IOException { String path = null; if (FulltextIndexConstants.PERSISTENCE_FILE.equalsIgnoreCase( definition.getString(FulltextIndexConstants.PERSISTENCE_NAME))) { path = definition.getString(FulltextIndexConstants.PERSISTENCE_PATH); } if (path == null) { if (!remoteDirectory()) { return new BufferedOakDirectory(definition, dirName, indexDefinition, blobStore, blobDeletionCallback); } else { return new OakDirectory(definition, dirName, indexDefinition, false, blobStore, blobDeletionCallback); } } else { // try { File file = new File(path); file.mkdirs(); // TODO: no locking used // --> using the FS backend for the index is in any case // troublesome in clustering scenarios and for backup // etc. so instead of fixing these issues we'd better // work on making the in-content index work without // problems (or look at the Solr indexer as alternative) return FSDirectory.open(file, getNoLockFactory()); } } }
@Override public Directory newInstance(LuceneIndexDefinition definition, NodeBuilder builder, String dirName, boolean reindex) throws IOException { File indexDir = DirectoryUtils.createIndexDir(baseDir, definition.getIndexPath()); File readMe = new File(indexDir, INDEX_METADATA_FILE_NAME); File subDir = DirectoryUtils.createSubDir(indexDir, dirName); FileUtils.forceMkdir(subDir); IndexMeta meta; if (!readMe.exists()) { meta = new IndexMeta(definition.getIndexPath()); } else { meta = new IndexMeta(readMe); } meta.addDirectoryMapping(dirName, subDir.getName()); DirectoryUtils.writeMeta(indexDir, meta); return FSDirectory.open(subDir, NoLockFactory.getNoLockFactory()); }
lockFactory = NoLockFactory.getNoLockFactory(); } else { String lockClassName = System.getProperty("org.apache.lucene.store.FSDirectoryLockFactoryClass");