OPNFLWPLUG-1032: Neon-MRI: Bump odlparent, yangtools, mdsal
[openflowplugin.git] / test-provider / src / main / java / org / opendaylight / openflowplugin / test / OpenflowpluginTestNodeConnectorNotification.java
1 /**
2  * Copyright (c) 2014, 2015 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.openflowplugin.test;
9
10 import java.util.ArrayList;
11 import java.util.List;
12 import org.opendaylight.controller.sal.binding.api.NotificationService;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemoved;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRemoved;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdated;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.OpendaylightInventoryListener;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
20
21 public class OpenflowpluginTestNodeConnectorNotification {
22
23     private static final Logger LOG = LoggerFactory.getLogger(OpenflowpluginTestNodeConnectorNotification.class);
24
25     private final PortEventListener portEventListener = new PortEventListener();
26     private final NotificationService notificationService;
27
28     public OpenflowpluginTestNodeConnectorNotification(NotificationService notificationService) {
29         this.notificationService = notificationService;
30     }
31
32     public void init() {
33         // For switch events
34         notificationService.registerNotificationListener(portEventListener);
35     }
36
37     private static final class PortEventListener implements OpendaylightInventoryListener {
38
39         List<NodeUpdated> nodeUpdated = new ArrayList<>();
40         List<NodeRemoved> nodeRemoved = new ArrayList<>();
41         List<NodeConnectorUpdated> nodeConnectorUpdated = new ArrayList<>();
42         List<NodeConnectorRemoved> nodeConnectorRemoved = new ArrayList<>();
43
44         @Override
45         public void onNodeConnectorRemoved(NodeConnectorRemoved notification) {
46             LOG.debug("NodeConnectorRemoved Notification");
47             LOG.debug("NodeConnectorRef {}", notification.getNodeConnectorRef());
48             nodeConnectorRemoved.add(notification);
49         }
50
51         @Override
52         public void onNodeConnectorUpdated(NodeConnectorUpdated notification) {
53             LOG.debug("NodeConnectorUpdated Notification");
54             LOG.debug("NodeConnectorRef {}", notification.getNodeConnectorRef());
55             nodeConnectorUpdated.add(notification);
56         }
57
58         @Override
59         public void onNodeRemoved(NodeRemoved notification) {
60             LOG.debug("NodeRemoved Notification");
61             LOG.debug("NodeRef {}", notification.getNodeRef());
62             nodeRemoved.add(notification);
63         }
64
65         @Override
66         public void onNodeUpdated(NodeUpdated notification) {
67             LOG.debug("NodeUpdated Notification");
68             LOG.debug("NodeRef {}", notification.getNodeRef());
69             nodeUpdated.add(notification);
70         }
71     }
72 }