try { // 这里发出了请求 client.send(request, time.milliseconds()); while (client.active()) { List<ClientResponse> responses = client.poll(Long.MAX_VALUE, time.milliseconds()); for (ClientResponse response : responses) { if (response.requestHeader().correlationId() == request.correlationId()) { if (response.wasDisconnected()) { thrownewIOException("Connection to " + response.destination() + " was disconnected before the response was read"); } if (response.versionMismatch() != null) { throw response.versionMismatch(); } return response; } } } thrownewIOException("Client was shutdown before response was read"); } catch (DisconnectException e) { if (client.active()) throw e; else thrownewIOException("Client was shutdown before response was read");
@Override public List<ClientResponse> poll(long timeout, long now) { ensureActive();
if (!abortedSends.isEmpty()) { // If there are aborted sends because of unsupported version exceptions or disconnects, // handle them immediately without waiting for Selector#poll. List<ClientResponse> responses = newArrayList<>(); handleAbortedSends(responses); completeResponses(responses); return responses; }
"metrics-1@746" prio=5 tid=0xf nid=NA runnable java.lang.Thread.State: RUNNABLE at sun.management.ThreadImpl.getThreadInfo(Native Method) at sun.management.ThreadImpl.getThreadInfo(ThreadImpl.java:185) at sun.management.ThreadImpl.getThreadInfo(ThreadImpl.java:149)