Madan Jampani
Committed by Gerrit Code Review

Use similar return types for LeadershipService.getCandidates() and LeadershipSer…

…vice.getCandidates(topic)

Change-Id: I9aaea9dfa14e4e9916103a61c8e59290ad656aa7
......@@ -16,8 +16,8 @@
package org.onosproject.cli.net;
import java.util.Comparator;
import java.util.Map;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import org.apache.karaf.shell.commands.Argument;
......@@ -94,7 +94,7 @@ public class LeaderCommand extends AbstractShellCommand {
}
private void displayCandidates(Map<String, Leadership> leaderBoard,
Map<String, Leadership> candidates) {
Map<String, List<NodeId>> candidates) {
print("--------------------------------------------------------------");
print(FMT_C, "Topic", "Leader", "Candidates");
print("--------------------------------------------------------------");
......@@ -104,7 +104,7 @@ public class LeaderCommand extends AbstractShellCommand {
.filter(l -> allTopics || pattern.matcher(l.topic()).matches())
.sorted(leadershipComparator)
.forEach(l -> {
List<NodeId> list = candidates.get(l.topic()).candidates();
List<NodeId> list = candidates.get(l.topic());
print(FMT_C,
l.topic(),
l.leader(),
......@@ -156,7 +156,7 @@ public class LeaderCommand extends AbstractShellCommand {
print("%s", json(leaderBoard));
} else {
if (showCandidates) {
Map<String, Leadership> candidates = leaderService.getCandidates();
Map<String, List<NodeId>> candidates = leaderService.getCandidates();
displayCandidates(leaderBoard, candidates);
} else {
displayLeaders(leaderBoard);
......
......@@ -15,9 +15,9 @@
*/
package org.onosproject.cluster;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.List;
/**
* Service for leader election.
......@@ -76,9 +76,9 @@ public interface LeadershipService {
/**
* Returns the candidates for all known topics.
*
* @return A mapping from topics to up-to-date candidate info.
* @return A mapping from topics to corresponding list of candidates.
*/
Map<String, Leadership> getCandidates();
Map<String, List<NodeId>> getCandidates();
/**
* Returns the candidates for a given topic.
......
......@@ -65,7 +65,7 @@ public class LeadershipServiceAdapter implements LeadershipService {
}
@Override
public Map<String, Leadership> getCandidates() {
public Map<String, List<NodeId>> getCandidates() {
return null;
}
......
......@@ -576,7 +576,7 @@ public class HazelcastLeadershipService implements LeadershipService {
}
@Override
public Map<String, Leadership> getCandidates() {
public Map<String, List<NodeId>> getCandidates() {
return null;
}
......
......@@ -166,8 +166,8 @@ public class DistributedLeadershipManager implements LeadershipService {
}
@Override
public Map<String, Leadership> getCandidates() {
return ImmutableMap.copyOf(candidateBoard);
public Map<String, List<NodeId>> getCandidates() {
return Maps.toMap(candidateBoard.keySet(), this::getCandidates);
}
@Override
......
......@@ -111,7 +111,7 @@ public class SimpleLeadershipManager implements LeadershipService {
}
@Override
public Map<String, Leadership> getCandidates() {
public Map<String, List<NodeId>> getCandidates() {
return null;
}
......