switch to ImmutableList
Change-Id: Ia5f8936d0aaf447253f5dde0db1ee688441d2472
Showing
3 changed files
with
14 additions
and
3 deletions
1 | package org.onlab.onos.cluster; | 1 | package org.onlab.onos.cluster; |
2 | 2 | ||
3 | -import java.util.Collections; | ||
4 | import java.util.List; | 3 | import java.util.List; |
5 | import java.util.Objects; | 4 | import java.util.Objects; |
6 | 5 | ||
6 | +import com.google.common.collect.ImmutableList; | ||
7 | + | ||
7 | /** | 8 | /** |
8 | * A container for detailed role information for a device, | 9 | * A container for detailed role information for a device, |
9 | * within the current cluster. Role attributes include current | 10 | * within the current cluster. Role attributes include current |
... | @@ -15,7 +16,7 @@ public class RoleInfo { | ... | @@ -15,7 +16,7 @@ public class RoleInfo { |
15 | 16 | ||
16 | public RoleInfo(NodeId master, List<NodeId> backups) { | 17 | public RoleInfo(NodeId master, List<NodeId> backups) { |
17 | this.master = master; | 18 | this.master = master; |
18 | - this.backups = Collections.unmodifiableList(backups); | 19 | + this.backups = ImmutableList.copyOf(backups); |
19 | } | 20 | } |
20 | 21 | ||
21 | public NodeId master() { | 22 | public NodeId master() { | ... | ... |
... | @@ -8,6 +8,7 @@ import java.util.HashMap; | ... | @@ -8,6 +8,7 @@ import java.util.HashMap; |
8 | import org.onlab.onos.cluster.ControllerNode; | 8 | import org.onlab.onos.cluster.ControllerNode; |
9 | import org.onlab.onos.cluster.DefaultControllerNode; | 9 | import org.onlab.onos.cluster.DefaultControllerNode; |
10 | import org.onlab.onos.cluster.NodeId; | 10 | import org.onlab.onos.cluster.NodeId; |
11 | +import org.onlab.onos.cluster.RoleInfo; | ||
11 | import org.onlab.onos.mastership.MastershipTerm; | 12 | import org.onlab.onos.mastership.MastershipTerm; |
12 | import org.onlab.onos.net.ConnectPoint; | 13 | import org.onlab.onos.net.ConnectPoint; |
13 | import org.onlab.onos.net.DefaultAnnotations; | 14 | import org.onlab.onos.net.DefaultAnnotations; |
... | @@ -107,7 +108,8 @@ public final class KryoNamespaces { | ... | @@ -107,7 +108,8 @@ public final class KryoNamespaces { |
107 | Criterion.Type.class, | 108 | Criterion.Type.class, |
108 | DefaultTrafficTreatment.class, | 109 | DefaultTrafficTreatment.class, |
109 | Instructions.DropInstruction.class, | 110 | Instructions.DropInstruction.class, |
110 | - Instructions.OutputInstruction.class | 111 | + Instructions.OutputInstruction.class, |
112 | + RoleInfo.class | ||
111 | ) | 113 | ) |
112 | .register(URI.class, new URISerializer()) | 114 | .register(URI.class, new URISerializer()) |
113 | .register(NodeId.class, new NodeIdSerializer()) | 115 | .register(NodeId.class, new NodeIdSerializer()) | ... | ... |
... | @@ -3,6 +3,7 @@ package org.onlab.onos.store.serializers; | ... | @@ -3,6 +3,7 @@ package org.onlab.onos.store.serializers; |
3 | import static org.junit.Assert.assertEquals; | 3 | import static org.junit.Assert.assertEquals; |
4 | import static org.onlab.onos.net.DeviceId.deviceId; | 4 | import static org.onlab.onos.net.DeviceId.deviceId; |
5 | import static org.onlab.onos.net.PortNumber.portNumber; | 5 | import static org.onlab.onos.net.PortNumber.portNumber; |
6 | +import static java.util.Arrays.asList; | ||
6 | 7 | ||
7 | import java.nio.ByteBuffer; | 8 | import java.nio.ByteBuffer; |
8 | 9 | ||
... | @@ -11,6 +12,7 @@ import org.junit.Before; | ... | @@ -11,6 +12,7 @@ import org.junit.Before; |
11 | import org.junit.BeforeClass; | 12 | import org.junit.BeforeClass; |
12 | import org.junit.Test; | 13 | import org.junit.Test; |
13 | import org.onlab.onos.cluster.NodeId; | 14 | import org.onlab.onos.cluster.NodeId; |
15 | +import org.onlab.onos.cluster.RoleInfo; | ||
14 | import org.onlab.onos.mastership.MastershipTerm; | 16 | import org.onlab.onos.mastership.MastershipTerm; |
15 | import org.onlab.onos.net.Annotations; | 17 | import org.onlab.onos.net.Annotations; |
16 | import org.onlab.onos.net.ConnectPoint; | 18 | import org.onlab.onos.net.ConnectPoint; |
... | @@ -198,6 +200,12 @@ public class KryoSerializerTest { | ... | @@ -198,6 +200,12 @@ public class KryoSerializerTest { |
198 | } | 200 | } |
199 | 201 | ||
200 | @Test | 202 | @Test |
203 | + public void testRoleInfo() { | ||
204 | + testSerialized(new RoleInfo(new NodeId("master"), | ||
205 | + asList(new NodeId("stby1"), new NodeId("stby2")))); | ||
206 | + } | ||
207 | + | ||
208 | + @Test | ||
201 | public void testAnnotations() { | 209 | public void testAnnotations() { |
202 | // Annotations does not have equals defined, manually test equality | 210 | // Annotations does not have equals defined, manually test equality |
203 | final byte[] a1Bytes = serializer.encode(A1); | 211 | final byte[] a1Bytes = serializer.encode(A1); | ... | ... |
-
Please register or login to post a comment