Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 1 | /* |
Ray Milkey | 34c9590 | 2015-04-15 09:47:53 -0700 | [diff] [blame] | 2 | * Copyright 2014-2015 Open Networking Laboratory |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 3 | * |
| 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'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.device.impl; |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 17 | |
Thomas Vachuska | 42e8cce | 2015-07-29 19:25:18 -0700 | [diff] [blame^] | 18 | import com.google.common.collect.Sets; |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 19 | import org.junit.After; |
| 20 | import org.junit.Before; |
| 21 | import org.junit.Test; |
Ray Milkey | cc53abd | 2015-02-19 12:31:33 -0800 | [diff] [blame] | 22 | import org.onlab.packet.ChassisId; |
| 23 | import org.onlab.packet.IpAddress; |
| 24 | import org.onosproject.cluster.ClusterServiceAdapter; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 25 | import org.onosproject.cluster.ControllerNode; |
| 26 | import org.onosproject.cluster.DefaultControllerNode; |
| 27 | import org.onosproject.cluster.NodeId; |
Thomas Vachuska | 36002e6 | 2015-05-19 16:12:29 -0700 | [diff] [blame] | 28 | import org.onosproject.common.event.impl.TestEventDispatcher; |
Thomas Vachuska | 42e8cce | 2015-07-29 19:25:18 -0700 | [diff] [blame^] | 29 | import org.onosproject.event.Event; |
Sahil Lele | 3a0cdd5 | 2015-07-21 14:16:31 -0700 | [diff] [blame] | 30 | import org.onosproject.incubator.net.config.NetworkConfigServiceAdapter; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 31 | import org.onosproject.mastership.MastershipServiceAdapter; |
| 32 | import org.onosproject.mastership.MastershipTerm; |
| 33 | import org.onosproject.mastership.MastershipTermService; |
| 34 | import org.onosproject.net.Device; |
| 35 | import org.onosproject.net.DeviceId; |
| 36 | import org.onosproject.net.MastershipRole; |
| 37 | import org.onosproject.net.Port; |
| 38 | import org.onosproject.net.PortNumber; |
| 39 | import org.onosproject.net.device.DefaultDeviceDescription; |
| 40 | import org.onosproject.net.device.DefaultPortDescription; |
| 41 | import org.onosproject.net.device.DeviceAdminService; |
| 42 | import org.onosproject.net.device.DeviceClockProviderService; |
| 43 | import org.onosproject.net.device.DeviceDescription; |
| 44 | import org.onosproject.net.device.DeviceEvent; |
| 45 | import org.onosproject.net.device.DeviceListener; |
| 46 | import org.onosproject.net.device.DeviceProvider; |
| 47 | import org.onosproject.net.device.DeviceProviderRegistry; |
| 48 | import org.onosproject.net.device.DeviceProviderService; |
| 49 | import org.onosproject.net.device.DeviceService; |
| 50 | import org.onosproject.net.device.PortDescription; |
| 51 | import org.onosproject.net.provider.AbstractProvider; |
| 52 | import org.onosproject.net.provider.ProviderId; |
Thomas Vachuska | c97aa61 | 2015-06-23 16:00:18 -0700 | [diff] [blame] | 53 | import org.onosproject.store.trivial.SimpleDeviceStore; |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 54 | |
Thomas Vachuska | 42e8cce | 2015-07-29 19:25:18 -0700 | [diff] [blame^] | 55 | import java.util.ArrayList; |
| 56 | import java.util.Iterator; |
| 57 | import java.util.List; |
| 58 | import java.util.Set; |
| 59 | import java.util.concurrent.CompletableFuture; |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 60 | |
Thomas Vachuska | 42e8cce | 2015-07-29 19:25:18 -0700 | [diff] [blame^] | 61 | import static org.junit.Assert.*; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 62 | import static org.onosproject.net.Device.Type.SWITCH; |
| 63 | import static org.onosproject.net.DeviceId.deviceId; |
Thomas Vachuska | 42e8cce | 2015-07-29 19:25:18 -0700 | [diff] [blame^] | 64 | import static org.onosproject.net.NetTestTools.injectEventDispatcher; |
| 65 | import static org.onosproject.net.device.DeviceEvent.Type.*; |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 66 | |
| 67 | /** |
| 68 | * Test codifying the device service & device provider service contracts. |
| 69 | */ |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 70 | public class DeviceManagerTest { |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 71 | |
tom | 7e02cda | 2014-09-18 12:05:46 -0700 | [diff] [blame] | 72 | private static final ProviderId PID = new ProviderId("of", "foo"); |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 73 | private static final DeviceId DID1 = deviceId("of:foo"); |
| 74 | private static final DeviceId DID2 = deviceId("of:bar"); |
| 75 | private static final String MFR = "whitebox"; |
| 76 | private static final String HW = "1.1.x"; |
| 77 | private static final String SW1 = "3.8.1"; |
| 78 | private static final String SW2 = "3.9.5"; |
| 79 | private static final String SN = "43311-12345"; |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 80 | private static final ChassisId CID = new ChassisId(); |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 81 | |
tom | 24c55cd | 2014-09-06 10:47:25 -0700 | [diff] [blame] | 82 | private static final PortNumber P1 = PortNumber.portNumber(1); |
| 83 | private static final PortNumber P2 = PortNumber.portNumber(2); |
| 84 | private static final PortNumber P3 = PortNumber.portNumber(3); |
Yuta HIGUCHI | 33faeaf | 2014-10-07 18:19:44 -0700 | [diff] [blame] | 85 | private static final NodeId NID_LOCAL = new NodeId("local"); |
Pavlin Radoslavov | 444b519 | 2014-10-28 10:45:19 -0700 | [diff] [blame] | 86 | private static final IpAddress LOCALHOST = IpAddress.valueOf("127.0.0.1"); |
tom | 24c55cd | 2014-09-06 10:47:25 -0700 | [diff] [blame] | 87 | |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 88 | private DeviceManager mgr; |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 89 | |
| 90 | protected DeviceService service; |
| 91 | protected DeviceAdminService admin; |
| 92 | protected DeviceProviderRegistry registry; |
| 93 | protected DeviceProviderService providerService; |
| 94 | protected TestProvider provider; |
| 95 | protected TestListener listener = new TestListener(); |
| 96 | |
| 97 | @Before |
| 98 | public void setUp() { |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 99 | mgr = new DeviceManager(); |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 100 | service = mgr; |
| 101 | admin = mgr; |
| 102 | registry = mgr; |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 103 | mgr.store = new SimpleDeviceStore(); |
Thomas Vachuska | 42e8cce | 2015-07-29 19:25:18 -0700 | [diff] [blame^] | 104 | injectEventDispatcher(mgr, new TestEventDispatcher()); |
Yuta HIGUCHI | bcac499 | 2014-11-22 19:27:57 -0800 | [diff] [blame] | 105 | TestMastershipManager mastershipManager = new TestMastershipManager(); |
| 106 | mgr.mastershipService = mastershipManager; |
| 107 | mgr.termService = mastershipManager; |
Yuta HIGUCHI | 33faeaf | 2014-10-07 18:19:44 -0700 | [diff] [blame] | 108 | mgr.clusterService = new TestClusterService(); |
Yuta HIGUCHI | 093e83e | 2014-10-10 22:26:11 -0700 | [diff] [blame] | 109 | mgr.deviceClockProviderService = new TestClockProviderService(); |
Sahil Lele | 3a0cdd5 | 2015-07-21 14:16:31 -0700 | [diff] [blame] | 110 | mgr.networkConfigService = new TestNetworkConfigService(); |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 111 | mgr.activate(); |
| 112 | |
Sahil Lele | 3a0cdd5 | 2015-07-21 14:16:31 -0700 | [diff] [blame] | 113 | |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 114 | service.addListener(listener); |
| 115 | |
| 116 | provider = new TestProvider(); |
| 117 | providerService = registry.register(provider); |
| 118 | assertTrue("provider should be registered", |
| 119 | registry.getProviders().contains(provider.id())); |
| 120 | } |
| 121 | |
| 122 | @After |
| 123 | public void tearDown() { |
| 124 | registry.unregister(provider); |
| 125 | assertFalse("provider should not be registered", |
| 126 | registry.getProviders().contains(provider.id())); |
| 127 | service.removeListener(listener); |
| 128 | mgr.deactivate(); |
| 129 | } |
| 130 | |
| 131 | private void connectDevice(DeviceId deviceId, String swVersion) { |
| 132 | DeviceDescription description = |
| 133 | new DefaultDeviceDescription(deviceId.uri(), SWITCH, MFR, |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 134 | HW, swVersion, SN, CID); |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 135 | providerService.deviceConnected(deviceId, description); |
| 136 | assertNotNull("device should be found", service.getDevice(DID1)); |
| 137 | } |
| 138 | |
| 139 | @Test |
| 140 | public void deviceConnected() { |
| 141 | assertNull("device should not be found", service.getDevice(DID1)); |
| 142 | connectDevice(DID1, SW1); |
| 143 | validateEvents(DEVICE_ADDED); |
| 144 | |
| 145 | Iterator<Device> it = service.getDevices().iterator(); |
| 146 | assertNotNull("one device expected", it.next()); |
| 147 | assertFalse("only one device expected", it.hasNext()); |
tom | ad2d209 | 2014-09-06 23:24:20 -0700 | [diff] [blame] | 148 | assertEquals("incorrect device count", 1, service.getDeviceCount()); |
tom | ff7eb7c | 2014-09-08 12:49:03 -0700 | [diff] [blame] | 149 | assertTrue("device should be available", service.isAvailable(DID1)); |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | @Test |
| 153 | public void deviceDisconnected() { |
| 154 | connectDevice(DID1, SW1); |
| 155 | connectDevice(DID2, SW1); |
| 156 | validateEvents(DEVICE_ADDED, DEVICE_ADDED); |
tom | ff7eb7c | 2014-09-08 12:49:03 -0700 | [diff] [blame] | 157 | assertTrue("device should be available", service.isAvailable(DID1)); |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 158 | |
| 159 | // Disconnect |
| 160 | providerService.deviceDisconnected(DID1); |
| 161 | assertNotNull("device should not be found", service.getDevice(DID1)); |
tom | ff7eb7c | 2014-09-08 12:49:03 -0700 | [diff] [blame] | 162 | assertFalse("device should not be available", service.isAvailable(DID1)); |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 163 | validateEvents(DEVICE_AVAILABILITY_CHANGED); |
| 164 | |
| 165 | // Reconnect |
| 166 | connectDevice(DID1, SW1); |
| 167 | validateEvents(DEVICE_AVAILABILITY_CHANGED); |
tom | ad2d209 | 2014-09-06 23:24:20 -0700 | [diff] [blame] | 168 | |
| 169 | assertEquals("incorrect device count", 2, service.getDeviceCount()); |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 170 | } |
| 171 | |
| 172 | @Test |
| 173 | public void deviceUpdated() { |
| 174 | connectDevice(DID1, SW1); |
| 175 | validateEvents(DEVICE_ADDED); |
| 176 | |
| 177 | connectDevice(DID1, SW2); |
| 178 | validateEvents(DEVICE_UPDATED); |
| 179 | } |
| 180 | |
| 181 | @Test |
| 182 | public void getRole() { |
| 183 | connectDevice(DID1, SW1); |
tom | 80c0e5e | 2014-09-08 18:08:58 -0700 | [diff] [blame] | 184 | assertEquals("incorrect role", MastershipRole.MASTER, service.getRole(DID1)); |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 185 | } |
| 186 | |
tom | 24c55cd | 2014-09-06 10:47:25 -0700 | [diff] [blame] | 187 | @Test |
| 188 | public void updatePorts() { |
| 189 | connectDevice(DID1, SW1); |
| 190 | List<PortDescription> pds = new ArrayList<>(); |
| 191 | pds.add(new DefaultPortDescription(P1, true)); |
| 192 | pds.add(new DefaultPortDescription(P2, true)); |
| 193 | pds.add(new DefaultPortDescription(P3, true)); |
| 194 | providerService.updatePorts(DID1, pds); |
| 195 | validateEvents(DEVICE_ADDED, PORT_ADDED, PORT_ADDED, PORT_ADDED); |
| 196 | pds.clear(); |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 197 | |
tom | 24c55cd | 2014-09-06 10:47:25 -0700 | [diff] [blame] | 198 | pds.add(new DefaultPortDescription(P1, false)); |
| 199 | pds.add(new DefaultPortDescription(P3, true)); |
| 200 | providerService.updatePorts(DID1, pds); |
| 201 | validateEvents(PORT_UPDATED, PORT_REMOVED); |
| 202 | } |
| 203 | |
| 204 | @Test |
| 205 | public void updatePortStatus() { |
| 206 | connectDevice(DID1, SW1); |
| 207 | List<PortDescription> pds = new ArrayList<>(); |
| 208 | pds.add(new DefaultPortDescription(P1, true)); |
| 209 | pds.add(new DefaultPortDescription(P2, true)); |
| 210 | providerService.updatePorts(DID1, pds); |
| 211 | validateEvents(DEVICE_ADDED, PORT_ADDED, PORT_ADDED); |
| 212 | |
| 213 | providerService.portStatusChanged(DID1, new DefaultPortDescription(P1, false)); |
| 214 | validateEvents(PORT_UPDATED); |
| 215 | providerService.portStatusChanged(DID1, new DefaultPortDescription(P1, false)); |
| 216 | assertTrue("no events expected", listener.events.isEmpty()); |
| 217 | } |
| 218 | |
| 219 | @Test |
| 220 | public void getPorts() { |
| 221 | connectDevice(DID1, SW1); |
| 222 | List<PortDescription> pds = new ArrayList<>(); |
| 223 | pds.add(new DefaultPortDescription(P1, true)); |
| 224 | pds.add(new DefaultPortDescription(P2, true)); |
| 225 | providerService.updatePorts(DID1, pds); |
| 226 | validateEvents(DEVICE_ADDED, PORT_ADDED, PORT_ADDED); |
| 227 | assertEquals("wrong port count", 2, service.getPorts(DID1).size()); |
| 228 | |
| 229 | Port port = service.getPort(DID1, P1); |
| 230 | assertEquals("incorrect port", P1, service.getPort(DID1, P1).number()); |
| 231 | assertEquals("incorrect state", true, service.getPort(DID1, P1).isEnabled()); |
| 232 | } |
| 233 | |
| 234 | @Test |
| 235 | public void removeDevice() { |
| 236 | connectDevice(DID1, SW1); |
| 237 | connectDevice(DID2, SW2); |
tom | ad2d209 | 2014-09-06 23:24:20 -0700 | [diff] [blame] | 238 | assertEquals("incorrect device count", 2, service.getDeviceCount()); |
tom | 24c55cd | 2014-09-06 10:47:25 -0700 | [diff] [blame] | 239 | admin.removeDevice(DID1); |
| 240 | assertNull("device should not be found", service.getDevice(DID1)); |
| 241 | assertNotNull("device should be found", service.getDevice(DID2)); |
tom | ad2d209 | 2014-09-06 23:24:20 -0700 | [diff] [blame] | 242 | assertEquals("incorrect device count", 1, service.getDeviceCount()); |
| 243 | |
tom | 24c55cd | 2014-09-06 10:47:25 -0700 | [diff] [blame] | 244 | } |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 245 | |
| 246 | protected void validateEvents(Enum... types) { |
| 247 | int i = 0; |
| 248 | assertEquals("wrong events received", types.length, listener.events.size()); |
| 249 | for (Event event : listener.events) { |
| 250 | assertEquals("incorrect event type", types[i], event.type()); |
| 251 | i++; |
| 252 | } |
| 253 | listener.events.clear(); |
| 254 | } |
| 255 | |
| 256 | |
| 257 | private class TestProvider extends AbstractProvider implements DeviceProvider { |
Yuta HIGUCHI | 5481532 | 2014-10-31 23:17:08 -0700 | [diff] [blame] | 258 | private DeviceId deviceReceived; |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 259 | private MastershipRole roleReceived; |
| 260 | |
| 261 | public TestProvider() { |
| 262 | super(PID); |
| 263 | } |
| 264 | |
| 265 | @Override |
Ayaka Koshibe | 78bcbc1 | 2014-11-19 14:28:58 -0800 | [diff] [blame] | 266 | public void triggerProbe(DeviceId deviceId) { |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 267 | } |
| 268 | |
| 269 | @Override |
Yuta HIGUCHI | 5481532 | 2014-10-31 23:17:08 -0700 | [diff] [blame] | 270 | public void roleChanged(DeviceId device, MastershipRole newRole) { |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 271 | deviceReceived = device; |
| 272 | roleReceived = newRole; |
| 273 | } |
Ayaka Koshibe | e60d452 | 2014-10-28 15:07:00 -0700 | [diff] [blame] | 274 | |
| 275 | @Override |
Yuta HIGUCHI | 5481532 | 2014-10-31 23:17:08 -0700 | [diff] [blame] | 276 | public boolean isReachable(DeviceId device) { |
Ayaka Koshibe | e60d452 | 2014-10-28 15:07:00 -0700 | [diff] [blame] | 277 | return false; |
| 278 | } |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | private static class TestListener implements DeviceListener { |
| 282 | final List<DeviceEvent> events = new ArrayList<>(); |
| 283 | |
| 284 | @Override |
| 285 | public void event(DeviceEvent event) { |
| 286 | events.add(event); |
| 287 | } |
| 288 | } |
| 289 | |
Yuta HIGUCHI | bcac499 | 2014-11-22 19:27:57 -0800 | [diff] [blame] | 290 | private static class TestMastershipManager |
| 291 | extends MastershipServiceAdapter implements MastershipTermService { |
Ayaka Koshibe | a7f044e | 2014-09-23 16:56:20 -0700 | [diff] [blame] | 292 | @Override |
tom | b41d1ac | 2014-09-24 01:51:24 -0700 | [diff] [blame] | 293 | public MastershipRole getLocalRole(DeviceId deviceId) { |
| 294 | return MastershipRole.MASTER; |
Ayaka Koshibe | a7f044e | 2014-09-23 16:56:20 -0700 | [diff] [blame] | 295 | } |
| 296 | |
| 297 | @Override |
| 298 | public Set<DeviceId> getDevicesOf(NodeId nodeId) { |
| 299 | return Sets.newHashSet(DID1, DID2); |
| 300 | } |
| 301 | |
| 302 | @Override |
Madan Jampani | de003d9 | 2015-05-11 17:14:20 -0700 | [diff] [blame] | 303 | public CompletableFuture<MastershipRole> requestRoleFor(DeviceId deviceId) { |
| 304 | return CompletableFuture.completedFuture(MastershipRole.MASTER); |
Ayaka Koshibe | a7f044e | 2014-09-23 16:56:20 -0700 | [diff] [blame] | 305 | } |
Yuta HIGUCHI | 33faeaf | 2014-10-07 18:19:44 -0700 | [diff] [blame] | 306 | |
| 307 | @Override |
Madan Jampani | c6e574f | 2015-05-29 13:41:52 -0700 | [diff] [blame] | 308 | public CompletableFuture<Void> relinquishMastership(DeviceId deviceId) { |
| 309 | return CompletableFuture.completedFuture(null); |
| 310 | } |
| 311 | |
| 312 | @Override |
Yuta HIGUCHI | bcac499 | 2014-11-22 19:27:57 -0800 | [diff] [blame] | 313 | public MastershipTerm getMastershipTerm(DeviceId deviceId) { |
| 314 | // FIXME: just returning something not null |
| 315 | return MastershipTerm.of(NID_LOCAL, 1); |
Yuta HIGUCHI | 33faeaf | 2014-10-07 18:19:44 -0700 | [diff] [blame] | 316 | } |
Ayaka Koshibe | a7f044e | 2014-09-23 16:56:20 -0700 | [diff] [blame] | 317 | } |
| 318 | |
Yuta HIGUCHI | 33faeaf | 2014-10-07 18:19:44 -0700 | [diff] [blame] | 319 | // code clone |
Ray Milkey | cc53abd | 2015-02-19 12:31:33 -0800 | [diff] [blame] | 320 | private final class TestClusterService extends ClusterServiceAdapter { |
Yuta HIGUCHI | 33faeaf | 2014-10-07 18:19:44 -0700 | [diff] [blame] | 321 | |
| 322 | ControllerNode local = new DefaultControllerNode(NID_LOCAL, LOCALHOST); |
| 323 | |
| 324 | @Override |
| 325 | public ControllerNode getLocalNode() { |
| 326 | return local; |
| 327 | } |
| 328 | |
Yuta HIGUCHI | 33faeaf | 2014-10-07 18:19:44 -0700 | [diff] [blame] | 329 | } |
| 330 | |
| 331 | private final class TestClockProviderService implements |
Yuta HIGUCHI | 093e83e | 2014-10-10 22:26:11 -0700 | [diff] [blame] | 332 | DeviceClockProviderService { |
Yuta HIGUCHI | 33faeaf | 2014-10-07 18:19:44 -0700 | [diff] [blame] | 333 | |
Yuta HIGUCHI | 13c0b87 | 2014-10-30 18:09:22 -0700 | [diff] [blame] | 334 | private Set<DeviceId> registerdBefore = Sets.newConcurrentHashSet(); |
| 335 | |
Yuta HIGUCHI | 33faeaf | 2014-10-07 18:19:44 -0700 | [diff] [blame] | 336 | @Override |
| 337 | public void setMastershipTerm(DeviceId deviceId, MastershipTerm term) { |
Yuta HIGUCHI | 13c0b87 | 2014-10-30 18:09:22 -0700 | [diff] [blame] | 338 | registerdBefore.add(deviceId); |
| 339 | } |
| 340 | |
| 341 | @Override |
| 342 | public boolean isTimestampAvailable(DeviceId deviceId) { |
| 343 | return registerdBefore.contains(deviceId); |
Yuta HIGUCHI | 33faeaf | 2014-10-07 18:19:44 -0700 | [diff] [blame] | 344 | } |
| 345 | } |
Sahil Lele | 3a0cdd5 | 2015-07-21 14:16:31 -0700 | [diff] [blame] | 346 | |
| 347 | private class TestNetworkConfigService extends NetworkConfigServiceAdapter { |
| 348 | } |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 349 | } |