Refactor: Inline invocations and remove methods
Change-Id: I004cab89f9d65cf9acc6721ef5865a8cb66dc61d
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 0631993..6808788 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
@@ -54,7 +54,6 @@
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.stream.Collectors;
-import java.util.stream.Stream;
import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.concurrent.Executors.newFixedThreadPool;
@@ -323,7 +322,17 @@
3. accumulate results and submit batch write of IntentData to store
(we can also try to update these individually)
*/
- submitUpdates(waitForFutures(createIntentUpdates(operations)));
+ store.batchWrite(operations.stream()
+ .map(IntentManager.this::submitIntentData)
+ .map(x -> x.exceptionally(e -> {
+ //FIXME
+ log.warn("Future failed: {}", e);
+ return null;
+ }))
+ .map(CompletableFuture::join)
+ .filter(Objects::nonNull)
+ .map(FinalIntentProcessPhase::data)
+ .collect(Collectors.toList()));
} catch (Exception e) {
log.error("Error submitting batches:", e);
// FIXME incomplete Intents should be cleaned up
@@ -340,28 +349,6 @@
}
}
- private Stream<CompletableFuture<FinalIntentProcessPhase>> createIntentUpdates(Collection<IntentData> data) {
- return data.stream()
- .map(IntentManager.this::submitIntentData);
- }
-
- private Stream<FinalIntentProcessPhase> waitForFutures(Stream<CompletableFuture<FinalIntentProcessPhase>> futures) {
- return futures
- .map(x -> x.exceptionally(e -> {
- //FIXME
- log.warn("Future failed: {}", e);
- return null;
- }))
- .map(CompletableFuture::join)
- .filter(Objects::nonNull);
- }
-
- private void submitUpdates(Stream<FinalIntentProcessPhase> updates) {
- store.batchWrite(updates
- .map(FinalIntentProcessPhase::data)
- .collect(Collectors.toList()));
- }
-
private class InternalIntentProcessor implements IntentProcessor {
@Override
public List<Intent> compile(Intent intent, List<Intent> previousInstallables) {