szetszwo commented on a change in pull request #2682:
URL: https://github.com/apache/ozone/pull/2682#discussion_r718225475
##########
File path:
hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockDataStreamOutput.java
##########
@@ -184,7 +187,48 @@ private DataStreamOutput setupStream() throws IOException {
ContainerCommandRequestMessage.toMessage(builder.build(), null);
return Preconditions.checkNotNull(xceiverClient.getDataStreamApi())
- .stream(message.getContent().asReadOnlyByteBuffer());
+ .stream(message.getContent().asReadOnlyByteBuffer(),
+ getRoutingTable(pipeline));
+ }
+
+ public RoutingTable getRoutingTable(Pipeline pipeline) {
+ RaftPeerId primary = null;
+ List<RaftPeerId> raftPeers = new ArrayList();
+
+ for (DatanodeDetails dn : pipeline.getNodes()) {
+ RaftPeer.Builder raftPeerBuilder = RaftPeer.newBuilder();
+ raftPeerBuilder.setId(dn.getUuidString()).setAddress(dn.getIpAddress()
+ + ":" + dn.getPort(DatanodeDetails.Port.Name.RATIS_SERVER)
+ .getValue());
+ raftPeerBuilder.setDataStreamAddress(dn.getIpAddress()
+ + ":" + dn.getPort(DatanodeDetails.Port.Name.RATIS_DATASTREAM)
+ .getValue());
+ raftPeerBuilder.setAdminAddress(dn.getIpAddress()
+ + ":" +
dn.getPort(DatanodeDetails.Port.Name.RATIS_ADMIN).getValue());
+ raftPeerBuilder.setClientAddress(dn.getIpAddress()
+ + ":" + dn.getPort(DatanodeDetails.Port.Name.RATIS).getValue());
+ try {
+ if (dn == pipeline.getFirstNode()) {
+ primary = raftPeerBuilder.build().getId();
+
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
Review comment:
It should return null when there is an exception.
##########
File path:
hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockDataStreamOutput.java
##########
@@ -184,7 +187,48 @@ private DataStreamOutput setupStream() throws IOException {
ContainerCommandRequestMessage.toMessage(builder.build(), null);
return Preconditions.checkNotNull(xceiverClient.getDataStreamApi())
- .stream(message.getContent().asReadOnlyByteBuffer());
+ .stream(message.getContent().asReadOnlyByteBuffer(),
+ getRoutingTable(pipeline));
+ }
+
+ public RoutingTable getRoutingTable(Pipeline pipeline) {
+ RaftPeerId primary = null;
+ List<RaftPeerId> raftPeers = new ArrayList();
+
+ for (DatanodeDetails dn : pipeline.getNodes()) {
+ RaftPeer.Builder raftPeerBuilder = RaftPeer.newBuilder();
+ raftPeerBuilder.setId(dn.getUuidString()).setAddress(dn.getIpAddress()
+ + ":" + dn.getPort(DatanodeDetails.Port.Name.RATIS_SERVER)
+ .getValue());
+ raftPeerBuilder.setDataStreamAddress(dn.getIpAddress()
+ + ":" + dn.getPort(DatanodeDetails.Port.Name.RATIS_DATASTREAM)
+ .getValue());
+ raftPeerBuilder.setAdminAddress(dn.getIpAddress()
+ + ":" +
dn.getPort(DatanodeDetails.Port.Name.RATIS_ADMIN).getValue());
+ raftPeerBuilder.setClientAddress(dn.getIpAddress()
+ + ":" + dn.getPort(DatanodeDetails.Port.Name.RATIS).getValue());
Review comment:
Since RaftPeer is not needed, let's just create a RaftPeerId.
```
final RaftPeerId id = RaftPeerId.valueOf(dn.getUuidString());
```
##########
File path:
hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockDataStreamOutput.java
##########
@@ -184,7 +187,48 @@ private DataStreamOutput setupStream() throws IOException {
ContainerCommandRequestMessage.toMessage(builder.build(), null);
return Preconditions.checkNotNull(xceiverClient.getDataStreamApi())
- .stream(message.getContent().asReadOnlyByteBuffer());
+ .stream(message.getContent().asReadOnlyByteBuffer(),
+ getRoutingTable(pipeline));
+ }
+
+ public RoutingTable getRoutingTable(Pipeline pipeline) {
+ RaftPeerId primary = null;
+ List<RaftPeerId> raftPeers = new ArrayList();
Review comment:
It should have an "<>", i.e. `new ArrayList<>()`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]