private void makeRequests(ReadCommand readCommand, Iterable<InetAddress> endpoints) { MessageOut<ReadCommand> message = null; boolean hasLocalEndpoint = false; for (InetAddress endpoint : endpoints) { if (isLocalRequest(endpoint)) { hasLocalEndpoint = true; continue; } if (traceState != null) traceState.trace("reading {} from {}", readCommand.isDigestQuery() ? "digest" : "data", endpoint); logger.trace("reading {} from {}", readCommand.isDigestQuery() ? "digest" : "data", endpoint); if (message == null) message = readCommand.createMessage(); MessagingService.instance().sendRR(message, endpoint, handler); } // We delay the local (potentially blocking) read till the end to avoid stalling remote requests. if (hasLocalEndpoint) { logger.trace("reading {} locally", readCommand.isDigestQuery() ? "digest" : "data"); StageManager.getStage(Stage.READ).maybeExecuteImmediately(new LocalReadRunnable(command, handler)); } }