blob: c04b8c3eacb70652f27812a6293f884b6371e23d [file] [log] [blame]
HIGUCHI Yuta15653fd2015-11-09 11:05:09 -08001/*
2 * Copyright 2015 Open Networking Laboratory
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 */
16package org.onosproject.incubator.rpc.grpc;
17
18import static org.junit.Assert.*;
19import static org.onosproject.net.DeviceId.deviceId;
HIGUCHI Yuta7c1583c2015-12-03 23:08:54 -080020import static org.onosproject.net.PortNumber.portNumber;
HIGUCHI Yuta15653fd2015-11-09 11:05:09 -080021
HIGUCHI Yuta15653fd2015-11-09 11:05:09 -080022import java.net.URI;
23import java.util.Collection;
24import java.util.Collections;
25import java.util.List;
26import java.util.Set;
27import java.util.concurrent.CountDownLatch;
28import java.util.concurrent.TimeUnit;
29
HIGUCHI Yuta15653fd2015-11-09 11:05:09 -080030import org.junit.After;
31import org.junit.Before;
32import org.junit.Test;
HIGUCHI Yuta97f7e472016-01-22 10:03:48 -080033import org.onlab.junit.TestTools;
HIGUCHI Yuta15653fd2015-11-09 11:05:09 -080034import org.onlab.packet.ChassisId;
35import org.onosproject.incubator.rpc.RemoteServiceContext;
36import org.onosproject.incubator.rpc.RemoteServiceContextProvider;
37import org.onosproject.incubator.rpc.RemoteServiceContextProviderService;
38import org.onosproject.incubator.rpc.RemoteServiceProviderRegistry;
HIGUCHI Yuta7c1583c2015-12-03 23:08:54 -080039import org.onosproject.net.ConnectPoint;
HIGUCHI Yuta15653fd2015-11-09 11:05:09 -080040import org.onosproject.net.DefaultAnnotations;
41import org.onosproject.net.Device.Type;
42import org.onosproject.net.DeviceId;
HIGUCHI Yuta7c1583c2015-12-03 23:08:54 -080043import org.onosproject.net.Link;
HIGUCHI Yuta15653fd2015-11-09 11:05:09 -080044import org.onosproject.net.MastershipRole;
45import org.onosproject.net.PortNumber;
46import org.onosproject.net.SparseAnnotations;
47import org.onosproject.net.device.DefaultDeviceDescription;
48import org.onosproject.net.device.DefaultPortDescription;
49import org.onosproject.net.device.DeviceDescription;
50import org.onosproject.net.device.DeviceProvider;
51import org.onosproject.net.device.DeviceProviderRegistry;
52import org.onosproject.net.device.DeviceProviderService;
53import org.onosproject.net.device.PortDescription;
54import org.onosproject.net.device.PortStatistics;
HIGUCHI Yuta7c1583c2015-12-03 23:08:54 -080055import org.onosproject.net.link.DefaultLinkDescription;
56import org.onosproject.net.link.LinkDescription;
57import org.onosproject.net.link.LinkProvider;
58import org.onosproject.net.link.LinkProviderRegistry;
59import org.onosproject.net.link.LinkProviderService;
HIGUCHI Yuta15653fd2015-11-09 11:05:09 -080060import org.onosproject.net.provider.AbstractProviderRegistry;
61import org.onosproject.net.provider.AbstractProviderService;
62import org.onosproject.net.provider.ProviderId;
63import org.slf4j.Logger;
64import org.slf4j.LoggerFactory;
65
66import com.google.common.collect.ImmutableList;
67
68/**
69 * Set of tests of the gRPC RemoteService components.
70 */
71public class GrpcRemoteServiceTest {
72
73 private static final DeviceId DEVICE_ID = deviceId("dev:000001");
74
75 private final Logger log = LoggerFactory.getLogger(getClass());
76
77 private static final ProviderId PID = new ProviderId("test", "com.exmaple.test");
78
79 private static final URI DURI = URI.create("dev:000001");
80
81 private static final String MFR = "mfr";
82
83 private static final String HW = "hw";
84
85 private static final String SW = "sw";
86
87 private static final String SN = "serial";
88
89 private static final ChassisId CHASSIS = new ChassisId(42);
90
91 private static final SparseAnnotations ANON = DefaultAnnotations.builder()
92 .set("foo", "var")
93 .build();
94
95 private static final PortNumber PORT = PortNumber.portNumber(99);
96
97 private static final DeviceDescription DDESC
98 = new DefaultDeviceDescription(DURI, Type.SWITCH, MFR, HW, SW, SN,
99 CHASSIS, ANON);
100
101 private GrpcRemoteServiceServer server;
102 private GrpcRemoteServiceProvider client;
103
104 private DeviceProvider svSideDeviceProvider;
105
106 private MTestDeviceProviderService svDeviceProviderService;
107
HIGUCHI Yuta7c1583c2015-12-03 23:08:54 -0800108 private ServerSideLinkProviderService svLinkProviderService;
109
110
HIGUCHI Yuta15653fd2015-11-09 11:05:09 -0800111 private CountDownLatch serverReady;
112
113 private URI uri;
114
HIGUCHI Yuta15653fd2015-11-09 11:05:09 -0800115 @Before
116 public void setUp() throws Exception {
117 serverReady = new CountDownLatch(1);
118 server = new GrpcRemoteServiceServer();
119 server.deviceProviderRegistry = new MTestDeviceProviderRegistry();
HIGUCHI Yuta7c1583c2015-12-03 23:08:54 -0800120 server.linkProviderRegistry = new ServerSideLinkProviderRegistry();
HIGUCHI Yuta97f7e472016-01-22 10:03:48 -0800121 server.listenPort = TestTools.findAvailablePort(11984);
HIGUCHI Yuta15653fd2015-11-09 11:05:09 -0800122 uri = URI.create("grpc://localhost:" + server.listenPort);
HIGUCHI Yuta97f7e472016-01-22 10:03:48 -0800123 // todo: pass proper ComponentContext
HIGUCHI Yuta15653fd2015-11-09 11:05:09 -0800124 server.activate(null);
125
126 client = new GrpcRemoteServiceProvider();
127 client.rpcRegistry = new NoOpRemoteServiceProviderRegistry();
128 client.activate();
129 }
130
131 @After
132 public void tearDown() {
133 client.deactivate();
134 server.deactivate();
HIGUCHI Yuta7c1583c2015-12-03 23:08:54 -0800135 svLinkProviderService = null;
HIGUCHI Yuta15653fd2015-11-09 11:05:09 -0800136 }
137
138 private static void assertEqualsButNotSame(Object expected, Object actual) {
139 assertEquals(expected, actual);
140 assertNotSame("Cannot be same instance if it properly went through gRPC",
141 expected, actual);
142 }
143
144 @Test
HIGUCHI Yuta7c1583c2015-12-03 23:08:54 -0800145 public void deviceServiceBasics() throws InterruptedException {
HIGUCHI Yuta15653fd2015-11-09 11:05:09 -0800146 RemoteServiceContext remoteServiceContext = client.get(uri);
147 assertNotNull(remoteServiceContext);
148
149 DeviceProviderRegistry deviceProviderRegistry = remoteServiceContext.get(DeviceProviderRegistry.class);
150 assertNotNull(deviceProviderRegistry);
151
152 CTestDeviceProvider clDeviceProvider = new CTestDeviceProvider();
153 DeviceProviderService clDeviceProviderService = deviceProviderRegistry.register(clDeviceProvider);
154
155 assertTrue(serverReady.await(10, TimeUnit.SECONDS));
156
157 // client to server communication
158 clDeviceProviderService.deviceConnected(DEVICE_ID, DDESC);
159 assertTrue(svDeviceProviderService.deviceConnected.await(10, TimeUnit.SECONDS));
160 assertEqualsButNotSame(DEVICE_ID, svDeviceProviderService.deviceConnectedDid);
161 assertEqualsButNotSame(DDESC, svDeviceProviderService.deviceConnectedDesc);
162
163 PortDescription portDescription = new DefaultPortDescription(PORT, true, ANON);
164 List<PortDescription> portDescriptions = ImmutableList.of(portDescription);
165 clDeviceProviderService.updatePorts(DEVICE_ID, portDescriptions);
166 assertTrue(svDeviceProviderService.updatePorts.await(10, TimeUnit.SECONDS));
167 assertEqualsButNotSame(DEVICE_ID, svDeviceProviderService.updatePortsDid);
168 assertEqualsButNotSame(portDescriptions, svDeviceProviderService.updatePortsDescs);
169
170 MastershipRole cRole = MastershipRole.MASTER;
171 MastershipRole dRole = MastershipRole.STANDBY;
172 clDeviceProviderService.receivedRoleReply(DEVICE_ID, cRole, dRole);
173 assertTrue(svDeviceProviderService.receivedRoleReply.await(10, TimeUnit.SECONDS));
174 assertEqualsButNotSame(DEVICE_ID, svDeviceProviderService.receivedRoleReplyDid);
175 assertEquals(cRole, svDeviceProviderService.receivedRoleReplyRequested);
176 assertEquals(dRole, svDeviceProviderService.receivedRoleReplyResponse);
177
178 clDeviceProviderService.portStatusChanged(DEVICE_ID, portDescription);
179 assertTrue(svDeviceProviderService.portStatusChanged.await(10, TimeUnit.SECONDS));
180 assertEqualsButNotSame(DEVICE_ID, svDeviceProviderService.portStatusChangedDid);
181 assertEqualsButNotSame(portDescription, svDeviceProviderService.portStatusChangedDesc);
182
183 Collection<PortStatistics> portStatistics = Collections.emptyList();
184 clDeviceProviderService.updatePortStatistics(DEVICE_ID, portStatistics);
185 assertTrue(svDeviceProviderService.updatePortStatistics.await(10, TimeUnit.SECONDS));
186 assertEqualsButNotSame(DEVICE_ID, svDeviceProviderService.updatePortStatisticsDid);
187 assertEqualsButNotSame(portStatistics, svDeviceProviderService.updatePortStatisticsStats);
188
189 clDeviceProviderService.deviceDisconnected(DEVICE_ID);
190 assertTrue(svDeviceProviderService.deviceDisconnected.await(10, TimeUnit.SECONDS));
191 assertEqualsButNotSame(DEVICE_ID, svDeviceProviderService.deviceDisconnectedDid);
192
193
194
195 // server to client communication
196 svSideDeviceProvider.triggerProbe(DEVICE_ID);
197 assertTrue(clDeviceProvider.triggerProbe.await(10, TimeUnit.SECONDS));
198 assertEquals(DEVICE_ID, clDeviceProvider.triggerProbeDid);
199 assertNotSame("Cannot be same instance if it properly went through gRPC",
200 DEVICE_ID, clDeviceProvider.triggerProbeDid);
201
202 svSideDeviceProvider.roleChanged(DEVICE_ID, MastershipRole.STANDBY);
203 assertTrue(clDeviceProvider.roleChanged.await(10, TimeUnit.SECONDS));
204 assertEquals(DEVICE_ID, clDeviceProvider.roleChangedDid);
205 assertNotSame("Cannot be same instance if it properly went through gRPC",
206 DEVICE_ID, clDeviceProvider.roleChangedDid);
207 assertEquals(MastershipRole.STANDBY, clDeviceProvider.roleChangedNewRole);
208
209 clDeviceProvider.isReachableReply = false;
210 assertEquals(clDeviceProvider.isReachableReply,
211 svSideDeviceProvider.isReachable(DEVICE_ID));
212 assertTrue(clDeviceProvider.isReachable.await(10, TimeUnit.SECONDS));
213 assertEquals(DEVICE_ID, clDeviceProvider.isReachableDid);
214 assertNotSame("Cannot be same instance if it properly went through gRPC",
215 DEVICE_ID, clDeviceProvider.isReachableDid);
216 }
217
HIGUCHI Yuta7c1583c2015-12-03 23:08:54 -0800218 @Test
219 public void linkVanishedDevice() throws InterruptedException {
220 RemoteServiceContext remoteServiceContext = client.get(uri);
221 assertNotNull(remoteServiceContext);
222
223 LinkProviderRegistry providerRegistry = remoteServiceContext.get(LinkProviderRegistry.class);
224 assertNotNull(providerRegistry);
225
226 final String schemeTest = "test";
227 LinkProviderService client = providerRegistry.register(new StubLinkProvider(schemeTest));
228 assertNotNull(client);
229
230 client.linksVanished(DEVICE_ID);
231
232 assertEquals(schemeTest, svLinkProviderService.provider().id().scheme());
233 assertTrue(svLinkProviderService.calls.await(10, TimeUnit.SECONDS));
234 assertEqualsButNotSame(DEVICE_ID, svLinkProviderService.arg);
235 }
236
237 @Test
238 public void linkVanishedPort() throws InterruptedException {
239 RemoteServiceContext remoteServiceContext = client.get(uri);
240 assertNotNull(remoteServiceContext);
241
242 LinkProviderRegistry providerRegistry = remoteServiceContext.get(LinkProviderRegistry.class);
243 assertNotNull(providerRegistry);
244
245 final String schemeTest = "test";
246 LinkProviderService client = providerRegistry.register(new StubLinkProvider(schemeTest));
247 assertNotNull(client);
248
249
250 final ConnectPoint cp = new ConnectPoint(DEVICE_ID, PORT);
251 client.linksVanished(cp);
252 assertEquals(schemeTest, svLinkProviderService.provider().id().scheme());
253 assertTrue(svLinkProviderService.calls.await(10, TimeUnit.SECONDS));
254 assertEqualsButNotSame(cp, svLinkProviderService.arg);
255 }
256
257 @Test
258 public void linkVanishedDescription() throws InterruptedException {
259 RemoteServiceContext remoteServiceContext = client.get(uri);
260 assertNotNull(remoteServiceContext);
261
262 LinkProviderRegistry providerRegistry = remoteServiceContext.get(LinkProviderRegistry.class);
263 assertNotNull(providerRegistry);
264
265 final String schemeTest = "test";
266 LinkProviderService client = providerRegistry.register(new StubLinkProvider(schemeTest));
267 assertNotNull(client);
268
269 ConnectPoint src = new ConnectPoint(deviceId("dev:1"), portNumber(10));
270 ConnectPoint dst = new ConnectPoint(deviceId("dev:2"), portNumber(20));
271 LinkDescription linkDescription = new DefaultLinkDescription(src, dst, Link.Type.DIRECT, ANON);
272 client.linkVanished(linkDescription);
273 assertEquals(schemeTest, svLinkProviderService.provider().id().scheme());
274 assertTrue(svLinkProviderService.calls.await(10, TimeUnit.SECONDS));
275 assertEqualsButNotSame(linkDescription, svLinkProviderService.arg);
276 }
277
278 @Test
279 public void linkDetected() throws InterruptedException {
280 RemoteServiceContext remoteServiceContext = client.get(uri);
281 assertNotNull(remoteServiceContext);
282
283 LinkProviderRegistry providerRegistry = remoteServiceContext.get(LinkProviderRegistry.class);
284 assertNotNull(providerRegistry);
285
286 final String schemeTest = "test";
287 LinkProviderService client = providerRegistry.register(new StubLinkProvider(schemeTest));
288 assertNotNull(client);
289
290 ConnectPoint src = new ConnectPoint(deviceId("dev:1"), portNumber(10));
291 ConnectPoint dst = new ConnectPoint(deviceId("dev:2"), portNumber(20));
292 LinkDescription linkDescription = new DefaultLinkDescription(src, dst, Link.Type.DIRECT, ANON);
293 client.linkDetected(linkDescription);
294 assertEquals(schemeTest, svLinkProviderService.provider().id().scheme());
295 assertTrue(svLinkProviderService.calls.await(10, TimeUnit.SECONDS));
296 assertEqualsButNotSame(linkDescription, svLinkProviderService.arg);
297 }
298
299 @Test
300 public void linkServiceBasics() throws InterruptedException {
301 RemoteServiceContext remoteServiceContext = client.get(uri);
302 assertNotNull(remoteServiceContext);
303
304 LinkProviderRegistry providerRegistry = remoteServiceContext.get(LinkProviderRegistry.class);
305 assertNotNull(providerRegistry);
306
307 final String schemeTest = "test";
308 LinkProviderService client = providerRegistry.register(new StubLinkProvider(schemeTest));
309 assertNotNull(client);
310
311 ConnectPoint src = new ConnectPoint(deviceId("dev:1"), portNumber(10));
312 ConnectPoint dst = new ConnectPoint(deviceId("dev:2"), portNumber(20));
313 LinkDescription linkDescription = new DefaultLinkDescription(src, dst, Link.Type.DIRECT, ANON);
314
315 client.linkDetected(linkDescription);
316 assertEquals(schemeTest, svLinkProviderService.provider().id().scheme());
317 assertTrue(svLinkProviderService.calls.await(10, TimeUnit.SECONDS));
318 assertEqualsButNotSame(linkDescription, svLinkProviderService.arg);
319
320 svLinkProviderService.reset();
321
322 client.linkVanished(linkDescription);
323 assertEquals(schemeTest, svLinkProviderService.provider().id().scheme());
324 assertTrue(svLinkProviderService.calls.await(10, TimeUnit.SECONDS));
325 assertEqualsButNotSame(linkDescription, svLinkProviderService.arg);
326 }
327
HIGUCHI Yuta15653fd2015-11-09 11:05:09 -0800328 /**
329 * Device Provider on CO side.
330 */
331 public class CTestDeviceProvider implements DeviceProvider {
332
333 final CountDownLatch triggerProbe = new CountDownLatch(1);
334 DeviceId triggerProbeDid;
335
336 final CountDownLatch roleChanged = new CountDownLatch(1);
337 DeviceId roleChangedDid;
338 MastershipRole roleChangedNewRole;
339
340 final CountDownLatch isReachable = new CountDownLatch(1);
341 DeviceId isReachableDid;
342 boolean isReachableReply = false;
343
Saurav Dasa2d37502016-03-25 17:50:40 -0700344 final CountDownLatch portStateChanged = new CountDownLatch(1);
345 DeviceId portStateChangedDid;
346 PortNumber portStateChangedPort;
347
HIGUCHI Yuta15653fd2015-11-09 11:05:09 -0800348 @Override
349 public ProviderId id() {
350 return PID;
351 }
352
353 @Override
354 public void triggerProbe(DeviceId deviceId) {
355 log.info("triggerProbe({}) on Client called", deviceId);
356 triggerProbeDid = deviceId;
357 triggerProbe.countDown();
358 }
359
360 @Override
361 public void roleChanged(DeviceId deviceId, MastershipRole newRole) {
362 log.info("roleChanged({},{}) on Client called", deviceId, newRole);
363 roleChangedDid = deviceId;
364 roleChangedNewRole = newRole;
365 roleChanged.countDown();
366 }
367
368 @Override
369 public boolean isReachable(DeviceId deviceId) {
370 log.info("isReachable({}) on Client called", deviceId);
371 isReachableDid = deviceId;
372 isReachable.countDown();
373 return isReachableReply;
374 }
375
Saurav Dasa2d37502016-03-25 17:50:40 -0700376 @Override
377 public void changePortState(DeviceId deviceId, PortNumber portNumber,
378 boolean enable) {
379 log.info("portState change to {} on ({},{}) on Client called", enable,
380 deviceId, portNumber);
381 portStateChangedDid = deviceId;
382 portStateChangedPort = portNumber;
383 portStateChanged.countDown();
384
385 }
386
HIGUCHI Yuta15653fd2015-11-09 11:05:09 -0800387 }
388
389 class NoOpRemoteServiceProviderRegistry
390 implements RemoteServiceProviderRegistry {
391
392 @Override
393 public RemoteServiceContextProviderService register(RemoteServiceContextProvider provider) {
394 return new RemoteServiceContextProviderService() {
395
396 @Override
397 public RemoteServiceContextProvider provider() {
398 return provider;
399 }
400 };
401 }
402
403 @Override
404 public void unregister(RemoteServiceContextProvider provider) {
405 }
406
407 @Override
408 public Set<ProviderId> getProviders() {
409 return Collections.emptySet();
410 }
411 }
412
413 /**
414 * DeviceProvider on Metro side.
415 */
416 public class MTestDeviceProviderRegistry
417 extends AbstractProviderRegistry<DeviceProvider, DeviceProviderService>
418 implements DeviceProviderRegistry {
419
420 @Override
421 protected DeviceProviderService createProviderService(DeviceProvider provider) {
422 log.info("createProviderService({})", provider);
423 svSideDeviceProvider = provider;
424 svDeviceProviderService = new MTestDeviceProviderService(provider);
425 serverReady.countDown();
426 return svDeviceProviderService;
427 }
428
429 }
430
431 private final class MTestDeviceProviderService
432 extends AbstractProviderService<DeviceProvider>
433 implements DeviceProviderService {
434
435 public MTestDeviceProviderService(DeviceProvider provider) {
436 super(provider);
437 }
438
439
440 final CountDownLatch deviceConnected = new CountDownLatch(1);
441 DeviceId deviceConnectedDid;
442 DeviceDescription deviceConnectedDesc;
443
444 @Override
445 public void deviceConnected(DeviceId deviceId,
446 DeviceDescription deviceDescription) {
447 log.info("deviceConnected({}, {}) on Server called", deviceId, deviceDescription);
448 deviceConnectedDid = deviceId;
449 deviceConnectedDesc = deviceDescription;
450 deviceConnected.countDown();
451 }
452
453
454 final CountDownLatch updatePorts = new CountDownLatch(1);
455 DeviceId updatePortsDid;
456 List<PortDescription> updatePortsDescs;
457
458 @Override
459 public void updatePorts(DeviceId deviceId,
460 List<PortDescription> portDescriptions) {
461 log.info("updatePorts({}, {}) on Server called", deviceId, portDescriptions);
462 updatePortsDid = deviceId;
463 updatePortsDescs = portDescriptions;
464 updatePorts.countDown();
465 }
466
467 final CountDownLatch receivedRoleReply = new CountDownLatch(1);
468 DeviceId receivedRoleReplyDid;
469 MastershipRole receivedRoleReplyRequested;
470 MastershipRole receivedRoleReplyResponse;
471
472 @Override
473 public void receivedRoleReply(DeviceId deviceId, MastershipRole requested,
474 MastershipRole response) {
475 log.info("receivedRoleReply({}, {}, {}) on Server called", deviceId, requested, response);
476 receivedRoleReplyDid = deviceId;
477 receivedRoleReplyRequested = requested;
478 receivedRoleReplyResponse = response;
479 receivedRoleReply.countDown();
480 }
481
482 final CountDownLatch portStatusChanged = new CountDownLatch(1);
483 DeviceId portStatusChangedDid;
484 PortDescription portStatusChangedDesc;
485
486
487 @Override
488 public void portStatusChanged(DeviceId deviceId,
489 PortDescription portDescription) {
490 log.info("portStatusChanged({}, {}) on Server called", deviceId, portDescription);
491 portStatusChangedDid = deviceId;
492 portStatusChangedDesc = portDescription;
493 portStatusChanged.countDown();
494 }
495
496 final CountDownLatch updatePortStatistics = new CountDownLatch(1);
497 DeviceId updatePortStatisticsDid;
498 Collection<PortStatistics> updatePortStatisticsStats;
499
500
501 @Override
502 public void updatePortStatistics(DeviceId deviceId,
503 Collection<PortStatistics> portStatistics) {
504 log.info("updatePortStatistics({}, {}) on Server called", deviceId, portStatistics);
505 updatePortStatisticsDid = deviceId;
506 updatePortStatisticsStats = portStatistics;
507 updatePortStatistics.countDown();
508 }
509
510 final CountDownLatch deviceDisconnected = new CountDownLatch(1);
511 DeviceId deviceDisconnectedDid;
512
513 @Override
514 public void deviceDisconnected(DeviceId deviceId) {
515 log.info("deviceDisconnected({}) on Server called", deviceId);
516 deviceDisconnectedDid = deviceId;
517 deviceDisconnected.countDown();
518 }
519 }
520
HIGUCHI Yuta7c1583c2015-12-03 23:08:54 -0800521 public class ServerSideLinkProviderRegistry
522 extends AbstractProviderRegistry<LinkProvider, LinkProviderService>
523 implements LinkProviderRegistry {
524
525 @Override
526 protected LinkProviderService createProviderService(LinkProvider provider) {
527 svLinkProviderService = new ServerSideLinkProviderService(provider);
528 return svLinkProviderService;
529 }
530
531 }
532
533 public class ServerSideLinkProviderService
534 extends AbstractProviderService<LinkProvider>
535 implements LinkProviderService {
536
537 CountDownLatch calls = new CountDownLatch(1);
538 Object arg = null;
539
540 public void reset() {
541 calls = new CountDownLatch(1);
542 arg = null;
543 }
544
545 public ServerSideLinkProviderService(LinkProvider provider) {
546 super(provider);
547 }
548
549 @Override
550 public void linksVanished(DeviceId deviceId) {
551 log.info("linksVanished({})", deviceId);
552 arg = deviceId;
553 calls.countDown();
554 }
555
556 @Override
557 public void linksVanished(ConnectPoint connectPoint) {
558 log.info("linksVanished({})", connectPoint);
559 arg = connectPoint;
560 calls.countDown();
561 }
562
563 @Override
564 public void linkVanished(LinkDescription linkDescription) {
565 log.info("linksVanished({})", linkDescription);
566 arg = linkDescription;
567 calls.countDown();
568 }
569
570 @Override
571 public void linkDetected(LinkDescription linkDescription) {
572 log.info("linkDetected({})", linkDescription);
573 arg = linkDescription;
574 calls.countDown();
575 }
576 }
577
HIGUCHI Yuta15653fd2015-11-09 11:05:09 -0800578}