aboutsummaryrefslogtreecommitdiffstats
path: root/vdslib/src/main/java/com/yahoo/vdslib/distribution/ConfiguredNode.java
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
committerJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
commit72231250ed81e10d66bfe70701e64fa5fe50f712 (patch)
tree2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /vdslib/src/main/java/com/yahoo/vdslib/distribution/ConfiguredNode.java
Publish
Diffstat (limited to 'vdslib/src/main/java/com/yahoo/vdslib/distribution/ConfiguredNode.java')
-rw-r--r--vdslib/src/main/java/com/yahoo/vdslib/distribution/ConfiguredNode.java42
1 files changed, 42 insertions, 0 deletions
diff --git a/vdslib/src/main/java/com/yahoo/vdslib/distribution/ConfiguredNode.java b/vdslib/src/main/java/com/yahoo/vdslib/distribution/ConfiguredNode.java
new file mode 100644
index 00000000000..dd0ad29f16b
--- /dev/null
+++ b/vdslib/src/main/java/com/yahoo/vdslib/distribution/ConfiguredNode.java
@@ -0,0 +1,42 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.vdslib.distribution;
+
+/**
+ * A node configured to exist, with its configured node specific information.
+ * This is immutable. The identity and natural order of a node is its index.
+ *
+ * @author bratseth
+ */
+public class ConfiguredNode implements Comparable<ConfiguredNode> {
+
+ private final int index;
+
+ private final boolean retired;
+
+ public ConfiguredNode(int index, boolean retired) {
+ this.index = index;
+ this.retired = retired;
+ }
+
+ /** Return the index (distribution key) of this node */
+ public int index() { return index; }
+
+ /** Returns whether the node is configured to be retired */
+ public boolean retired() { return retired; }
+
+ @Override
+ public int hashCode() { return index; }
+
+ @Override
+ public boolean equals(Object other) {
+ if (other == this) return true;
+ if ( ! (other instanceof ConfiguredNode)) return false;
+ return ((ConfiguredNode)other).index == this.index;
+ }
+
+ @Override
+ public int compareTo(ConfiguredNode other) {
+ return Integer.compare(this.index, other.index);
+ }
+
+}