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.ConstructionException;
17 import org.opendaylight.controller.sal.core.Node;
18 import org.opendaylight.controller.sal.core.NodeConnector;
19 import org.opendaylight.controller.sal.flowprogrammer.Flow;
20 import org.opendaylight.controller.sal.match.Match;
21 import org.opendaylight.controller.sal.match.MatchType;
22 import org.opendaylight.controller.sal.reader.FlowOnNode;
23 import org.opendaylight.controller.sal.reader.IPluginInReadService;
24 import org.opendaylight.controller.sal.reader.NodeConnectorStatistics;
25 import org.opendaylight.controller.sal.reader.NodeDescription;
28 * Stub Implementation for IPluginInReadService used by SAL
32 public class ReadService implements IPluginInReadService {
33 private static final Logger logger = LoggerFactory
34 .getLogger(ReadService.class);
37 * Function called by the dependency manager when all the required
38 * dependencies are satisfied
45 * Function called by the dependency manager when at least one dependency
46 * become unsatisfied or when the component is shutting down because for
47 * example bundle is being stopped.
54 * Function called by dependency manager after "init ()" is called and after
55 * the services provided by the class are registered in the service registry
62 * Function called by the dependency manager before the services exported by
63 * the component are unregistered, this will be followed by a "destroy ()"
71 public FlowOnNode readFlow(Node node, Flow flow, boolean cached) {
72 FlowOnNode fn1 = new FlowOnNode(flow);
73 fn1.setByteCount(100);
74 fn1.setDurationNanoseconds(400);
75 fn1.setDurationSeconds(40);
76 fn1.setTableId((byte) 0x1);
77 fn1.setPacketCount(200);
82 public List<FlowOnNode> readAllFlow(Node node, boolean cached) {
83 Flow flow = new Flow();
85 Match match = new Match();
87 match.setField(MatchType.NW_DST, InetAddress.getByName("1.1.1.1"));
88 } catch (UnknownHostException e) {
92 Action action = new Drop();
94 List<Action> actions = new ArrayList<Action>();
96 flow.setActions(actions);
98 FlowOnNode fn1 = new FlowOnNode(flow);
99 fn1.setByteCount(100);
100 fn1.setDurationNanoseconds(400);
101 fn1.setDurationSeconds(40);
102 fn1.setTableId((byte) 0x1);
103 fn1.setPacketCount(200);
105 ArrayList<FlowOnNode> list = new ArrayList<FlowOnNode>();
111 public NodeDescription readDescription(Node node, boolean cached) {
112 NodeDescription desc = new NodeDescription();
113 desc.setDescription("This is a sample node description");
114 desc.setHardware("stub hardware");
115 desc.setSoftware("stub software");
116 desc.setSerialNumber("123");
117 desc.setManufacturer("opendaylight");
122 public NodeConnectorStatistics readNodeConnector(NodeConnector connector,
124 NodeConnectorStatistics stats = new NodeConnectorStatistics();
125 stats.setNodeConnector(connector);
126 stats.setCollisionCount(4);
127 stats.setReceiveByteCount(1000);
128 stats.setReceiveCRCErrorCount(1);
129 stats.setReceiveDropCount(2);
130 stats.setReceiveErrorCount(3);
131 stats.setReceiveFrameErrorCount(5);
132 stats.setReceiveOverRunErrorCount(6);
133 stats.setReceivePacketCount(250);
134 stats.setTransmitByteCount(5000);
135 stats.setTransmitDropCount(50);
136 stats.setTransmitErrorCount(10);
137 stats.setTransmitPacketCount(500);
143 public List<NodeConnectorStatistics> readAllNodeConnector(Node node,
145 NodeConnectorStatistics stats = new NodeConnectorStatistics();
147 NodeConnector nc = new NodeConnector("STUB", 0xCAFE, node);
148 stats.setNodeConnector(nc);
149 }catch(ConstructionException e){
150 //couldn't create nodeconnector.
152 stats.setCollisionCount(4);
153 stats.setReceiveByteCount(1000);
154 stats.setReceiveCRCErrorCount(1);
155 stats.setReceiveDropCount(2);
156 stats.setReceiveErrorCount(3);
157 stats.setReceiveFrameErrorCount(5);
158 stats.setReceiveOverRunErrorCount(6);
159 stats.setReceivePacketCount(250);
160 stats.setTransmitByteCount(5000);
161 stats.setTransmitDropCount(50);
162 stats.setTransmitErrorCount(10);
163 stats.setTransmitPacketCount(500);
165 List<NodeConnectorStatistics> result = new ArrayList<NodeConnectorStatistics>();
171 public long getTransmitRate(NodeConnector connector) {