You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2019/12/17 17:07:27 UTC

[GitHub] [hadoop-ozone] adoroszlai commented on a change in pull request #363: HDDS-2679. Ratis ring creation might be failed with async pipeline creation.

adoroszlai commented on a change in pull request #363: HDDS-2679. Ratis ring creation might be failed with async pipeline creation.
URL: https://github.com/apache/hadoop-ozone/pull/363#discussion_r358884292
 
 

 ##########
 File path: hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/CreatePipelineCommandHandler.java
 ##########
 @@ -75,22 +98,35 @@ public void handle(SCMCommand command, OzoneContainer ozoneContainer,
     final CreatePipelineCommandProto createCommand =
         ((CreatePipelineCommand)command).getProto();
     final HddsProtos.PipelineID pipelineID = createCommand.getPipelineID();
-    Collection<DatanodeDetails> peers =
+    final Collection<DatanodeDetails> peers =
         createCommand.getDatanodeList().stream()
             .map(DatanodeDetails::getFromProtoBuf)
             .collect(Collectors.toList());
 
     try {
       XceiverServerSpi server = ozoneContainer.getWriteChannel();
-      server.addGroup(pipelineID, peers);
-      LOG.info("Create Pipeline {} {} #{} command succeed on datanode {}.",
-          createCommand.getType(), createCommand.getFactor(), pipelineID,
-          dn.getUuidString());
-      // Trigger heartbeat report
-      context.addReport(context.getParent().getContainer().getPipelineReport());
-      context.getParent().triggerHeartbeat();
-    } catch (NotLeaderException e) {
-      LOG.debug("Follower cannot create pipeline #{}.", pipelineID);
+      if (!server.isExist(pipelineID)) {
+        final RaftGroupId groupId = RaftGroupId.valueOf(
+            PipelineID.getFromProtobuf(pipelineID).getId());
+        final RaftGroup group = RatisHelper.newRaftGroup(groupId, peers);
+        server.addGroup(pipelineID, peers);
+        createCommand.getDatanodeList().stream().filter(
+            d -> !d.getUuid().equals(dn.getUuidString()))
+            .forEach(d -> {
+              final RaftPeer peer = RatisHelper.toRaftPeer(
+                  DatanodeDetails.getFromProtoBuf(d));
 
 Review comment:
   `peers` already contains converted `DatanodeDetails`, so this `getFromProtoBuf` can be avoided by streaming that list instead of the one from the command.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: ozone-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: ozone-issues-help@hadoop.apache.org