public void register(SocketChannel socketChannel, AbstractSession session) throws ClosedChannelException { this.nextReactor().register(socketChannel, SelectionKey.OP_READ, session); }
public void register(SocketChannel socketChannel) throws ClosedChannelException { this.register(socketChannel, null); }
public ServerBootstrap(int reactors, int port) throws IOException { reactor = new Reactor(reactors, new DefaultSessionFactory()); acceptor = new Acceptor("goudai-rpc-accpector-trhead", new InetSocketAddress(port), this.reactor); this.port = port; }
@Override public void shutdown() { try { SessionManager.getInstance().close(); } catch (Exception e) { throw new RpcException(e.getMessage(), e); } this.connector.shutdown(); log.info("[{}] shutdown connector complete", this.connector); this.reactor.shutdown(); log.info("[{}] shutdown reactorPool complete", this.reactor); } }
public void register(SocketChannel socketChannel, int ops, AbstractSession session) throws ClosedChannelException { this.asyncRegistrySocketChannels.offer(new AsyncRegistrySocketChannel(socketChannel, ops, session)); this.doWakeup(); }
public Reactor(int rwCount, SessionFactory sessionFactory) throws IOException { if (rwCount <= 0) { rwCount = 1; log.warn("reactor less than 1,using auto reactors 1"); } this.rws = new RW[rwCount]; for (int i = 0; i < this.rws.length; i++) { this.rws[i] = new RW("$rw--" + i, sessionFactory); } this.rwCount = rwCount; }
public Connector(String name, Reactor reactor) throws IOException { super(name); this.setDaemon(true); this.reactor = reactor; this.selector = Selector.open(); }
public RW(String name, SessionFactory sessionFactory) throws IOException { super(name); this.setDaemon(true); this.selector = Selector.open(); this.sessionFactory = sessionFactory; }
public RequestSession(Connector connector, InetSocketAddress remoteAddress, SessionFactory sessionFactory) { this.connector = connector; this.remoteAddress = remoteAddress; this.sessionFactory = sessionFactory; try { session = connector.connect(this.remoteAddress, timeout, sessionFactory); } catch (Exception e) { throw new RequestSessionStartedException(e); } }
public ClusterServerBootstrap(int reactors) throws IOException { reactor = new Reactor(reactors, new DefaultSessionFactory()); acceptor = new Acceptor("goudai-rpc-accpector-trhead", new InetSocketAddress(ClusterConfig.port), this.reactor); }