@Override public int hashCode() { int hash = 7; hash = 79 * hash + (this.getSource() != null ? this.getSource().hashCode() : 0); hash = 79 * hash + (this.getDestination() != null ? this.getDestination().hashCode() : 0); hash = 79 * hash + (this.getProtocol() != null ? this.getProtocol().hashCode() : 0); hash = 79 * hash + this.udtPort; hash = 79 * hash + (this.reply ? 1 : 0); return hash; }
channels.disambiguate(msg, c); if (msg.reply) { c.writeAndFlush(new MessageWrapper(new DisambiguateConnection(self, msg.getSource(), msg.getProtocol(), boundUDTPort, false)));
@Override public void channelActive(ChannelHandlerContext ctx) { super.channelActive(ctx); UdtChannel channel = (UdtChannel) ctx.channel(); component.channels.addLocalSocket(channel); InetSocketAddress other = channel.remoteAddress(); channel.writeAndFlush(new DisambiguateConnection(component.self, new NettyAddress(other), protocol, component.boundUDTPort, true)); }
if (c instanceof SocketChannel) { SocketChannel sc = (SocketChannel) c; address4Remote.put(sc.remoteAddress(), msg.getSource().asSocket()); tcpChannels.put(msg.getSource().asSocket(), sc); component.networkStatus(ConnectionStatus.established(msg.getSource(), Transport.TCP)); if (!tcpChannels.get(msg.getSource().asSocket()).isEmpty()) { // don't add if we don't have a TCP channel since host is most likely dead udtBoundPorts.put(msg.getSource().asSocket(), new InetSocketAddress(msg.getSource().getIp(), msg.udtPort)); component.trigger(new SendDelayed(msg.getSource(), Transport.TCP)); if (waitingForCreationUDT.remove(msg.getSource().asSocket())) { component.extLog.debug("Requesting creation of outstanding UDT channel to {}", msg.getSource()); createUDTChannel(msg.getSource(), component.bootstrapUDTClient); address4Remote.put(uc.remoteAddress(), msg.getSource().asSocket()); udtChannels.put(msg.getSource().asSocket(), uc); component.networkStatus(ConnectionStatus.established(msg.getSource(), Transport.UDT)); if (!tcpChannels.get(msg.getSource().asSocket()).isEmpty()) { // don't add if we don't have a TCP channel since host is most likely dead udtBoundPorts.put(msg.getSource().asSocket(), new InetSocketAddress(msg.getSource().getIp(), msg.udtPort)); component.trigger(new SendDelayed(msg.getSource(), Transport.UDT));
@Override public void channelActive(ChannelHandlerContext ctx) { super.channelActive(ctx); SocketChannel channel = (SocketChannel) ctx.channel(); component.channels.addLocalSocket(channel); InetSocketAddress other = channel.remoteAddress(); DisambiguateConnection r = new DisambiguateConnection(component.self, new NettyAddress(other), protocol, component.boundUDTPort, true); channel.writeAndFlush(r); } }
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final DisambiguateConnection other = (DisambiguateConnection) obj; if (this.getSource() != other.getSource() && (this.getSource() == null || !this.getSource().equals(other.getSource()))) { return false; } if (this.getDestination() != other.getDestination() && (this.getDestination() == null || !this.getDestination().equals(other.getDestination()))) { return false; } if (this.getProtocol() != other.getProtocol()) { return false; } if (this.udtPort != other.udtPort) { return false; } if (this.reply != other.reply) { return false; } return true; }
if (isa == null) { // We have to ask for the UDT port first, since it's random component.extLog.trace("Need to find UDT port at {} before creating channel.", destination.asSocket()); DisambiguateConnection r = new DisambiguateConnection(component.self, new NettyAddress(destination), Transport.TCP, component.boundUDTPort, true); SocketChannel tcpC = this.getTCPChannel(destination); if (tcpC == null) {
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(this.getClass().getSimpleName()); sb.append("("); sb.append("SRC: "); sb.append(this.getSource()); sb.append(", DST: "); sb.append(this.getDestination()); sb.append(", PRT: "); sb.append(this.getProtocol()); sb.append(", UDTport: "); sb.append(udtPort); sb.append(", reply? "); sb.append(reply); sb.append(")"); return sb.toString(); }
byte portLower = buf.readByte(); int udtPort = Ints.fromBytes((byte) 0, (byte) 0, portUpper, portLower); return new DisambiguateConnection(fields.src, fields.dst, fields.proto, udtPort, fields.flag1);
@Override public Object fromBinary(ByteBuf buf, DatagramPacket datagram) { byte type = buf.readByte(); SpecialSerializers.MessageSerializationUtil.MessageFields fields = SpecialSerializers.MessageSerializationUtil.msgFromBinary(buf); switch (type) { case DIS: { // Port 2 byte byte portUpper = buf.readByte(); byte portLower = buf.readByte(); int udtPort = Ints.fromBytes((byte) 0, (byte) 0, portUpper, portLower); return new DisambiguateConnection(new NettyAddress(datagram.sender()), new NettyAddress(datagram.recipient()), Transport.UDP, udtPort, fields.flag1); } case ACK: { UUID id = (UUID) SpecialSerializers.UUIDSerializer.INSTANCE.fromBinary(buf, Optional.absent()); return new NotifyAck(new NettyAddress(datagram.sender()), new NettyAddress(datagram.recipient()), Transport.UDP, id); } case ACK_REQ: { UUID id = (UUID) SpecialSerializers.UUIDSerializer.INSTANCE.fromBinary(buf, Optional.absent()); Msg msg = (Msg) Serializers.fromBinary(buf, datagram); return new AckRequestMsg(msg, id); } } return null; }