You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2015/03/04 10:27:17 UTC
[5/6] incubator-ignite git commit: # IGNITE-386: WIP.
# IGNITE-386: WIP.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/2cbc7ea5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/2cbc7ea5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/2cbc7ea5
Branch: refs/heads/ignite-386
Commit: 2cbc7ea5a16318dfd1a3bf2c946c4fa646eef5e9
Parents: 7ef9198
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Tue Mar 3 18:02:28 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Mar 3 18:02:28 2015 +0300
----------------------------------------------------------------------
.../org/apache/ignite/igfs/IgfsInputStream.java | 2 +-
.../igfs/secondary/IgfsSecondaryFileSystem.java | 2 +-
...fsSecondaryFileSystemPositionedReadable.java | 38 +++++++
.../IgfsSecondaryFileSystemReader.java | 38 -------
.../processors/igfs/IgfsDataManager.java | 2 +-
.../internal/processors/igfs/IgfsImpl.java | 2 +-
.../processors/igfs/IgfsInputStreamImpl.java | 4 +-
.../processors/igfs/IgfsMetaManager.java | 2 +-
.../IgfsSecondaryInputStreamDescriptor.java | 6 +-
.../fs/IgniteHadoopIgfsSecondaryFileSystem.java | 4 +-
...fsSecondaryFileSystemPositionedReadable.java | 104 +++++++++++++++++++
.../HadoopIgfsSecondaryFileSystemReader.java | 104 -------------------
12 files changed, 154 insertions(+), 154 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2cbc7ea5/modules/core/src/main/java/org/apache/ignite/igfs/IgfsInputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/igfs/IgfsInputStream.java b/modules/core/src/main/java/org/apache/ignite/igfs/IgfsInputStream.java
index 746aa6f..79d69a8 100644
--- a/modules/core/src/main/java/org/apache/ignite/igfs/IgfsInputStream.java
+++ b/modules/core/src/main/java/org/apache/ignite/igfs/IgfsInputStream.java
@@ -25,7 +25,7 @@ import java.io.*;
* {@code IGFS} input stream to read data from the file system.
* It provides several additional methods for asynchronous access.
*/
-public abstract class IgfsInputStream extends InputStream implements IgfsSecondaryFileSystemReader {
+public abstract class IgfsInputStream extends InputStream implements IgfsSecondaryFileSystemPositionedReadable {
/**
* Gets file length during file open.
*
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2cbc7ea5/modules/core/src/main/java/org/apache/ignite/igfs/secondary/IgfsSecondaryFileSystem.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/igfs/secondary/IgfsSecondaryFileSystem.java b/modules/core/src/main/java/org/apache/ignite/igfs/secondary/IgfsSecondaryFileSystem.java
index f306d67..abefd74 100644
--- a/modules/core/src/main/java/org/apache/ignite/igfs/secondary/IgfsSecondaryFileSystem.java
+++ b/modules/core/src/main/java/org/apache/ignite/igfs/secondary/IgfsSecondaryFileSystem.java
@@ -141,7 +141,7 @@ public interface IgfsSecondaryFileSystem {
* @throws IgniteException In case of error.
* @throws IgfsFileNotFoundException If path doesn't exist.
*/
- public IgfsSecondaryFileSystemReader open(IgfsPath path, int bufSize) throws IgniteException;
+ public IgfsSecondaryFileSystemPositionedReadable open(IgfsPath path, int bufSize) throws IgniteException;
/**
* Creates a file and opens it for writing.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2cbc7ea5/modules/core/src/main/java/org/apache/ignite/igfs/secondary/IgfsSecondaryFileSystemPositionedReadable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/igfs/secondary/IgfsSecondaryFileSystemPositionedReadable.java b/modules/core/src/main/java/org/apache/ignite/igfs/secondary/IgfsSecondaryFileSystemPositionedReadable.java
new file mode 100644
index 0000000..3b43c2a
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/igfs/secondary/IgfsSecondaryFileSystemPositionedReadable.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.igfs.secondary;
+
+import java.io.*;
+
+/**
+ * The simplest data input interface to read from secondary file system in dual modes.
+ */
+public interface IgfsSecondaryFileSystemPositionedReadable extends Closeable {
+ /**
+ * Read up to the specified number of bytes, from a given position within a file, and return the number of bytes
+ * read.
+ *
+ * @param pos Position in the input stream to seek.
+ * @param buf Buffer into which data is read.
+ * @param off Offset in the buffer from which stream data should be written.
+ * @param len The number of bytes to read.
+ * @return Total number of bytes read into the buffer, or -1 if there is no more data (EOF).
+ * @throws IOException In case of any exception.
+ */
+ public int read(long pos, byte[] buf, int off, int len) throws IOException;
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2cbc7ea5/modules/core/src/main/java/org/apache/ignite/igfs/secondary/IgfsSecondaryFileSystemReader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/igfs/secondary/IgfsSecondaryFileSystemReader.java b/modules/core/src/main/java/org/apache/ignite/igfs/secondary/IgfsSecondaryFileSystemReader.java
deleted file mode 100644
index 02a135e..0000000
--- a/modules/core/src/main/java/org/apache/ignite/igfs/secondary/IgfsSecondaryFileSystemReader.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.igfs.secondary;
-
-import java.io.*;
-
-/**
- * The simplest data input interface to read from secondary file system in dual modes.
- */
-public interface IgfsSecondaryFileSystemReader extends Closeable {
- /**
- * Read up to the specified number of bytes, from a given position within a file, and return the number of bytes
- * read.
- *
- * @param pos Position in the input stream to seek.
- * @param buf Buffer into which data is read.
- * @param off Offset in the buffer from which stream data should be written.
- * @param len The number of bytes to read.
- * @return Total number of bytes read into the buffer, or -1 if there is no more data (EOF).
- * @throws IOException In case of any exception.
- */
- public int read(long pos, byte[] buf, int off, int len) throws IOException;
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2cbc7ea5/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
index 964a5c2..333c5ca 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
@@ -383,7 +383,7 @@ public class IgfsDataManager extends IgfsManager {
* @throws IgniteCheckedException If failed.
*/
@Nullable public IgniteInternalFuture<byte[]> dataBlock(final IgfsFileInfo fileInfo, final IgfsPath path,
- final long blockIdx, @Nullable final IgfsSecondaryFileSystemReader secReader)
+ final long blockIdx, @Nullable final IgfsSecondaryFileSystemPositionedReadable secReader)
throws IgniteCheckedException {
//assert validTxState(any); // Allow this method call for any transaction state.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2cbc7ea5/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java
index 5d11fe7..c3c81f9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java
@@ -2034,7 +2034,7 @@ public final class IgfsImpl implements IgfsEx {
* @param metrics Metrics.
*/
IgfsEventAwareInputStream(IgfsContext igfsCtx, IgfsPath path, IgfsFileInfo fileInfo,
- int prefetchBlocks, int seqReadsBeforePrefetch, @Nullable IgfsSecondaryFileSystemReader secReader,
+ int prefetchBlocks, int seqReadsBeforePrefetch, @Nullable IgfsSecondaryFileSystemPositionedReadable secReader,
IgfsLocalMetrics metrics) {
super(igfsCtx, path, fileInfo, prefetchBlocks, seqReadsBeforePrefetch, secReader, metrics);
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2cbc7ea5/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInputStreamImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInputStreamImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInputStreamImpl.java
index c38103d..5afa523 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInputStreamImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInputStreamImpl.java
@@ -46,7 +46,7 @@ public class IgfsInputStreamImpl extends IgfsInputStreamAdapter {
/** Secondary file system reader. */
@SuppressWarnings("FieldAccessedSynchronizedAndUnsynchronized")
- private final IgfsSecondaryFileSystemReader secReader;
+ private final IgfsSecondaryFileSystemPositionedReadable secReader;
/** Logger. */
private IgniteLogger log;
@@ -111,7 +111,7 @@ public class IgfsInputStreamImpl extends IgfsInputStreamAdapter {
* @param metrics Local IGFS metrics.
*/
IgfsInputStreamImpl(IgfsContext igfsCtx, IgfsPath path, IgfsFileInfo fileInfo, int prefetchBlocks,
- int seqReadsBeforePrefetch, @Nullable IgfsSecondaryFileSystemReader secReader, IgfsLocalMetrics metrics) {
+ int seqReadsBeforePrefetch, @Nullable IgfsSecondaryFileSystemPositionedReadable secReader, IgfsLocalMetrics metrics) {
assert igfsCtx != null;
assert path != null;
assert fileInfo != null;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2cbc7ea5/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
index ea95875..f2fc9f9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
@@ -1784,7 +1784,7 @@ public class IgfsMetaManager extends IgfsManager {
if (remainder > 0) {
int blockIdx = (int)(len / blockSize);
- IgfsSecondaryFileSystemReader reader = fs.open(path, bufSize);
+ IgfsSecondaryFileSystemPositionedReadable reader = fs.open(path, bufSize);
try {
igfsCtx.data().dataBlock(info, path, blockIdx, reader).get();
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2cbc7ea5/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryInputStreamDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryInputStreamDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryInputStreamDescriptor.java
index b9728cd..e9ba6f4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryInputStreamDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryInputStreamDescriptor.java
@@ -27,7 +27,7 @@ public class IgfsSecondaryInputStreamDescriptor {
private final IgfsFileInfo info;
/** Secondary file system input stream wrapper. */
- private final IgfsSecondaryFileSystemReader secReader;
+ private final IgfsSecondaryFileSystemPositionedReadable secReader;
/**
* Constructor.
@@ -35,7 +35,7 @@ public class IgfsSecondaryInputStreamDescriptor {
* @param info File info in the primary file system.
* @param secReader Secondary file system reader.
*/
- IgfsSecondaryInputStreamDescriptor(IgfsFileInfo info, IgfsSecondaryFileSystemReader secReader) {
+ IgfsSecondaryInputStreamDescriptor(IgfsFileInfo info, IgfsSecondaryFileSystemPositionedReadable secReader) {
assert info != null;
assert secReader != null;
@@ -53,7 +53,7 @@ public class IgfsSecondaryInputStreamDescriptor {
/**
* @return Secondary file system reader.
*/
- IgfsSecondaryFileSystemReader reader() {
+ IgfsSecondaryFileSystemPositionedReadable reader() {
return secReader;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2cbc7ea5/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/IgniteHadoopIgfsSecondaryFileSystem.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/IgniteHadoopIgfsSecondaryFileSystem.java b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/IgniteHadoopIgfsSecondaryFileSystem.java
index 3e5f32f..dfdbe91 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/IgniteHadoopIgfsSecondaryFileSystem.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/IgniteHadoopIgfsSecondaryFileSystem.java
@@ -275,8 +275,8 @@ public class IgniteHadoopIgfsSecondaryFileSystem implements IgfsSecondaryFileSys
}
/** {@inheritDoc} */
- @Override public IgfsSecondaryFileSystemReader open(IgfsPath path, int bufSize) {
- return new HadoopIgfsSecondaryFileSystemReader(fileSys, convert(path), bufSize);
+ @Override public IgfsSecondaryFileSystemPositionedReadable open(IgfsPath path, int bufSize) {
+ return new HadoopIgfsSecondaryFileSystemPositionedReadable(fileSys, convert(path), bufSize);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2cbc7ea5/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/igfs/HadoopIgfsSecondaryFileSystemPositionedReadable.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/igfs/HadoopIgfsSecondaryFileSystemPositionedReadable.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/igfs/HadoopIgfsSecondaryFileSystemPositionedReadable.java
new file mode 100644
index 0000000..e921fd3
--- /dev/null
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/igfs/HadoopIgfsSecondaryFileSystemPositionedReadable.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.hadoop.igfs;
+
+import org.apache.hadoop.fs.*;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.ignite.igfs.secondary.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+
+import java.io.*;
+
+/**
+ * Secondary file system input stream wrapper which actually opens input stream only in case it is explicitly
+ * requested.
+ * <p>
+ * The class is expected to be used only from synchronized context and therefore is not tread-safe.
+ */
+public class HadoopIgfsSecondaryFileSystemPositionedReadable implements IgfsSecondaryFileSystemPositionedReadable {
+ /** Secondary file system. */
+ private final FileSystem fs;
+
+ /** Path to the file to open. */
+ private final Path path;
+
+ /** Buffer size. */
+ private final int bufSize;
+
+ /** Actual input stream. */
+ private FSDataInputStream in;
+
+ /** Cached error occurred during output stream open. */
+ private IOException err;
+
+ /** Flag indicating that the stream was already opened. */
+ private boolean opened;
+
+ /**
+ * Constructor.
+ *
+ * @param fs Secondary file system.
+ * @param path Path to the file to open.
+ * @param bufSize Buffer size.
+ */
+ public HadoopIgfsSecondaryFileSystemPositionedReadable(FileSystem fs, Path path, int bufSize) {
+ assert fs != null;
+ assert path != null;
+
+ this.fs = fs;
+ this.path = path;
+ this.bufSize = bufSize;
+ }
+
+ /** Get input stream. */
+ private PositionedReadable in() throws IOException {
+ if (opened) {
+ if (err != null)
+ throw err;
+ }
+ else {
+ opened = true;
+
+ try {
+ in = fs.open(path, bufSize);
+
+ if (in == null)
+ throw new IOException("Failed to open input stream (file system returned null): " + path);
+ }
+ catch (IOException e) {
+ err = e;
+
+ throw err;
+ }
+ }
+
+ return in;
+ }
+
+ /**
+ * Close wrapped input stream in case it was previously opened.
+ */
+ @Override public void close() {
+ U.closeQuiet(in);
+ }
+
+ /** {@inheritDoc} */
+ @Override public int read(long pos, byte[] buf, int off, int len) throws IOException {
+ return in().read(pos, buf, off, len);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2cbc7ea5/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/igfs/HadoopIgfsSecondaryFileSystemReader.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/igfs/HadoopIgfsSecondaryFileSystemReader.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/igfs/HadoopIgfsSecondaryFileSystemReader.java
deleted file mode 100644
index 15d5419..0000000
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/igfs/HadoopIgfsSecondaryFileSystemReader.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.hadoop.igfs;
-
-import org.apache.hadoop.fs.*;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.ignite.igfs.secondary.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-
-import java.io.*;
-
-/**
- * Secondary file system input stream wrapper which actually opens input stream only in case it is explicitly
- * requested.
- * <p>
- * The class is expected to be used only from synchronized context and therefore is not tread-safe.
- */
-public class HadoopIgfsSecondaryFileSystemReader implements IgfsSecondaryFileSystemReader {
- /** Secondary file system. */
- private final FileSystem fs;
-
- /** Path to the file to open. */
- private final Path path;
-
- /** Buffer size. */
- private final int bufSize;
-
- /** Actual input stream. */
- private FSDataInputStream in;
-
- /** Cached error occurred during output stream open. */
- private IOException err;
-
- /** Flag indicating that the stream was already opened. */
- private boolean opened;
-
- /**
- * Constructor.
- *
- * @param fs Secondary file system.
- * @param path Path to the file to open.
- * @param bufSize Buffer size.
- */
- public HadoopIgfsSecondaryFileSystemReader(FileSystem fs, Path path, int bufSize) {
- assert fs != null;
- assert path != null;
-
- this.fs = fs;
- this.path = path;
- this.bufSize = bufSize;
- }
-
- /** Get input stream. */
- private PositionedReadable in() throws IOException {
- if (opened) {
- if (err != null)
- throw err;
- }
- else {
- opened = true;
-
- try {
- in = fs.open(path, bufSize);
-
- if (in == null)
- throw new IOException("Failed to open input stream (file system returned null): " + path);
- }
- catch (IOException e) {
- err = e;
-
- throw err;
- }
- }
-
- return in;
- }
-
- /**
- * Close wrapped input stream in case it was previously opened.
- */
- @Override public void close() {
- U.closeQuiet(in);
- }
-
- /** {@inheritDoc} */
- @Override public int read(long pos, byte[] buf, int off, int len) throws IOException {
- return in().read(pos, buf, off, len);
- }
-}