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);
97 flow.setPriority((short)3500);
98 flow.setIdleTimeout((short)1000);
99 flow.setHardTimeout((short)2000);
102 FlowOnNode fn1 = new FlowOnNode(flow);
103 fn1.setByteCount(100);
104 fn1.setDurationNanoseconds(400);
105 fn1.setDurationSeconds(40);
106 fn1.setTableId((byte) 0x1);
107 fn1.setPacketCount(200);
109 ArrayList<FlowOnNode> list = new ArrayList<FlowOnNode>();
115 public NodeDescription readDescription(Node node, boolean cached) {
116 NodeDescription desc = new NodeDescription();
117 desc.setDescription("This is a sample node description");
118 desc.setHardware("stub hardware");
119 desc.setSoftware("stub software");
120 desc.setSerialNumber("123");
121 desc.setManufacturer("opendaylight");
126 public NodeConnectorStatistics readNodeConnector(NodeConnector connector,
128 NodeConnectorStatistics stats = new NodeConnectorStatistics();
129 stats.setNodeConnector(connector);
130 stats.setCollisionCount(4);
131 stats.setReceiveByteCount(1000);
132 stats.setReceiveCRCErrorCount(1);
133 stats.setReceiveDropCount(2);
134 stats.setReceiveErrorCount(3);
135 stats.setReceiveFrameErrorCount(5);
136 stats.setReceiveOverRunErrorCount(6);
137 stats.setReceivePacketCount(250);
138 stats.setTransmitByteCount(5000);
139 stats.setTransmitDropCount(50);
140 stats.setTransmitErrorCount(10);
141 stats.setTransmitPacketCount(500);
147 public List<NodeConnectorStatistics> readAllNodeConnector(Node node,
149 NodeConnectorStatistics stats = new NodeConnectorStatistics();
151 NodeConnector nc = new NodeConnector("STUB", 0xCAFE, node);
152 stats.setNodeConnector(nc);
153 }catch(ConstructionException e){
154 //couldn't create nodeconnector.
156 stats.setCollisionCount(4);
157 stats.setReceiveByteCount(1000);
158 stats.setReceiveCRCErrorCount(1);
159 stats.setReceiveDropCount(2);
160 stats.setReceiveErrorCount(3);
161 stats.setReceiveFrameErrorCount(5);
162 stats.setReceiveOverRunErrorCount(6);
163 stats.setReceivePacketCount(250);
164 stats.setTransmitByteCount(5000);
165 stats.setTransmitDropCount(50);
166 stats.setTransmitErrorCount(10);
167 stats.setTransmitPacketCount(500);
169 List<NodeConnectorStatistics> result = new ArrayList<NodeConnectorStatistics>();
175 public long getTransmitRate(NodeConnector connector) {