use of org.apache.hadoop.hdfs.ReplicaAccessor in project hadoop by apache.
the class BlockReaderFactory method tryToCreateExternalBlockReader.
private BlockReader tryToCreateExternalBlockReader() {
List<Class<? extends ReplicaAccessorBuilder>> clses = conf.getReplicaAccessorBuilderClasses();
for (Class<? extends ReplicaAccessorBuilder> cls : clses) {
try {
ByteArrayDataOutput bado = ByteStreams.newDataOutput();
token.write(bado);
byte[] tokenBytes = bado.toByteArray();
Constructor<? extends ReplicaAccessorBuilder> ctor = cls.getConstructor();
ReplicaAccessorBuilder builder = ctor.newInstance();
long visibleLength = startOffset + length;
ReplicaAccessor accessor = builder.setAllowShortCircuitReads(allowShortCircuitLocalReads).setBlock(block.getBlockId(), block.getBlockPoolId()).setGenerationStamp(block.getGenerationStamp()).setBlockAccessToken(tokenBytes).setClientName(clientName).setConfiguration(configuration).setFileName(fileName).setVerifyChecksum(verifyChecksum).setVisibleLength(visibleLength).build();
if (accessor == null) {
LOG.trace("{}: No ReplicaAccessor created by {}", this, cls.getName());
} else {
return new ExternalBlockReader(accessor, visibleLength, startOffset);
}
} catch (Throwable t) {
LOG.warn("Failed to construct new object of type " + cls.getName(), t);
}
}
return null;
}
Aggregations