@Override public void run() { try { LOG.info("running TCP storage server, address " + address); this.alive = true; while(true){ NaRPCServerChannel endpoint = serverEndpoint.accept(); LOG.info("new connection " + endpoint.address()); } } catch(Exception e){ e.printStackTrace(); } }
public NaRPCServerChannel accept() throws Exception { SocketChannel channel = serverSocket.accept(); NaRPCServerChannel serverChannel = new NaRPCServerChannel(serverGroup, channel); this.serverGroup.registerEndpoint(serverChannel); return serverChannel; }
public long fetch(NaRPCMessage message) throws IOException { long ticket = fetchBuffer(channel, buffer); if (ticket > 0){ message.update(buffer); } return ticket; }
long ticket = channel.fetch(request); if(ticket > 0){ T response = service.processRequest(request); channel.transmit(ticket, response); } else if (ticket < 0){ LOG.info("closing channel " + channel.address()); this.service.removeEndpoint(channel); key.cancel(); channel.close(); } else { throw new Exception("ticket number invalid");
public void processIncomingChannels() throws IOException{ NaRPCServerChannel channel = incomingChannels.poll(); while(channel != null){ SocketChannel socket = channel.getSocketChannel(); socket.configureBlocking(false); socket.socket().setTcpNoDelay(group.isNodelay()); socket.socket().setReuseAddress(true); socket.register(selector, SelectionKey.OP_READ, channel); LOG.info("adding new channel to selector, from " + socket.getRemoteAddress()); channel = incomingChannels.poll(); } } }
public void run() { try { while (true) { NaRPCServerChannel endpoint = serverEndpoint.accept(); LOG.info("new connection from " + endpoint.address()); } } catch (Exception e) { e.printStackTrace(); } } }
public void run() { try { while (true) { NaRPCServerChannel endpoint = serverEndpoint.accept(); LOG.info("new connection from " + endpoint.address()); } } catch (Exception e) { e.printStackTrace(); } } }
@Override public void run() { try { LOG.info("running TCP storage server, address " + address); this.alive = true; while(true){ NaRPCServerChannel endpoint = serverEndpoint.accept(); LOG.info("new connection " + endpoint.address()); } } catch(Exception e){ e.printStackTrace(); } }