@Override public InputStream open(String path) throws IOException { return open(path, OpenOptions.defaults()); }
JournalInputStream(UfsJournalFile file) throws IOException { mFile = file; LOG.info("Reading journal file {}.", file.getLocation()); mReader = new JournalEntryStreamReader(mUfs.open(file.getLocation().toString(), OpenOptions.defaults().setRecoverFailedOpen(true))); }
/** * Tests for default {@link OpenOptions}. */ @Test public void defaults() throws IOException { OpenOptions options = OpenOptions.defaults(); Assert.assertEquals(0, options.getOffset()); }
inputStream = mUnderFileInputStreamCache.get(nextId, () -> { SeekableUnderFileInputStream ufsStream = (SeekableUnderFileInputStream) ufs.open(path, OpenOptions.defaults().setOffset(openOptions.getOffset())); LOG.debug("Created the under file input stream resource of {}", newId); return new CachedSeekableInputStream(ufsStream, newId, fileId, path); path); return ufs.open(path, OpenOptions.defaults().setOffset(openOptions.getOffset()));
@Test public void createOpenAtPosition() throws IOException { String testFile = PathUtils.concatPath(mUnderfsAddress, "createOpenAtPosition"); prepareMultiBlockFile(testFile); int[] offsets = {0, 256, 511, 512, 513, 768, 1024, 1025}; for (int offset : offsets) { InputStream inputStream = mUfs.open(testFile, OpenOptions.defaults().setOffset(offset)); assertEquals(TEST_BYTES[offset % TEST_BYTES.length], inputStream.read()); inputStream.close(); } }
/** * Tests getting and setting fields. */ @Test public void fields() { OpenOptions options = OpenOptions.defaults(); long[] offsets = {100, 110, 150, 200}; for (long offset : offsets) { options.setOffset(offset); Assert.assertEquals(offset, options.getOffset()); } }
/** * Updates the UFS input stream given an offset to read. * * @param offset the read offset within the block */ private void updateUnderFileSystemInputStream(long offset) throws IOException { if ((mUnderFileSystemInputStream != null) && offset != mInStreamPos) { mUfsInstreamManager.release(mUnderFileSystemInputStream); mUnderFileSystemInputStream = null; mInStreamPos = -1; } if (mUnderFileSystemInputStream == null && offset < mBlockMeta.getBlockSize()) { UnderFileSystem ufs = mUfsResource.get(); mUnderFileSystemInputStream = mUfsInstreamManager.acquire(ufs, mBlockMeta.getUnderFileSystemPath(), IdUtils.fileIdFromBlockId(mBlockMeta.getBlockId()), OpenOptions.defaults().setOffset(mBlockMeta.getOffset() + offset)); mInStreamPos = offset; } }
@Override public InputStream open(String path) throws IOException { return open(path, OpenOptions.defaults()); }
JournalInputStream(UfsJournalFile file) throws IOException { mFile = file; LOG.info("Reading journal file {}.", file.getLocation()); mReader = new JournalEntryStreamReader(mUfs.open(file.getLocation().toString(), OpenOptions.defaults().setRecoverFailedOpen(true))); }