3 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
5 * This program and the accompanying materials are made available under the
6 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 * and is available at http://www.eclipse.org/legal/epl-v10.html
10 package org.opendaylight.controller.protocol_plugin.openflow.internal;
12 import java.util.Dictionary;
13 import java.util.List;
15 import org.apache.felix.dm.Component;
16 import org.opendaylight.controller.protocol_plugin.openflow.IPluginReadServiceFilter;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
20 import org.opendaylight.controller.sal.core.Node;
21 import org.opendaylight.controller.sal.core.Node.NodeIDType;
22 import org.opendaylight.controller.sal.core.NodeConnector;
23 import org.opendaylight.controller.sal.core.NodeTable;
24 import org.opendaylight.controller.sal.flowprogrammer.Flow;
25 import org.opendaylight.controller.sal.reader.FlowOnNode;
26 import org.opendaylight.controller.sal.reader.IPluginInReadService;
27 import org.opendaylight.controller.sal.reader.NodeConnectorStatistics;
28 import org.opendaylight.controller.sal.reader.NodeDescription;
29 import org.opendaylight.controller.sal.reader.NodeTableStatistics;
32 * Container Instance of IPluginInReadService implementation class
37 public class ReadService implements IPluginInReadService {
38 private static final Logger logger = LoggerFactory
39 .getLogger(ReadService.class);
40 private IPluginReadServiceFilter filter;
41 private String containerName;
44 * Function called by the dependency manager when all the required
45 * dependencies are satisfied
48 @SuppressWarnings("unchecked")
49 void init(Component c) {
50 Dictionary<Object, Object> props = c.getServiceProperties();
51 containerName = (props != null) ? (String) props.get("containerName")
56 * Function called by the dependency manager when at least one
57 * dependency become unsatisfied or when the component is shutting
58 * down because for example bundle is being stopped.
65 * Function called by dependency manager after "init ()" is called
66 * and after the services provided by the class are registered in
67 * the service registry
74 * Function called by the dependency manager before the services
75 * exported by the component are unregistered, this will be
76 * followed by a "destroy ()" calls
82 public void setService(IPluginReadServiceFilter filter) {
86 public void unsetService(IPluginReadServiceFilter filter) {
91 public FlowOnNode readFlow(Node node, Flow flow, boolean cached) {
92 if (!node.getType().equals(NodeIDType.OPENFLOW)) {
93 logger.error("Invalid node type");
97 return filter.readFlow(containerName, node, flow, cached);
101 public List<FlowOnNode> readAllFlow(Node node, boolean cached) {
102 if (!node.getType().equals(NodeIDType.OPENFLOW)) {
103 logger.error("Invalid node type");
107 return filter.readAllFlow(containerName, node, cached);
111 public NodeDescription readDescription(Node node, boolean cached) {
112 if (!node.getType().equals(NodeIDType.OPENFLOW)) {
113 logger.error("Invalid node type");
117 return filter.readDescription(node, cached);
121 public NodeConnectorStatistics readNodeConnector(NodeConnector connector,
123 if (!connector.getNode().getType()
124 .equals(NodeIDType.OPENFLOW)) {
125 logger.error("Invalid node type");
128 return filter.readNodeConnector(containerName, connector, cached);
132 public List<NodeConnectorStatistics> readAllNodeConnector(Node node,
134 if (!node.getType().equals(NodeIDType.OPENFLOW)) {
135 logger.error("Invalid node type");
139 return filter.readAllNodeConnector(containerName, node, cached);
143 public long getTransmitRate(NodeConnector connector) {
144 if (!connector.getNode().getType()
145 .equals(NodeIDType.OPENFLOW)) {
146 logger.error("Invalid node type");
149 return filter.getTransmitRate(containerName, connector);
153 public NodeTableStatistics readNodeTable(NodeTable table, boolean cached) {
154 if (!table.getNode().getType()
155 .equals(NodeIDType.OPENFLOW)) {
156 logger.error("Invalid node type");
159 return filter.readNodeTable(containerName, table, cached);
163 public List<NodeTableStatistics> readAllNodeTable(Node node, boolean cached) {
164 if (!node.getType().equals(NodeIDType.OPENFLOW)) {
165 logger.error("Invalid node type");
169 return filter.readAllNodeTable(containerName, node, cached);