Small extensions in server driver
First extension is the ability to prevent the installation
of a full wildcard rule, when only one rule is present per
NIC. Such a rule will redirect all the system's load on one
core, which is undesirable.
Second, we introduce the ability to detect the duration of
load on a core by converting the boolean field isBusy to
a timestamp busySince.
Addressed code review suggestions.
Change-Id: I631cf322ee3724d9f1f97246d4189b5b2a008a76
Signed-off-by: Georgios Katsikas <katsikas.gp@gmail.com>
diff --git a/drivers/server/src/main/java/org/onosproject/drivers/server/FlowRuleProgrammableServerImpl.java b/drivers/server/src/main/java/org/onosproject/drivers/server/FlowRuleProgrammableServerImpl.java
index 3dc7d59..34947cb 100644
--- a/drivers/server/src/main/java/org/onosproject/drivers/server/FlowRuleProgrammableServerImpl.java
+++ b/drivers/server/src/main/java/org/onosproject/drivers/server/FlowRuleProgrammableServerImpl.java
@@ -251,16 +251,26 @@
rules.forEach(rule -> {
if (!(rule instanceof FlowEntry)) {
- NicFlowRule nicRule = (NicFlowRule) rule;
- String tcId = nicRule.trafficClassId();
+ NicFlowRule nicRule = null;
- // Create a bucket of flow rules for this traffic class
- if (!rulesPerTc.containsKey(tcId)) {
- rulesPerTc.put(tcId, Sets.<FlowRule>newConcurrentHashSet());
+ // Only NicFlowRules are accepted
+ try {
+ nicRule = (NicFlowRule) rule;
+ } catch (ClassCastException cEx) {
+ log.warn("Skipping rule not crafted for NIC: {}", rule);
}
- Set<FlowRule> tcRuleSet = rulesPerTc.get(tcId);
- tcRuleSet.add(nicRule);
+ if (nicRule != null) {
+ String tcId = nicRule.trafficClassId();
+
+ // Create a bucket of flow rules for this traffic class
+ if (!rulesPerTc.containsKey(tcId)) {
+ rulesPerTc.put(tcId, Sets.<FlowRule>newConcurrentHashSet());
+ }
+
+ Set<FlowRule> tcRuleSet = rulesPerTc.get(tcId);
+ tcRuleSet.add(nicRule);
+ }
}
});
@@ -322,6 +332,11 @@
for (FlowRule rule : rules) {
NicFlowRule nicRule = (NicFlowRule) rule;
+ if (nicRule.isFullWildcard() && (rules.size() > 1)) {
+ log.warn("Skipping wildcard rule: {}", nicRule);
+ continue;
+ }
+
long coreIndex = nicRule.cpuCoreIndex();
// Keep the ID of the target NIC