mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Improved messages on all event. Shard events now resolve the relevant node ids to node object.
This commit is contained in:
parent
0b15c60926
commit
d5add9bb96
5 changed files with 53 additions and 10 deletions
|
@ -311,23 +311,32 @@ public class StatsExportersService extends AbstractLifecycleComponent<StatsExpor
|
|||
|
||||
|
||||
class IndicesLifeCycleListener extends IndicesLifecycle.Listener {
|
||||
|
||||
@Override
|
||||
public void afterIndexShardStarted(IndexShard indexShard) {
|
||||
DiscoveryNode relocatedFrom = null;
|
||||
if (indexShard.routingEntry().relocatingNodeId() != null) {
|
||||
relocatedFrom = clusterService.state().nodes().get(indexShard.routingEntry().relocatingNodeId());
|
||||
}
|
||||
pendingEventsQueue.add(new ShardEvent(System.currentTimeMillis(), ShardEvent.EventType.STARTED,
|
||||
indexShard.shardId(), indexShard.routingEntry()));
|
||||
indexShard.shardId(), clusterService.localNode(), relocatedFrom, indexShard.routingEntry()));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeIndexShardCreated(ShardId shardId) {
|
||||
pendingEventsQueue.add(new ShardEvent(System.currentTimeMillis(), ShardEvent.EventType.CREATED,
|
||||
shardId, null));
|
||||
shardId, clusterService.localNode(), null, null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeIndexShardClosed(ShardId shardId, @Nullable IndexShard indexShard) {
|
||||
DiscoveryNode relocatedTo = null;
|
||||
if (indexShard.routingEntry().relocating()) {
|
||||
relocatedTo = clusterService.state().nodes().get(indexShard.routingEntry().relocatingNodeId());
|
||||
}
|
||||
pendingEventsQueue.add(new ShardEvent(System.currentTimeMillis(), ShardEvent.EventType.CLOSED,
|
||||
indexShard.shardId(), indexShard.routingEntry()));
|
||||
indexShard.shardId(), clusterService.localNode(), relocatedTo, indexShard.routingEntry()));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ public abstract class ClusterEvent extends Event {
|
|||
|
||||
@Override
|
||||
String conciseDescription() {
|
||||
return node.toString() + (joined ? "joined" : "left");
|
||||
return node.toString() + (joined ? " joined" : " left");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -68,7 +68,7 @@ public abstract class IndexEvent extends Event {
|
|||
|
||||
@Override
|
||||
String conciseDescription() {
|
||||
return "[" + index + "] " + (created ? "created" : "deleted");
|
||||
return "[" + index + "] " + (created ? " created" : " deleted");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,10 +19,13 @@ package org.elasticsearch.marvel.monitor.event;
|
|||
*/
|
||||
|
||||
|
||||
import org.elasticsearch.ElasticSearchException;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.marvel.monitor.Utils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
|
@ -31,6 +34,8 @@ public class ShardEvent extends Event {
|
|||
|
||||
private final ShardRouting shardRouting;
|
||||
private final ShardId shardId;
|
||||
private final DiscoveryNode node;
|
||||
private final DiscoveryNode relocatingNode; // either relocating from or relocating to (depending on event)
|
||||
private EventType event;
|
||||
|
||||
public enum EventType {
|
||||
|
@ -40,10 +45,14 @@ public class ShardEvent extends Event {
|
|||
}
|
||||
|
||||
|
||||
public ShardEvent(long timestamp, EventType event, ShardId shardId, ShardRouting shardRouting) {
|
||||
public ShardEvent(long timestamp, EventType event, ShardId shardId, DiscoveryNode node,
|
||||
DiscoveryNode reloactingNode,
|
||||
ShardRouting shardRouting) {
|
||||
super(timestamp);
|
||||
this.event = event;
|
||||
this.shardId = shardId;
|
||||
this.node = node;
|
||||
this.relocatingNode = reloactingNode;
|
||||
this.shardRouting = shardRouting;
|
||||
}
|
||||
|
||||
|
@ -54,7 +63,26 @@ public class ShardEvent extends Event {
|
|||
|
||||
@Override
|
||||
String conciseDescription() {
|
||||
return "[" + event.toString().toLowerCase(Locale.ROOT) + "]" + (shardRouting != null ? shardRouting : shardId);
|
||||
switch (event) {
|
||||
case CREATED:
|
||||
// no shard routing
|
||||
return shardId + " created on" + node;
|
||||
case STARTED:
|
||||
if (relocatingNode != null) {
|
||||
return shardId + " started on " + node + ", relocated from " + relocatingNode;
|
||||
} else {
|
||||
return shardId + " started on " + node;
|
||||
}
|
||||
case CLOSED:
|
||||
if (relocatingNode != null) {
|
||||
return shardId + " closed on " + node + ", relocated to " + relocatingNode;
|
||||
} else {
|
||||
return shardId + " closed on " + node;
|
||||
}
|
||||
default:
|
||||
throw new ElasticSearchException("unmapped event type [" + event + "]");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -63,11 +91,18 @@ public class ShardEvent extends Event {
|
|||
builder.field("event", event.toString().toLowerCase(Locale.ROOT));
|
||||
builder.field("index", shardId.index());
|
||||
builder.field("shard_id", shardId.id());
|
||||
builder.startObject("node");
|
||||
Utils.NodeToXContent(node, builder);
|
||||
builder.endObject();
|
||||
if (shardRouting != null) {
|
||||
builder.field("routing");
|
||||
shardRouting.toXContent(builder, params);
|
||||
}
|
||||
|
||||
if (relocatingNode != null) {
|
||||
builder.startObject(event == EventType.STARTED ? "relocated_from" : "relocated_to");
|
||||
Utils.NodeToXContent(relocatingNode, builder);
|
||||
builder.endObject();
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -325,8 +325,7 @@ public class ESExporter extends AbstractLifecycleComponent<ESExporter> implement
|
|||
|
||||
private void addNodeInfo(XContentBuilder builder, String fieldname) throws IOException {
|
||||
builder.startObject(fieldname);
|
||||
DiscoveryNode node = discovery.localNode();
|
||||
Utils.NodeToXContent(node, builder);
|
||||
Utils.NodeToXContent(discovery.localNode(), builder);
|
||||
builder.endObject();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue