/** Just like {@link #open(Path)}, but allows you to * also specify a custom {@link LockFactory}. */ public static FSDirectory open(Path path, LockFactory lockFactory) throws IOException { if (Constants.JRE_IS_64BIT && MMapDirectory.UNMAP_SUPPORTED) { return new MMapDirectory(path, lockFactory); } else if (Constants.WINDOWS) { return new SimpleFSDirectory(path, lockFactory); } else { return new NIOFSDirectory(path, lockFactory); } }
/** Creates an IndexInput for the file with the given name. */ @Override public IndexInput openInput(String name, IOContext context) throws IOException { ensureOpen(); ensureCanRead(name); Path path = directory.resolve(name); SeekableByteChannel channel = Files.newByteChannel(path, StandardOpenOption.READ); return new SimpleFSIndexInput("SimpleFSIndexInput(path=\"" + path + "\")", channel, context); }
SimpleFSDirectory directory = new SimpleFSDirectory(configDir); try (IndexInput indexInput = directory.openInput(KEYSTORE_FILENAME, IOContext.READONCE)) { ChecksumIndexInput input = new BufferedChecksumIndexInput(indexInput); int formatVersion = CodecUtil.checkHeader(input, KEYSTORE_FILENAME, MIN_FORMAT_VERSION, FORMAT_VERSION);
ensureOpen(); SimpleFSDirectory directory = new SimpleFSDirectory(configDir); try (IndexOutput output = directory.createOutput(tmpFile, IOContext.DEFAULT)) { CodecUtil.writeHeader(output, KEYSTORE_FILENAME, FORMAT_VERSION); output.writeByte(password.length == 0 ? (byte)0 : (byte)1);
@Test public void marginIsRespected() throws Exception { writeFile(remote, "a"); FileUtils.write(new File(localFSDir, "beyond-margin"), "beyond-margin-data", (Charset) null); DelayCopyingSimpleFSDirectory.updateLastModified(localFSDir, "beyond-margin"); // Delay 1 more second to avoid FS time granularity CLOCK.waitUntil(CLOCK.getTime() + SAFE_MARGIN_FOR_DELETION + MARGIN_BUFFER_FOR_FS_GRANULARITY); FileUtils.write(new File(localFSDir, "within-margin"), "within-margin-data", (Charset) null); DelayCopyingSimpleFSDirectory.updateLastModified(localFSDir, "within-margin"); copier.getCoRDir().close(); assertEquals(Sets.newHashSet("within-margin", "a"), Sets.newHashSet(new SimpleFSDirectory(localFSDir).listAll())); }
@Override public int compare(ZoieMultiReader<R> r1, ZoieMultiReader<R> r2) { String name1 = ((SimpleFSDirectory)(r1.directory())).getDirectory().getName(); String name2 = ((SimpleFSDirectory)(r1.directory())).getDirectory().getName(); return name2.compareTo(name1); } });
@Override public IndexInputSlicer createSlicer(final String name, final IOContext context) throws IOException { ensureOpen(); final File file = new File(getDirectory(), name); final RandomAccessFile descriptor = new RandomAccessFile(file, "r"); return new IndexInputSlicer() { @Override public void close() throws IOException { descriptor.close(); } @Override public IndexInput openSlice(String sliceDescription, long offset, long length) { return new SimpleFSIndexInput("SimpleFSIndexInput(" + sliceDescription + " in path=\"" + file.getPath() + "\" slice=" + offset + ":" + (offset+length) + ")", descriptor, offset, length, BufferedIndexInput.bufferSize(context), getReadChunkSize()); } @Override public IndexInput openFullSlice() { try { return openSlice("full-slice", 0, descriptor.length()); } catch (IOException ex) { throw new RuntimeException(ex); } } }; }
/** Creates an IndexInput for the file with the given name. */ @Override public IndexInput openInput(String name, IOContext context) throws IOException { ensureOpen(); final File path = new File(directory, name); return new SimpleFSIndexInput("SimpleFSIndexInput(path=\"" + path.getPath() + "\")", path, context, getReadChunkSize()); }
/** Creates an IndexInput for the file with the given name. */ @Override public IndexInput openInput(String name, IOContext context) throws IOException { ensureOpen(); Path path = directory.resolve(name); SeekableByteChannel channel = Files.newByteChannel(path, StandardOpenOption.READ); return new SimpleFSIndexInput("SimpleFSIndexInput(path=\"" + path + "\")", channel, context); }
char[] password = this.keystorePassword.get().getPassword(); SimpleFSDirectory directory = new SimpleFSDirectory(configDir); try (IndexOutput output = directory.createOutput(tmpFile, IOContext.DEFAULT)) { CodecUtil.writeHeader(output, KEYSTORE_FILENAME, FORMAT_VERSION); output.writeByte(password.length == 0 ? (byte)0 : (byte)1);
Sets.newHashSet(new SimpleFSDirectory(localFSDir).listAll())); Sets.newHashSet(new SimpleFSDirectory(localFSDir).listAll())); Sets.newHashSet(new SimpleFSDirectory(localFSDir).listAll()));
@Override public int compare(ZoieIndexReader<R> r1, ZoieIndexReader<R> r2) { String name1 = ((SimpleFSDirectory) r1.directory()).getDirectory().getName(); String name2 = ((SimpleFSDirectory) r2.directory()).getDirectory().getName(); return name2.compareTo(name1); } });
/** Creates an IndexInput for the file with the given name. */ @Override public IndexInput openInput(String name, IOContext context) throws IOException { ensureOpen(); Path path = directory.resolve(name); SeekableByteChannel channel = Files.newByteChannel(path, StandardOpenOption.READ); return new SimpleFSIndexInput("SimpleFSIndexInput(path=\"" + path + "\")", channel, context); }
final FSDirectory lockDir = new SimpleFSDirectory(lockDirPath, NoLockFactory.INSTANCE); final InetSocketAddress addr = new InetSocketAddress(verifierHost, verifierPort); System.out.println("Connecting to server " + addr +
ensureOpen(); SimpleFSDirectory directory = new SimpleFSDirectory(configDir); try (IndexOutput output = directory.createOutput(tmpFile, IOContext.DEFAULT)) { CodecUtil.writeHeader(output, KEYSTORE_FILENAME, FORMAT_VERSION); output.writeByte(password.length == 0 ? (byte)0 : (byte)1);
SimpleFSDirectory directory = new SimpleFSDirectory(configDir); try (IndexInput indexInput = directory.openInput(KEYSTORE_FILENAME, IOContext.READONCE)) { ChecksumIndexInput input = new BufferedChecksumIndexInput(indexInput); int formatVersion = CodecUtil.checkHeader(input, KEYSTORE_FILENAME, MIN_FORMAT_VERSION, FORMAT_VERSION);
@Override public int compare(ZoieMultiReader<R> r1, ZoieMultiReader<R> r2) { String name1 = ((SimpleFSDirectory)(r1.directory())).getDirectory().getName(); String name2 = ((SimpleFSDirectory)(r1.directory())).getDirectory().getName(); return name2.compareTo(name1); } });
/** Creates an IndexInput for the file with the given name. */ @Override public IndexInput openInput(String name, IOContext context) throws IOException { ensureOpen(); ensureCanRead(name); Path path = directory.resolve(name); SeekableByteChannel channel = Files.newByteChannel(path, StandardOpenOption.READ); return new SimpleFSIndexInput("SimpleFSIndexInput(path=\"" + path + "\")", channel, context); }
protected Directory newDirectory(Path dir) throws IOException { return new SimpleFSDirectory(dir); }
ensureOpen(); SimpleFSDirectory directory = new SimpleFSDirectory(configDir); try (IndexOutput output = directory.createOutput(tmpFile, IOContext.DEFAULT)) { CodecUtil.writeHeader(output, KEYSTORE_FILENAME, FORMAT_VERSION); output.writeByte(password.length == 0 ? (byte)0 : (byte)1);