/** * If this server has initiated the connection, then it gives up on the * connection if it loses challenge. Otherwise, it keeps the connection. */ public void initiateConnection(final Socket sock, final Long sid) { try { startConnection(sock, sid); } catch (IOException e) { LOG.error("Exception while connecting, id: {}, addr: {}, closing learner connection", new Object[] { sid, sock.getRemoteSocketAddress() }, e); closeSocket(sock); return; } }
/** * Server receives a connection request and handles it asynchronously via * separate thread. */ public void receiveConnectionAsync(final Socket sock) { try { connectionExecutor.execute( new QuorumConnectionReceiverThread(sock)); connectionThreadCnt.incrementAndGet(); } catch (Throwable e) { LOG.error("Exception handling connection, addr: {}, closing server connection", sock.getRemoteSocketAddress()); closeSocket(sock); } }
/** * If this server receives a connection request, then it gives up on the new * connection if it wins. Notice that it checks whether it has a connection * to this server already or not. If it does, then it sends the smallest * possible long value to lose the challenge. * */ public void receiveConnection(final Socket sock) { DataInputStream din = null; try { din = new DataInputStream( new BufferedInputStream(sock.getInputStream())); handleConnection(sock, din); } catch (IOException e) { LOG.error("Exception handling connection, addr: {}, closing server connection", sock.getRemoteSocketAddress()); closeSocket(sock); } }
/** * Server will initiate the connection request to its peer server * asynchronously via separate connection thread. */ public void initiateConnectionAsync(final Socket sock, final Long sid) { if(!inprogressConnections.add(sid)){ // simply return as there is a connection request to // server 'sid' already in progress. LOG.debug("Connection request to server id: {} is already in progress, so skipping this request", sid); closeSocket(sock); return; } try { connectionExecutor.execute( new QuorumConnectionReqThread(sock, sid)); connectionThreadCnt.incrementAndGet(); } catch (Throwable e) { // Imp: Safer side catching all type of exceptions and remove 'sid' // from inprogress connections. This is to avoid blocking further // connection requests from this 'sid' in case of errors. inprogressConnections.remove(sid); LOG.error("Exception while submitting quorum connection request", e); closeSocket(sock); } }
/** * If this server has initiated the connection, then it gives up on the * connection if it loses challenge. Otherwise, it keeps the connection. */ public void initiateConnection(final Socket sock, final Long sid) { try { startConnection(sock, sid); } catch (IOException e) { LOG.error("Exception while connecting, id: {}, addr: {}, closing learner connection", new Object[] { sid, sock.getRemoteSocketAddress() }, e); closeSocket(sock); return; } }
/** * Server receives a connection request and handles it asynchronously via * separate thread. */ public void receiveConnectionAsync(final Socket sock) { try { connectionExecutor.execute( new QuorumConnectionReceiverThread(sock)); connectionThreadCnt.incrementAndGet(); } catch (Throwable e) { LOG.error("Exception handling connection, addr: {}, closing server connection", sock.getRemoteSocketAddress()); closeSocket(sock); } }
/** * If this server receives a connection request, then it gives up on the new * connection if it wins. Notice that it checks whether it has a connection * to this server already or not. If it does, then it sends the smallest * possible long value to lose the challenge. * */ public void receiveConnection(final Socket sock) { DataInputStream din = null; try { din = new DataInputStream( new BufferedInputStream(sock.getInputStream())); handleConnection(sock, din); } catch (IOException e) { LOG.error("Exception handling connection, addr: {}, closing server connection", sock.getRemoteSocketAddress()); closeSocket(sock); } }
/** * Server will initiate the connection request to its peer server * asynchronously via separate connection thread. */ public void initiateConnectionAsync(final Socket sock, final Long sid) { if(!inprogressConnections.add(sid)){ // simply return as there is a connection request to // server 'sid' already in progress. LOG.debug("Connection request to server id: {} is already in progress, so skipping this request", sid); closeSocket(sock); return; } try { connectionExecutor.execute( new QuorumConnectionReqThread(sock, sid)); connectionThreadCnt.incrementAndGet(); } catch (Throwable e) { // Imp: Safer side catching all type of exceptions and remove 'sid' // from inprogress connections. This is to avoid blocking further // connection requests from this 'sid' in case of errors. inprogressConnections.remove(sid); LOG.error("Exception while submitting quorum connection request", e); closeSocket(sock); } }
closeSocket(sock); throw e; } catch (X509Exception e) { LOG.warn("Cannot open secure channel to " + sid + " at election address " + electionAddr, e); closeSocket(sock); return false; } catch (IOException e) { + " at election address " + electionAddr, e); closeSocket(sock); return false;
} catch (IOException e) { LOG.warn("Ignoring exception reading or writing challenge: ", e); closeSocket(sock); return false; LOG.info("Have smaller server identifier, so dropping the " + "connection: (" + sid + ", " + self.getId() + ")"); closeSocket(sock);
} catch (IOException e) { LOG.warn("Ignoring exception reading or writing challenge: ", e); closeSocket(sock); return false; LOG.info("Have smaller server identifier, so dropping the " + "connection: (" + sid + ", " + this.mySid + ")"); closeSocket(sock);
} catch (InitialMessage.InitialMessageException ex) { LOG.error(ex.toString()); closeSocket(sock); return; closeSocket(sock); return; closeSocket(sock);
if (num_remaining_bytes < 0 || num_remaining_bytes > maxBuffer) { LOG.error("Unreasonable buffer length: {}", num_remaining_bytes); closeSocket(sock); return; closeSocket(sock); LOG.warn("Exception reading or writing challenge: " + e.toString()); return; closeSocket(sock); connectOne(sid);