Yuta HIGUCHI

switch to ImmutableList

Change-Id: Ia5f8936d0aaf447253f5dde0db1ee688441d2472
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 class RoleInfo {
public RoleInfo(NodeId master, List<NodeId> backups) {
this.master = master;
this.backups = Collections.unmodifiableList(backups);
this.backups = ImmutableList.copyOf(backups);
}
public NodeId master() {
......
......@@ -8,6 +8,7 @@ import java.util.HashMap;
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 @@ public final class KryoNamespaces {
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())
......
......@@ -3,6 +3,7 @@ package org.onlab.onos.store.serializers;
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.Before;
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 @@ public class KryoSerializerTest {
}
@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);
......