@Override public void connectionClosed(Connection conn, String reason) { removeConnectionIfPresent(conn.peerAddress(), conn); }
protected void sendToAll(byte[] data, int offset, int length) { for(Map.Entry<Address,Connection> entry: conns.entrySet()) { Connection conn=entry.getValue(); try { conn.send(data, offset, length); } catch(Throwable ex) { Address dest=entry.getKey(); removeConnectionIfPresent(dest, conn); log.error("failed sending data to %s: %s", dest, ex); } } }
protected void sendToAll(ByteBuffer data) { for(Map.Entry<Address,Connection> entry: conns.entrySet()) { Connection conn=entry.getValue(); try { conn.send(data.duplicate()); } catch(Throwable ex) { Address dest=entry.getKey(); removeConnectionIfPresent(dest, conn); log.error("failed sending data to %s: %s", dest, ex); } } }
public void closeConnection(Connection conn, Throwable ex) { Util.close(conn); notifyConnectionClosed(conn, ex.toString()); removeConnectionIfPresent(conn != null? conn.peerAddress() : null, conn); }
public void send(Address dest, ByteBuffer data) throws Exception { if(!validateArgs(dest, data)) return; if(dest == null) { sendToAll(data); return; } if(dest.equals(local_addr)) { receive(dest, data); return; } // Get a connection (or create one if not yet existent) and send the data Connection conn=null; try { conn=getConnection(dest); conn.send(data); } catch(Exception ex) { removeConnectionIfPresent(dest, conn); throw ex; } }
public void send(Address dest, byte[] data, int offset, int length) throws Exception { if(!validateArgs(dest, data)) return; if(dest == null) { sendToAll(data, offset, length); return; } if(dest.equals(local_addr)) { receive(dest, data, offset, length); return; } // Get a connection (or create one if not yet existent) and send the data Connection conn=null; try { conn=getConnection(dest); conn.send(data, offset, length); } catch(Exception ex) { removeConnectionIfPresent(dest, conn); throw ex; } }
removeConnectionIfPresent(dest, conn); // removes and closes the conn throw connect_exception;
@Override public void connectionClosed(Connection conn, String reason) { removeConnectionIfPresent(conn.peerAddress(), conn); }
protected void sendToAll(byte[] data, int offset, int length) { for(Map.Entry<Address,Connection> entry: conns.entrySet()) { Connection conn=entry.getValue(); try { conn.send(data, offset, length); } catch(Throwable ex) { Address dest=entry.getKey(); removeConnectionIfPresent(dest, conn); log.error("failed sending data to %s: %s", dest, ex); } } }
protected void sendToAll(ByteBuffer data) { for(Map.Entry<Address,Connection> entry: conns.entrySet()) { Connection conn=entry.getValue(); try { conn.send(data.duplicate()); } catch(Throwable ex) { Address dest=entry.getKey(); removeConnectionIfPresent(dest, conn); log.error("failed sending data to %s: %s", dest, ex); } } }
public void closeConnection(Connection conn, Throwable ex) { Util.close(conn); notifyConnectionClosed(conn, ex.toString()); removeConnectionIfPresent(conn != null? conn.peerAddress() : null, conn); }
public void send(Address dest, byte[] data, int offset, int length) throws Exception { if(!validateArgs(dest, data)) return; if(dest == null) { sendToAll(data, offset, length); return; } if(dest.equals(local_addr)) { receive(dest, data, offset, length); return; } // Get a connection (or create one if not yet existent) and send the data Connection conn=null; try { conn=getConnection(dest); conn.send(data, offset, length); } catch(Exception ex) { removeConnectionIfPresent(dest, conn); throw ex; } }
public void send(Address dest, ByteBuffer data) throws Exception { if(!validateArgs(dest, data)) return; if(dest == null) { sendToAll(data); return; } if(dest.equals(local_addr)) { receive(dest, data); return; } // Get a connection (or create one if not yet existent) and send the data Connection conn=null; try { conn=getConnection(dest); conn.send(data); } catch(Exception ex) { removeConnectionIfPresent(dest, conn); throw ex; } }
removeConnectionIfPresent(dest, conn); // removes and closes the conn throw connect_exception;