Committed by
Gerrit Code Review
Adding ready() to IntentAccumulator
Change-Id: I34dc32c1a416629afbf3ba1f5b65d6a764e55fd6
Showing
2 changed files
with
15 additions
and
2 deletions
| ... | @@ -42,6 +42,8 @@ public class IntentAccumulator extends AbstractAccumulator<IntentData> { | ... | @@ -42,6 +42,8 @@ public class IntentAccumulator extends AbstractAccumulator<IntentData> { |
| 42 | 42 | ||
| 43 | private final IntentBatchDelegate delegate; | 43 | private final IntentBatchDelegate delegate; |
| 44 | 44 | ||
| 45 | + private volatile boolean ready; | ||
| 46 | + | ||
| 45 | /** | 47 | /** |
| 46 | * Creates an intent operation accumulator. | 48 | * Creates an intent operation accumulator. |
| 47 | * | 49 | * |
| ... | @@ -50,13 +52,14 @@ public class IntentAccumulator extends AbstractAccumulator<IntentData> { | ... | @@ -50,13 +52,14 @@ public class IntentAccumulator extends AbstractAccumulator<IntentData> { |
| 50 | protected IntentAccumulator(IntentBatchDelegate delegate) { | 52 | protected IntentAccumulator(IntentBatchDelegate delegate) { |
| 51 | super(TIMER, DEFAULT_MAX_EVENTS, DEFAULT_MAX_BATCH_MS, DEFAULT_MAX_IDLE_MS); | 53 | super(TIMER, DEFAULT_MAX_EVENTS, DEFAULT_MAX_BATCH_MS, DEFAULT_MAX_IDLE_MS); |
| 52 | this.delegate = delegate; | 54 | this.delegate = delegate; |
| 55 | + // Assume that the delegate is ready for work at the start | ||
| 56 | + ready = true; //TODO validate the assumption that delegate is ready | ||
| 53 | } | 57 | } |
| 54 | 58 | ||
| 55 | @Override | 59 | @Override |
| 56 | public void processItems(List<IntentData> items) { | 60 | public void processItems(List<IntentData> items) { |
| 61 | + ready = false; | ||
| 57 | delegate.execute(reduce(items)); | 62 | delegate.execute(reduce(items)); |
| 58 | - // FIXME kick off the work | ||
| 59 | - //for (IntentData data : opMap.values()) {} | ||
| 60 | } | 63 | } |
| 61 | 64 | ||
| 62 | private Collection<IntentData> reduce(List<IntentData> ops) { | 65 | private Collection<IntentData> reduce(List<IntentData> ops) { |
| ... | @@ -67,4 +70,13 @@ public class IntentAccumulator extends AbstractAccumulator<IntentData> { | ... | @@ -67,4 +70,13 @@ public class IntentAccumulator extends AbstractAccumulator<IntentData> { |
| 67 | //TODO check the version... or maybe store will handle this. | 70 | //TODO check the version... or maybe store will handle this. |
| 68 | return map.values(); | 71 | return map.values(); |
| 69 | } | 72 | } |
| 73 | + | ||
| 74 | + @Override | ||
| 75 | + public boolean isReady() { | ||
| 76 | + return ready; | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + public void ready() { | ||
| 80 | + ready = true; | ||
| 81 | + } | ||
| 70 | } | 82 | } | ... | ... |
| ... | @@ -317,6 +317,7 @@ public class IntentManager | ... | @@ -317,6 +317,7 @@ public class IntentManager |
| 317 | //FIXME | 317 | //FIXME |
| 318 | // batchService.removeIntentOperations(data); | 318 | // batchService.removeIntentOperations(data); |
| 319 | } | 319 | } |
| 320 | + accumulator.ready(); | ||
| 320 | } | 321 | } |
| 321 | 322 | ||
| 322 | private List<Future<FinalIntentProcessPhase>> createIntentUpdates() { | 323 | private List<Future<FinalIntentProcessPhase>> createIntentUpdates() { | ... | ... |
-
Please register or login to post a comment