Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;

import org.apache.hadoop.hdds.utils.NettyMetrics;
import org.apache.hadoop.hdds.utils.TransactionInfo;
Expand Down Expand Up @@ -215,8 +216,10 @@ public void notifyConfigurationChanged(long term, long index,
RaftProtos.RaftConfigurationProto newRaftConfiguration) {
List<RaftProtos.RaftPeerProto> newPeers =
newRaftConfiguration.getPeersList();
LOG.info("Received Configuration change notification from Ratis. New Peer" +
" list:\n{}", newPeers);
List<String> newPeersLogWithoutStartupRole = newPeers.stream()
.map(peer -> String.format("id: \"%s\" address: \"%s\"", peer.getId().toStringUtf8(), peer.getAddress()))
.collect(Collectors.toList());
LOG.info("Received Configuration change notification from Ratis. New Peer list: {}", newPeersLogWithoutStartupRole);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Let's use StringBuilder instead of creating a new List.
  • Print also term and index.
    final StringBuilder b = new StringBuilder(1024)
        .append("notifyConfigurationChanged from Ratis: term=").append(term)
        .append(", index=").append(index)
        .append(", New Peer list: ");
   newPeers.forEach(peer -> b.append(peer.getId()).append("(").append(peer.getAddress()).append("), "));
   LOG.info(b.substring(0, b.length() - 2));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reviewing!

After the modification, the current log will be like:

notifyConfigurationChanged from Ratis: term=1, index=0, New Peer list: omNode-3(localhost:15015), omNode-1(localhost:15007), omNode-2(localhost:15011)


List<String> newPeerIds = new ArrayList<>();
for (RaftProtos.RaftPeerProto raftPeerProto : newPeers) {
Expand Down