minor fixes to RoleInfo
Change-Id: Ie3cfab9a18c18db3abef2a6c0c1a5c07e2ee102a
Showing
1 changed file
with
5 additions
and
10 deletions
1 | package org.onlab.onos.cluster; | 1 | package org.onlab.onos.cluster; |
2 | 2 | ||
3 | import java.util.Collections; | 3 | import java.util.Collections; |
4 | -import java.util.LinkedList; | ||
5 | import java.util.List; | 4 | import java.util.List; |
6 | import java.util.Objects; | 5 | import java.util.Objects; |
7 | 6 | ||
8 | -import static com.google.common.base.Preconditions.checkNotNull; | ||
9 | - | ||
10 | /** | 7 | /** |
11 | * A container for detailed role information for a device, | 8 | * A container for detailed role information for a device, |
12 | * within the current cluster. Role attributes include current | 9 | * within the current cluster. Role attributes include current |
... | @@ -18,9 +15,7 @@ public class RoleInfo { | ... | @@ -18,9 +15,7 @@ public class RoleInfo { |
18 | 15 | ||
19 | public RoleInfo(NodeId master, List<NodeId> backups) { | 16 | public RoleInfo(NodeId master, List<NodeId> backups) { |
20 | this.master = master; | 17 | this.master = master; |
21 | - this.backups = new LinkedList<>(); | 18 | + this.backups = Collections.unmodifiableList(backups); |
22 | - | ||
23 | - this.backups.addAll(checkNotNull(backups)); | ||
24 | } | 19 | } |
25 | 20 | ||
26 | public NodeId master() { | 21 | public NodeId master() { |
... | @@ -28,7 +23,7 @@ public class RoleInfo { | ... | @@ -28,7 +23,7 @@ public class RoleInfo { |
28 | } | 23 | } |
29 | 24 | ||
30 | public List<NodeId> backups() { | 25 | public List<NodeId> backups() { |
31 | - return Collections.unmodifiableList(backups); | 26 | + return backups; |
32 | } | 27 | } |
33 | 28 | ||
34 | @Override | 29 | @Override |
... | @@ -57,10 +52,10 @@ public class RoleInfo { | ... | @@ -57,10 +52,10 @@ public class RoleInfo { |
57 | @Override | 52 | @Override |
58 | public String toString() { | 53 | public String toString() { |
59 | final StringBuilder builder = new StringBuilder(); | 54 | final StringBuilder builder = new StringBuilder(); |
60 | - builder.append("master: \n\t").append(master).append("\n"); | 55 | + builder.append("master:").append(master).append(","); |
61 | - builder.append("backups: \n"); | 56 | + builder.append("backups:"); |
62 | for (NodeId n : backups) { | 57 | for (NodeId n : backups) { |
63 | - builder.append("\t").append(n).append("\n"); | 58 | + builder.append(" ").append(n); |
64 | } | 59 | } |
65 | return builder.toString(); | 60 | return builder.toString(); |
66 | } | 61 | } | ... | ... |
-
Please register or login to post a comment