switch to ImmutableList
Change-Id: Ia5f8936d0aaf447253f5dde0db1ee688441d2472
diff --git a/core/api/src/main/java/org/onlab/onos/cluster/RoleInfo.java b/core/api/src/main/java/org/onlab/onos/cluster/RoleInfo.java
index d2bee8b..45b96ab 100644
--- a/core/api/src/main/java/org/onlab/onos/cluster/RoleInfo.java
+++ b/core/api/src/main/java/org/onlab/onos/cluster/RoleInfo.java
@@ -1,9 +1,10 @@
package org.onlab.onos.cluster;
-import java.util.Collections;
import java.util.List;
import java.util.Objects;
+import com.google.common.collect.ImmutableList;
+
/**
* A container for detailed role information for a device,
* within the current cluster. Role attributes include current
@@ -15,7 +16,7 @@
public RoleInfo(NodeId master, List<NodeId> backups) {
this.master = master;
- this.backups = Collections.unmodifiableList(backups);
+ this.backups = ImmutableList.copyOf(backups);
}
public NodeId master() {
diff --git a/core/store/serializers/src/main/java/org/onlab/onos/store/serializers/KryoNamespaces.java b/core/store/serializers/src/main/java/org/onlab/onos/store/serializers/KryoNamespaces.java
index cbb2bc5..9de6d8c 100644
--- a/core/store/serializers/src/main/java/org/onlab/onos/store/serializers/KryoNamespaces.java
+++ b/core/store/serializers/src/main/java/org/onlab/onos/store/serializers/KryoNamespaces.java
@@ -8,6 +8,7 @@
import org.onlab.onos.cluster.ControllerNode;
import org.onlab.onos.cluster.DefaultControllerNode;
import org.onlab.onos.cluster.NodeId;
+import org.onlab.onos.cluster.RoleInfo;
import org.onlab.onos.mastership.MastershipTerm;
import org.onlab.onos.net.ConnectPoint;
import org.onlab.onos.net.DefaultAnnotations;
@@ -107,7 +108,8 @@
Criterion.Type.class,
DefaultTrafficTreatment.class,
Instructions.DropInstruction.class,
- Instructions.OutputInstruction.class
+ Instructions.OutputInstruction.class,
+ RoleInfo.class
)
.register(URI.class, new URISerializer())
.register(NodeId.class, new NodeIdSerializer())
diff --git a/core/store/serializers/src/test/java/org/onlab/onos/store/serializers/KryoSerializerTest.java b/core/store/serializers/src/test/java/org/onlab/onos/store/serializers/KryoSerializerTest.java
index f76513d..1bd2097 100644
--- a/core/store/serializers/src/test/java/org/onlab/onos/store/serializers/KryoSerializerTest.java
+++ b/core/store/serializers/src/test/java/org/onlab/onos/store/serializers/KryoSerializerTest.java
@@ -3,6 +3,7 @@
import static org.junit.Assert.assertEquals;
import static org.onlab.onos.net.DeviceId.deviceId;
import static org.onlab.onos.net.PortNumber.portNumber;
+import static java.util.Arrays.asList;
import java.nio.ByteBuffer;
@@ -11,6 +12,7 @@
import org.junit.BeforeClass;
import org.junit.Test;
import org.onlab.onos.cluster.NodeId;
+import org.onlab.onos.cluster.RoleInfo;
import org.onlab.onos.mastership.MastershipTerm;
import org.onlab.onos.net.Annotations;
import org.onlab.onos.net.ConnectPoint;
@@ -198,6 +200,12 @@
}
@Test
+ public void testRoleInfo() {
+ testSerialized(new RoleInfo(new NodeId("master"),
+ asList(new NodeId("stby1"), new NodeId("stby2"))));
+ }
+
+ @Test
public void testAnnotations() {
// Annotations does not have equals defined, manually test equality
final byte[] a1Bytes = serializer.encode(A1);