Ayaka Koshibe

fixes for RoleValue serialization

Change-Id: Ie51d0e16a0623061790523920f6a22aa18e74517
1 +package org.onlab.onos.cli;
2 +
3 +import static com.google.common.collect.Lists.newArrayList;
4 +
5 +import java.util.Collections;
6 +import java.util.List;
7 +
8 +import org.apache.karaf.shell.commands.Command;
9 +import org.onlab.onos.cluster.NodeId;
10 +import org.onlab.onos.mastership.MastershipService;
11 +import org.onlab.onos.net.Device;
12 +import org.onlab.onos.net.DeviceId;
13 +import org.onlab.onos.net.device.DeviceService;
14 +
15 +
16 +/**
17 + * Lists mastership roles of nodes for each device.
18 + */
19 +@Command(scope = "onos", name = "roles",
20 + description = "Lists mastership roles of nodes for each device.")
21 +public class RolesCommand extends AbstractShellCommand {
22 +
23 + private static final String FMT_HDR = "%s: master=%s\nstandbys: %s nodes";
24 + private static final String FMT_SB = "\t%s";
25 +
26 + @Override
27 + protected void execute() {
28 + DeviceService deviceService = get(DeviceService.class);
29 + MastershipService roleService = get(MastershipService.class);
30 +
31 + for (Device d : getSortedDevices(deviceService)) {
32 + DeviceId did = d.id();
33 + printRoles(roleService, did);
34 + }
35 + }
36 +
37 + /**
38 + * Returns the list of devices sorted using the device ID URIs.
39 + *
40 + * @param service device service
41 + * @return sorted device list
42 + */
43 + protected static List<Device> getSortedDevices(DeviceService service) {
44 + List<Device> devices = newArrayList(service.getDevices());
45 + Collections.sort(devices, Comparators.ELEMENT_COMPARATOR);
46 + return devices;
47 + }
48 +
49 + /**
50 + * Prints the role information for a device.
51 + *
52 + * @param deviceId the ID of the device
53 + * @param master the current master
54 + */
55 + protected void printRoles(MastershipService service, DeviceId deviceId) {
56 + List<NodeId> nodes = service.getNodesFor(deviceId);
57 + NodeId first = null;
58 + NodeId master = null;
59 +
60 + if (!nodes.isEmpty()) {
61 + first = nodes.get(0);
62 + }
63 + if (first != null &&
64 + first.equals(service.getMasterFor(deviceId))) {
65 + master = nodes.get(0);
66 + nodes.remove(master);
67 + }
68 + print(FMT_HDR, deviceId, master == null ? "NONE" : master, nodes.size());
69 +
70 + for (NodeId nid : nodes) {
71 + print(FMT_SB, nid);
72 + }
73 + }
74 +}
...@@ -24,11 +24,12 @@ import org.onlab.onos.net.DeviceId; ...@@ -24,11 +24,12 @@ import org.onlab.onos.net.DeviceId;
24 import org.onlab.onos.net.MastershipRole; 24 import org.onlab.onos.net.MastershipRole;
25 import org.onlab.onos.store.common.AbstractHazelcastStore; 25 import org.onlab.onos.store.common.AbstractHazelcastStore;
26 import org.onlab.onos.store.common.SMap; 26 import org.onlab.onos.store.common.SMap;
27 +import org.onlab.onos.store.serializers.KryoPoolUtil;
27 import org.onlab.onos.store.serializers.KryoSerializer; 28 import org.onlab.onos.store.serializers.KryoSerializer;
29 +import org.onlab.util.KryoPool;
28 30
29 import com.google.common.collect.ImmutableSet; 31 import com.google.common.collect.ImmutableSet;
30 -import com.hazelcast.core.IMap; 32 +import com.hazelcast.core.IAtomicLong;
31 -import com.hazelcast.core.MultiMap;
32 33
33 import static org.onlab.onos.net.MastershipRole.*; 34 import static org.onlab.onos.net.MastershipRole.*;
34 35
...@@ -49,6 +50,9 @@ implements MastershipStore { ...@@ -49,6 +50,9 @@ implements MastershipStore {
49 protected SMap<DeviceId, RoleValue> roleMap; 50 protected SMap<DeviceId, RoleValue> roleMap;
50 //devices to terms 51 //devices to terms
51 protected SMap<DeviceId, Integer> terms; 52 protected SMap<DeviceId, Integer> terms;
53 + //last-known cluster size, used for tie-breaking when partitioning occurs
54 + protected IAtomicLong clusterSize;
55 +
52 56
53 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 57 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
54 protected ClusterService clusterService; 58 protected ClusterService clusterService;
...@@ -59,8 +63,21 @@ implements MastershipStore { ...@@ -59,8 +63,21 @@ implements MastershipStore {
59 public void activate() { 63 public void activate() {
60 super.activate(); 64 super.activate();
61 65
62 - roleMap = new SMap(theInstance.getMap("nodeRoles"), new KryoSerializer()); 66 + this.serializer = new KryoSerializer() {
63 - terms = new SMap(theInstance.getMap("terms"), new KryoSerializer()); 67 + @Override
68 + protected void setupKryoPool() {
69 + serializerPool = KryoPool.newBuilder()
70 + .register(KryoPoolUtil.API)
71 +
72 + .register(RoleValue.class, new RoleValueSerializer())
73 + .build()
74 + .populate(1);
75 + }
76 + };
77 +
78 + roleMap = new SMap(theInstance.getMap("nodeRoles"), this.serializer);
79 + terms = new SMap(theInstance.getMap("terms"), this.serializer);
80 + clusterSize = theInstance.getAtomicLong("clustersize");
64 // roleMap.addEntryListener(new RemoteMasterShipEventHandler(), true); 81 // roleMap.addEntryListener(new RemoteMasterShipEventHandler(), true);
65 82
66 log.info("Started"); 83 log.info("Started");
...@@ -103,6 +120,7 @@ implements MastershipStore { ...@@ -103,6 +120,7 @@ implements MastershipStore {
103 case MASTER: 120 case MASTER:
104 //reinforce mastership 121 //reinforce mastership
105 rv.reassign(nodeId, STANDBY, NONE); 122 rv.reassign(nodeId, STANDBY, NONE);
123 + roleMap.put(deviceId, rv);
106 return null; 124 return null;
107 case STANDBY: 125 case STANDBY:
108 NodeId current = rv.get(MASTER); 126 NodeId current = rv.get(MASTER);
...@@ -115,11 +133,13 @@ implements MastershipStore { ...@@ -115,11 +133,13 @@ implements MastershipStore {
115 rv.add(MASTER, nodeId); 133 rv.add(MASTER, nodeId);
116 } 134 }
117 rv.reassign(nodeId, STANDBY, NONE); 135 rv.reassign(nodeId, STANDBY, NONE);
136 + roleMap.put(deviceId, rv);
118 updateTerm(deviceId); 137 updateTerm(deviceId);
119 return new MastershipEvent(MASTER_CHANGED, deviceId, nodeId); 138 return new MastershipEvent(MASTER_CHANGED, deviceId, nodeId);
120 case NONE: 139 case NONE:
121 rv.add(MASTER, nodeId); 140 rv.add(MASTER, nodeId);
122 rv.reassign(nodeId, STANDBY, NONE); 141 rv.reassign(nodeId, STANDBY, NONE);
142 + roleMap.put(deviceId, rv);
123 updateTerm(deviceId); 143 updateTerm(deviceId);
124 return new MastershipEvent(MASTER_CHANGED, deviceId, nodeId); 144 return new MastershipEvent(MASTER_CHANGED, deviceId, nodeId);
125 default: 145 default:
...@@ -133,7 +153,7 @@ implements MastershipStore { ...@@ -133,7 +153,7 @@ implements MastershipStore {
133 153
134 @Override 154 @Override
135 public NodeId getMaster(DeviceId deviceId) { 155 public NodeId getMaster(DeviceId deviceId) {
136 - return getMaster(deviceId); 156 + return getNode(MASTER, deviceId);
137 } 157 }
138 158
139 159
...@@ -181,15 +201,18 @@ implements MastershipStore { ...@@ -181,15 +201,18 @@ implements MastershipStore {
181 switch (role) { 201 switch (role) {
182 case MASTER: 202 case MASTER:
183 rv.reassign(local, STANDBY, NONE); 203 rv.reassign(local, STANDBY, NONE);
204 + roleMap.put(deviceId, rv);
184 break; 205 break;
185 case STANDBY: 206 case STANDBY:
186 rv.reassign(local, NONE, STANDBY); 207 rv.reassign(local, NONE, STANDBY);
208 + roleMap.put(deviceId, rv);
187 terms.putIfAbsent(deviceId, INIT); 209 terms.putIfAbsent(deviceId, INIT);
188 break; 210 break;
189 case NONE: 211 case NONE:
190 //claim mastership 212 //claim mastership
191 rv.add(MASTER, local); 213 rv.add(MASTER, local);
192 rv.reassign(local, STANDBY, NONE); 214 rv.reassign(local, STANDBY, NONE);
215 + roleMap.put(deviceId, rv);
193 updateTerm(deviceId); 216 updateTerm(deviceId);
194 role = MastershipRole.MASTER; 217 role = MastershipRole.MASTER;
195 break; 218 break;
...@@ -221,12 +244,13 @@ implements MastershipStore { ...@@ -221,12 +244,13 @@ implements MastershipStore {
221 MastershipRole role = getRole(nodeId, deviceId); 244 MastershipRole role = getRole(nodeId, deviceId);
222 switch (role) { 245 switch (role) {
223 case MASTER: 246 case MASTER:
224 - event = reelect(nodeId, deviceId); 247 + event = reelect(nodeId, deviceId, rv);
225 //fall through to reinforce role 248 //fall through to reinforce role
226 case STANDBY: 249 case STANDBY:
227 //fall through to reinforce role 250 //fall through to reinforce role
228 case NONE: 251 case NONE:
229 rv.reassign(nodeId, NONE, STANDBY); 252 rv.reassign(nodeId, NONE, STANDBY);
253 + roleMap.put(deviceId, rv);
230 break; 254 break;
231 default: 255 default:
232 log.warn("unknown Mastership Role {}", role); 256 log.warn("unknown Mastership Role {}", role);
...@@ -247,12 +271,13 @@ implements MastershipStore { ...@@ -247,12 +271,13 @@ implements MastershipStore {
247 MastershipRole role = getRole(nodeId, deviceId); 271 MastershipRole role = getRole(nodeId, deviceId);
248 switch (role) { 272 switch (role) {
249 case MASTER: 273 case MASTER:
250 - event = reelect(nodeId, deviceId); 274 + event = reelect(nodeId, deviceId, rv);
251 //fall through to reinforce relinquishment 275 //fall through to reinforce relinquishment
252 case STANDBY: 276 case STANDBY:
253 //fall through to reinforce relinquishment 277 //fall through to reinforce relinquishment
254 case NONE: 278 case NONE:
255 rv.reassign(nodeId, STANDBY, NONE); 279 rv.reassign(nodeId, STANDBY, NONE);
280 + roleMap.put(deviceId, rv);
256 break; 281 break;
257 default: 282 default:
258 log.warn("unknown Mastership Role {}", role); 283 log.warn("unknown Mastership Role {}", role);
...@@ -264,8 +289,7 @@ implements MastershipStore { ...@@ -264,8 +289,7 @@ implements MastershipStore {
264 } 289 }
265 290
266 //helper to fetch a new master candidate for a given device. 291 //helper to fetch a new master candidate for a given device.
267 - private MastershipEvent reelect(NodeId current, DeviceId deviceId) { 292 + private MastershipEvent reelect(NodeId current, DeviceId deviceId, RoleValue rv) {
268 - RoleValue rv = roleMap.get(deviceId);
269 293
270 //if this is an queue it'd be neater. 294 //if this is an queue it'd be neater.
271 NodeId backup = null; 295 NodeId backup = null;
...@@ -278,10 +302,12 @@ implements MastershipStore { ...@@ -278,10 +302,12 @@ implements MastershipStore {
278 302
279 if (backup == null) { 303 if (backup == null) {
280 rv.remove(MASTER, current); 304 rv.remove(MASTER, current);
305 + roleMap.put(deviceId, rv);
281 return null; 306 return null;
282 } else { 307 } else {
283 rv.replace(current, backup, MASTER); 308 rv.replace(current, backup, MASTER);
284 rv.reassign(backup, STANDBY, NONE); 309 rv.reassign(backup, STANDBY, NONE);
310 + roleMap.put(deviceId, rv);
285 Integer term = terms.get(deviceId); 311 Integer term = terms.get(deviceId);
286 terms.put(deviceId, ++term); 312 terms.put(deviceId, ++term);
287 return new MastershipEvent( 313 return new MastershipEvent(
......
1 package org.onlab.onos.store.mastership.impl; 1 package org.onlab.onos.store.mastership.impl;
2 2
3 import java.util.Collections; 3 import java.util.Collections;
4 +import java.util.HashMap;
4 import java.util.LinkedList; 5 import java.util.LinkedList;
5 import java.util.List; 6 import java.util.List;
6 import java.util.Map; 7 import java.util.Map;
...@@ -14,7 +15,7 @@ import org.onlab.onos.net.MastershipRole; ...@@ -14,7 +15,7 @@ import org.onlab.onos.net.MastershipRole;
14 */ 15 */
15 public class RoleValue { 16 public class RoleValue {
16 17
17 - Map<MastershipRole, List<NodeId>> value; 18 + protected Map<MastershipRole, List<NodeId>> value = new HashMap<>();
18 19
19 public RoleValue() { 20 public RoleValue() {
20 value.put(MastershipRole.MASTER, new LinkedList<NodeId>()); 21 value.put(MastershipRole.MASTER, new LinkedList<NodeId>());
...@@ -96,4 +97,16 @@ public class RoleValue { ...@@ -96,4 +97,16 @@ public class RoleValue {
96 add(type, to); 97 add(type, to);
97 } 98 }
98 99
100 + @Override
101 + public String toString() {
102 + final StringBuilder builder = new StringBuilder();
103 + for (Map.Entry<MastershipRole, List<NodeId>> el : value.entrySet()) {
104 + builder.append(el.getKey().toString()).append(": [");
105 + for (NodeId n : el.getValue()) {
106 + builder.append(n);
107 + }
108 + builder.append("]\n");
109 + }
110 + return builder.toString();
111 + }
99 } 112 }
......
1 -package org.onlab.onos.store.serializers; 1 +package org.onlab.onos.store.mastership.impl;
2 2
3 import java.util.List; 3 import java.util.List;
4 import java.util.Map; 4 import java.util.Map;
5 5
6 import org.onlab.onos.cluster.NodeId; 6 import org.onlab.onos.cluster.NodeId;
7 import org.onlab.onos.net.MastershipRole; 7 import org.onlab.onos.net.MastershipRole;
8 -import org.onlab.onos.store.mastership.impl.RoleValue;
9 8
10 import com.esotericsoftware.kryo.Kryo; 9 import com.esotericsoftware.kryo.Kryo;
11 import com.esotericsoftware.kryo.Serializer; 10 import com.esotericsoftware.kryo.Serializer;
...@@ -13,7 +12,7 @@ import com.esotericsoftware.kryo.io.Input; ...@@ -13,7 +12,7 @@ import com.esotericsoftware.kryo.io.Input;
13 import com.esotericsoftware.kryo.io.Output; 12 import com.esotericsoftware.kryo.io.Output;
14 13
15 /** 14 /**
16 - * Serializer for RoleValues used by {@link DistributedMastershipStore} 15 + * Serializer for RoleValues used by {@link DistributedMastershipStore}.
17 */ 16 */
18 public class RoleValueSerializer extends Serializer<RoleValue> { 17 public class RoleValueSerializer extends Serializer<RoleValue> {
19 18
......
...@@ -116,7 +116,6 @@ public class DistributedMastershipStoreTest { ...@@ -116,7 +116,6 @@ public class DistributedMastershipStoreTest {
116 testStore.put(DID1, N1, true, false, false); 116 testStore.put(DID1, N1, true, false, false);
117 testStore.put(DID2, N1, true, false, false); 117 testStore.put(DID2, N1, true, false, false);
118 testStore.put(DID3, N2, true, false, false); 118 testStore.put(DID3, N2, true, false, false);
119 -
120 assertEquals("wrong devices", 119 assertEquals("wrong devices",
121 Sets.newHashSet(DID1, DID2), dms.getDevices(N1)); 120 Sets.newHashSet(DID1, DID2), dms.getDevices(N1));
122 } 121 }
...@@ -244,7 +243,6 @@ public class DistributedMastershipStoreTest { ...@@ -244,7 +243,6 @@ public class DistributedMastershipStoreTest {
244 RoleValue rv = dms.roleMap.get(dev); 243 RoleValue rv = dms.roleMap.get(dev);
245 if (rv == null) { 244 if (rv == null) {
246 rv = new RoleValue(); 245 rv = new RoleValue();
247 - dms.roleMap.put(dev, rv);
248 } 246 }
249 247
250 if (master) { 248 if (master) {
...@@ -259,6 +257,7 @@ public class DistributedMastershipStoreTest { ...@@ -259,6 +257,7 @@ public class DistributedMastershipStoreTest {
259 if (term) { 257 if (term) {
260 dms.terms.put(dev, 0); 258 dms.terms.put(dev, 0);
261 } 259 }
260 + dms.roleMap.put(dev, rv);
262 } 261 }
263 262
264 //a dumb utility function. 263 //a dumb utility function.
...@@ -266,9 +265,9 @@ public class DistributedMastershipStoreTest { ...@@ -266,9 +265,9 @@ public class DistributedMastershipStoreTest {
266 for (Map.Entry<DeviceId, RoleValue> el : dms.roleMap.entrySet()) { 265 for (Map.Entry<DeviceId, RoleValue> el : dms.roleMap.entrySet()) {
267 System.out.println("DID: " + el.getKey()); 266 System.out.println("DID: " + el.getKey());
268 for (MastershipRole role : MastershipRole.values()) { 267 for (MastershipRole role : MastershipRole.values()) {
269 - System.out.println(role.toString() + ":"); 268 + System.out.println("\t" + role.toString() + ":");
270 for (NodeId n : el.getValue().nodesOfRole(role)) { 269 for (NodeId n : el.getValue().nodesOfRole(role)) {
271 - System.out.println("\t" + n); 270 + System.out.println("\t\t" + n);
272 } 271 }
273 } 272 }
274 } 273 }
......
1 +package org.onlab.onos.store.mastership.impl;
2 +
3 +import static org.junit.Assert.assertEquals;
4 +import static org.junit.Assert.assertTrue;
5 +import static org.onlab.onos.net.MastershipRole.*;
6 +
7 +import org.junit.Test;
8 +import org.onlab.onos.cluster.NodeId;
9 +
10 +import com.google.common.collect.Sets;
11 +
12 +public class RoleValueTest {
13 +
14 + private static final RoleValue RV = new RoleValue();
15 +
16 + private static final NodeId NID1 = new NodeId("node1");
17 + private static final NodeId NID2 = new NodeId("node2");
18 + private static final NodeId NID3 = new NodeId("node3");
19 +
20 + @Test
21 + public void add() {
22 + assertEquals("faulty initialization: ", 3, RV.value.size());
23 + RV.add(MASTER, NID1);
24 + RV.add(STANDBY, NID2);
25 + RV.add(STANDBY, NID3);
26 +
27 + assertEquals("wrong nodeID: ", NID1, RV.get(MASTER));
28 + assertTrue("wrong nodeIDs: ",
29 + Sets.newHashSet(NID3, NID2).containsAll(RV.nodesOfRole(STANDBY)));
30 + }
31 +}
...@@ -26,7 +26,6 @@ import org.onlab.onos.net.device.DefaultPortDescription; ...@@ -26,7 +26,6 @@ import org.onlab.onos.net.device.DefaultPortDescription;
26 import org.onlab.onos.net.link.DefaultLinkDescription; 26 import org.onlab.onos.net.link.DefaultLinkDescription;
27 import org.onlab.onos.net.provider.ProviderId; 27 import org.onlab.onos.net.provider.ProviderId;
28 import org.onlab.onos.store.Timestamp; 28 import org.onlab.onos.store.Timestamp;
29 -import org.onlab.onos.store.mastership.impl.RoleValue;
30 import org.onlab.packet.IpAddress; 29 import org.onlab.packet.IpAddress;
31 import org.onlab.packet.IpPrefix; 30 import org.onlab.packet.IpPrefix;
32 import org.onlab.util.KryoPool; 31 import org.onlab.util.KryoPool;
...@@ -66,7 +65,6 @@ public final class KryoPoolUtil { ...@@ -66,7 +65,6 @@ public final class KryoPoolUtil {
66 DefaultDevice.class, 65 DefaultDevice.class,
67 DefaultDeviceDescription.class, 66 DefaultDeviceDescription.class,
68 DefaultLinkDescription.class, 67 DefaultLinkDescription.class,
69 - RoleValue.class,
70 Port.class, 68 Port.class,
71 DefaultPortDescription.class, 69 DefaultPortDescription.class,
72 Element.class, 70 Element.class,
...@@ -84,7 +82,6 @@ public final class KryoPoolUtil { ...@@ -84,7 +82,6 @@ public final class KryoPoolUtil {
84 .register(ConnectPoint.class, new ConnectPointSerializer()) 82 .register(ConnectPoint.class, new ConnectPointSerializer())
85 .register(DefaultLink.class, new DefaultLinkSerializer()) 83 .register(DefaultLink.class, new DefaultLinkSerializer())
86 .register(MastershipTerm.class, new MastershipTermSerializer()) 84 .register(MastershipTerm.class, new MastershipTermSerializer())
87 - .register(RoleValue.class, new RoleValueSerializer())
88 85
89 .build(); 86 .build();
90 87
......
1 -package org.onlab.onos.store.serializers;
2 -
3 -import org.onlab.onos.net.MastershipRole;
4 -
5 -import com.esotericsoftware.kryo.Kryo;
6 -import com.esotericsoftware.kryo.Serializer;
7 -import com.esotericsoftware.kryo.io.Input;
8 -import com.esotericsoftware.kryo.io.Output;
9 -
10 -/**
11 - * Kryo Serializer for {@link org.onlab.onos.net.MastershipRole}.
12 - */
13 -public class MastershipRoleSerializer extends Serializer<MastershipRole> {
14 -
15 - /**
16 - * Creates {@link MastershipRole} serializer instance.
17 - */
18 - public MastershipRoleSerializer() {
19 - // non-null, immutable
20 - super(false, true);
21 - }
22 -
23 - @Override
24 - public MastershipRole read(Kryo kryo, Input input, Class<MastershipRole> type) {
25 - final String role = kryo.readObject(input, String.class);
26 - return MastershipRole.valueOf(role);
27 - }
28 -
29 - @Override
30 - public void write(Kryo kryo, Output output, MastershipRole object) {
31 - kryo.writeObject(output, object.toString());
32 - }
33 -
34 -}
...@@ -22,11 +22,9 @@ import org.onlab.onos.net.Device; ...@@ -22,11 +22,9 @@ import org.onlab.onos.net.Device;
22 import org.onlab.onos.net.DeviceId; 22 import org.onlab.onos.net.DeviceId;
23 import org.onlab.onos.net.Link; 23 import org.onlab.onos.net.Link;
24 import org.onlab.onos.net.LinkKey; 24 import org.onlab.onos.net.LinkKey;
25 -import org.onlab.onos.net.MastershipRole;
26 import org.onlab.onos.net.PortNumber; 25 import org.onlab.onos.net.PortNumber;
27 import org.onlab.onos.net.SparseAnnotations; 26 import org.onlab.onos.net.SparseAnnotations;
28 import org.onlab.onos.net.provider.ProviderId; 27 import org.onlab.onos.net.provider.ProviderId;
29 -import org.onlab.onos.store.mastership.impl.RoleValue;
30 import org.onlab.packet.IpAddress; 28 import org.onlab.packet.IpAddress;
31 import org.onlab.packet.IpPrefix; 29 import org.onlab.packet.IpPrefix;
32 import org.onlab.util.KryoPool; 30 import org.onlab.util.KryoPool;
...@@ -59,13 +57,6 @@ public class KryoSerializerTest { ...@@ -59,13 +57,6 @@ public class KryoSerializerTest {
59 .remove("A1") 57 .remove("A1")
60 .set("B3", "b3") 58 .set("B3", "b3")
61 .build(); 59 .build();
62 - private static final RoleValue RV = new RoleValue();
63 - static {
64 - RV.add(MastershipRole.MASTER, new NodeId("node1"));
65 - RV.add(MastershipRole.STANDBY, new NodeId("node2"));
66 - RV.add(MastershipRole.STANDBY, new NodeId("node3"));
67 - RV.add(MastershipRole.NONE, new NodeId("node4"));
68 - };
69 60
70 private static KryoPool kryos; 61 private static KryoPool kryos;
71 62
...@@ -123,9 +114,6 @@ public class KryoSerializerTest { ...@@ -123,9 +114,6 @@ public class KryoSerializerTest {
123 testSerialized(PIDA); 114 testSerialized(PIDA);
124 testSerialized(new NodeId("bar")); 115 testSerialized(new NodeId("bar"));
125 testSerialized(MastershipTerm.of(new NodeId("foo"), 2)); 116 testSerialized(MastershipTerm.of(new NodeId("foo"), 2));
126 - for (MastershipRole role : MastershipRole.values()) {
127 - testSerialized(role);
128 - }
129 } 117 }
130 118
131 @Test 119 @Test
......
1 -#!/bin/bash
2 -# -----------------------------------------------------------------------------
3 -# Remotely configures & starts ONOS for the first time.
4 -# -----------------------------------------------------------------------------
5 -
6 -[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
7 -. $ONOS_ROOT/tools/build/envDefaults
8 -
9 -remote=$ONOS_USER@${1:-$OCI}
10 -
11 -# Generate a cluster.json from the ON* environment variables
12 -CDEF_FILE=/tmp/cluster.json
13 -echo "{ \"nodes\":[" > $CDEF_FILE
14 -for node in $(env | sort | egrep "OC[2-9]+" | cut -d= -f2); do
15 - echo " { \"id\": \"$node\", \"ip\": \"$node\", \"tcpPort\": 9876 }," >> $CDEF_FILE
16 -done
17 -echo " { \"id\": \"$OC1\", \"ip\": \"$OC1\", \"tcpPort\": 9876 }" >> $CDEF_FILE
18 -echo "]}" >> $CDEF_FILE
19 -
20 -ssh $remote "
21 - sudo perl -pi.bak -e \"s/ <interface>.*</ <interface>${ONOS_NIC:-192.168.56.*}</g\" \
22 - $ONOS_INSTALL_DIR/$KARAF_DIST/etc/hazelcast.xml
23 -
24 - echo \"onos.ip = \$(ifconfig | grep $ONOS_NIC | cut -d: -f2 | cut -d\\ -f1)\" \
25 - >> $ONOS_INSTALL_DIR/$KARAF_DIST/etc/system.properties
26 -"
27 -scp -q $CDEF_FILE $remote:$ONOS_INSTALL_DIR/config/