Skip to content

Commit 5cde582

Browse files
committed
add trace logging to unicast discovery
1 parent 5e4a1e8 commit 5cde582

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

modules/elasticsearch/src/main/java/org/elasticsearch/discovery/zen/ping/ZenPing.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,6 @@ public static PingResponse readPingResponse(StreamInput in) throws IOException {
9393

9494
@Override public void writeTo(StreamOutput out) throws IOException {
9595
clusterName.writeTo(out);
96-
if (target == null) {
97-
System.out.println("ARGH!");
98-
}
9996
target.writeTo(out);
10097
if (master == null) {
10198
out.writeBoolean(false);
@@ -106,7 +103,7 @@ public static PingResponse readPingResponse(StreamInput in) throws IOException {
106103
}
107104

108105
@Override public String toString() {
109-
return "ping_response target [" + target + "], master [" + master + "]";
106+
return "ping_response{target [" + target + "], master [" + master + "], cluster_name[" + clusterName.value() + "]}";
110107
}
111108
}
112109
}

modules/elasticsearch/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import org.elasticsearch.transport.*;
4040

4141
import java.io.IOException;
42+
import java.util.Arrays;
4243
import java.util.List;
4344
import java.util.Map;
4445
import java.util.Queue;
@@ -158,7 +159,7 @@ public PingResponse[] pingAndWait(TimeValue timeout) {
158159
}, timeout);
159160
}
160161

161-
private void sendPings(int id, TimeValue timeout, boolean wait) {
162+
private void sendPings(final int id, TimeValue timeout, boolean wait) {
162163
UnicastPingRequest pingRequest = new UnicastPingRequest();
163164
pingRequest.id = id;
164165
pingRequest.timeout = timeout;
@@ -185,11 +186,13 @@ private void sendPings(int id, TimeValue timeout, boolean wait) {
185186
try {
186187
transportService.connectToNode(nodeToSend);
187188
} catch (ConnectTransportException e) {
189+
logger.trace("[{}] failed to connect to {}", e, id, nodeToSend);
188190
latch.countDown();
189191
// can't connect to the node
190192
continue;
191193
}
192194

195+
logger.trace("[{}] connecting to {}, disconnect[{}]", id, nodeToSend, disconnectX);
193196
final boolean disconnect = disconnectX;
194197
transportService.sendRequest(nodeToSend, UnicastPingRequestHandler.ACTION, pingRequest, TransportRequestOptions.options().withTimeout((long) (timeout.millis() * 1.25)), new BaseTransportResponseHandler<UnicastPingResponse>() {
195198

@@ -198,6 +201,7 @@ private void sendPings(int id, TimeValue timeout, boolean wait) {
198201
}
199202

200203
@Override public void handleResponse(UnicastPingResponse response) {
204+
logger.trace("[{}] received response from {}: {}", id, nodeToSend, Arrays.toString(response.pingResponses));
201205
try {
202206
DiscoveryNodes discoveryNodes = nodesProvider.nodes();
203207
for (PingResponse pingResponse : response.pingResponses) {
@@ -210,6 +214,7 @@ private void sendPings(int id, TimeValue timeout, boolean wait) {
210214
}
211215
if (!pingResponse.clusterName().equals(clusterName)) {
212216
// not part of the cluster
217+
logger.debug("[{}] filtering out response from {}, not same cluster_name [{}]", pingResponse.target(), pingResponse.clusterName().value());
213218
return;
214219
}
215220
ConcurrentMap<DiscoveryNode, PingResponse> responses = receivedResponses.get(response.id);
@@ -228,6 +233,7 @@ private void sendPings(int id, TimeValue timeout, boolean wait) {
228233
latch.countDown();
229234
if (exp instanceof ConnectTransportException) {
230235
// ok, not connected...
236+
logger.trace("failed to connect to {}", exp, nodeToSend);
231237
} else {
232238
if (disconnect) {
233239
transportService.disconnectFromNode(nodeToSend);

0 commit comments

Comments
 (0)