Sho SHIMIZU
Committed by Brian O'Connor

Remove calls of IntentStore.batchWrite()

We are changing the write behavior to IntentStore, then
calls of IntentStore.batchWrite will be replaced.

Change-Id: Id9685d5631fea02f1d2ef30e12c503c7cf2c44ef
......@@ -15,11 +15,9 @@
*/
package org.onosproject.net.intent.impl;
import org.onosproject.net.intent.BatchWrite;
import org.onosproject.net.intent.Intent;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.onosproject.net.intent.IntentState.FAILED;
/**
* A processing phase after compilation failure.
......@@ -36,10 +34,4 @@ class CompilingFailed implements CompletedIntentUpdate {
CompilingFailed(Intent intent) {
this.intent = checkNotNull(intent);
}
@Override
public void writeAfterExecution(BatchWrite batchWrite) {
batchWrite.setState(intent, FAILED);
batchWrite.removeInstalledIntents(intent.id());
}
}
......
......@@ -16,7 +16,6 @@
package org.onosproject.net.intent.impl;
import org.onosproject.net.flow.FlowRuleBatchOperation;
import org.onosproject.net.intent.BatchWrite;
import org.onosproject.net.intent.Intent;
import java.util.Collections;
......@@ -29,13 +28,6 @@ import java.util.Optional;
interface CompletedIntentUpdate extends IntentUpdate {
/**
* Write data to the specified BatchWrite after execution() is called.
*
* @param batchWrite batchWrite
*/
default void writeAfterExecution(BatchWrite batchWrite) {}
/**
* Moves forward with the contained current batch.
* This method is invoked when the batch is successfully completed.
*/
......
......@@ -45,7 +45,6 @@ import org.onosproject.event.EventDeliveryService;
import org.onosproject.net.flow.CompletedBatchOperation;
import org.onosproject.net.flow.FlowRuleBatchOperation;
import org.onosproject.net.flow.FlowRuleService;
import org.onosproject.net.intent.BatchWrite;
import org.onosproject.net.intent.Intent;
import org.onosproject.net.intent.IntentBatchDelegate;
import org.onosproject.net.intent.IntentCompiler;
......@@ -70,10 +69,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.concurrent.Executors.newFixedThreadPool;
import static org.onlab.util.Tools.namedThreads;
import static org.onosproject.net.intent.IntentState.FAILED;
import static org.onosproject.net.intent.IntentState.INSTALLED;
import static org.onosproject.net.intent.IntentState.INSTALLING;
import static org.onosproject.net.intent.IntentState.INSTALL_REQ;
import static org.onosproject.net.intent.IntentState.WITHDRAWN;
import static org.onosproject.net.intent.IntentState.WITHDRAW_REQ;
import static org.slf4j.LoggerFactory.getLogger;
......@@ -447,13 +444,6 @@ public class IntentManager
}
@Override
public void writeBeforeExecution(BatchWrite batchWrite) {
// TODO consider only "creating" intent if it does not exist
// Note: We need to set state to INSTALL_REQ regardless.
batchWrite.createIntent(intent);
}
@Override
public Optional<IntentUpdate> execute() {
return Optional.of(new Compiling(intent)); //FIXME
}
......@@ -470,11 +460,6 @@ public class IntentManager
}
@Override
public void writeBeforeExecution(BatchWrite batchWrite) {
batchWrite.setState(intent, WITHDRAW_REQ);
}
@Override
public Optional<IntentUpdate> execute() {
return Optional.of(new Withdrawing(intent, currentState.installables())); //FIXME
}
......@@ -583,22 +568,6 @@ public class IntentManager
}
@Override
public void writeAfterExecution(BatchWrite batchWrite) {
switch (intentState) {
case INSTALLING:
batchWrite.setState(intent, INSTALLED);
batchWrite.setInstallableIntents(intent.id(), this.installables);
break;
case FAILED:
batchWrite.setState(intent, FAILED);
batchWrite.removeInstalledIntents(intent.id());
break;
default:
break;
}
}
@Override
public FlowRuleBatchOperation currentBatch() {
return currentBatch < batches.size() ? batches.get(currentBatch) : null;
}
......@@ -640,13 +609,6 @@ public class IntentManager
}
@Override
public void writeAfterExecution(BatchWrite batchWrite) {
batchWrite.setState(intent, WITHDRAWN);
batchWrite.removeInstalledIntents(intent.id());
batchWrite.removeIntent(intent.id());
}
@Override
public FlowRuleBatchOperation currentBatch() {
return currentBatch < batches.size() ? batches.get(currentBatch) : null;
}
......@@ -684,12 +646,6 @@ public class IntentManager
}
@Override
public void writeAfterExecution(BatchWrite batchWrite) {
batchWrite.setState(intent, FAILED);
batchWrite.removeInstalledIntents(intent.id());
}
@Override
public FlowRuleBatchOperation currentBatch() {
return currentBatch < batches.size() ? batches.get(currentBatch) : null;
}
......@@ -736,10 +692,6 @@ public class IntentManager
try {
List<IntentUpdate> updates = createIntentUpdates();
// Write batch information
BatchWrite batchWrite = createBatchWrite(updates);
store.batchWrite(batchWrite);
new IntentBatchApplyFirst(ops, processIntentUpdates(updates), endTime, 0, null).run();
} catch (Exception e) {
log.error("Error submitting batches:", e);
......@@ -760,12 +712,6 @@ public class IntentManager
.collect(Collectors.toList());
}
private BatchWrite createBatchWrite(List<IntentUpdate> updates) {
BatchWrite batchWrite = BatchWrite.newInstance();
updates.forEach(update -> update.writeBeforeExecution(batchWrite));
return batchWrite;
}
private List<CompletedIntentUpdate> processIntentUpdates(List<IntentUpdate> updates) {
// start processing each Intents
List<CompletedIntentUpdate> completed = new ArrayList<>();
......@@ -821,10 +767,6 @@ public class IntentManager
//FIXME apply batch might throw an exception
return flowRuleService.applyBatch(batch);
} else {
// there are no flow rule batches; finalize the intent update
BatchWrite batchWrite = createFinalizedBatchWrite(updates);
store.batchWrite(batchWrite);
return null;
}
}
......@@ -840,14 +782,6 @@ public class IntentManager
return batch;
}
private BatchWrite createFinalizedBatchWrite(List<CompletedIntentUpdate> intentUpdates) {
BatchWrite batchWrite = BatchWrite.newInstance();
for (CompletedIntentUpdate update : intentUpdates) {
update.writeAfterExecution(batchWrite);
}
return batchWrite;
}
protected void abandonShip() {
// the batch has failed
// TODO: maybe we should do more?
......
......@@ -15,8 +15,6 @@
*/
package org.onosproject.net.intent.impl;
import org.onosproject.net.intent.BatchWrite;
import java.util.Optional;
/**
......@@ -31,11 +29,4 @@ interface IntentUpdate {
* @return next update
*/
Optional<IntentUpdate> execute();
/**
* Write data to the specified BatchWrite before execution() is called.
*
* @param batchWrite batchWrite
*/
default void writeBeforeExecution(BatchWrite batchWrite) {}
}
......