|
@@ -61,6 +61,7 @@ import org.apache.hadoop.fs.FileEncryptionInfo;
|
|
import org.apache.hadoop.fs.HasEnhancedByteBufferAccess;
|
|
import org.apache.hadoop.fs.HasEnhancedByteBufferAccess;
|
|
import org.apache.hadoop.fs.ReadOption;
|
|
import org.apache.hadoop.fs.ReadOption;
|
|
import org.apache.hadoop.fs.StorageType;
|
|
import org.apache.hadoop.fs.StorageType;
|
|
|
|
+import org.apache.hadoop.fs.StreamCapabilities;
|
|
import org.apache.hadoop.hdfs.client.impl.BlockReaderFactory;
|
|
import org.apache.hadoop.hdfs.client.impl.BlockReaderFactory;
|
|
import org.apache.hadoop.hdfs.client.impl.DfsClientConf;
|
|
import org.apache.hadoop.hdfs.client.impl.DfsClientConf;
|
|
import org.apache.hadoop.hdfs.protocol.ClientDatanodeProtocol;
|
|
import org.apache.hadoop.hdfs.protocol.ClientDatanodeProtocol;
|
|
@@ -83,6 +84,7 @@ import org.apache.hadoop.security.token.SecretManager.InvalidToken;
|
|
import org.apache.hadoop.security.token.Token;
|
|
import org.apache.hadoop.security.token.Token;
|
|
import org.apache.hadoop.util.IdentityHashStore;
|
|
import org.apache.hadoop.util.IdentityHashStore;
|
|
import org.apache.hadoop.util.StopWatch;
|
|
import org.apache.hadoop.util.StopWatch;
|
|
|
|
+import org.apache.hadoop.util.StringUtils;
|
|
import org.apache.htrace.core.SpanId;
|
|
import org.apache.htrace.core.SpanId;
|
|
import org.apache.htrace.core.TraceScope;
|
|
import org.apache.htrace.core.TraceScope;
|
|
import org.apache.htrace.core.Tracer;
|
|
import org.apache.htrace.core.Tracer;
|
|
@@ -98,7 +100,7 @@ import javax.annotation.Nonnull;
|
|
@InterfaceAudience.Private
|
|
@InterfaceAudience.Private
|
|
public class DFSInputStream extends FSInputStream
|
|
public class DFSInputStream extends FSInputStream
|
|
implements ByteBufferReadable, CanSetDropBehind, CanSetReadahead,
|
|
implements ByteBufferReadable, CanSetDropBehind, CanSetReadahead,
|
|
- HasEnhancedByteBufferAccess, CanUnbuffer {
|
|
|
|
|
|
+ HasEnhancedByteBufferAccess, CanUnbuffer, StreamCapabilities {
|
|
@VisibleForTesting
|
|
@VisibleForTesting
|
|
public static boolean tcpReadsDisabledForTesting = false;
|
|
public static boolean tcpReadsDisabledForTesting = false;
|
|
private long hedgedReadOpsLoopNumForTesting = 0;
|
|
private long hedgedReadOpsLoopNumForTesting = 0;
|
|
@@ -1991,4 +1993,16 @@ public class DFSInputStream extends FSInputStream
|
|
public synchronized void unbuffer() {
|
|
public synchronized void unbuffer() {
|
|
closeCurrentBlockReaders();
|
|
closeCurrentBlockReaders();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean hasCapability(String capability) {
|
|
|
|
+ switch (StringUtils.toLowerCase(capability)) {
|
|
|
|
+ case StreamCapabilities.READAHEAD:
|
|
|
|
+ case StreamCapabilities.DROPBEHIND:
|
|
|
|
+ case StreamCapabilities.UNBUFFER:
|
|
|
|
+ return true;
|
|
|
|
+ default:
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|