1 package org.opendaylight.controller.protocol_plugins.stub.internal;
3 import java.net.InetAddress;
4 import java.net.UnknownHostException;
5 import java.util.ArrayList;
7 import java.util.Dictionary;
8 import java.util.HashMap;
9 import java.util.HashSet;
10 import java.util.List;
13 import java.util.concurrent.ConcurrentHashMap;
14 import java.util.concurrent.ConcurrentMap;
16 import org.apache.felix.dm.Component;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
20 import org.opendaylight.controller.sal.core.Actions;
21 import org.opendaylight.controller.sal.core.Bandwidth;
22 import org.opendaylight.controller.sal.core.Buffers;
23 import org.opendaylight.controller.sal.core.Capabilities;
24 import org.opendaylight.controller.sal.core.Capabilities.CapabilitiesType;
25 import org.opendaylight.controller.sal.core.ConstructionException;
26 import org.opendaylight.controller.sal.core.Node;
27 import org.opendaylight.controller.sal.core.NodeConnector;
28 import org.opendaylight.controller.sal.core.Property;
29 import org.opendaylight.controller.sal.core.State;
30 import org.opendaylight.controller.sal.core.Tables;
31 import org.opendaylight.controller.sal.core.TimeStamp;
32 import org.opendaylight.controller.sal.inventory.IPluginInInventoryService;
33 import org.opendaylight.controller.sal.utils.NodeCreator;
34 import org.opendaylight.controller.sal.utils.NodeConnectorCreator;
37 * Stub Implementation for IPluginInReadService used by SAL
41 public class InventoryService implements IPluginInInventoryService {
42 private static final Logger logger = LoggerFactory
43 .getLogger(InventoryService.class);
45 private ConcurrentMap<Node, Map<String, Property>> nodeProps; // properties
51 private ConcurrentMap<NodeConnector, Map<String, Property>> nodeConnectorProps; // properties
60 * Function called by the dependency manager when all the required
61 * dependencies are satisfied
65 nodeProps = new ConcurrentHashMap<Node, Map<String, Property>>();
66 nodeConnectorProps = new ConcurrentHashMap<NodeConnector, Map<String, Property>>();
67 Node.NodeIDType.registerIDType("STUB", Integer.class);
68 NodeConnector.NodeConnectorIDType.registerIDType("STUB", Integer.class,
72 setupNodeConnectorProps();
75 private void setupNodeConnectorProps() {
76 Map<String, Property> ncPropMap = new HashMap<String, Property>();
77 Capabilities cap = new Capabilities(
78 CapabilitiesType.FLOW_STATS_CAPABILITY.getValue());
79 ncPropMap.put(Capabilities.CapabilitiesPropName, cap);
80 Bandwidth bw = new Bandwidth(Bandwidth.BW1Gbps);
81 ncPropMap.put(Bandwidth.BandwidthPropName, bw);
82 State st = new State(State.EDGE_UP);
83 ncPropMap.put(State.StatePropName, st);
85 // setup property map for all node connectors
89 node = new Node("STUB", new Integer(0xCAFE));
90 nc = new NodeConnector("STUB", 0xCAFE, node);
91 } catch (ConstructionException e) {
95 nodeConnectorProps.put(nc, ncPropMap);
98 node = new Node("STUB", 3366);
99 nc = new NodeConnector("STUB", 12, node);
100 } catch (ConstructionException e) {
104 nodeConnectorProps.put(nc, ncPropMap);
107 node = new Node("STUB", 4477);
108 nc = new NodeConnector("STUB", 34, node);
109 } catch (ConstructionException e) {
113 nodeConnectorProps.put(nc, ncPropMap);
117 private void setupNodeProps() {
118 Map<String, Property> propMap = new HashMap<String, Property>();
120 Tables t = new Tables((byte) 1);
121 propMap.put(Tables.TablesPropName, t);
122 Capabilities c = new Capabilities((int) 3);
123 propMap.put(Capabilities.CapabilitiesPropName, c);
124 Actions a = new Actions((int) 2);
125 propMap.put(Actions.ActionsPropName, a);
126 Buffers b = new Buffers((int) 1);
127 propMap.put(Buffers.BuffersPropName, b);
128 Long connectedSinceTime = 100000L;
129 TimeStamp timeStamp = new TimeStamp(connectedSinceTime,
131 propMap.put(TimeStamp.TimeStampPropName, timeStamp);
133 // setup property map for all nodes
136 node = new Node("STUB", new Integer(0xCAFE));
137 } catch (ConstructionException e) {
141 nodeProps.put(node, propMap);
144 node = new Node("STUB", 3366);
145 } catch (ConstructionException e) {
148 nodeProps.put(node, propMap);
151 node = new Node("STUB", 4477);
152 } catch (ConstructionException e) {
155 nodeProps.put(node, propMap);
160 * Function called by the dependency manager when at least one dependency
161 * become unsatisfied or when the component is shutting down because for
162 * example bundle is being stopped.
169 * Function called by dependency manager after "init ()" is called and after
170 * the services provided by the class are registered in the service registry
177 * Function called by the dependency manager before the services exported by
178 * the component are unregistered, this will be followed by a "destroy ()"
186 * Retrieve nodes from openflow
189 public ConcurrentMap<Node, Map<String, Property>> getNodeProps() {
194 * Retrieve nodeConnectors from openflow
197 public ConcurrentMap<NodeConnector, Map<String, Property>> getNodeConnectorProps(
199 return nodeConnectorProps;