@Override public InputStream open(String path, OpenOptions options) throws IOException { path = stripPath(path); FileInputStream inputStream = new FileInputStream(path); try { ByteStreams.skipFully(inputStream, options.getOffset()); } catch (IOException e) { inputStream.close(); throw e; } return inputStream; }
@Override protected InputStream openObject(String key, OpenOptions options) throws IOException { try { return new GCSInputStream(mBucketName, key, mClient, options.getOffset()); } catch (ServiceException e) { throw new IOException(e.getMessage()); } } }
@Override protected InputStream openObject(String key, OpenOptions options) { try { return new KodoInputStream(key, mKodoClinet, options.getOffset(), mAlluxioConf.getBytes(PropertyKey.UNDERFS_OBJECT_STORE_MULTI_RANGE_CHUNK_SIZE)); } catch (QiniuException e) { LOG.error("Failed to open Object {}, Msg: {}", key, e); } return null; }
@Override protected InputStream openObject(String key, OpenOptions options) throws IOException { return new SwiftInputStream(mAccount, mContainerName, key, options.getOffset(), mAlluxioConf.getBytes(PropertyKey.UNDERFS_OBJECT_STORE_MULTI_RANGE_CHUNK_SIZE)); } }
@Override protected InputStream openObject(String key, OpenOptions options) throws IOException { try { return new OSSInputStream(mBucketName, key, mClient, options.getOffset(), mAlluxioConf.getBytes(PropertyKey.UNDERFS_OBJECT_STORE_MULTI_RANGE_CHUNK_SIZE)); } catch (ServiceException e) { throw new IOException(e.getMessage()); } } }
@Override protected InputStream openObject(String key, OpenOptions options) throws IOException { try { return new COSInputStream(mBucketNameInternal, key, mClient, options.getOffset(), mAlluxioConf.getBytes(PropertyKey.UNDERFS_OBJECT_STORE_MULTI_RANGE_CHUNK_SIZE)); } catch (CosClientException e) { throw new IOException(e.getMessage()); } } }
@Override protected InputStream openObject(String key, OpenOptions options) throws IOException { try { RetryPolicy retryPolicy = new ExponentialBackoffRetry( (int) mUfsConf.getMs(PropertyKey.UNDERFS_OBJECT_STORE_READ_RETRY_BASE_SLEEP_MS), (int) mUfsConf.getMs(PropertyKey.UNDERFS_OBJECT_STORE_READ_RETRY_MAX_SLEEP_MS), mUfsConf.getInt(PropertyKey.UNDERFS_OBJECT_STORE_READ_RETRY_MAX_NUM)); return new S3AInputStream(mBucketName, key, mClient, retryPolicy, options.getOffset()); } catch (AmazonClientException e) { throw new IOException(e); } } }
FSDataInputStream inputStream = hdfs.open(new Path(path)); try { inputStream.seek(options.getOffset()); } catch (IOException e) { inputStream.close();
LOG.debug("Reused the under file input stream resource of {}", nextId); inputStream.seek(openOptions.getOffset()); break; 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()));
/** * Tests for default {@link OpenOptions}. */ @Test public void defaults() throws IOException { OpenOptions options = OpenOptions.defaults(); Assert.assertEquals(0, options.getOffset()); }
/** * 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()); } }
@Override protected InputStream openObject(String key, OpenOptions options) throws IOException { return new SwiftInputStream(mAccount, mContainerName, key, options.getOffset()); } }
@Override protected InputStream openObject(String key, OpenOptions options) throws IOException { try { return new GCSInputStream(mBucketName, key, mClient, options.getOffset()); } catch (ServiceException e) { throw new IOException(e.getMessage()); } } }
@Override protected InputStream openObject(String key, OpenOptions options) throws IOException { try { return new S3InputStream(mBucketName, key, mClient, options.getOffset()); } catch (ServiceException e) { throw new IOException(e.getMessage()); } } }
@Override public InputStream open(String path, OpenOptions options) throws IOException { IOException te = null; RetryPolicy retryPolicy = new CountingRetry(MAX_TRY); while (retryPolicy.attemptRetry()) { try { FSDataInputStream inputStream = mFileSystem.open(new Path(path)); try { inputStream.seek(options.getOffset()); } catch (IOException e) { inputStream.close(); throw e; } return new GlusterFSUnderFileInputStream(inputStream); } catch (IOException e) { LOG.warn("{} try to open {} : {}", retryPolicy.getRetryCount(), path, e.getMessage()); te = e; } } throw te; }