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.flowprogrammer.Flow;
24 import org.opendaylight.controller.sal.reader.FlowOnNode;
25 import org.opendaylight.controller.sal.reader.IPluginInReadService;
26 import org.opendaylight.controller.sal.reader.NodeConnectorStatistics;
27 import org.opendaylight.controller.sal.reader.NodeDescription;
30 * Container Instance of IPluginInReadService implementation class
35 public class ReadService implements IPluginInReadService {
36 private static final Logger logger = LoggerFactory
37 .getLogger(ReadService.class);
38 private IPluginReadServiceFilter filter;
39 private String containerName;
42 * Function called by the dependency manager when all the required
43 * dependencies are satisfied
46 @SuppressWarnings("unchecked")
47 void init(Component c) {
48 Dictionary<Object, Object> props = c.getServiceProperties();
49 containerName = (props != null) ? (String) props.get("containerName")
54 * Function called by the dependency manager when at least one
55 * dependency become unsatisfied or when the component is shutting
56 * down because for example bundle is being stopped.
63 * Function called by dependency manager after "init ()" is called
64 * and after the services provided by the class are registered in
65 * the service registry
72 * Function called by the dependency manager before the services
73 * exported by the component are unregistered, this will be
74 * followed by a "destroy ()" calls
80 public void setService(IPluginReadServiceFilter filter) {
84 public void unsetService(IPluginReadServiceFilter filter) {
89 public FlowOnNode readFlow(Node node, Flow flow, boolean cached) {
90 if (!node.getType().equals(NodeIDType.OPENFLOW)) {
91 logger.error("Invalid node type");
95 return filter.readFlow(containerName, node, flow, cached);
99 public List<FlowOnNode> readAllFlow(Node node, boolean cached) {
100 if (!node.getType().equals(NodeIDType.OPENFLOW)) {
101 logger.error("Invalid node type");
105 return filter.readAllFlow(containerName, node, cached);
109 public NodeDescription readDescription(Node node, boolean cached) {
110 if (!node.getType().equals(NodeIDType.OPENFLOW)) {
111 logger.error("Invalid node type");
115 return filter.readDescription(node, cached);
119 public NodeConnectorStatistics readNodeConnector(NodeConnector connector,
121 if (!connector.getNode().getType()
122 .equals(NodeIDType.OPENFLOW)) {
123 logger.error("Invalid node type");
126 return filter.readNodeConnector(containerName, connector, cached);
130 public List<NodeConnectorStatistics> readAllNodeConnector(Node node,
132 if (!node.getType().equals(NodeIDType.OPENFLOW)) {
133 logger.error("Invalid node type");
137 return filter.readAllNodeConnector(containerName, node, cached);
141 public long getTransmitRate(NodeConnector connector) {
142 if (!connector.getNode().getType()
143 .equals(NodeIDType.OPENFLOW)) {
144 logger.error("Invalid node type");
147 return filter.getTransmitRate(containerName, connector);