private void sendUDT(MessageWrapper msg) { Address peer = msg.msg.getDestination(); Queue<MessageWrapper> delays = udtDelays.get(peer.asSocket()); if (delays != null) { component.extLog.debug("Delaying message while establishing connection: {}", msg); delays.add(msg); return; } Channel c = component.channels.getUDTChannel(peer); if (c == null) { c = component.channels.createUDTChannel(peer, component.bootstrapUDTClient); } if (c == null) { delays = new LinkedList<>(); udtDelays.put(peer.asSocket(), delays); component.extLog.debug("Delaying message while establishing connection: {}", msg); delays.add(msg); return; } component.extLog.debug("Sending message {}. Local {}, Remote {}", new Object[]{msg, c.localAddress(), c.remoteAddress()}); ChannelFuture cf = c.writeAndFlush(msg); if (msg.notify.isPresent()) { cf.addListener(new NotifyListener(msg.notify.get())); } }
private void sendTCP(MessageWrapper msg) { Address peer = msg.msg.getDestination(); Queue<MessageWrapper> delays = tcpDelays.get(peer.asSocket()); if (delays != null) { component.extLog.debug("Delaying message while establishing connection: {}", msg); delays.add(msg); return; } Channel c = component.channels.getTCPChannel(peer); if (c == null) { c = component.channels.createTCPChannel(peer, component.bootstrapTCPClient); } if (c == null) { delays = new LinkedList<>(); tcpDelays.put(peer.asSocket(), delays); component.extLog.debug("Delaying message while establishing connection: {}", msg); delays.add(msg); return; } component.extLog.debug("Sending message {}. Local {}, Remote {}", new Object[]{msg, c.localAddress(), c.remoteAddress()}); ChannelFuture cf = c.writeAndFlush(msg); if (msg.notify.isPresent()) { cf.addListener(new NotifyListener(msg.notify.get())); } }
private void send(MessageWrapper msg) { switch (msg.msg.getProtocol()) { case TCP: sendTCP(msg); break; case UDT: sendUDT(msg); break; case UDP: { ChannelFuture cf = component.sendUdpMessage(msg); if (msg.notify.isPresent()) { if (cf != null) { cf.addListener(new NotifyListener(msg.notify.get())); } else { msg.notify.get().prepareResponse(System.currentTimeMillis(), false, System.nanoTime()); component.notify(msg.notify.get()); } } } break; default: throw new Error("Unknown Transport type"); } }
private void retryUDT(Address peer) { Queue<MessageWrapper> delays = udtDelays.get(peer.asSocket()); if (delays == null) { return; } Channel c = component.channels.getUDTChannel(peer); if (c == null) { component.extLog.warn("Connection to {} still not available. Not retrying anything.", peer); return; } while (!delays.isEmpty()) { MessageWrapper msg = delays.poll(); component.extLog.debug("Sending message {}. Local {}, Remote {}", new Object[]{msg, c.localAddress(), c.remoteAddress()}); ChannelFuture cf = c.write(msg); if (msg.notify.isPresent()) { cf.addListener(new NotifyListener(msg.notify.get())); } } c.flush(); udtDelays.remove(peer.asSocket()); }
private void retryTCP(Address peer) { Queue<MessageWrapper> delays = tcpDelays.get(peer.asSocket()); if (delays == null) { return; } Channel c = component.channels.getTCPChannel(peer); if (c == null) { component.extLog.warn("Connection to {} still not available. Not retrying anything.", peer); return; } while (!delays.isEmpty()) { MessageWrapper msg = delays.poll(); component.extLog.debug("Sending message {}. Local {}, Remote {}", new Object[]{msg, c.localAddress(), c.remoteAddress()}); ChannelFuture cf = c.write(msg); if (msg.notify.isPresent()) { cf.addListener(new NotifyListener(msg.notify.get())); } } c.flush(); tcpDelays.remove(peer.asSocket()); }