use of org.onosproject.net.flow.StoredFlowEntry in project onos by opennetworkinglab.
the class DistributedVirtualFlowRuleStore method updateStoreInternal.
private Set<FlowRuleBatchEntry> updateStoreInternal(NetworkId networkId, FlowRuleBatchOperation operation) {
return operation.getOperations().stream().map(op -> {
StoredFlowEntry entry;
switch(op.operator()) {
case ADD:
entry = new DefaultFlowEntry(op.target());
// always add requested FlowRule
// Note: 2 equal FlowEntry may have different treatment
flowTable.remove(networkId, entry.deviceId(), entry);
flowTable.add(networkId, entry);
return op;
case REMOVE:
entry = flowTable.getFlowEntry(networkId, op.target());
if (entry != null) {
// FIXME modification of "stored" flow entry outside of flow table
entry.setState(FlowEntry.FlowEntryState.PENDING_REMOVE);
log.debug("Setting state of rule to pending remove: {}", entry);
return op;
}
break;
case MODIFY:
// TODO: figure this out at some point
break;
default:
log.warn("Unknown flow operation operator: {}", op.operator());
}
return null;
}).filter(Objects::nonNull).collect(Collectors.toSet());
}
use of org.onosproject.net.flow.StoredFlowEntry in project onos by opennetworkinglab.
the class SimpleVirtualFlowRuleStore method removeFlowRule.
@Override
public FlowRuleEvent removeFlowRule(NetworkId networkId, FlowEntry rule) {
// This is where one could mark a rule as removed and still keep it in the store.
final DeviceId did = rule.deviceId();
List<StoredFlowEntry> entries = getFlowEntries(networkId, did, rule.id());
synchronized (entries) {
if (entries.remove(rule)) {
return new FlowRuleEvent(RULE_REMOVED, rule);
}
}
return null;
}
use of org.onosproject.net.flow.StoredFlowEntry in project onos by opennetworkinglab.
the class SimpleFlowRuleStore method addOrUpdateFlowRule.
@Override
public FlowRuleEvent addOrUpdateFlowRule(FlowEntry rule) {
// check if this new rule is an update to an existing entry
List<StoredFlowEntry> entries = getFlowEntries(rule.deviceId(), rule.id());
synchronized (entries) {
for (StoredFlowEntry stored : entries) {
if (stored.equals(rule)) {
synchronized (stored) {
// FIXME modification of "stored" flow entry outside of flow table
stored.setBytes(rule.bytes());
stored.setLife(rule.life());
stored.setPackets(rule.packets());
if (stored.state() == FlowEntryState.PENDING_ADD) {
stored.setState(FlowEntryState.ADDED);
// TODO: Do we need to change `rule` state?
return new FlowRuleEvent(Type.RULE_ADDED, rule);
}
return new FlowRuleEvent(Type.RULE_UPDATED, rule);
}
}
}
}
// should not reach here
// storeFlowRule was expected to be called
log.error("FlowRule was not found in store {} to update", rule);
// flowEntries.put(did, rule);
return null;
}
Aggregations