X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fprotocol_plugins%2Fstub%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fprotocol_plugins%2Fstub%2Finternal%2FInventoryService.java;h=22a4343f332ed2e79e7f7ecc979d8535acc4ea26;hb=9c8108faabf300747a2a5529dc7a8ef76e79c2bc;hp=b4d6166d3636efa901aa490a8dd0d23dad0bbe4c;hpb=59cc8f34c24d81a8890a94c11dedd4b21caa0adf;p=controller.git diff --git a/opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/InventoryService.java b/opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/InventoryService.java index b4d6166d36..22a4343f33 100644 --- a/opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/InventoryService.java +++ b/opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/InventoryService.java @@ -42,9 +42,19 @@ public class InventoryService implements IPluginInInventoryService { private static final Logger logger = LoggerFactory .getLogger(InventoryService.class); - private ConcurrentMap> nodeProps; // properties are maintained in global container only - private ConcurrentMap> nodeConnectorProps; // properties are maintained in global container only - + private ConcurrentMap> nodeProps; // properties + // are + // maintained + // in global + // container + // only + private ConcurrentMap> nodeConnectorProps; // properties + // are + // maintained + // in + // global + // container + // only /** * Function called by the dependency manager when all the required @@ -55,7 +65,95 @@ public class InventoryService implements IPluginInInventoryService { nodeProps = new ConcurrentHashMap>(); nodeConnectorProps = new ConcurrentHashMap>(); Node.NodeIDType.registerIDType("STUB", Integer.class); - NodeConnector.NodeConnectorIDType.registerIDType("STUB", Integer.class, "STUB"); + NodeConnector.NodeConnectorIDType.registerIDType("STUB", Integer.class, + "STUB"); + + setupNodeProps(); + setupNodeConnectorProps(); + } + + private void setupNodeConnectorProps() { + Map ncPropMap = new HashMap(); + Capabilities cap = new Capabilities( + CapabilitiesType.FLOW_STATS_CAPABILITY.getValue()); + ncPropMap.put(Capabilities.CapabilitiesPropName, cap); + Bandwidth bw = new Bandwidth(Bandwidth.BW1Gbps); + ncPropMap.put(Bandwidth.BandwidthPropName, bw); + State st = new State(State.EDGE_UP); + ncPropMap.put(State.StatePropName, st); + + // setup property map for all node connectors + NodeConnector nc; + Node node; + try { + node = new Node("STUB", new Integer(0xCAFE)); + nc = new NodeConnector("STUB", 0xCAFE, node); + } catch (ConstructionException e) { + nc = null; + node = null; + } + nodeConnectorProps.put(nc, ncPropMap); + + try { + node = new Node("STUB", 3366); + nc = new NodeConnector("STUB", 12, node); + } catch (ConstructionException e) { + nc = null; + node = null; + } + nodeConnectorProps.put(nc, ncPropMap); + + try { + node = new Node("STUB", 4477); + nc = new NodeConnector("STUB", 34, node); + } catch (ConstructionException e) { + nc = null; + node = null; + } + nodeConnectorProps.put(nc, ncPropMap); + + } + + private void setupNodeProps() { + Map propMap = new HashMap(); + + Tables t = new Tables((byte) 1); + propMap.put(Tables.TablesPropName, t); + Capabilities c = new Capabilities((int) 3); + propMap.put(Capabilities.CapabilitiesPropName, c); + Actions a = new Actions((int) 2); + propMap.put(Actions.ActionsPropName, a); + Buffers b = new Buffers((int) 1); + propMap.put(Buffers.BuffersPropName, b); + Long connectedSinceTime = 100000L; + TimeStamp timeStamp = new TimeStamp(connectedSinceTime, + "connectedSince"); + propMap.put(TimeStamp.TimeStampPropName, timeStamp); + + // setup property map for all nodes + Node node; + try { + node = new Node("STUB", new Integer(0xCAFE)); + } catch (ConstructionException e) { + node = null; + } + + nodeProps.put(node, propMap); + + try { + node = new Node("STUB", 3366); + } catch (ConstructionException e) { + node = null; + } + nodeProps.put(node, propMap); + + try { + node = new Node("STUB", 4477); + } catch (ConstructionException e) { + node = null; + } + nodeProps.put(node, propMap); + } /** @@ -89,47 +187,6 @@ public class InventoryService implements IPluginInInventoryService { */ @Override public ConcurrentMap> getNodeProps() { - - // setup nodeProps - Map propMap = new HashMap(); - - Tables t = new Tables((byte)1); - propMap.put(Tables.TablesPropName, t); - Capabilities c = new Capabilities((int)3); - propMap.put(Capabilities.CapabilitiesPropName, c); - Actions a = new Actions((int)2); - propMap.put(Actions.ActionsPropName, a); - Buffers b = new Buffers((int)1); - propMap.put(Buffers.BuffersPropName, b); - Long connectedSinceTime = 100000L; - TimeStamp timeStamp = new TimeStamp(connectedSinceTime, - "connectedSince"); - propMap.put(TimeStamp.TimeStampPropName, timeStamp); - - // setup property map for all nodes - Node node; - try{ - node = new Node("STUB", new Integer(0xCAFE)); - }catch(ConstructionException e){ - node = null; - } - - nodeProps.put(node, propMap); - - try{ - node = new Node("STUB", 3366); - }catch(ConstructionException e){ - node = null; - } - nodeProps.put(node, propMap); - - try{ - node = new Node("STUB", 4477); - }catch(ConstructionException e){ - node = null; - } - nodeProps.put(node, propMap); - return nodeProps; } @@ -139,49 +196,7 @@ public class InventoryService implements IPluginInInventoryService { @Override public ConcurrentMap> getNodeConnectorProps( Boolean refresh) { - - // setup nodeConnectorProps - Map ncPropMap = new HashMap(); - Capabilities cap = new Capabilities - (CapabilitiesType.FLOW_STATS_CAPABILITY.getValue()); - ncPropMap.put(Capabilities.CapabilitiesPropName, cap); - Bandwidth bw = new Bandwidth (Bandwidth.BW1Gbps); - ncPropMap.put(Bandwidth.BandwidthPropName, bw); - State st = new State (State.EDGE_UP); - ncPropMap.put(State.StatePropName, st); - - // setup property map for all node connectors - NodeConnector nc; - Node node; - try{ - node = new Node("STUB", new Integer(0xCAFE)); - nc = new NodeConnector("STUB", 0xCAFE, node); - }catch(ConstructionException e){ - nc = null; - node = null; - } - nodeConnectorProps.put(nc, ncPropMap); - - try{ - node = new Node("STUB", 3366); - nc = new NodeConnector("STUB", 12, node); - } catch(ConstructionException e){ - nc = null; - node = null; - } - nodeConnectorProps.put(nc, ncPropMap); - - try{ - node = new Node("STUB", 4477); - nc = new NodeConnector("STUB", 34, node); - }catch(ConstructionException e){ - nc = null; - node = null; - } - nodeConnectorProps.put(nc, ncPropMap); - - return nodeConnectorProps; + return nodeConnectorProps; } - }