|
@@ -159,7 +159,8 @@ public class NIOServerCnxn extends ServerCnxn {
|
|
throw new EndOfStreamException(
|
|
throw new EndOfStreamException(
|
|
"Unable to read additional data from client sessionid 0x"
|
|
"Unable to read additional data from client sessionid 0x"
|
|
+ Long.toHexString(sessionId)
|
|
+ Long.toHexString(sessionId)
|
|
- + ", likely client has closed socket");
|
|
|
|
|
|
+ + ", likely client has closed socket",
|
|
|
|
+ DisconnectReason.UNABLE_TO_READ_FROM_CLIENT);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -224,7 +225,8 @@ public class NIOServerCnxn extends ServerCnxn {
|
|
ByteBuffer bb;
|
|
ByteBuffer bb;
|
|
while ((bb = outgoingBuffers.peek()) != null) {
|
|
while ((bb = outgoingBuffers.peek()) != null) {
|
|
if (bb == ServerCnxnFactory.closeConn) {
|
|
if (bb == ServerCnxnFactory.closeConn) {
|
|
- throw new CloseRequestException("close requested");
|
|
|
|
|
|
+ throw new CloseRequestException("close requested",
|
|
|
|
+ DisconnectReason.CLIENT_CLOSED_CONNECTION);
|
|
}
|
|
}
|
|
if (bb == packetSentinel) {
|
|
if (bb == packetSentinel) {
|
|
packetSent();
|
|
packetSent();
|
|
@@ -274,7 +276,8 @@ public class NIOServerCnxn extends ServerCnxn {
|
|
// Remove the buffers that we have sent
|
|
// Remove the buffers that we have sent
|
|
while ((bb = outgoingBuffers.peek()) != null) {
|
|
while ((bb = outgoingBuffers.peek()) != null) {
|
|
if (bb == ServerCnxnFactory.closeConn) {
|
|
if (bb == ServerCnxnFactory.closeConn) {
|
|
- throw new CloseRequestException("close requested");
|
|
|
|
|
|
+ throw new CloseRequestException("close requested",
|
|
|
|
+ DisconnectReason.CLIENT_CLOSED_CONNECTION);
|
|
}
|
|
}
|
|
if (bb == packetSentinel) {
|
|
if (bb == packetSentinel) {
|
|
packetSent();
|
|
packetSent();
|
|
@@ -319,7 +322,8 @@ public class NIOServerCnxn extends ServerCnxn {
|
|
throw new EndOfStreamException(
|
|
throw new EndOfStreamException(
|
|
"Unable to read additional data from client sessionid 0x"
|
|
"Unable to read additional data from client sessionid 0x"
|
|
+ Long.toHexString(sessionId)
|
|
+ Long.toHexString(sessionId)
|
|
- + ", likely client has closed socket");
|
|
|
|
|
|
+ + ", likely client has closed socket",
|
|
|
|
+ DisconnectReason.UNABLE_TO_READ_FROM_CLIENT);
|
|
}
|
|
}
|
|
if (incomingBuffer.remaining() == 0) {
|
|
if (incomingBuffer.remaining() == 0) {
|
|
boolean isPayload;
|
|
boolean isPayload;
|
|
@@ -345,7 +349,8 @@ public class NIOServerCnxn extends ServerCnxn {
|
|
handleWrite(k);
|
|
handleWrite(k);
|
|
|
|
|
|
if (!initialized && !getReadInterest() && !getWriteInterest()) {
|
|
if (!initialized && !getReadInterest() && !getWriteInterest()) {
|
|
- throw new CloseRequestException("responded to info probe");
|
|
|
|
|
|
+ throw new CloseRequestException("responded to info probe",
|
|
|
|
+ DisconnectReason.INFO_PROBE);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} catch (CancelledKeyException e) {
|
|
} catch (CancelledKeyException e) {
|
|
@@ -354,14 +359,14 @@ public class NIOServerCnxn extends ServerCnxn {
|
|
if (LOG.isDebugEnabled()) {
|
|
if (LOG.isDebugEnabled()) {
|
|
LOG.debug("CancelledKeyException stack trace", e);
|
|
LOG.debug("CancelledKeyException stack trace", e);
|
|
}
|
|
}
|
|
- close();
|
|
|
|
|
|
+ close(DisconnectReason.CANCELLED_KEY_EXCEPTION);
|
|
} catch (CloseRequestException e) {
|
|
} catch (CloseRequestException e) {
|
|
// expecting close to log session closure
|
|
// expecting close to log session closure
|
|
close();
|
|
close();
|
|
} catch (EndOfStreamException e) {
|
|
} catch (EndOfStreamException e) {
|
|
LOG.warn(e.getMessage());
|
|
LOG.warn(e.getMessage());
|
|
// expecting close to log session closure
|
|
// expecting close to log session closure
|
|
- close();
|
|
|
|
|
|
+ close(e.getReason());
|
|
} catch (ClientCnxnLimitException e) {
|
|
} catch (ClientCnxnLimitException e) {
|
|
// Common case exception, print at debug level
|
|
// Common case exception, print at debug level
|
|
ServerMetrics.getMetrics().CONNECTION_REJECTED.add(1);
|
|
ServerMetrics.getMetrics().CONNECTION_REJECTED.add(1);
|
|
@@ -369,14 +374,14 @@ public class NIOServerCnxn extends ServerCnxn {
|
|
LOG.debug("Exception causing close of session 0x"
|
|
LOG.debug("Exception causing close of session 0x"
|
|
+ Long.toHexString(sessionId) + ": " + e.getMessage());
|
|
+ Long.toHexString(sessionId) + ": " + e.getMessage());
|
|
}
|
|
}
|
|
- close();
|
|
|
|
|
|
+ close(DisconnectReason.CLIENT_CNX_LIMIT);
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
LOG.warn("Exception causing close of session 0x"
|
|
LOG.warn("Exception causing close of session 0x"
|
|
+ Long.toHexString(sessionId) + ": " + e.getMessage());
|
|
+ Long.toHexString(sessionId) + ": " + e.getMessage());
|
|
if (LOG.isDebugEnabled()) {
|
|
if (LOG.isDebugEnabled()) {
|
|
LOG.debug("IOException stack trace", e);
|
|
LOG.debug("IOException stack trace", e);
|
|
}
|
|
}
|
|
- close();
|
|
|
|
|
|
+ close(DisconnectReason.IO_EXCEPTION);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -576,11 +581,17 @@ public class NIOServerCnxn extends ServerCnxn {
|
|
" sessionId: 0x" + Long.toHexString(sessionId);
|
|
" sessionId: 0x" + Long.toHexString(sessionId);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Close the cnxn and remove it from the factory cnxns list.
|
|
* Close the cnxn and remove it from the factory cnxns list.
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public void close() {
|
|
|
|
|
|
+ public void close(DisconnectReason reason) {
|
|
|
|
+ disconnectReason = reason;
|
|
|
|
+ close();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void close() {
|
|
setStale();
|
|
setStale();
|
|
if (!factory.removeCnxn(this)) {
|
|
if (!factory.removeCnxn(this)) {
|
|
return;
|
|
return;
|