Update FlowRuleOperations API

stripeKey now exposes an Optional instead of an Integer

Change-Id: I9a13fcea85ba3e0b52c004ece5a47fc50e99c9d6
diff --git a/core/api/src/main/java/org/onosproject/net/flow/FlowRuleOperations.java b/core/api/src/main/java/org/onosproject/net/flow/FlowRuleOperations.java
index 14af90d..ef41ca7 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/FlowRuleOperations.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/FlowRuleOperations.java
@@ -21,6 +21,7 @@
 import com.google.common.collect.Lists;
 
 import java.util.List;
+import java.util.Optional;
 import java.util.Set;
 
 import static com.google.common.base.Preconditions.checkNotNull;
@@ -80,8 +81,8 @@
      *
      * @return the stripe key associated to this or null if not present
      */
-    public Integer stripeKey() {
-        return stripeKey;
+    public Optional<Integer> stripeKey() {
+        return Optional.ofNullable(stripeKey);
     }
 
     /**
diff --git a/core/net/src/main/java/org/onosproject/net/flow/impl/FlowRuleManager.java b/core/net/src/main/java/org/onosproject/net/flow/impl/FlowRuleManager.java
index e7cd691..d25ceab 100644
--- a/core/net/src/main/java/org/onosproject/net/flow/impl/FlowRuleManager.java
+++ b/core/net/src/main/java/org/onosproject/net/flow/impl/FlowRuleManager.java
@@ -78,6 +78,7 @@
 import java.util.Map;
 import java.util.Objects;
 import java.util.Optional;
+import java.util.Random;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutorService;
@@ -157,6 +158,8 @@
 
     private NodeId local;
 
+    private Random randomGenerator = new Random();
+
     @Reference(cardinality = ReferenceCardinality.MANDATORY)
     protected FlowRuleStore store;
 
@@ -389,7 +392,7 @@
     @Override
     public void apply(FlowRuleOperations ops) {
         checkPermission(FLOWRULE_WRITE);
-        if (ops.stripeKey() == null) {
+        if (ops.stripeKey().isEmpty()) {
             // Null means that we don't care about the in-order processing
             // this approach maximizes the throughput but it can introduce
             // consistency issues as the original order between conflictual
@@ -947,7 +950,7 @@
 
         @Override
         public int hint() {
-            return fops.stripeKey();
+            return fops.stripeKey().orElse(randomGenerator.nextInt());
         }
     }