Initial implementation of distributed intent batch queue
Change-Id: I7ffed03651569ade1be1e8dca905bfaf369b7e03
diff --git a/core/api/src/main/java/org/onlab/onos/net/intent/IntentBatchService.java b/core/api/src/main/java/org/onlab/onos/net/intent/IntentBatchService.java
index 0364ad7..762bbb8 100644
--- a/core/api/src/main/java/org/onlab/onos/net/intent/IntentBatchService.java
+++ b/core/api/src/main/java/org/onlab/onos/net/intent/IntentBatchService.java
@@ -15,6 +15,8 @@
*/
package org.onlab.onos.net.intent;
+import org.onlab.onos.core.ApplicationId;
+
import java.util.Set;
/**
@@ -46,9 +48,20 @@
* Returns the set of intent batches currently being processed.
* @return set of batches
*/
+ //TODO we may want to get rid of this method
+ @Deprecated
Set<IntentOperations> getCurrentOperations();
/**
+ * Return true if this instance is the local leader for batch
+ * processing a given application id.
+ *
+ * @param applicationId
+ * @return
+ */
+ boolean isLocalLeader(ApplicationId applicationId);
+
+ /**
* Sets the batch service delegate.
*
* @param delegate delegate to apply
diff --git a/core/api/src/main/java/org/onlab/onos/net/intent/IntentOperations.java b/core/api/src/main/java/org/onlab/onos/net/intent/IntentOperations.java
index ee7c243..c282a01 100644
--- a/core/api/src/main/java/org/onlab/onos/net/intent/IntentOperations.java
+++ b/core/api/src/main/java/org/onlab/onos/net/intent/IntentOperations.java
@@ -19,6 +19,7 @@
import java.util.Objects;
import com.google.common.collect.ImmutableList;
+import org.onlab.onos.core.ApplicationId;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -33,14 +34,16 @@
public final class IntentOperations {
private final List<IntentOperation> operations;
+ private final ApplicationId appId;
/**
* Creates a batch of intent operations using the supplied list.
*
* @param operations list of intent operations
*/
- private IntentOperations(List<IntentOperation> operations) {
+ private IntentOperations(List<IntentOperation> operations, ApplicationId appId) {
this.operations = operations;
+ this.appId = appId;
}
/**
@@ -52,16 +55,20 @@
return operations;
}
+ public ApplicationId appId() {
+ return appId;
+ }
+
/**
* Returns a builder for intent operation batches.
*
* @return intent operations builder
+ * @param applicationId application id
*/
- public static Builder builder() {
- return new Builder();
+ public static Builder builder(ApplicationId applicationId) {
+ return new Builder(applicationId);
}
-
@Override
public int hashCode() {
return Objects.hash(operations);
@@ -92,9 +99,11 @@
public static final class Builder {
private final ImmutableList.Builder<IntentOperation> builder = ImmutableList.builder();
+ private final ApplicationId appId;
// Public construction is forbidden.
- private Builder() {
+ private Builder(ApplicationId appId) {
+ this.appId = appId;
}
/**
@@ -153,7 +162,7 @@
* @return immutable batch of intent operations
*/
public IntentOperations build() {
- return new IntentOperations(builder.build());
+ return new IntentOperations(builder.build(), appId);
}
}
diff --git a/core/api/src/main/java/org/onlab/onos/store/service/Lock.java b/core/api/src/main/java/org/onlab/onos/store/service/Lock.java
index 01682d1..7558ae2 100644
--- a/core/api/src/main/java/org/onlab/onos/store/service/Lock.java
+++ b/core/api/src/main/java/org/onlab/onos/store/service/Lock.java
@@ -82,7 +82,7 @@
* lock acquisition events
* @return epoch
*/
- long epoch();
+ long epoch();
/**
* Releases the lock.