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