nicer logging
This commit is contained in:
parent
be6aaa157f
commit
720e6a6d5b
|
@ -196,7 +196,7 @@ public class DiscoveryNodes implements Iterable<DiscoveryNode> {
|
|||
|
||||
public String prettyPrint() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Nodes: \n");
|
||||
sb.append("nodes: \n");
|
||||
for (DiscoveryNode node : this) {
|
||||
sb.append(" ").append(node);
|
||||
if (node == localNode()) {
|
||||
|
@ -272,16 +272,16 @@ public class DiscoveryNodes implements Iterable<DiscoveryNode> {
|
|||
if (!removed() && masterNodeChanged()) {
|
||||
if (newMasterNode.id().equals(localNodeId)) {
|
||||
// we are the master, no nodes we removed, we are actually the first master
|
||||
sb.append("New Master ").append(newMasterNode());
|
||||
sb.append("new_master ").append(newMasterNode());
|
||||
} else {
|
||||
// we are not the master, so we just got this event. No nodes were removed, so its not a *new* master
|
||||
sb.append("Detected Master ").append(newMasterNode());
|
||||
sb.append("detected_master ").append(newMasterNode());
|
||||
}
|
||||
} else {
|
||||
if (masterNodeChanged()) {
|
||||
sb.append("Master {New ").append(newMasterNode());
|
||||
sb.append("master {new ").append(newMasterNode());
|
||||
if (previousMasterNode() != null) {
|
||||
sb.append(", Previous ").append(previousMasterNode());
|
||||
sb.append(", previous ").append(previousMasterNode());
|
||||
}
|
||||
sb.append("}");
|
||||
}
|
||||
|
@ -289,7 +289,7 @@ public class DiscoveryNodes implements Iterable<DiscoveryNode> {
|
|||
if (masterNodeChanged()) {
|
||||
sb.append(", ");
|
||||
}
|
||||
sb.append("Removed {");
|
||||
sb.append("removed {");
|
||||
for (DiscoveryNode node : removedNodes()) {
|
||||
sb.append(node).append(',');
|
||||
}
|
||||
|
@ -302,7 +302,7 @@ public class DiscoveryNodes implements Iterable<DiscoveryNode> {
|
|||
if (removed() || masterNodeChanged()) {
|
||||
sb.append(", ");
|
||||
}
|
||||
sb.append("Added {");
|
||||
sb.append("added {");
|
||||
for (DiscoveryNode node : addedNodes()) {
|
||||
if (!node.id().equals(localNodeId)) {
|
||||
// don't print ourself
|
||||
|
|
|
@ -237,16 +237,16 @@ public class ImmutableShardRouting implements Streamable, Serializable, ShardRou
|
|||
@Override public String shortSummary() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append('[').append(index).append(']').append('[').append(shardId).append(']');
|
||||
sb.append(", Node[").append(currentNodeId).append("], ");
|
||||
sb.append(", node[").append(currentNodeId).append("], ");
|
||||
if (relocatingNodeId != null) {
|
||||
sb.append("Relocating [").append(relocatingNodeId).append("], ");
|
||||
sb.append("relocating [").append(relocatingNodeId).append("], ");
|
||||
}
|
||||
if (primary) {
|
||||
sb.append("[P]");
|
||||
} else {
|
||||
sb.append("[B]");
|
||||
sb.append("[R]");
|
||||
}
|
||||
sb.append(", S[").append(state).append("]");
|
||||
sb.append(", s[").append(state).append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -210,9 +210,9 @@ public class IndexRoutingTable implements Iterable<IndexShardRoutingTable> {
|
|||
|
||||
|
||||
public String prettyPrint() {
|
||||
StringBuilder sb = new StringBuilder("-- Index[" + index + "]\n");
|
||||
StringBuilder sb = new StringBuilder("-- index [" + index + "]\n");
|
||||
for (IndexShardRoutingTable indexShard : this) {
|
||||
sb.append("----ShardId[").append(indexShard.shardId().index().name()).append("][").append(indexShard.shardId().id()).append("]\n");
|
||||
sb.append("----shard_id [").append(indexShard.shardId().index().name()).append("][").append(indexShard.shardId().id()).append("]\n");
|
||||
for (ShardRouting shard : indexShard) {
|
||||
sb.append("--------").append(shard.shortSummary()).append("\n");
|
||||
}
|
||||
|
|
|
@ -145,7 +145,7 @@ public class RoutingNode implements Iterable<MutableShardRouting> {
|
|||
|
||||
public String prettyPrint() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("-----NodeId[").append(nodeId).append("]\n");
|
||||
sb.append("-----node_id[").append(nodeId).append("]\n");
|
||||
for (MutableShardRouting entry : shards) {
|
||||
sb.append("--------").append(entry.shortSummary()).append('\n');
|
||||
}
|
||||
|
|
|
@ -171,11 +171,11 @@ public class RoutingNodes implements Iterable<RoutingNode> {
|
|||
}
|
||||
|
||||
public String prettyPrint() {
|
||||
StringBuilder sb = new StringBuilder("Routing Nodes:\n");
|
||||
StringBuilder sb = new StringBuilder("routing_nodes:\n");
|
||||
for (RoutingNode routingNode : this) {
|
||||
sb.append(routingNode.prettyPrint());
|
||||
}
|
||||
sb.append("---- Unassigned\n");
|
||||
sb.append("---- unassigned\n");
|
||||
for (MutableShardRouting shardEntry : unassigned) {
|
||||
sb.append("--------").append(shardEntry.shortSummary()).append('\n');
|
||||
}
|
||||
|
|
|
@ -220,7 +220,7 @@ public class RoutingTable implements Iterable<IndexRoutingTable> {
|
|||
}
|
||||
|
||||
public String prettyPrint() {
|
||||
StringBuilder sb = new StringBuilder("Routing Table:\n");
|
||||
StringBuilder sb = new StringBuilder("routing_table:\n");
|
||||
for (Map.Entry<String, IndexRoutingTable> entry : indicesRouting.entrySet()) {
|
||||
sb.append(entry.getValue().prettyPrint()).append('\n');
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
|
|||
this.initialPingTimeout = componentSettings.getAsTime("initial_ping_timeout", timeValueSeconds(3));
|
||||
this.sendLeaveRequest = componentSettings.getAsBoolean("send_leave_request", true);
|
||||
|
||||
logger.debug("Using initial_ping_timeout [{}]", initialPingTimeout);
|
||||
logger.debug("using initial_ping_timeout [{}]", initialPingTimeout);
|
||||
|
||||
this.electMaster = new ElectMasterService(settings);
|
||||
|
||||
|
@ -164,7 +164,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
|
|||
try {
|
||||
membership.sendLeaveRequestBlocking(latestDiscoNodes.masterNode(), localNode, TimeValue.timeValueSeconds(1));
|
||||
} catch (Exception e) {
|
||||
logger.debug("Failed to send leave request to master [{}]", e, latestDiscoNodes.masterNode());
|
||||
logger.debug("failed to send leave request to master [{}]", e, latestDiscoNodes.masterNode());
|
||||
}
|
||||
} else {
|
||||
DiscoveryNode[] possibleMasters = electMaster.nextPossibleMasters(latestDiscoNodes.nodes().values(), 5);
|
||||
|
@ -175,7 +175,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
|
|||
try {
|
||||
membership.sendLeaveRequest(latestDiscoNodes.masterNode(), possibleMaster);
|
||||
} catch (Exception e) {
|
||||
logger.debug("Failed to send leave request from master [{}] to possible master [{}]", e, latestDiscoNodes.masterNode(), possibleMaster);
|
||||
logger.debug("failed to send leave request from master [{}] to possible master [{}]", e, latestDiscoNodes.masterNode(), possibleMaster);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
|
|||
// first, make sure we can connect to the master
|
||||
transportService.connectToNode(masterNode);
|
||||
} catch (Exception e) {
|
||||
logger.warn("Failed to connect to master [{}], retrying...", e, masterNode);
|
||||
logger.warn("failed to connect to master [{}], retrying...", e, masterNode);
|
||||
retry = true;
|
||||
continue;
|
||||
}
|
||||
|
@ -260,12 +260,12 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
|
|||
membership.sendJoinRequestBlocking(masterNode, localNode, initialPingTimeout);
|
||||
} catch (Exception e) {
|
||||
if (e instanceof ElasticSearchException) {
|
||||
logger.info("Failed to send join request to master [{}], reason [{}]", masterNode, ((ElasticSearchException) e).getDetailedMessage());
|
||||
logger.info("failed to send join request to master [{}], reason [{}]", masterNode, ((ElasticSearchException) e).getDetailedMessage());
|
||||
} else {
|
||||
logger.info("Failed to send join request to master [{}], reason [{}]", masterNode, e.getMessage());
|
||||
logger.info("failed to send join request to master [{}], reason [{}]", masterNode, e.getMessage());
|
||||
}
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Detailed failed reason", e);
|
||||
logger.trace("detailed failed reason", e);
|
||||
}
|
||||
// failed to send the join request, retry
|
||||
retry = true;
|
||||
|
@ -316,7 +316,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
|
|||
return;
|
||||
}
|
||||
|
||||
logger.info("Master [{}] left, reason [{}]", masterNode, reason);
|
||||
logger.info("master [{}] left, reason [{}]", masterNode, reason);
|
||||
List<DiscoveryNode> nodes = newArrayList(latestDiscoNodes.nodes().values());
|
||||
nodes.remove(masterNode); // remove the master node from the list, it has failed
|
||||
DiscoveryNode electedMaster = electMaster.electMaster(nodes); // elect master
|
||||
|
@ -353,7 +353,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
|
|||
|
||||
void handleNewClusterState(final ClusterState clusterState) {
|
||||
if (master) {
|
||||
logger.warn("Master should not receive new cluster state from [{}]", clusterState.nodes().masterNode());
|
||||
logger.warn("master should not receive new cluster state from [{}]", clusterState.nodes().masterNode());
|
||||
} else {
|
||||
latestDiscoNodes = clusterState.nodes();
|
||||
|
||||
|
@ -363,7 +363,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
|
|||
}
|
||||
|
||||
if (clusterState.nodes().localNode() == null) {
|
||||
logger.warn("Received a cluster state from [{}] and not part of the cluster, should not happen", clusterState.nodes().masterNode());
|
||||
logger.warn("received a cluster state from [{}] and not part of the cluster, should not happen", clusterState.nodes().masterNode());
|
||||
} else {
|
||||
clusterService.submitStateUpdateTask("zen-disco-receive(from [" + clusterState.nodes().masterNode() + "])", new ProcessedClusterStateUpdateTask() {
|
||||
@Override public ClusterState execute(ClusterState currentState) {
|
||||
|
@ -400,7 +400,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
|
|||
}
|
||||
if (!transportService.addressSupported(node.address().getClass())) {
|
||||
// TODO, what should we do now? Maybe inform that node that its crap?
|
||||
logger.warn("Received a wrong address type from [{}], ignoring...", node);
|
||||
logger.warn("received a wrong address type from [{}], ignoring...", node);
|
||||
} else {
|
||||
// try and connect to the node, if it fails, we can raise an exception back to the client...
|
||||
transportService.connectToNode(node);
|
||||
|
@ -409,7 +409,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
|
|||
@Override public ClusterState execute(ClusterState currentState) {
|
||||
if (currentState.nodes().nodeExists(node.id())) {
|
||||
// no change, the node already exists in the cluster
|
||||
logger.warn("Received a join request for an existing node [{}]", node);
|
||||
logger.warn("received a join request for an existing node [{}]", node);
|
||||
return currentState;
|
||||
}
|
||||
return newClusterStateBuilder().state(currentState).nodes(currentState.nodes().newNode(node)).build();
|
||||
|
@ -501,7 +501,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
|
|||
try {
|
||||
membership.sendJoinRequest(masterNode, localNode);
|
||||
} catch (Exception e) {
|
||||
logger.warn("Failed to send join request on disconnection from master [{}]", masterNode);
|
||||
logger.warn("failed to send join request on disconnection from master [{}]", masterNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ public class MulticastZenPing extends AbstractLifecycleComponent<ZenPing> implem
|
|||
this.bufferSize = componentSettings.getAsInt("buffer_size", 2048);
|
||||
this.ttl = componentSettings.getAsInt("ttl", 3);
|
||||
|
||||
logger.debug("Using group [{}], with port [{}], ttl [{}], and address [{}]", group, port, ttl, address);
|
||||
logger.debug("using group [{}], with port [{}], ttl [{}], and address [{}]", group, port, ttl, address);
|
||||
|
||||
this.transportService.registerHandler(MulticastPingResponseRequestHandler.ACTION, new MulticastPingResponseRequestHandler());
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ public class MulticastZenPing extends AbstractLifecycleComponent<ZenPing> implem
|
|||
try {
|
||||
sendPingRequest(id);
|
||||
} catch (Exception e) {
|
||||
logger.debug("[{}] Failed to send second ping request", e, id);
|
||||
logger.debug("[{}] failed to send second ping request", e, id);
|
||||
}
|
||||
}
|
||||
}, timeout.millis() / 2, TimeUnit.MILLISECONDS);
|
||||
|
@ -233,7 +233,7 @@ public class MulticastZenPing extends AbstractLifecycleComponent<ZenPing> implem
|
|||
try {
|
||||
multicastSocket.send(datagramPacketSend);
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("[{}] Sending ping request", id);
|
||||
logger.trace("[{}] sending ping request", id);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
receivedResponses.remove(id);
|
||||
|
@ -252,11 +252,11 @@ public class MulticastZenPing extends AbstractLifecycleComponent<ZenPing> implem
|
|||
|
||||
@Override public void messageReceived(MulticastPingResponse request, TransportChannel channel) throws Exception {
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("[{}] Received {}", request.id, request.pingResponse);
|
||||
logger.trace("[{}] received {}", request.id, request.pingResponse);
|
||||
}
|
||||
ConcurrentMap<DiscoveryNode, PingResponse> responses = receivedResponses.get(request.id);
|
||||
if (responses == null) {
|
||||
logger.warn("Received ping response with no matching id [{}]", request.id);
|
||||
logger.warn("received ping response with no matching id [{}]", request.id);
|
||||
} else {
|
||||
responses.put(request.pingResponse.target(), request.pingResponse);
|
||||
}
|
||||
|
@ -306,7 +306,7 @@ public class MulticastZenPing extends AbstractLifecycleComponent<ZenPing> implem
|
|||
continue;
|
||||
} catch (Exception e) {
|
||||
if (running) {
|
||||
logger.warn("Failed to receive packet", e);
|
||||
logger.warn("failed to receive packet", e);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -316,7 +316,7 @@ public class MulticastZenPing extends AbstractLifecycleComponent<ZenPing> implem
|
|||
clusterName = ClusterName.readClusterName(input);
|
||||
requestingNodeX = readNode(input);
|
||||
} catch (Exception e) {
|
||||
logger.warn("Failed to read requesting node from {}", e, datagramPacketReceive.getSocketAddress());
|
||||
logger.warn("failed to read requesting node from {}", e, datagramPacketReceive.getSocketAddress());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -335,7 +335,7 @@ public class MulticastZenPing extends AbstractLifecycleComponent<ZenPing> implem
|
|||
multicastPingResponse.pingResponse = new PingResponse(discoveryNodes.localNode(), discoveryNodes.masterNode(), clusterName);
|
||||
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("[{}] Received ping_request from [{}], sending {}", id, requestingNode, multicastPingResponse.pingResponse);
|
||||
logger.trace("[{}] received ping_request from [{}], sending {}", id, requestingNode, multicastPingResponse.pingResponse);
|
||||
}
|
||||
|
||||
if (!transportService.nodeConnected(requestingNode)) {
|
||||
|
@ -346,11 +346,11 @@ public class MulticastZenPing extends AbstractLifecycleComponent<ZenPing> implem
|
|||
try {
|
||||
transportService.connectToNode(requestingNode);
|
||||
} catch (Exception e) {
|
||||
logger.warn("Failed to connect to requesting node {}", e, requestingNode);
|
||||
logger.warn("failed to connect to requesting node {}", e, requestingNode);
|
||||
}
|
||||
transportService.sendRequest(requestingNode, MulticastPingResponseRequestHandler.ACTION, multicastPingResponse, new VoidTransportResponseHandler(false) {
|
||||
@Override public void handleException(RemoteTransportException exp) {
|
||||
logger.warn("Failed to receive confirmation on sent ping response to [{}]", exp, requestingNode);
|
||||
logger.warn("failed to receive confirmation on sent ping response to [{}]", exp, requestingNode);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -358,12 +358,12 @@ public class MulticastZenPing extends AbstractLifecycleComponent<ZenPing> implem
|
|||
} else {
|
||||
transportService.sendRequest(requestingNode, MulticastPingResponseRequestHandler.ACTION, multicastPingResponse, new VoidTransportResponseHandler(false) {
|
||||
@Override public void handleException(RemoteTransportException exp) {
|
||||
logger.warn("Failed to receive confirmation on sent ping response to [{}]", exp, requestingNode);
|
||||
logger.warn("failed to receive confirmation on sent ping response to [{}]", exp, requestingNode);
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.warn("Unexpected exception in multicast receiver", e);
|
||||
logger.warn("unexpected exception in multicast receiver", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ public class UnicastZenPing extends AbstractLifecycleComponent<ZenPing> implemen
|
|||
hosts.addAll(Strings.commaDelimitedListToSet(componentSettings.get("hosts")));
|
||||
}
|
||||
|
||||
logger.debug("Using initial hosts {}", hosts);
|
||||
logger.debug("using initial hosts {}", hosts);
|
||||
|
||||
List<DiscoveryNode> nodes = Lists.newArrayList();
|
||||
int idCounter = 0;
|
||||
|
@ -219,7 +219,7 @@ public class UnicastZenPing extends AbstractLifecycleComponent<ZenPing> implemen
|
|||
}
|
||||
ConcurrentMap<DiscoveryNode, PingResponse> responses = receivedResponses.get(response.id);
|
||||
if (responses == null) {
|
||||
logger.warn("Received ping response with no matching id [{}]", response.id);
|
||||
logger.warn("received ping response with no matching id [{}]", response.id);
|
||||
} else {
|
||||
responses.put(pingResponse.target(), pingResponse);
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ public class UnicastZenPing extends AbstractLifecycleComponent<ZenPing> implemen
|
|||
if (disconnect) {
|
||||
transportService.disconnectFromNode(nodeToSend);
|
||||
}
|
||||
logger.warn("Failed to send ping to [{}]", exp, node);
|
||||
logger.warn("failed to send ping to [{}]", exp, node);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -69,7 +69,7 @@ public class PublishClusterStateAction extends AbstractComponent {
|
|||
}
|
||||
transportService.sendRequest(node, PublishClusterStateRequestHandler.ACTION, new PublishClusterStateRequest(clusterState), new VoidTransportResponseHandler(false) {
|
||||
@Override public void handleException(RemoteTransportException exp) {
|
||||
logger.warn("Failed to send cluster state to [{}], should be detected as failed soon...", exp, node);
|
||||
logger.warn("failed to send cluster state to [{}], should be detected as failed soon...", exp, node);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue