private void processSelection(SelectionKey selection) { assert isReadOpsOnly(selection) : "only expected read"; //System.err.println("processSelection"); ClientConnection cc = (ClientConnection)selection.attachment(); boolean didWork = false; if (!cc.isClientClosedNotificationSent() && !cc.isDisconnecting()) { didWork = processConnection(didWork, cc); // if we need the channel we can get it from selection.channel().... } else { didWork = true; } //always remove in-case we need to get to the following doneSelectors.add(selection); if (!didWork) { hasRoomForMore = false;//if any one is blocked go work elsewhere. } }
private boolean tryWrite(int i) { ClientConnection cc = connections[i]; ByteBuffer mappedByteBuffer = buffers[i]; if (cc!=null && cc.isValid() && !cc.isDisconnecting()) { SocketChannel sc = cc.getSocketChannel(); if (sc!=null) {
private void abandonNow(ClientConnection abandonded) { Pipe<NetPayloadSchema> pipe = output[abandonded.getResponsePipeIdx()]; ///ensure that this will not cause any stall, better to skip this than be blocked. if (Pipe.hasRoomForWrite(pipe)) { long nowNS = System.nanoTime(); long callTime = abandonded.outstandingCallTime(nowNS); logger.warn("\nClient disconnected {} con:{} session:{} because call was taking too long. Estimated:{}", abandonded, abandonded.id, abandonded.sessionId,Appendables.appendNearestTimeUnit(new StringBuilder(), callTime)); abandonded.touchSentTime(nowNS);//rest the timeout so we do not attempt to close this again until the timeout has passed again. if (!abandonded.isDisconnecting()) { abandonded.beginDisconnect(); } int size = Pipe.addMsgIdx(pipe, NetPayloadSchema.MSG_DISCONNECT_203); Pipe.addLongValue(abandonded.getId(), pipe); Pipe.confirmLowLevelWrite(pipe, size); Pipe.publishWrites(pipe); //Do not set notification sent this message will trigger that one later once it makes it down the pipe. } }
if (cc.isValid() && !cc.isDisconnecting()) { cc.recordArrivalTime(temp);
&& (activeConnection.sessionId==sessionId) && (activeConnection.hostId == hostId) && (!activeConnection.isDisconnecting()) && (!activeConnection.isClientClosedNotificationSent())
|| cc.isDisconnecting() //was closed without notification and we need to establish a new socket || cc.isClientClosedNotificationSent() ) { if (cc.isDisconnecting()) { return cc;
if (!cc.isDisconnecting()) {