blob: 50fc37794fc2e4a26f4726b406daf7f84e678d9d [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2014-present Open Networking Foundation
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.cluster.impl;
Ayaka Koshibe406d0102014-09-24 16:08:12 -070017
Claudine Chiudce08152016-03-09 18:19:28 +000018import java.util.List;
Ayaka Koshibe406d0102014-09-24 16:08:12 -070019import java.util.Set;
Claudine Chiudce08152016-03-09 18:19:28 +000020import java.util.function.Consumer;
Ayaka Koshibe406d0102014-09-24 16:08:12 -070021
Claudine Chiudce08152016-03-09 18:19:28 +000022import com.google.common.collect.ImmutableList;
23import com.google.common.collect.ImmutableSet;
Victor Silvaf2b9d032016-09-19 19:43:20 -030024import org.easymock.EasyMock;
Ayaka Koshibe406d0102014-09-24 16:08:12 -070025import org.junit.After;
26import org.junit.Before;
27import org.junit.Test;
Claudine Chiudce08152016-03-09 18:19:28 +000028import org.onlab.junit.TestUtils;
Ray Milkeycc53abd2015-02-19 12:31:33 -080029import org.onlab.packet.IpAddress;
Victor Silvaf2b9d032016-09-19 19:43:20 -030030import org.onosproject.cfg.ComponentConfigService;
Brian O'Connorabafb502014-12-02 22:26:20 -080031import org.onosproject.cluster.ClusterService;
32import org.onosproject.cluster.ControllerNode;
Brian O'Connorabafb502014-12-02 22:26:20 -080033import org.onosproject.cluster.DefaultControllerNode;
34import org.onosproject.cluster.NodeId;
Thomas Vachuska36002e62015-05-19 16:12:29 -070035import org.onosproject.common.event.impl.TestEventDispatcher;
Brian O'Connorabafb502014-12-02 22:26:20 -080036import org.onosproject.mastership.MastershipService;
37import org.onosproject.mastership.MastershipStore;
38import org.onosproject.mastership.MastershipTermService;
39import org.onosproject.net.DeviceId;
Simon Hunt53612212016-12-04 17:19:52 -080040import org.onosproject.net.config.NetworkConfigServiceAdapter;
Claudine Chiudce08152016-03-09 18:19:28 +000041import org.onosproject.net.region.Region;
42import org.onosproject.net.region.RegionId;
43import org.onosproject.net.region.RegionStore;
44import org.onosproject.net.region.impl.RegionManager;
45import org.onosproject.store.cluster.StaticClusterService;
46import org.onosproject.store.region.impl.DistributedRegionStore;
47import org.onosproject.store.service.TestStorageService;
Thomas Vachuskac97aa612015-06-23 16:00:18 -070048import org.onosproject.store.trivial.SimpleMastershipStore;
Ayaka Koshibe406d0102014-09-24 16:08:12 -070049
Ayaka Koshibeea5b4ce2014-10-11 14:17:17 -070050import com.google.common.collect.Sets;
Madan Jampanide003d92015-05-11 17:14:20 -070051import com.google.common.util.concurrent.Futures;
Jordan Halterman61aeb352017-10-18 16:22:17 -070052import org.onosproject.upgrade.impl.UpgradeServiceAdapter;
Ayaka Koshibeea5b4ce2014-10-11 14:17:17 -070053
Victor Silvaf2b9d032016-09-19 19:43:20 -030054import static org.easymock.EasyMock.anyObject;
55import static org.easymock.EasyMock.expect;
56import static org.easymock.EasyMock.expectLastCall;
57import static org.easymock.EasyMock.replay;
Claudine Chiudce08152016-03-09 18:19:28 +000058import static org.junit.Assert.*;
Ray Milkeycc53abd2015-02-19 12:31:33 -080059import static org.onosproject.net.MastershipRole.MASTER;
60import static org.onosproject.net.MastershipRole.NONE;
61import static org.onosproject.net.MastershipRole.STANDBY;
Thomas Vachuska42e8cce2015-07-29 19:25:18 -070062import static org.onosproject.net.NetTestTools.injectEventDispatcher;
Claudine Chiudce08152016-03-09 18:19:28 +000063import static org.onosproject.net.region.Region.Type.METRO;
Ayaka Koshibe406d0102014-09-24 16:08:12 -070064
65/**
66 * Test codifying the mastership service contracts.
67 */
68public class MastershipManagerTest {
69
70 private static final NodeId NID_LOCAL = new NodeId("local");
71 private static final NodeId NID_OTHER = new NodeId("foo");
Pavlin Radoslavov444b5192014-10-28 10:45:19 -070072 private static final IpAddress LOCALHOST = IpAddress.valueOf("127.0.0.1");
Ayaka Koshibe406d0102014-09-24 16:08:12 -070073 private static final DeviceId DEV_MASTER = DeviceId.deviceId("of:1");
74 private static final DeviceId DEV_OTHER = DeviceId.deviceId("of:2");
75
Claudine Chiudce08152016-03-09 18:19:28 +000076 private static final RegionId RID1 = RegionId.regionId("r1");
77 private static final RegionId RID2 = RegionId.regionId("r2");
78 private static final DeviceId DID1 = DeviceId.deviceId("foo:d1");
79 private static final DeviceId DID2 = DeviceId.deviceId("foo:d2");
80 private static final DeviceId DID3 = DeviceId.deviceId("foo:d3");
Thomas Vachuskaf2e09cb2017-11-06 15:17:06 -080081 private static final DeviceId DID4 = DeviceId.deviceId("foo:d4");
82 private static final DeviceId DID5 = DeviceId.deviceId("foo:d5");
83 private static final DeviceId DID6 = DeviceId.deviceId("foo:d6");
Claudine Chiudce08152016-03-09 18:19:28 +000084 private static final NodeId NID1 = NodeId.nodeId("n1");
85 private static final NodeId NID2 = NodeId.nodeId("n2");
86 private static final NodeId NID3 = NodeId.nodeId("n3");
87 private static final NodeId NID4 = NodeId.nodeId("n4");
88 private static final ControllerNode CNODE1 =
89 new DefaultControllerNode(NID1, IpAddress.valueOf("127.0.1.1"));
90 private static final ControllerNode CNODE2 =
91 new DefaultControllerNode(NID2, IpAddress.valueOf("127.0.1.2"));
92 private static final ControllerNode CNODE3 =
93 new DefaultControllerNode(NID3, IpAddress.valueOf("127.0.1.3"));
94 private static final ControllerNode CNODE4 =
95 new DefaultControllerNode(NID4, IpAddress.valueOf("127.0.1.4"));
96
97
Ayaka Koshibe406d0102014-09-24 16:08:12 -070098 private MastershipManager mgr;
99 protected MastershipService service;
Claudine Chiudce08152016-03-09 18:19:28 +0000100 private TestRegionManager regionManager;
101 private RegionStore regionStore;
102 private TestClusterService testClusterService;
Ayaka Koshibe406d0102014-09-24 16:08:12 -0700103
104 @Before
Claudine Chiudce08152016-03-09 18:19:28 +0000105 public void setUp() throws Exception {
Ayaka Koshibe406d0102014-09-24 16:08:12 -0700106 mgr = new MastershipManager();
107 service = mgr;
Thomas Vachuska42e8cce2015-07-29 19:25:18 -0700108 injectEventDispatcher(mgr, new TestEventDispatcher());
Claudine Chiudce08152016-03-09 18:19:28 +0000109 testClusterService = new TestClusterService();
110 mgr.clusterService = testClusterService;
Jordan Halterman61aeb352017-10-18 16:22:17 -0700111 mgr.upgradeService = new UpgradeServiceAdapter();
Yuta HIGUCHI0c6e1842014-11-05 22:34:23 -0800112 mgr.store = new TestSimpleMastershipStore(mgr.clusterService);
Claudine Chiudce08152016-03-09 18:19:28 +0000113 regionStore = new DistributedRegionStore();
114 TestUtils.setField(regionStore, "storageService", new TestStorageService());
115 TestUtils.callMethod(regionStore, "activate",
116 new Class<?>[] {});
117 regionManager = new TestRegionManager();
118 TestUtils.setField(regionManager, "store", regionStore);
119 regionManager.activate();
120 mgr.regionService = regionManager;
Victor Silvaf2b9d032016-09-19 19:43:20 -0300121
122 ComponentConfigService mockConfigService =
123 EasyMock.createMock(ComponentConfigService.class);
124 expect(mockConfigService.getProperties(anyObject())).andReturn(ImmutableSet.of());
125 mockConfigService.registerProperties(mgr.getClass());
126 expectLastCall();
127 mockConfigService.unregisterProperties(mgr.getClass(), false);
128 expectLastCall();
129 expect(mockConfigService.getProperties(anyObject())).andReturn(ImmutableSet.of());
130 mgr.cfgService = mockConfigService;
131 replay(mockConfigService);
132
Ayaka Koshibe406d0102014-09-24 16:08:12 -0700133 mgr.activate();
134 }
135
136 @After
137 public void tearDown() {
138 mgr.deactivate();
139 mgr.clusterService = null;
Thomas Vachuska42e8cce2015-07-29 19:25:18 -0700140 injectEventDispatcher(mgr, null);
Claudine Chiudce08152016-03-09 18:19:28 +0000141 regionManager.deactivate();
142 mgr.regionService = null;
Ayaka Koshibe406d0102014-09-24 16:08:12 -0700143 mgr.store = null;
144 }
145
146 @Test
147 public void setRole() {
148 mgr.setRole(NID_OTHER, DEV_MASTER, MASTER);
Yuta HIGUCHI0c6e1842014-11-05 22:34:23 -0800149 assertEquals("wrong local role:", NONE, mgr.getLocalRole(DEV_MASTER));
Madan Jampanide003d92015-05-11 17:14:20 -0700150 assertEquals("wrong obtained role:", STANDBY, Futures.getUnchecked(mgr.requestRoleFor(DEV_MASTER)));
Ayaka Koshibe406d0102014-09-24 16:08:12 -0700151
152 //set to master
153 mgr.setRole(NID_LOCAL, DEV_MASTER, MASTER);
154 assertEquals("wrong local role:", MASTER, mgr.getLocalRole(DEV_MASTER));
155 }
156
157 @Test
158 public void relinquishMastership() {
Ayaka Koshibeb62aab52014-10-24 13:15:25 -0700159 //no backups - should just turn to NONE for device.
Ayaka Koshibed9f693e2014-09-29 18:04:54 -0700160 mgr.setRole(NID_LOCAL, DEV_MASTER, MASTER);
161 assertEquals("wrong role:", MASTER, mgr.getLocalRole(DEV_MASTER));
162 mgr.relinquishMastership(DEV_MASTER);
163 assertNull("wrong master:", mgr.getMasterFor(DEV_OTHER));
Ayaka Koshibeb62aab52014-10-24 13:15:25 -0700164 assertEquals("wrong role:", NONE, mgr.getLocalRole(DEV_MASTER));
Ayaka Koshibed9f693e2014-09-29 18:04:54 -0700165
166 //not master, nothing should happen
Ayaka Koshibeb62aab52014-10-24 13:15:25 -0700167 mgr.setRole(NID_LOCAL, DEV_OTHER, NONE);
Ayaka Koshibed9f693e2014-09-29 18:04:54 -0700168 mgr.relinquishMastership(DEV_OTHER);
169 assertNull("wrong role:", mgr.getMasterFor(DEV_OTHER));
170
171 //provide NID_OTHER as backup and relinquish
172 mgr.setRole(NID_LOCAL, DEV_MASTER, MASTER);
173 assertEquals("wrong master:", NID_LOCAL, mgr.getMasterFor(DEV_MASTER));
174 mgr.setRole(NID_OTHER, DEV_MASTER, STANDBY);
175 mgr.relinquishMastership(DEV_MASTER);
176 assertEquals("wrong master:", NID_OTHER, mgr.getMasterFor(DEV_MASTER));
Ayaka Koshibe406d0102014-09-24 16:08:12 -0700177 }
178
179 @Test
180 public void requestRoleFor() {
181 mgr.setRole(NID_LOCAL, DEV_MASTER, MASTER);
182 mgr.setRole(NID_OTHER, DEV_OTHER, MASTER);
183
184 //local should be master for one but standby for other
Madan Jampanide003d92015-05-11 17:14:20 -0700185 assertEquals("wrong role:", MASTER, Futures.getUnchecked(mgr.requestRoleFor(DEV_MASTER)));
186 assertEquals("wrong role:", STANDBY, Futures.getUnchecked(mgr.requestRoleFor(DEV_OTHER)));
Ayaka Koshibe406d0102014-09-24 16:08:12 -0700187 }
188
189 @Test
190 public void getMasterFor() {
191 mgr.setRole(NID_LOCAL, DEV_MASTER, MASTER);
192 mgr.setRole(NID_OTHER, DEV_OTHER, MASTER);
193 assertEquals("wrong master:", NID_LOCAL, mgr.getMasterFor(DEV_MASTER));
194 assertEquals("wrong master:", NID_OTHER, mgr.getMasterFor(DEV_OTHER));
195
196 //have NID_OTHER hand over DEV_OTHER to NID_LOCAL
197 mgr.setRole(NID_LOCAL, DEV_OTHER, MASTER);
198 assertEquals("wrong master:", NID_LOCAL, mgr.getMasterFor(DEV_OTHER));
199 }
200
201 @Test
202 public void getDevicesOf() {
203 mgr.setRole(NID_LOCAL, DEV_MASTER, MASTER);
204 mgr.setRole(NID_LOCAL, DEV_OTHER, STANDBY);
205 assertEquals("should be one device:", 1, mgr.getDevicesOf(NID_LOCAL).size());
Ayaka Koshibe406d0102014-09-24 16:08:12 -0700206 //hand both devices to NID_LOCAL
207 mgr.setRole(NID_LOCAL, DEV_OTHER, MASTER);
208 assertEquals("should be two devices:", 2, mgr.getDevicesOf(NID_LOCAL).size());
209 }
210
Ayaka Koshibe48239b02014-09-25 17:12:31 -0700211 @Test
212 public void termService() {
Yuta HIGUCHIbcac4992014-11-22 19:27:57 -0800213 MastershipTermService ts = mgr;
Ayaka Koshibe48239b02014-09-25 17:12:31 -0700214
Yuta HIGUCHIdfe6e3b2014-10-30 11:31:51 -0700215 //term = 1 for both
Ayaka Koshibe48239b02014-09-25 17:12:31 -0700216 mgr.setRole(NID_LOCAL, DEV_MASTER, MASTER);
Yuta HIGUCHIdfe6e3b2014-10-30 11:31:51 -0700217 assertEquals("inconsistent term: ", 1, ts.getMastershipTerm(DEV_MASTER).termNumber());
Ayaka Koshibe48239b02014-09-25 17:12:31 -0700218
Yuta HIGUCHIdfe6e3b2014-10-30 11:31:51 -0700219 //hand devices to NID_LOCAL and back: term = 1 + 2
Ayaka Koshibe48239b02014-09-25 17:12:31 -0700220 mgr.setRole(NID_OTHER, DEV_MASTER, MASTER);
221 mgr.setRole(NID_LOCAL, DEV_MASTER, MASTER);
Yuta HIGUCHIdfe6e3b2014-10-30 11:31:51 -0700222 assertEquals("inconsistent terms: ", 3, ts.getMastershipTerm(DEV_MASTER).termNumber());
Ayaka Koshibe48239b02014-09-25 17:12:31 -0700223 }
224
Claudine Chiudce08152016-03-09 18:19:28 +0000225 @Test
Thomas Vachuskaf2e09cb2017-11-06 15:17:06 -0800226 public void balanceWithOrphans() {
227 // Setup cluster of three nodes
228 testClusterService.put(CNODE1, ControllerNode.State.ACTIVE);
229 testClusterService.put(CNODE2, ControllerNode.State.INACTIVE);
230 testClusterService.put(CNODE3, ControllerNode.State.ACTIVE);
231
232 // Pre-assign some devices to each of the node
233 // Leave some devices as orphans assigned to a downed node
234 assignRoles(NID1, ImmutableSet.of(DID1, DID2, DID3, DID4));
235 assignRoles(NID2, ImmutableSet.of(DID5));
236 assignRoles(NID3, ImmutableSet.of(DID6));
237
238 // Trigger load balancing
239 mgr.balanceRoles();
240
241 // Make sure we have a balanced load
242 // Make sure that we no longer have any orphans
243 assertEquals("incorrect balance for node 1", 3, mgr.getDevicesOf(NID1).size());
244 assertEquals("incorrect balance for node 2", 0, mgr.getDevicesOf(NID2).size());
245 assertEquals("incorrect balance for node 3", 3, mgr.getDevicesOf(NID3).size());
246 }
247
248 private void assignRoles(NodeId nid, Set<DeviceId> deviceIds) {
249 Set<DeviceId> all = ImmutableSet.of(DID1, DID2, DID3, DID4, DID5, DID6);
250 for (DeviceId did : all) {
251 mgr.setRole(nid, did, deviceIds.contains(did) ? MASTER : STANDBY);
252 }
253 }
254
255 @Test
Claudine Chiudce08152016-03-09 18:19:28 +0000256 public void balanceWithRegion1() {
257 //set up region - 2 sets of masters with 1 node in each
258 Set<NodeId> masterSet1 = ImmutableSet.of(NID1);
259 Set<NodeId> masterSet2 = ImmutableSet.of(NID2);
260 List<Set<NodeId>> masters = ImmutableList.of(masterSet1, masterSet2);
261 Region r = regionManager.createRegion(RID1, "R1", METRO, masters);
262 regionManager.addDevices(RID1, ImmutableSet.of(DID1, DID2));
263 Set<DeviceId> deviceIds = regionManager.getRegionDevices(RID1);
264 assertEquals("incorrect device count", 2, deviceIds.size());
265
266 testClusterService.put(CNODE1, ControllerNode.State.ACTIVE);
267 testClusterService.put(CNODE2, ControllerNode.State.ACTIVE);
268
269 //set master to non region nodes
270 mgr.setRole(NID_LOCAL, DID1, MASTER);
271 mgr.setRole(NID_LOCAL, DID2, MASTER);
272 assertEquals("wrong local role:", MASTER, mgr.getLocalRole(DID1));
273 assertEquals("wrong local role:", MASTER, mgr.getLocalRole(DID2));
274 assertEquals("wrong master:", NID_LOCAL, mgr.getMasterFor(DID1));
275 assertEquals("wrong master:", NID_LOCAL, mgr.getMasterFor(DID2));
276
277 //do region balancing
278 mgr.useRegionForBalanceRoles = true;
279 mgr.balanceRoles();
280 assertEquals("wrong master:", NID1, mgr.getMasterFor(DID1));
281 assertEquals("wrong master:", NID1, mgr.getMasterFor(DID2));
282
283 // make N1 inactive
284 testClusterService.put(CNODE1, ControllerNode.State.INACTIVE);
285 mgr.balanceRoles();
286 assertEquals("wrong master:", NID2, mgr.getMasterFor(DID1));
287 assertEquals("wrong master:", NID2, mgr.getMasterFor(DID2));
288
289 }
290
291 @Test
292 public void balanceWithRegion2() {
293 //set up region - 2 sets of masters with (3 nodes, 1 node)
294 Set<NodeId> masterSet1 = ImmutableSet.of(NID1, NID3, NID4);
295 Set<NodeId> masterSet2 = ImmutableSet.of(NID2);
296 List<Set<NodeId>> masters = ImmutableList.of(masterSet1, masterSet2);
297 Region r = regionManager.createRegion(RID1, "R1", METRO, masters);
298 Set<DeviceId> deviceIdsOrig = ImmutableSet.of(DID1, DID2, DID3, DEV_OTHER);
299 regionManager.addDevices(RID1, deviceIdsOrig);
300 Set<DeviceId> deviceIds = regionManager.getRegionDevices(RID1);
301 assertEquals("incorrect device count", deviceIdsOrig.size(), deviceIds.size());
302 assertEquals("incorrect devices in region", deviceIdsOrig, deviceIds);
303
304 testClusterService.put(CNODE1, ControllerNode.State.ACTIVE);
305 testClusterService.put(CNODE2, ControllerNode.State.ACTIVE);
306 testClusterService.put(CNODE3, ControllerNode.State.ACTIVE);
307 testClusterService.put(CNODE4, ControllerNode.State.ACTIVE);
308
309 //set master to non region nodes
310 deviceIdsOrig.forEach(deviceId1 -> mgr.setRole(NID_LOCAL, deviceId1, MASTER));
311 checkDeviceMasters(deviceIds, Sets.newHashSet(NID_LOCAL), deviceId ->
312 assertEquals("wrong local role:", MASTER, mgr.getLocalRole(deviceId)));
313
314 //do region balancing
315 mgr.useRegionForBalanceRoles = true;
316 mgr.balanceRoles();
317 Set<NodeId> expectedMasters = Sets.newHashSet(NID1, NID3, NID4);
318 checkDeviceMasters(deviceIds, expectedMasters);
319
320 // make N1 inactive
321 testClusterService.put(CNODE1, ControllerNode.State.INACTIVE);
322 expectedMasters.remove(NID1);
323 mgr.balanceRoles();
324 checkDeviceMasters(deviceIds, expectedMasters);
325
326 // make N4 inactive
327 testClusterService.put(CNODE4, ControllerNode.State.INACTIVE);
328 expectedMasters.remove(NID4);
329 mgr.balanceRoles();
330 checkDeviceMasters(deviceIds, expectedMasters);
331
332 // make N3 inactive
333 testClusterService.put(CNODE3, ControllerNode.State.INACTIVE);
334 expectedMasters = Sets.newHashSet(NID2);
335 mgr.balanceRoles();
336 checkDeviceMasters(deviceIds, expectedMasters);
337
338 // make N3 active
339 testClusterService.put(CNODE3, ControllerNode.State.ACTIVE);
340 expectedMasters = Sets.newHashSet(NID3);
341 mgr.balanceRoles();
342 checkDeviceMasters(deviceIds, expectedMasters);
343
344 // make N4 active
345 testClusterService.put(CNODE4, ControllerNode.State.ACTIVE);
346 expectedMasters.add(NID4);
347 mgr.balanceRoles();
348 checkDeviceMasters(deviceIds, expectedMasters);
349
350 // make N1 active
351 testClusterService.put(CNODE1, ControllerNode.State.ACTIVE);
352 expectedMasters.add(NID1);
353 mgr.balanceRoles();
354 checkDeviceMasters(deviceIds, expectedMasters);
355 }
356
357 private void checkDeviceMasters(Set<DeviceId> deviceIds, Set<NodeId> expectedMasters) {
358 checkDeviceMasters(deviceIds, expectedMasters, null);
359 }
360
361 private void checkDeviceMasters(Set<DeviceId> deviceIds, Set<NodeId> expectedMasters,
362 Consumer<DeviceId> checkRole) {
363 // each device's master must be contained in the list of expectedMasters
Sho SHIMIZUa09e1bb2016-08-01 14:25:25 -0700364 deviceIds.forEach(deviceId -> {
Claudine Chiudce08152016-03-09 18:19:28 +0000365 assertTrue("wrong master:", expectedMasters.contains(mgr.getMasterFor(deviceId)));
366 if (checkRole != null) {
367 checkRole.accept(deviceId);
368 }
369 });
370 // each node in expectedMasters must have approximately the same number of devices
371 if (expectedMasters.size() > 1) {
372 int minValue = Integer.MAX_VALUE;
373 int maxDevices = -1;
374 for (NodeId nodeId: expectedMasters) {
375 int numDevicesManagedByNode = mgr.getDevicesOf(nodeId).size();
376 if (numDevicesManagedByNode < minValue) {
377 minValue = numDevicesManagedByNode;
378 }
379 if (numDevicesManagedByNode > maxDevices) {
380 maxDevices = numDevicesManagedByNode;
381 }
382 assertTrue("not balanced:", maxDevices - minValue <= 1);
383 }
384 }
385 }
386
387 private final class TestClusterService extends StaticClusterService {
Ayaka Koshibe406d0102014-09-24 16:08:12 -0700388
389 ControllerNode local = new DefaultControllerNode(NID_LOCAL, LOCALHOST);
390
391 @Override
392 public ControllerNode getLocalNode() {
393 return local;
394 }
395
Claudine Chiudce08152016-03-09 18:19:28 +0000396 public void put(ControllerNode cn, ControllerNode.State state) {
397 nodes.put(cn.id(), cn);
398 nodeStates.put(cn.id(), state);
Ayaka Koshibe406d0102014-09-24 16:08:12 -0700399 }
Ayaka Koshibe406d0102014-09-24 16:08:12 -0700400 }
Yuta HIGUCHI0c6e1842014-11-05 22:34:23 -0800401
402 private final class TestSimpleMastershipStore extends SimpleMastershipStore
403 implements MastershipStore {
404
405 public TestSimpleMastershipStore(ClusterService clusterService) {
406 super.clusterService = clusterService;
407 }
408 }
Claudine Chiudce08152016-03-09 18:19:28 +0000409
410 private class TestRegionManager extends RegionManager {
411 TestRegionManager() {
412 eventDispatcher = new TestEventDispatcher();
Simon Hunt53612212016-12-04 17:19:52 -0800413 networkConfigService = new NetworkConfigServiceAdapter();
Claudine Chiudce08152016-03-09 18:19:28 +0000414 }
415 }
Ayaka Koshibe406d0102014-09-24 16:08:12 -0700416}