Pavlin Radoslavov

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
...@@ -18,6 +18,7 @@ package org.onlab.onos.store.cluster.impl; ...@@ -18,6 +18,7 @@ package org.onlab.onos.store.cluster.impl;
18 import static com.google.common.base.Preconditions.checkArgument; 18 import static com.google.common.base.Preconditions.checkArgument;
19 import static org.onlab.util.Tools.namedThreads; 19 import static org.onlab.util.Tools.namedThreads;
20 20
21 +import java.util.HashMap;
21 import java.util.Map; 22 import java.util.Map;
22 import java.util.concurrent.ExecutorService; 23 import java.util.concurrent.ExecutorService;
23 import java.util.concurrent.Executors; 24 import java.util.concurrent.Executors;
...@@ -153,8 +154,20 @@ public class HazelcastLeadershipService implements LeadershipService { ...@@ -153,8 +154,20 @@ public class HazelcastLeadershipService implements LeadershipService {
153 154
154 @Override 155 @Override
155 public Map<String, Leadership> getLeaderBoard() { 156 public Map<String, Leadership> getLeaderBoard() {
156 - throw new UnsupportedOperationException("I don't know what to do." + 157 + Map<String, Leadership> result = new HashMap<>();
157 - " I wish you luck."); 158 +
159 + //
160 + // Get the leaders for the topics.
161 + // NOTE: A topic is listed only if this instance is running for
162 + // a leadership for that topic.
163 + //
164 + for (Topic topic : topics.values()) {
165 + Leadership leadership = new Leadership(topic.topicName(),
166 + topic.leader(),
167 + 0L); // TODO: epoch not used
168 + result.put(topic.topicName(), leadership);
169 + }
170 + return result;
158 } 171 }
159 172
160 @Override 173 @Override
...@@ -193,6 +206,15 @@ public class HazelcastLeadershipService implements LeadershipService { ...@@ -193,6 +206,15 @@ public class HazelcastLeadershipService implements LeadershipService {
193 } 206 }
194 207
195 /** 208 /**
209 + * Gets the topic name.
210 + *
211 + * @return the topic name
212 + */
213 + private String topicName() {
214 + return topicName;
215 + }
216 +
217 + /**
196 * Gets the leader for the topic. 218 * Gets the leader for the topic.
197 * 219 *
198 * @return the leader for the topic 220 * @return the leader for the topic
......