Skip to content

Commit 10ea33b

Browse files
authored
HDDS-14217. Reconciler should not cast BlockExtendedInputStream to BlockInputStream (#9589)
1 parent b633473 commit 10ea33b

2 files changed

Lines changed: 20 additions & 4 deletions

File tree

hadoop-hdds/client/src/main/java/org/apache/hadoop/ozone/client/io/BlockInputStreamFactoryImpl.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,23 @@ private boolean allDataNodesSupportStreamBlock(Pipeline pipeline) {
110110
return true;
111111
}
112112

113+
/**
114+
* Create a new BlockInputStream for RATIS.
115+
*
116+
* @param blockInfo The blockInfo representing the block.
117+
* @param pipeline The pipeline to be used for reading the block
118+
* @param token The block Access Token
119+
* @param xceiverFactory Factory to create the xceiver in the client
120+
* @param refreshFunction Function to refresh the block location if needed
121+
* @param config The client configuration
122+
* @return BlockInputStream instance.
123+
*/
124+
public BlockInputStream createBlockInputStream(BlockLocationInfo blockInfo,
125+
Pipeline pipeline, Token<OzoneBlockTokenIdentifier> token,
126+
XceiverClientFactory xceiverFactory,
127+
Function<BlockID, BlockLocationInfo> refreshFunction,
128+
OzoneClientConfig config) throws IOException {
129+
130+
return new BlockInputStream(blockInfo, pipeline, token, xceiverFactory, refreshFunction, config);
131+
}
113132
}

hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueHandler.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@
9595
import org.apache.hadoop.fs.FileUtil;
9696
import org.apache.hadoop.hdds.HddsUtils;
9797
import org.apache.hadoop.hdds.client.BlockID;
98-
import org.apache.hadoop.hdds.client.RatisReplicationConfig;
9998
import org.apache.hadoop.hdds.conf.ConfigurationSource;
10099
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
101100
import org.apache.hadoop.hdds.conf.StorageUnit;
@@ -111,7 +110,6 @@
111110
import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ReadBlockRequestProto;
112111
import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.Type;
113112
import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.WriteChunkRequestProto;
114-
import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
115113
import org.apache.hadoop.hdds.scm.ByteStringConversion;
116114
import org.apache.hadoop.hdds.scm.OzoneClientConfig;
117115
import org.apache.hadoop.hdds.scm.ScmConfigKeys;
@@ -1853,8 +1851,7 @@ private long reconcileChunksPerBlock(KeyValueContainer container, Pipeline pipel
18531851
.build();
18541852
// Under construction is set here, during BlockInputStream#initialize() it is used to update the block length.
18551853
blkInfo.setUnderConstruction(true);
1856-
try (BlockInputStream blockInputStream = (BlockInputStream) blockInputStreamFactory.create(
1857-
RatisReplicationConfig.getInstance(HddsProtos.ReplicationFactor.ONE),
1854+
try (BlockInputStream blockInputStream = blockInputStreamFactory.createBlockInputStream(
18581855
blkInfo, pipeline, blockToken, dnClient.getXceiverClientManager(),
18591856
null, conf.getObject(OzoneClientConfig.class))) {
18601857
// Initialize the BlockInputStream. Gets the blockData from the peer, sets the block length and

0 commit comments

Comments
 (0)