1 package org.opendaylight.controller.protocol_plugins.stub.internal;
3 import java.net.InetAddress;
4 import java.net.UnknownHostException;
5 import java.util.ArrayList;
6 import java.util.Dictionary;
9 import org.apache.felix.dm.Component;
10 //import org.opendaylight.controller.protocol_plugin_stubs.IPluginReadServiceFilter;
11 import org.slf4j.Logger;
12 import org.slf4j.LoggerFactory;
14 import org.opendaylight.controller.sal.action.Action;
15 import org.opendaylight.controller.sal.action.Drop;
16 import org.opendaylight.controller.sal.core.Node;
17 import org.opendaylight.controller.sal.core.NodeConnector;
18 import org.opendaylight.controller.sal.flowprogrammer.Flow;
19 import org.opendaylight.controller.sal.match.Match;
20 import org.opendaylight.controller.sal.match.MatchType;
21 import org.opendaylight.controller.sal.reader.FlowOnNode;
22 import org.opendaylight.controller.sal.reader.IPluginInReadService;
23 import org.opendaylight.controller.sal.reader.NodeConnectorStatistics;
24 import org.opendaylight.controller.sal.reader.NodeDescription;
27 * Stub Implementation for IPluginInReadService used by SAL
31 public class ReadService implements IPluginInReadService {
32 private static final Logger logger = LoggerFactory
33 .getLogger(ReadService.class);
36 * Function called by the dependency manager when all the required
37 * dependencies are satisfied
44 * Function called by the dependency manager when at least one dependency
45 * become unsatisfied or when the component is shutting down because for
46 * example bundle is being stopped.
53 * Function called by dependency manager after "init ()" is called and after
54 * the services provided by the class are registered in the service registry
61 * Function called by the dependency manager before the services exported by
62 * the component are unregistered, this will be followed by a "destroy ()"
70 public FlowOnNode readFlow(Node node, Flow flow, boolean cached) {
71 FlowOnNode fn1 = new FlowOnNode(flow);
72 fn1.setByteCount(100);
73 fn1.setDurationNanoseconds(400);
74 fn1.setDurationSeconds(40);
75 fn1.setTableId((byte) 0x1);
76 fn1.setPacketCount(200);
81 public List<FlowOnNode> readAllFlow(Node node, boolean cached) {
82 Flow flow = new Flow();
84 Match match = new Match();
86 match.setField(MatchType.NW_DST, InetAddress.getByName("1.1.1.1"));
87 } catch (UnknownHostException e) {
91 Action action = new Drop();
93 List<Action> actions = new ArrayList<Action>();
95 flow.setActions(actions);
97 FlowOnNode fn1 = new FlowOnNode(flow);
98 fn1.setByteCount(100);
99 fn1.setDurationNanoseconds(400);
100 fn1.setDurationSeconds(40);
101 fn1.setTableId((byte) 0x1);
102 fn1.setPacketCount(200);
104 ArrayList<FlowOnNode> list = new ArrayList<FlowOnNode>();
110 public NodeDescription readDescription(Node node, boolean cached) {
111 NodeDescription desc = new NodeDescription();
112 desc.setDescription("This is a sample node description");
113 desc.setHardware("stub hardware");
114 desc.setSoftware("stub software");
115 desc.setSerialNumber("123");
116 desc.setManufacturer("opendaylight");
121 public NodeConnectorStatistics readNodeConnector(NodeConnector connector,
123 NodeConnectorStatistics stats = new NodeConnectorStatistics();
124 stats.setNodeConnector(connector);
125 stats.setCollisionCount(4);
126 stats.setReceiveByteCount(1000);
127 stats.setReceiveCRCErrorCount(1);
128 stats.setReceiveDropCount(2);
129 stats.setReceiveErrorCount(3);
130 stats.setReceiveFrameErrorCount(5);
131 stats.setReceiveOverRunErrorCount(6);
132 stats.setReceivePacketCount(250);
133 stats.setTransmitByteCount(5000);
134 stats.setTransmitDropCount(50);
135 stats.setTransmitErrorCount(10);
136 stats.setTransmitPacketCount(500);
142 public List<NodeConnectorStatistics> readAllNodeConnector(Node node,
144 NodeConnector nc = NodeConnector.fromStringNoNode("123", node);
145 NodeConnectorStatistics stats = new NodeConnectorStatistics();
146 stats.setNodeConnector(nc);
147 stats.setCollisionCount(4);
148 stats.setReceiveByteCount(1000);
149 stats.setReceiveCRCErrorCount(1);
150 stats.setReceiveDropCount(2);
151 stats.setReceiveErrorCount(3);
152 stats.setReceiveFrameErrorCount(5);
153 stats.setReceiveOverRunErrorCount(6);
154 stats.setReceivePacketCount(250);
155 stats.setTransmitByteCount(5000);
156 stats.setTransmitDropCount(50);
157 stats.setTransmitErrorCount(10);
158 stats.setTransmitPacketCount(500);
160 List<NodeConnectorStatistics> result = new ArrayList<NodeConnectorStatistics>();
166 public long getTransmitRate(NodeConnector connector) {