public RefCntRamDirectory(Directory dir) throws IOException { this(); // CODELUTIN Directory.copy(dir, this, false); // for (String file : dir.listAll()) { // dir.copy(this, file, file); // } // CODELUTIN }
private RAMDirectory(Directory dir, boolean closeDir) throws IOException { this(); Directory.copy(dir, this, closeDir); }
private TerracottaDirectory(Directory dir, boolean closeDir) throws IOException { this(DEFAULT_BUFFER_SIZE, DEFAULT_FLUSH_RATE); Directory.copy(dir, this, closeDir); }
private RAMDirectory(Directory dir, boolean closeDir) throws IOException { this(); Directory.copy(dir, this, closeDir); }
public void copy(Directory to, String src, String dest) throws IOException { _directory.copy(to, src, dest); }
@Override public void copy(Directory to, String src, String dest, IOContext context) throws IOException { createdFileNames.add(dest); other.copy(to, src, dest, context); }
@Override public void copy(Directory to, String src, String dest, IOContext context) throws IOException { ensureOpen(); delegate.copy(to, src, dest, context); }
private RAMDirectory(Directory dir, boolean closeDir, IOContext context) throws IOException { this(); for (String file : dir.listAll()) { dir.copy(this, file, file, context); } if (closeDir) { dir.close(); } }
private void copyDirectory(LuceneIndexDefinition definition, NodeBuilder definitionBuilder, String jcrName, File dir) throws IOException { try (Closer closer = Closer.create()) { Directory sourceDir = FSDirectory.open(dir); closer.register(sourceDir); //Remove any existing directory as in import case //the builder can have existing hidden node structures //So remove the ones which are being imported and leave // //others as is definitionBuilder.getChildNode(jcrName).remove(); Directory targetDir = new OakDirectory(definitionBuilder, jcrName, definition, false, blobStore); closer.register(targetDir); for (String file : sourceDir.listAll()) { sourceDir.copy(targetDir, file, file, IOContext.DEFAULT); } } } }
private void copyDirectory(LuceneIndexDefinition definition, NodeBuilder definitionBuilder, String jcrName, File dir) throws IOException { try (Closer closer = Closer.create()) { Directory sourceDir = FSDirectory.open(dir); closer.register(sourceDir); //Remove any existing directory as in import case //the builder can have existing hidden node structures //So remove the ones which are being imported and leave // //others as is definitionBuilder.getChildNode(jcrName).remove(); Directory targetDir = new OakDirectory(definitionBuilder, jcrName, definition, false, blobStore); closer.register(targetDir); for (String file : sourceDir.listAll()) { sourceDir.copy(targetDir, file, file, IOContext.DEFAULT); } } } }
private static void copy(Directory source, Directory dest) throws IOException { for (String file : source.listAll()) { source.copy(dest, file, file, IOContext.DEFAULT); } }
private void copyContent(NodeState idx, LuceneIndexDefinition defn, IndexMeta meta, File dir, String dirName, Closer closer) throws IOException { File idxDir = DirectoryUtils.createSubDir(dir, dirName); meta.addDirectoryMapping(dirName, idxDir.getName()); Directory sourceDir = new OakDirectory(new ReadOnlyBuilder(idx), dirName, defn, true); Directory targetDir = FSDirectory.open(idxDir); closer.register(sourceDir); closer.register(targetDir); for (String file : sourceDir.listAll()) { sourceDir.copy(targetDir, file, file, IOContext.DEFAULT); size += sourceDir.fileLength(file); } } }
private void copyContent(NodeState idx, LuceneIndexDefinition defn, IndexMeta meta, File dir, String dirName, Closer closer) throws IOException { File idxDir = DirectoryUtils.createSubDir(dir, dirName); meta.addDirectoryMapping(dirName, idxDir.getName()); Directory sourceDir = new OakDirectory(new ReadOnlyBuilder(idx), dirName, defn, true); Directory targetDir = FSDirectory.open(idxDir); closer.register(sourceDir); closer.register(targetDir); for (String file : sourceDir.listAll()) { sourceDir.copy(targetDir, file, file, IOContext.DEFAULT); size += sourceDir.fileLength(file); } } }
public void dumpIndexContent(String sourcePath, String destPath) throws IOException { LuceneIndexNode indexNode = null; try { if(sourcePath == null){ sourcePath = "/"; } indexNode = indexTracker.acquireIndexNode(sourcePath); if (indexNode != null) { log.info("Dumping Lucene directory content for [{}] to [{}]", sourcePath, destPath); Directory source = getDirectory(getPrimaryReader(indexNode.getPrimaryReaders())); checkNotNull(source, "IndexSearcher not backed by DirectoryReader"); Directory dest = FSDirectory.open(new File(destPath)); for (String file : source.listAll()) { source.copy(dest, file, file, IOContext.DEFAULT); } } } finally { if (indexNode != null) { indexNode.release(); } } }
public void dumpIndexContent(String sourcePath, String destPath) throws IOException { LuceneIndexNode indexNode = null; try { if(sourcePath == null){ sourcePath = "/"; } indexNode = indexTracker.acquireIndexNode(sourcePath); if (indexNode != null) { log.info("Dumping Lucene directory content for [{}] to [{}]", sourcePath, destPath); Directory source = getDirectory(getPrimaryReader(indexNode.getPrimaryReaders())); checkNotNull(source, "IndexSearcher not backed by DirectoryReader"); Directory dest = FSDirectory.open(new File(destPath)); for (String file : source.listAll()) { source.copy(dest, file, file, IOContext.DEFAULT); } } } finally { if (indexNode != null) { indexNode.release(); } } }
@Override public Void call() throws Exception { indexCopier.copyDone(); if (deletedFilesLocal.contains(name)){ skippedFiles.add(name); log.trace("[COW][{}] Skip copying of deleted file {}", indexPath, name); return null; } long fileSize = local.fileLength(name); LocalIndexFile file = new LocalIndexFile(local, name, fileSize, false); long perfStart = PERF_LOGGER.start(); long start = indexCopier.startCopy(file); local.copy(remote, name, name, IOContext.DEFAULT); indexCopier.doneCopy(file, start); PERF_LOGGER.end(perfStart, 0, "[COW][{}] Copied to remote {} -- size: {}", indexPath, name, IOUtils.humanReadableByteCount(fileSize)); return null; }
@Override public Void call() throws Exception { indexCopier.copyDone(); if (deletedFilesLocal.contains(name)){ skippedFiles.add(name); log.trace("[COW][{}] Skip copying of deleted file {}", indexPath, name); return null; } long fileSize = local.fileLength(name); LocalIndexFile file = new LocalIndexFile(local, name, fileSize, false); long perfStart = PERF_LOGGER.start(); long start = indexCopier.startCopy(file); local.copy(remote, name, name, IOContext.DEFAULT); indexCopier.doneCopy(file, start); PERF_LOGGER.end(perfStart, 0, "[COW][{}] Copied to remote {} -- size: {}", indexPath, name, IOUtils.humanReadableByteCount(fileSize)); return null; }
public static void copyDirectory( Directory source, Directory target ) throws IOException { //FIXME: check if this copies too much, Lucene 4 has no filter for lucene files //Directory.copy( source, target, false ); for (String file : source.listAll()) { source.copy(target, file, file, IOContext.DEFAULT); } copyFile( source, target, IndexingContext.INDEX_UPDATER_PROPERTIES_FILE ); copyFile( source, target, IndexingContext.INDEX_PACKER_PROPERTIES_FILE ); Date ts = getTimestamp( source ); updateTimestamp( target, ts ); }
@Override public void snapshot(Directory destDir) throws IOException { assertWriterNotClosed(); try (Ticker ignored = snapShotIndexMetric.start()) { final IndexCommit snapshot = snapshotter.snapshot(); try { for (String fileName : snapshot.getFileNames()) { snapshot.getDirectory().copy(destDir, fileName, fileName, IOContext.DEFAULT); } } finally { snapshotter.release(snapshot); } } }
public void replace( Directory directory ) throws IOException { synchronized ( indexLock ) { closeReaders(); deleteIndexFiles(); Directory.copy( directory, indexDirectory, false ); // reclaim the index as mine storeDescriptor(); timestamp = IndexUtils.getTimestamp( directory ); IndexUtils.updateTimestamp( indexDirectory, getTimestamp() ); optimize(); } }