Merge "BUG-4117: add support for flow old Notif"
[openflowplugin.git] / test-provider / src / main / java / org / opendaylight / openflowplugin / test / OpenflowpluginTestTopologyNotification.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
13 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
14 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
15 import org.opendaylight.controller.sal.binding.api.NotificationService;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.FlowTopologyDiscoveryListener;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkDiscovered;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkOverutilized;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkRemoved;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkUtilizationNormal;
21 import org.opendaylight.yangtools.concepts.Registration;
22 import org.osgi.framework.BundleContext;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
25
26 public class OpenflowpluginTestTopologyNotification {
27
28     private static final Logger LOG = LoggerFactory.getLogger(OpenflowpluginTestTopologyNotification.class);
29
30     private DataBroker dataBroker;
31     private ProviderContext pc;
32     private final BundleContext ctx;
33     private final TopologyEventListener topologyEventListener = new TopologyEventListener();
34     private static NotificationService notificationService;
35     private Registration listenerReg;
36
37     public OpenflowpluginTestTopologyNotification(BundleContext ctx) {
38         this.ctx = ctx;
39     }
40
41     public void onSessionInitiated(ProviderContext session) {
42         pc = session;
43         notificationService = session.getSALService(NotificationService.class);
44         // For switch events
45         listenerReg = notificationService.registerNotificationListener(topologyEventListener);
46         dataBroker = session.getSALService(DataBroker.class);
47     }
48
49     final class TopologyEventListener implements FlowTopologyDiscoveryListener {
50
51         List<LinkDiscovered> linkdiscovered = new ArrayList<>();
52         List<LinkOverutilized> linkoverutilized = new ArrayList<>();
53         List<LinkRemoved> linkremoved = new ArrayList<>();
54         List<LinkUtilizationNormal> linkutilizationnormal = new ArrayList<>();
55
56         @Override
57         public void onLinkDiscovered(LinkDiscovered notification) {
58             LOG.debug("-------------------------------------------");
59             LOG.debug("LinkDiscovered notification ........");
60             LOG.debug("-------------------------------------------");
61         }
62
63         @Override
64         public void onLinkOverutilized(LinkOverutilized notification) {
65             LOG.debug("-------------------------------------------");
66             LOG.debug("LinkOverutilized notification ........");
67             LOG.debug("-------------------------------------------");
68         }
69
70         @Override
71         public void onLinkRemoved(LinkRemoved notification) {
72             LOG.debug("-------------------------------------------");
73             LOG.debug("LinkRemoved notification   ........");
74             LOG.debug("-------------------------------------------");
75         }
76
77         @Override
78         public void onLinkUtilizationNormal(LinkUtilizationNormal notification) {
79             LOG.debug("-------------------------------------------");
80             LOG.debug("LinkUtilizationNormal notification ........");
81             LOG.debug("-------------------------------------------");
82         }
83
84     }
85 }