diff options
Diffstat (limited to 'clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/NodeEvent.java')
-rw-r--r-- | clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/NodeEvent.java | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/NodeEvent.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/NodeEvent.java index 676f4228405..918c44b7caa 100644 --- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/NodeEvent.java +++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/NodeEvent.java @@ -1,11 +1,14 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.clustercontroller.core; +import java.util.Optional; + public class NodeEvent implements Event { private final NodeInfo node; private final String description; private final long eventTime; + private final Optional<String> bucketSpace; public enum Type { REPORTED, @@ -15,11 +18,28 @@ public class NodeEvent implements Event { private final Type type; - public NodeEvent(NodeInfo node, String description, Type type, long currentTime) { + private NodeEvent(NodeInfo node, String description, Type type, long currentTime) { + this.node = node; + this.description = description; + this.eventTime = currentTime; + this.type = type; + this.bucketSpace = Optional.empty(); + } + + private NodeEvent(NodeInfo node, String bucketSpace, String description, Type type, long currentTime) { this.node = node; this.description = description; this.eventTime = currentTime; this.type = type; + this.bucketSpace = Optional.of(bucketSpace); + } + + public static NodeEvent forBaseline(NodeInfo node, String description, Type type, long currentTime) { + return new NodeEvent(node, description, type, currentTime); + } + + public static NodeEvent forBucketSpace(NodeInfo node, String bucketSpace, String description, Type type, long currentTime) { + return new NodeEvent(node, bucketSpace, description, type, currentTime); } public NodeInfo getNode() { @@ -38,7 +58,14 @@ public class NodeEvent implements Event { @Override public String toString() { - return "Event: " + node.getNode() + ": " + description; + return "Event: " + getNodeBucketSpaceDescription() + ": " + description; + } + + private String getNodeBucketSpaceDescription() { + if (bucketSpace.isPresent()) { + return node.getNode() + " (" + bucketSpace.get() + ")"; + } + return node.getNode().toString(); } @Override @@ -50,4 +77,8 @@ public class NodeEvent implements Event { return type; } + public Optional<String> getBucketSpace() { + return bucketSpace; + } + } |