Adding ready() to IntentAccumulator
Change-Id: I34dc32c1a416629afbf3ba1f5b65d6a764e55fd6
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/IntentAccumulator.java b/core/net/src/main/java/org/onosproject/net/intent/impl/IntentAccumulator.java
index fdd6677..54276ad 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/IntentAccumulator.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/IntentAccumulator.java
@@ -42,6 +42,8 @@
private final IntentBatchDelegate delegate;
+ private volatile boolean ready;
+
/**
* Creates an intent operation accumulator.
*
@@ -50,13 +52,14 @@
protected IntentAccumulator(IntentBatchDelegate delegate) {
super(TIMER, DEFAULT_MAX_EVENTS, DEFAULT_MAX_BATCH_MS, DEFAULT_MAX_IDLE_MS);
this.delegate = delegate;
+ // Assume that the delegate is ready for work at the start
+ ready = true; //TODO validate the assumption that delegate is ready
}
@Override
public void processItems(List<IntentData> items) {
+ ready = false;
delegate.execute(reduce(items));
- // FIXME kick off the work
- //for (IntentData data : opMap.values()) {}
}
private Collection<IntentData> reduce(List<IntentData> ops) {
@@ -67,4 +70,13 @@
//TODO check the version... or maybe store will handle this.
return map.values();
}
+
+ @Override
+ public boolean isReady() {
+ return ready;
+ }
+
+ public void ready() {
+ ready = true;
+ }
}
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/IntentManager.java b/core/net/src/main/java/org/onosproject/net/intent/impl/IntentManager.java
index 280ff32..1993729 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/IntentManager.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/IntentManager.java
@@ -317,6 +317,7 @@
//FIXME
// batchService.removeIntentOperations(data);
}
+ accumulator.ready();
}
private List<Future<FinalIntentProcessPhase>> createIntentUpdates() {