Search in sources :

Example 1 with Connection

use of tezc.core.connection.Connection in project tezcRaft by tezc.

the class Core method createConnection.

/**
 * Create connection for node
 * @param node node
 * @return     connection for node
 */
public Connection createConnection(PeerNode node) {
    Connection conn = new Connection(dispatcher, null, node);
    dispatcher.addEvent(new AddConnectionEvent(dispatcher, conn));
    return conn;
}
Also used : Connection(tezc.core.connection.Connection) AddConnectionEvent(tezc.core.worker.ioworker.AddConnectionEvent)

Example 2 with Connection

use of tezc.core.connection.Connection in project tezcRaft by tezc.

the class IOWorker method handleAcceptEvent.

/**
 * New connection arrived
 *
 * @param listener Listener object which has accepted the connection
 */
@Override
public void handleAcceptEvent(Listener listener) {
    Sock sock;
    try {
        sock = listener.accept();
    } catch (Exception e) {
        logError(e);
        return;
    }
    try {
        logInfo(listener.toString(), " accepted : ", sock);
        sock.register(poll.getSelector(), SelectionKey.OP_READ);
        sock.handshake();
    } catch (Exception e) {
        sock.close();
        logInfo("Disconnected : ", sock.toString());
        return;
    }
    pendings.add(new Connection(this, sock, null));
}
Also used : Sock(tezc.base.transport.sock.Sock) Connection(tezc.core.connection.Connection)

Aggregations

Connection (tezc.core.connection.Connection)2 Sock (tezc.base.transport.sock.Sock)1 AddConnectionEvent (tezc.core.worker.ioworker.AddConnectionEvent)1