2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.controller.protocol_plugin.openflow.internal;
11 import org.apache.felix.dm.Component;
12 import org.opendaylight.controller.protocol_plugin.openflow.IFlowProgrammerNotifier;
13 import org.opendaylight.controller.sal.connection.IPluginOutConnectionService;
14 import org.opendaylight.controller.sal.core.Node;
15 import org.opendaylight.controller.sal.flowprogrammer.Flow;
16 import org.opendaylight.controller.sal.flowprogrammer.IPluginOutFlowProgrammerService;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
21 * Flow Programmer Notifier class for relaying asynchronous messages received
22 * from the network node to the listeners on the proper container
24 public class FlowProgrammerNotifier implements IFlowProgrammerNotifier {
25 protected static final Logger logger = LoggerFactory
26 .getLogger(FlowProgrammerNotifier.class);
27 private IPluginOutFlowProgrammerService salNotifier;
28 private IPluginOutConnectionService connectionOutService;
30 public FlowProgrammerNotifier() {
34 void init(Component c) {
35 logger.debug("INIT called!");
39 * Function called by the dependency manager when at least one dependency
40 * become unsatisfied or when the component is shutting down because for
41 * example bundle is being stopped.
45 logger.debug("DESTROY called!");
49 * Function called by dependency manager after "init ()" is called and after
50 * the services provided by the class are registered in the service registry
54 logger.debug("START called!");
58 * Function called by the dependency manager before the services exported by
59 * the component are unregistered, this will be followed by a "destroy ()"
64 logger.debug("STOP called!");
67 public void setPluginOutFlowProgrammerService(
68 IPluginOutFlowProgrammerService s) {
72 public void unsetPluginOutFlowProgrammerService(
73 IPluginOutFlowProgrammerService s) {
74 if (this.salNotifier == s) {
75 this.salNotifier = null;
80 public void flowRemoved(Node node, Flow flow) {
81 if (!connectionOutService.isLocal(node)) {
82 logger.debug("flow removed will not be notified in a non-master controller for node "+node);
86 if (salNotifier != null) {
87 salNotifier.flowRemoved(node, flow);
89 logger.warn("Unable to relay switch message to upper layer");
94 public void flowErrorReported(Node node, long rid, Object err) {
95 if (!connectionOutService.isLocal(node)) {
96 logger.debug("flow error will not be notified in a non-master controller for node "+node);
100 if (salNotifier != null) {
101 salNotifier.flowErrorReported(node, rid, err);
103 logger.warn("Unable to relay switch error message to upper layer");
107 void setIPluginOutConnectionService(IPluginOutConnectionService s) {
108 connectionOutService = s;
111 void unsetIPluginOutConnectionService(IPluginOutConnectionService s) {
112 if (connectionOutService == s) {
113 connectionOutService = null;