/** * Add a MD-SAL flow entry to be removed from the flow table. * * @param flow A MD-SAL flow entry to be removed from the flow table. */ public void addRemoved(Flow flow) { removedIds.add(flow.getId().getValue()); }
private void notifyTaskIfRequired(BigInteger dpId, Flow flow) { FlowInfoKey flowKey = new FlowInfoKey(dpId, flow.getTableId(), flow.getMatch(), flow.getId().getValue()); Runnable notifyTask = flowMap.remove(flowKey); if (notifyTask == null) { return; } executorService.execute(notifyTask); }
/** * Add the given flow information into this instance. * * @param data An {@link IdentifiedData} instance which contains * flow statistics. */ public void add(IdentifiedData<Flow> data) { Flow flow = data.getValue(); FlowCookie cookie = flow.getCookie(); VtnFlowId vtnId = FlowUtils.getVtnFlowId(cookie); if (vtnId == null) { LOG.debug("{}: Unwanted flow cookie: {}", flow.getId().getValue(), cookie); } else { InstanceIdentifier<Flow> path = data.getIdentifier(); SalNode snode = SalNode.create(path.firstKeyOf(Node.class)); if (snode == null) { LOG.debug("{}: Invalid flow path: {}", flow.getId().getValue(), path); } else { Map<SalNode, Flow> flowMap = addedFlows.get(vtnId); if (flowMap == null) { flowMap = new HashMap<>(); addedFlows.put(vtnId, flowMap); } flowMap.put(snode, flow); } } }
/** * {@inheritDoc} */ @Override protected void execute(ReadWriteTransaction tx) { removedFlow = null; // Fetch the target flow entry. LogicalDatastoreType oper = LogicalDatastoreType.OPERATIONAL; Optional<Flow> opt = DataStoreUtils.read(tx, oper, flowPath); if (opt.isPresent()) { Flow flow = opt.get(); if (targetFlow.equalsFlow(flow) && cookieMatcher.match(flow)) { // Delete the target flow entry. tx.delete(oper, flowPath); removedFlow = flow.getId().getValue(); } } }
void removeUnreportedFlows(final ReadWriteTransaction tx) { final InstanceIdentifier<Node> nodeIdent = tableRef.firstIdentifierOf(Node.class); final List<InstanceIdentifier<Flow>> listMissingConfigFlows = notStatReportedConfigFlows(); final Map<InstanceIdentifier<Flow>, Integer> nodeDeleteMap = mapNodesForDelete.get(nodeIdent); final Map<FlowHashIdMapKey, FlowId> listForRemove = getRemovalList(); for (final Entry<FlowHashIdMapKey, FlowId> entryForRemove : listForRemove.entrySet()) { final FlowKey flowKey = new FlowKey(entryForRemove.getValue()); final InstanceIdentifier<Flow> flowRef = tableRef.child(Flow.class, flowKey); if (nodeDeleteMap != null && flowKey.getId().getValue().startsWith(ALIEN_SYSTEM_FLOW_ID)) { final Integer lifeIndex = nodeDeleteMap.get(flowRef); if (lifeIndex != null && lifeIndex > 0) { break; } else { nodeDeleteMap.remove(flowRef); } } else { if (listMissingConfigFlows.remove(flowRef)) { // it is probable that some multipart message was lost break; } } final InstanceIdentifier<FlowHashIdMap> flHashIdent = tableRef.augmentation(FlowHashIdMapping.class).child(FlowHashIdMap.class, entryForRemove.getKey()); tx.delete(LogicalDatastoreType.OPERATIONAL, flowRef); tx.delete(LogicalDatastoreType.OPERATIONAL, flHashIdent); } }
void removeUnreportedFlows(final ReadWriteTransaction tx) { final InstanceIdentifier<Node> nodeIdent = tableRef.firstIdentifierOf(Node.class); final List<InstanceIdentifier<Flow>> listMissingConfigFlows = notStatReportedConfigFlows(); final Map<InstanceIdentifier<Flow>, Integer> nodeDeleteMap = mapNodesForDelete.get(nodeIdent); final Map<FlowHashIdMapKey, FlowId> listForRemove = getRemovalList(); for (final Entry<FlowHashIdMapKey, FlowId> entryForRemove : listForRemove.entrySet()) { final FlowKey flowKey = new FlowKey(entryForRemove.getValue()); final InstanceIdentifier<Flow> flowRef = tableRef.child(Flow.class, flowKey); if (nodeDeleteMap != null && flowKey.getId().getValue().startsWith(ALIEN_SYSTEM_FLOW_ID)) { final Integer lifeIndex = nodeDeleteMap.get(flowRef); if (lifeIndex > 0) { break; } else { nodeDeleteMap.remove(flowRef); } } else { if (listMissingConfigFlows.remove(flowRef)) { break; // we probably lost some multipart msg } } final InstanceIdentifier<FlowHashIdMap> flHashIdent = tableRef.augmentation(FlowHashIdMapping.class).child(FlowHashIdMap.class, entryForRemove.getKey()); tx.delete(LogicalDatastoreType.OPERATIONAL, flowRef); tx.delete(LogicalDatastoreType.OPERATIONAL, flHashIdent); } }
/** * Return a MD-SAL flow ID configured in the given flow-ref instance. * * @param fref A flow-ref instance. * @return A MD-SAL flow ID configured in the given flow-ref instance. * @throws IllegalArgumentException * The given flow-ref instance is invalid. */ private String getFlowId(FlowRef fref) { if (fref == null) { throw new IllegalArgumentException("flow-ref cannot be null."); } // Verify the specified path. InstanceIdentifier<?> path = fref.getValue(); FlowKey fkey = path.firstKeyOf(Flow.class); if (fkey != null) { InstanceIdentifier<Flow> expected = tablePath.child(Flow.class, fkey); if (expected.equals(path)) { return fkey.getId().getValue(); } } throw new IllegalArgumentException("Invalid flow-ref: " + path); }
@Override public FlowsStatisticsUpdate createNotification(final FlowStatistics o, final InstanceIdentifier<FlowStatistics> path) { Preconditions.checkArgument(o != null); Preconditions.checkArgument(path != null); final FlowAndStatisticsMapListBuilder fsmlBuilder = new FlowAndStatisticsMapListBuilder(o); fsmlBuilder.setFlowId(new FlowId(path.firstKeyOf(Flow.class, FlowKey.class).getId().getValue())); final FlowsStatisticsUpdateBuilder builder = new FlowsStatisticsUpdateBuilder(); builder.setId(getNodeId(path)); builder.setMoreReplies(Boolean.FALSE); // NOTE : fix if it needs, but we have to ask DataStore for the NodeConnector list builder.setNodeConnector(Collections.<NodeConnector>emptyList()); builder.setFlowAndStatisticsMapList(Collections.singletonList(fsmlBuilder.build())); return builder.build(); } }
builder.setFlowRef(new FlowRef(lacpFId)); builder.setFlowTable(new FlowTableRef(tableId)); builder.setTransactionUri(new Uri(lacpFlow.getId().getValue())); Future<RpcResult<RemoveFlowOutput>> result = salFlow.removeFlow(builder.build()); try
builder.setFlowRef(new FlowRef(lacpFId)); builder.setFlowTable(new FlowTableRef(tableId)); builder.setTransactionUri(new Uri(lacpFlow.getId().getValue())); try
private Future<RpcResult<AddFlowOutput>> writeFlowToController(InstanceIdentifier<Node> nodeInstanceId, InstanceIdentifier<Table> tableInstanceId, InstanceIdentifier<Flow> flowPath, Flow flow) { LOG.trace("Adding flow to node {}",nodeInstanceId.firstKeyOf(Node.class, NodeKey.class).getId().getValue()); final AddFlowInputBuilder builder = new AddFlowInputBuilder(flow); builder.setNode(new NodeRef(nodeInstanceId)); builder.setFlowRef(new FlowRef(flowPath)); builder.setFlowTable(new FlowTableRef(tableInstanceId)); builder.setTransactionUri(new Uri(flow.getId().getValue())); return salFlowService.addFlow(builder.build()); } }
private Future<RpcResult<AddFlowOutput>> writeFlowToController(InstanceIdentifier<Node> nodeInstanceId, InstanceIdentifier<Table> tableInstanceId, InstanceIdentifier<Flow> flowPath, Flow flow) { LOG.trace("Adding flow to node {}",nodeInstanceId.firstKeyOf(Node.class, NodeKey.class).getId().getValue()); final AddFlowInputBuilder builder = new AddFlowInputBuilder(flow); builder.setNode(new NodeRef(nodeInstanceId)); builder.setFlowRef(new FlowRef(flowPath)); builder.setFlowTable(new FlowTableRef(tableInstanceId)); builder.setTransactionUri(new Uri(flow.getId().getValue())); return salFlowService.addFlow(builder.build()); } }
void reportFlow(final FlowAndStatisticsMapList flowStat, final ReadWriteTransaction trans) { ensureTableFowHashIdMapping(trans); final FlowHashIdMapKey hashingKey = new FlowHashIdMapKey(buildFlowIdOperKey(flowStat)); FlowKey flowKey = getFlowKeyAndRemoveHash(hashingKey); if (flowKey == null) { flowKey = searchInConfiguration(flowStat, trans); if ( flowKey == null) { flowKey = makeAlienFlowKey(); } updateHashCache(trans,flowKey,hashingKey); } final FlowBuilder flowBuilder = new FlowBuilder(flowStat); flowBuilder.setKey(flowKey); addStatistics(flowBuilder, flowStat); final InstanceIdentifier<Flow> flowIdent = tableRef.child(Flow.class, flowKey); trans.put(LogicalDatastoreType.OPERATIONAL, flowIdent, flowBuilder.build()); /* check life for Alien flows */ if (flowKey.getId().getValue().startsWith(ALIEN_SYSTEM_FLOW_ID)) { removeData(flowIdent, REMOVE_AFTER_MISSING_COLLECTION); } }
void reportFlow(final FlowAndStatisticsMapList flowStat, final ReadWriteTransaction trans) { ensureTableFowHashIdMapping(trans); final FlowHashIdMapKey hashingKey = new FlowHashIdMapKey(buildFlowIdOperKey(flowStat)); FlowKey flowKey = getFlowKeyAndRemoveHash(hashingKey); if (flowKey == null) { flowKey = searchInConfiguration(flowStat, trans); if ( flowKey == null) { flowKey = makeAlienFlowKey(); } updateHashCache(trans,flowKey,hashingKey); } final FlowBuilder flowBuilder = new FlowBuilder(flowStat); flowBuilder.setKey(flowKey); addStatistics(flowBuilder, flowStat); final InstanceIdentifier<Flow> flowIdent = tableRef.child(Flow.class, flowKey); trans.put(LogicalDatastoreType.OPERATIONAL, flowIdent, flowBuilder.build()); /* check life for Alien flows */ if (flowKey.getId().getValue().startsWith(ALIEN_SYSTEM_FLOW_ID)) { removeData(flowIdent, REMOVE_AFTER_MISSING_COLLECTION); } }
for (Flow flow : flows) { String flowId = null; flowId = flow.getId().getValue().toString(); if (flowId.contains(logFlowId)) { return flowId;
/** * Starts and commits data change transaction which modifies provided * flow path with supplied body. */ private Future<RpcResult<AddFlowOutput>> writeFlowToSwitch(NodeId nodeId, Flow flow) { InstanceIdentifier<Node> nodeInstanceId = InstanceIdentifier.<Nodes>builder(Nodes.class) .<Node, NodeKey>child(Node.class, new NodeKey(nodeId)).build(); InstanceIdentifier<Table> tableInstanceId = nodeInstanceId .<FlowCapableNode>augmentation(FlowCapableNode.class) .<Table, TableKey>child(Table.class, new TableKey(flowTableId)); InstanceIdentifier<Flow> flowPath = tableInstanceId.<Flow, FlowKey>child(Flow.class, new FlowKey(new FlowId(String.valueOf(flowIdInc.getAndIncrement())))); final AddFlowInputBuilder builder = new AddFlowInputBuilder(flow).setNode(new NodeRef(nodeInstanceId)) .setFlowTable(new FlowTableRef(tableInstanceId)).setFlowRef(new FlowRef(flowPath)) .setTransactionUri(new Uri(flow.getId().getValue())); return salFlowService.addFlow(builder.build()); } }
"{}: {}: No flow statistics: {}", builder.getFlowId().getValue(), flow.getId().getValue(), err);
/** * Starts and commits data change transaction which modifies provided flow * path with supplied body. * * @param flowPath * @param flow * @return transaction commit */ private Future<RpcResult<AddFlowOutput>> writeFlowToConfigData(InstanceIdentifier<Flow> flowPath, Flow flow) { final InstanceIdentifier<Table> tableInstanceId = flowPath.<Table>firstIdentifierOf(Table.class); final InstanceIdentifier<Node> nodeInstanceId = flowPath.<Node>firstIdentifierOf(Node.class); final AddFlowInputBuilder builder = new AddFlowInputBuilder(flow); builder.setNode(new NodeRef(nodeInstanceId)); builder.setFlowRef(new FlowRef(flowPath)); builder.setFlowTable(new FlowTableRef(tableInstanceId)); builder.setTransactionUri(new Uri(flow.getId().getValue())); return salFlowService.addFlow(builder.build()); } }
ctx.log(LOG, VTNLogLevel.TRACE, "Flow statistics has been updated: {}, {}", id, fid.getValue());
if (ia.getKey() instanceof FlowKey) { FlowKey flowKey = (FlowKey) ia.getKey(); rec.setKeyValue("" + flowKey.getId().getValue()); } else if (ia.getKey() instanceof QueueKey) { QueueKey qk = (QueueKey) ia.getKey();