Add missing implementation of HazelcastLeadershipService.getLeaderBoard()
NOTE: A topic is listed only if this instance is running for
a leadership for that topic.
Change-Id: I01450a83c54a9a47c9d4409139cdecc9152fbee1
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/cluster/impl/HazelcastLeadershipService.java b/core/store/dist/src/main/java/org/onlab/onos/store/cluster/impl/HazelcastLeadershipService.java
index 801b0b3..8e2a7ee 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/cluster/impl/HazelcastLeadershipService.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/cluster/impl/HazelcastLeadershipService.java
@@ -18,6 +18,7 @@
import static com.google.common.base.Preconditions.checkArgument;
import static org.onlab.util.Tools.namedThreads;
+import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -153,8 +154,20 @@
@Override
public Map<String, Leadership> getLeaderBoard() {
- throw new UnsupportedOperationException("I don't know what to do." +
- " I wish you luck.");
+ Map<String, Leadership> result = new HashMap<>();
+
+ //
+ // Get the leaders for the topics.
+ // NOTE: A topic is listed only if this instance is running for
+ // a leadership for that topic.
+ //
+ for (Topic topic : topics.values()) {
+ Leadership leadership = new Leadership(topic.topicName(),
+ topic.leader(),
+ 0L); // TODO: epoch not used
+ result.put(topic.topicName(), leadership);
+ }
+ return result;
}
@Override
@@ -193,6 +206,15 @@
}
/**
+ * Gets the topic name.
+ *
+ * @return the topic name
+ */
+ private String topicName() {
+ return topicName;
+ }
+
+ /**
* Gets the leader for the topic.
*
* @return the leader for the topic