@Override public boolean isValid(ClientConnection connection) { return null!=connection && connection.isValid(); }
private boolean connectionIsBad() { //only check once out of every 16 calls since this is expensive if (0 == (0xF&badConnectionCounter++)) { return (!activeConnection.isValid()) && activeConnection.isFinishConnect(); } else { return false;//assumed to be ok } }
public BaseConnection connectionObjForConnectionId(long connectionId, boolean alsoReturnDisconnected) { ClientConnection response = connections.get(connectionId); if (null != response) { if (response.isValid()) { connections.incUsageCount(response.id); return response; } else { //the connection has been disconnected if (!alsoReturnDisconnected) { response = null; } } } connections.resetUsageCount(connectionId); return response; }
public BaseConnection lookupConnectionById(long id) { if (null!=connections) { ClientConnection response = connections.get(id); if (null != response) { if (response.isValid()) { connections.incUsageCount(response.id); return response; } else { //logger.info("connection was disconnected {}",id); //the connection has been disconnected response = null; } } else { //logger.info("got null lookup {}",id); } connections.resetUsageCount(id); return response; } else { return null; } }
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 boolean writeEncrypted(boolean didWork, int i, Pipe<NetPayloadSchema> pipe) { long chnl = Pipe.peekLong(pipe, 0xF&NetPayloadSchema.MSG_ENCRYPTED_200_FIELD_CONNECTIONID_201); ClientConnection cc = (ClientConnection)ccm.lookupConnectionById(chnl); if (null==cc) {//closed or we can not get it yet, just push back till later. return false; } final int msgIdx = Pipe.takeMsgIdx(pipe); final long channelId = Pipe.takeLong(pipe); assert(chnl==channelId); final long arrivalTime = Pipe.takeLong(pipe); int meta = Pipe.takeByteArrayMetaData(pipe); //for string and byte array int len = Pipe.takeByteArrayLength(pipe); if (showWrites) { logger.info("/////\n/// has connection "+((cc!=null)&&cc.isValid())+" channelId "+channelId+" write encrypted length:"+len); } didWork = wrapupUpEncryptedToSingleWrite(didWork, i, pipe, msgIdx, channelId, meta, len, cc); return didWork; }
logger.info("/////\n///pos "+pos+" has connection "+((cc!=null)&&cc.isValid())+" channelId "+channelId+ "\n"+Appendables.appendUTF8(new StringBuilder(), Pipe.blob(pipe), pos, len, Pipe.blobMask(pipe)));
System.out.println("Con: "+conObjPrev.id+" registered:"+conObjPrev.isRegistered()+" valid:"+conObjPrev.isValid()+" Outstanding:" + Appendables.appendNearestTimeUnit(new StringBuilder(), conObjPrev.outstandingCallTime(System.nanoTime()))+" atIdx: "+prevConnectionId + " closedNoticeSent:"+conObjPrev.isClientClosedNotificationSent()
logger.info("/////\n/// has connection "+((cc!=null)&&cc.isValid())+" channelId "+channelId+" write encrypted length:"+len2);
if (cc.isValid() && !cc.isDisconnecting()) { cc.recordArrivalTime(temp);
private boolean writeDisconnect(Pipe<NetPayloadSchema> pipe) { long chnl = Pipe.peekLong(pipe, 0xF&NetPayloadSchema.MSG_DISCONNECT_203_FIELD_CONNECTIONID_201); ClientConnection cc = (ClientConnection)ccm.lookupConnectionById(chnl); int msgIdx = Pipe.takeMsgIdx(pipe); long channelId = Pipe.takeLong(pipe); assert(chnl==channelId); if (cc!=null) { if (cc.isValid()) { //only begin disconnect if not already disconnected cc.beginDisconnect();//do not close or we will not get any response } else { //already closed so remove value ccm.removeConnection(channelId); } } else { //already closed so remove value ccm.removeConnection(channelId);//already closed so remove if possible } Pipe.confirmLowLevelRead(pipe, Pipe.sizeOf(pipe, msgIdx)); Pipe.releaseReadLock(pipe); return true; }
|| (!cc.isValid()) //was closed with notification or not yet open