/** * When handshake procedure completes, we should send all accumulated messages. */ public void sendAllFromOutputQueue() { try { if (state.get() != Session.STATE_HANDSHAKE) { OutputQueueItem queuedItem; int maxOutputs = MAX_RETRANSMIT_QUEUE_SIZE - retransmitMap.size(); int i = 0; while ((queuedItem = outputQueue.poll()) != null) { send(queuedItem.destination, queuedItem.payload); if (i++ > maxOutputs) break; } } } catch (InterruptedException e) { callErrorCallbacks("(sendAllFromOutputQueue) InterruptedException in node " + myNodeInfo.getNumber() + ": " + e); } }
@Override public void deliver(NodeInfo toNode, Notification notification) { if(!shutdown) { try { byte[] data = packNotifications(myInfo, Do.listOf(notification)); try { unpack(data); } catch (Exception e) { System.err.println("-- pack test failed -- " + e); e.printStackTrace(); System.exit(75); } adapter.send(toNode, data); } catch (InterruptedException e) { System.err.println("expected interrupt exception " + e.toString()); } catch (Exception e) { System.out.println("--------------> " + shutdown + " " + myInfo + " " + adapter + " " + consumer); e.printStackTrace(); } } }
@Override public void deliver(NodeInfo toNode, Notification notification) { try { byte[] data = packNotifications(myInfo, Do.listOf(notification)); logNotification(notification,toNode); if(adapter != null) { adapter.send(toNode, data); } else { report(getLabel(), "UDPAdapter is null"); } } catch (InterruptedException e) { report(getLabel(), "Expected interrupted exception"); } catch (Exception e) { report(getLabel(), "deliver exception: " + e.getMessage()); e.printStackTrace(); } }