@Override public FlowRuleEvent addOrUpdateFlowRule(FlowEntry rule) { NodeId master = mastershipService.getMasterFor(rule.deviceId()); if (Objects.equal(local, master)) { return addOrUpdateFlowRuleInternal(rule); } log.warn("Tried to update FlowRule {} state," + " while the Node was not the master.", rule); return null; }
public void add(FlowEntry rule) { getFlowEntriesInternal(rule.deviceId(), rule.id()).add((StoredFlowEntry) rule); lastUpdateTimes.put(rule.deviceId(), System.currentTimeMillis()); }
private FlowRuleEvent removeFlowRuleInternal(FlowEntry rule) { final DeviceId deviceId = rule.deviceId(); // This is where one could mark a rule as removed and still keep it in the store. final boolean removed = flowTable.remove(deviceId, rule); // flowEntries.remove(deviceId, rule); return removed ? new FlowRuleEvent(RULE_REMOVED, rule) : null; }
@Override public FlowRuleEvent removeFlowRule(FlowEntry rule) { final DeviceId deviceId = rule.deviceId(); NodeId master = mastershipService.getMasterFor(deviceId); if (Objects.equal(local, master)) { // bypass and handle it locally return removeFlowRuleInternal(rule); } if (master == null) { log.warn("Failed to removeFlowRule: No master for {}", deviceId); // TODO: revisit if this should be null (="no-op") or Exception return null; } log.trace( "Forwarding removeFlowRule to {}, which is the master for device {}", master, deviceId); return Futures.get( clusterCommunicator.sendAndReceive( rule, REMOVE_FLOW_ENTRY, SERIALIZER::encode, SERIALIZER::decode, master), FLOW_RULE_STORE_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS, RuntimeException.class); }