is the HDFS BlockReceiver.PacketResponder source code wrong ?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

is the HDFS BlockReceiver.PacketResponder source code wrong ?

QiXiangming
In org.apache.hadoop.hdfs.server.datanode.BlockReceiver class, defined a inner class PacketResponder.
 
in the the contructor of PacketResponder
 
    PacketResponder(final DataOutputStream upstreamOut,
        final DataInputStream downstreamIn,
        final DatanodeInfo[] downstreams) {
      this.downstreamIn = downstreamIn;
      this.upstreamOut = upstreamOut;
      this.type = downstreams == null? PacketResponderType.NON_PIPELINE
          : downstreams.length == 0? PacketResponderType.LAST_IN_PIPELINE
              : PacketResponderType.HAS_DOWNSTREAM_IN_PIPELINE;
      final StringBuilder b = new StringBuilder(getClass().getSimpleName())
          .append(": ").append(block).append(", type=").append(type);
      if (type != PacketResponderType.HAS_DOWNSTREAM_IN_PIPELINE) {
        b.append(", downstreams=").append(downstreams.length)
            .append(":").append(Arrays.asList(downstreams));
      }
      this.myString = b.toString();
    }

has there mistakes ?
 
 if (type != PacketResponderType.HAS_DOWNSTREAM_IN_PIPELINE) {
b.append(", downstreams=").append(downstreams.length)
.append(":").append(Arrays.asList(downstreams));
}
 
the if criteria shoud be ==, not !=
 
 
Reply | Threaded
Open this post in threaded view
|

RE: is the HDFS BlockReceiver.PacketResponder source code wrong ?

java8964 java8964
Why do you say so? Does it cause a bug in your case? If so, can you explain the problem you are facing?

Yong


From: [hidden email]
To: [hidden email]
Subject: is the HDFS BlockReceiver.PacketResponder source code wrong ?
Date: Tue, 23 Sep 2014 07:37:41 +0000

In org.apache.hadoop.hdfs.server.datanode.BlockReceiver class, defined a inner class PacketResponder.
 
in the the contructor of PacketResponder
 
    PacketResponder(final DataOutputStream upstreamOut,
        final DataInputStream downstreamIn,
        final DatanodeInfo[] downstreams) {
      this.downstreamIn = downstreamIn;
      this.upstreamOut = upstreamOut;
      this.type = downstreams == null? PacketResponderType.NON_PIPELINE
          : downstreams.length == 0? PacketResponderType.LAST_IN_PIPELINE
              : PacketResponderType.HAS_DOWNSTREAM_IN_PIPELINE;
      final StringBuilder b = new StringBuilder(getClass().getSimpleName())
          .append(": ").append(block).append(", type=").append(type);
      if (type != PacketResponderType.HAS_DOWNSTREAM_IN_PIPELINE) {
        b.append(", downstreams=").append(downstreams.length)
            .append(":").append(Arrays.asList(downstreams));
      }
      this.myString = b.toString();
    }

has there mistakes ?
 
 if (type != PacketResponderType.HAS_DOWNSTREAM_IN_PIPELINE) {
b.append(", downstreams=").append(downstreams.length)
.append(":").append(Arrays.asList(downstreams));
}
 
the if criteria shoud be ==, not !=