/** * Copy constructor for NodeTable * * @param src NodeTable to copy from * */ public NodeTable(NodeTable src) throws ConstructionException { if (src != null) { this.nodeTableType = src.getType(); // Here we can reference the object because that is // supposed to be an immutable identifier as well like a // UUID/Integer and so on, hence no need to create a copy // of it this.nodeTableID = src.getID(); this.nodeTableNode = new Node(src.getNode()); } else { throw new ConstructionException("Null incoming object to copy from"); } }
public static NodeTable createOFNodeTable(byte tableId, Node node) { try { return new NodeTable(NodeTableIDType.OPENFLOW, tableId, node); } catch (ConstructionException e1) { logger.error("",e1); return null; } }
/** * Private setter for nodeConnectorType to be called by JAXB not by anyone * else, NodeConnector is immutable * * @param type the nodeTableType to set */ @SuppressWarnings("unused") private void setType(String type) { this.nodeTableType = type; if (this.nodeTableIDString != null) { this.fillmeFromString(type, this.nodeTableIDString); } }
@Override public NodeTableStatistics readNodeTable(String containerName, NodeTable table, boolean cached) { if (!containerOwnsNodeTable(containerName, table)) { return null; } Node node = table.getNode(); long sid = (Long) node.getID(); Byte tableId = (Byte) table.getID(); List<OFStatistics> ofList = (cached == true) ? statsMgr.getOFTableStatistics(sid, tableId) : statsMgr.queryStatistics(sid, OFStatisticsType.TABLE, tableId); List<NodeTableStatistics> ntStatistics = new TableStatisticsConverter(sid, ofList).getNodeTableStatsList(); return (ntStatistics.isEmpty()) ? new NodeTableStatistics() : ntStatistics.get(0); }
@Override public NodeTableStatistics readNodeTable(NodeTable table, boolean cached) { if (!table.getNode().getType() .equals(NodeIDType.OPENFLOW)) { logger.error("Invalid node type"); return null; } if (!connectionOutService.isLocal(table.getNode())) { logger.debug("This Controller is not the master for connector : "+table); return null; } return filter.readNodeTable(containerName, table, cached); }
public static byte toOFTable(NodeTable salTable) { log.trace("SAL Table: {}", salTable); return (Byte) salTable.getID(); } }
@Override public String toString() { return this.getNodeTableIdAsString() + "@" + this.nodeTableNode; }
return false; } else if (!nodeTable.equals(other.nodeTable)) { return false;
@Override public NodeTableStatistics readNodeTable(String containerName, NodeTable table, boolean cached) { if (!containerOwnsNodeTable(containerName, table)) { return null; } Node node = table.getNode(); long sid = (Long) node.getID(); Byte tableId = (Byte) table.getID(); List<OFStatistics> ofList = (cached == true) ? statsMgr .getOFTableStatistics(sid, tableId) : statsMgr.queryStatistics( sid, OFStatisticsType.TABLE, tableId); List<NodeTableStatistics> ntStatistics = new TableStatisticsConverter( sid, ofList).getNodeTableStatsList(); return (ntStatistics.isEmpty()) ? new NodeTableStatistics() : ntStatistics.get(0); }
@Override public NodeTableStatistics readNodeTable(NodeTable table, boolean cached) { if (!table.getNode().getType() .equals("SNMP")) { logger.error("Invalid node type"); return null; } return filter.readNodeTable(containerName, table, cached); }
public static byte toOFTable(NodeTable salTable) { log.trace("SAL Table: {}", salTable); return (Byte) salTable.getID(); } }
@Override public NodeTableStatistics readNodeTable(final NodeTable nodeTable, final boolean cached) { NodeTableStatistics nodeStats = null; final Table table = readOperationalTable(nodeTable.getNode(), (short) nodeTable.getID()); if (table != null) { final FlowTableStatisticsData tableStats = table.getAugmentation(FlowTableStatisticsData.class); if (tableStats != null) { try { nodeStats = toNodeTableStatistics(tableStats.getFlowTableStatistics(), table.getId(), nodeTable.getNode()); } catch (ConstructionException e) { LOG.warn("Failed to instantiate table statistics for node {} table {}, ignoring it", nodeTable.getNode(), table.getId(), e); } } } //TODO: Refer TODO (main) getFlowTableStatisticsService().getFlowTablesStatistics( new GetFlowTablesStatisticsInputBuilder().setNode(NodeMapping.toNodeRef(nodeTable.getNode())).build()); return nodeStats; }
@Override public NodeTableStatistics nonCachedReadNodeTable(NodeTable table) { Node node = table.getNode(); if (pluginReader != null && node != null) { ProtocolService<IPluginInReadService> service = this.pluginReader.get(node.getType()); if (service != null) { return service.getService().readNodeTable(table, false); } } logger.warn("Plugin {} unavailable", node.getType()); return null; }
private List<FlowTableAndStatisticsMap> toOdFlowTableStatistics(List<NodeTableStatistics> tableStatsList) { List<FlowTableAndStatisticsMap> flowTableStatsMap = new ArrayList<FlowTableAndStatisticsMap>(); for (NodeTableStatistics nodeTableStatistics : tableStatsList) { FlowTableAndStatisticsMapBuilder flowTableAndStatisticsMapBuilder = new FlowTableAndStatisticsMapBuilder(); flowTableAndStatisticsMapBuilder.setActiveFlows(new Counter32((long) nodeTableStatistics.getActiveCount())); flowTableAndStatisticsMapBuilder.setPacketsLookedUp(toCounter64(nodeTableStatistics.getLookupCount())); flowTableAndStatisticsMapBuilder.setPacketsMatched(toCounter64(nodeTableStatistics.getMatchedCount())); flowTableAndStatisticsMapBuilder.setActiveFlows(new Counter32((long) nodeTableStatistics.getActiveCount())); flowTableAndStatisticsMapBuilder.setTableId(new TableId((short)nodeTableStatistics.getNodeTable().getID())); flowTableStatsMap.add(flowTableAndStatisticsMapBuilder.build()); } return flowTableStatsMap; }
/** * Generic NodeTable creator * The nodeTable type is OPENFLOW only for the time being * * @param portId * @param node * @return */ public static NodeTable createNodeTable(byte tableId, Node node) { try { return new NodeTable(NodeTableIDType.OPENFLOW, tableId, node); } catch (ConstructionException e1) { logger.error("",e1); return null; } }
/** * @param nodeTableIDString the nodeTableIDString to set */ @SuppressWarnings("unused") private void setNodeTableIDString(String IDStr) { this.nodeTableIDString = IDStr; if (this.nodeTableType != null) { this.fillmeFromString(this.nodeTableType, IDStr); } }
@Override public NodeTableStatistics readNodeTable(NodeTable table) { Node node = table.getNode(); if (pluginReader != null && node != null) { ProtocolService<IPluginInReadService> service = this.pluginReader.get(node.getType()); if (service != null) { return service.getService().readNodeTable(table, true); } } logger.warn("Plugin {} unavailable", node.getType()); return null; }
@Override public List<NodeTableStatistics> readAllNodeTable(Node node, boolean cached) { NodeTableStatistics stats = new NodeTableStatistics(); try { NodeTable nt = new NodeTable(NodeTable.NodeTableIDType.OPENFLOW, Byte.valueOf("10"), node); stats.setNodeTable(nt); } catch (ConstructionException e) { // couldn't create nodetable. } stats.setActiveCount(4); stats.setLookupCount(4); stats.setMatchedCount(4); List<NodeTableStatistics> result = new ArrayList<NodeTableStatistics>(); result.add(stats); return result; } }
private static NodeTableStatistics toNodeTableStatistics(final FlowTableStatistics tableStats, final Short tableId, final Node node) throws ConstructionException { final NodeTableStatistics it = new NodeTableStatistics(); it.setActiveCount(tableStats.getActiveFlows().getValue().intValue()); it.setLookupCount(tableStats.getPacketsLookedUp().getValue().longValue()); it.setMatchedCount(tableStats.getPacketsMatched().getValue().longValue()); it.setName(tableId.toString()); it.setNodeTable(new NodeTable(NodeTableIDType.OPENFLOW, tableId.byteValue(), node)); return it; }