Removed deprecated IntentStore#batchWrite() API.
Also javadoc fixes.
Change-Id: I4ccd109a22189f4762afec15a719e42a3b9e4f7b
diff --git a/core/api/src/main/java/org/onosproject/net/intent/IntentStore.java b/core/api/src/main/java/org/onosproject/net/intent/IntentStore.java
index ceb5493..b6f7aed 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/IntentStore.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/IntentStore.java
@@ -15,7 +15,6 @@
*/
package org.onosproject.net.intent;
-import org.onosproject.net.intent.BatchWrite.Operation;
import org.onosproject.store.Store;
import java.util.List;
@@ -61,16 +60,18 @@
}
/**
- * Execute writes in a batch.
- * If the specified BatchWrite is empty, write will not be executed.
+ * Writes an IntentData object to the store.
*
- * @param batch BatchWrite to execute
- * @return failed operations
+ * @param newData new intent data to write
*/
- @Deprecated
- List<Operation> batchWrite(BatchWrite batch);
-
default void write(IntentData newData) {}
+
+ /**
+ * Writes a batch of IntentData objects to the store. A batch has no
+ * semantics, this is simply a convenience API.
+ *
+ * @param updates collection of intent data objects to write
+ */
default void batchWrite(Iterable<IntentData> updates) {}
/**
diff --git a/core/store/dist/src/main/java/org/onosproject/store/intent/impl/DistributedIntentStore.java b/core/store/dist/src/main/java/org/onosproject/store/intent/impl/DistributedIntentStore.java
index 8d56098..fd76653 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/intent/impl/DistributedIntentStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/intent/impl/DistributedIntentStore.java
@@ -22,7 +22,6 @@
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Lists;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
@@ -32,8 +31,6 @@
import org.onlab.metrics.MetricsService;
import org.onlab.util.KryoNamespace;
import org.onosproject.core.MetricsHelper;
-import org.onosproject.net.intent.BatchWrite;
-import org.onosproject.net.intent.BatchWrite.Operation;
import org.onosproject.net.intent.Intent;
import org.onosproject.net.intent.IntentEvent;
import org.onosproject.net.intent.IntentId;
@@ -45,24 +42,17 @@
import org.onosproject.store.serializers.KryoNamespaces;
import org.onosproject.store.serializers.KryoSerializer;
import org.onosproject.store.serializers.StoreSerializer;
-import org.onosproject.store.service.BatchWriteRequest;
-import org.onosproject.store.service.BatchWriteRequest.Builder;
-import org.onosproject.store.service.BatchWriteResult;
import org.onosproject.store.service.DatabaseAdminService;
import org.onosproject.store.service.DatabaseService;
import org.onosproject.store.service.impl.CMap;
import org.slf4j.Logger;
-import java.util.ArrayList;
-import java.util.Collections;
import java.util.EnumSet;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
-import static com.google.common.base.Preconditions.checkArgument;
import static org.onlab.metrics.MetricsUtil.startTimer;
import static org.onlab.metrics.MetricsUtil.stopTimer;
import static org.onosproject.net.intent.IntentState.FAILED;
@@ -292,7 +282,7 @@
}
}
- @Override
+ /*@Override
public List<Operation> batchWrite(BatchWrite batch) {
if (batch.isEmpty()) {
return Collections.emptyList();
@@ -370,5 +360,5 @@
// everything failed
return batch.operations();
}
- }
+ }*/
}
diff --git a/core/store/dist/src/main/java/org/onosproject/store/intent/impl/GossipIntentStore.java b/core/store/dist/src/main/java/org/onosproject/store/intent/impl/GossipIntentStore.java
index d81435f..c78b5f9 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/intent/impl/GossipIntentStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/intent/impl/GossipIntentStore.java
@@ -23,7 +23,6 @@
import org.apache.felix.scr.annotations.Service;
import org.onlab.util.KryoNamespace;
import org.onosproject.cluster.ClusterService;
-import org.onosproject.net.intent.BatchWrite;
import org.onosproject.net.intent.Intent;
import org.onosproject.net.intent.IntentData;
import org.onosproject.net.intent.IntentEvent;
@@ -45,11 +44,7 @@
import java.util.List;
import java.util.stream.Collectors;
-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.WITHDRAWING;
-import static org.onosproject.net.intent.IntentState.WITHDRAWN;
+import static org.onosproject.net.intent.IntentState.*;
import static org.slf4j.LoggerFactory.getLogger;
/**
@@ -143,12 +138,6 @@
return null;
}
- @Override
- public List<BatchWrite.Operation> batchWrite(BatchWrite batch) {
- // Deprecated
- return null;
- }
-
private IntentData copyData(IntentData original) {
if (original == null) {
return null;
@@ -163,10 +152,13 @@
}
/**
- * TODO.
- * @param currentData
- * @param newData
- * @return
+ * Determines whether an intent data update is allowed. The update must
+ * either have a higher version than the current data, or the state
+ * transition between two updates of the same version must be sane.
+ *
+ * @param currentData existing intent data in the store
+ * @param newData new intent data update proposal
+ * @return true if we can apply the update, otherwise false
*/
private boolean isUpdateAcceptable(IntentData currentData, IntentData newData) {
diff --git a/core/store/dist/src/main/java/org/onosproject/store/intent/impl/HazelcastIntentStore.java b/core/store/dist/src/main/java/org/onosproject/store/intent/impl/HazelcastIntentStore.java
index e66d7ca..8514ded 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/intent/impl/HazelcastIntentStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/intent/impl/HazelcastIntentStore.java
@@ -20,7 +20,6 @@
import com.google.common.base.Verify;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Lists;
import com.hazelcast.config.Config;
import com.hazelcast.config.MapConfig;
import com.hazelcast.core.EntryAdapter;
@@ -53,8 +52,6 @@
import org.onosproject.store.serializers.KryoSerializer;
import org.slf4j.Logger;
-import java.util.ArrayList;
-import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
@@ -66,7 +63,10 @@
import static com.google.common.base.Preconditions.checkArgument;
import static org.onlab.metrics.MetricsUtil.startTimer;
import static org.onlab.metrics.MetricsUtil.stopTimer;
-import static org.onosproject.net.intent.IntentState.*;
+import static org.onosproject.net.intent.IntentState.FAILED;
+import static org.onosproject.net.intent.IntentState.INSTALLED;
+import static org.onosproject.net.intent.IntentState.INSTALL_REQ;
+import static org.onosproject.net.intent.IntentState.WITHDRAWN;
import static org.slf4j.LoggerFactory.getLogger;
//TODO Note: this store will be removed
@@ -277,7 +277,7 @@
*/
}
- @Override
+ /*@Override
public List<Operation> batchWrite(BatchWrite batch) {
if (batch.isEmpty()) {
return Collections.emptyList();
@@ -297,7 +297,7 @@
notifyDelegate(events);
return failed;
- }
+ }*/
private void batchWriteAsync(BatchWrite batch, List<Operation> failed,
List<Pair<Operation, List<Future<?>>>> futures) {
diff --git a/core/store/dist/src/main/java/org/onosproject/store/intent/impl/SimpleIntentStore.java b/core/store/dist/src/main/java/org/onosproject/store/intent/impl/SimpleIntentStore.java
index 89952ce..2bc5b63 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/intent/impl/SimpleIntentStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/intent/impl/SimpleIntentStore.java
@@ -20,8 +20,6 @@
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Service;
-import org.onosproject.net.intent.BatchWrite;
-import org.onosproject.net.intent.BatchWrite.Operation;
import org.onosproject.net.intent.Intent;
import org.onosproject.net.intent.IntentData;
import org.onosproject.net.intent.IntentEvent;
@@ -110,76 +108,15 @@
*/
}
- /*
- * Execute writes in a batch.
- *
- * @param batch BatchWrite to execute
- * @return failed operations
- */
- @Override
- public List<Operation> batchWrite(BatchWrite batch) {
- throw new UnsupportedOperationException("deprecated");
- /*
- if (batch.isEmpty()) {
- return Collections.emptyList();
- }
-
- List<Operation> failed = Lists.newArrayList();
- for (Operation op : batch.operations()) {
- switch (op.type()) {
- case CREATE_INTENT:
- checkArgument(op.args().size() == 1,
- "CREATE_INTENT takes 1 argument. %s", op);
- Intent intent = (Intent) op.args().get(0);
- // TODO: what if it failed?
-// createIntent(intent); FIXME
- break;
-
- case REMOVE_INTENT:
- checkArgument(op.args().size() == 1,
- "REMOVE_INTENT takes 1 argument. %s", op);
- IntentId intentId = (IntentId) op.args().get(0);
-// removeIntent(intentId); FIXME
- break;
-
- case REMOVE_INSTALLED:
- checkArgument(op.args().size() == 1,
- "REMOVE_INSTALLED takes 1 argument. %s", op);
- intentId = (IntentId) op.args().get(0);
- removeInstalledIntents(intentId);
- break;
-
- case SET_INSTALLABLE:
- checkArgument(op.args().size() == 2,
- "SET_INSTALLABLE takes 2 arguments. %s", op);
- intentId = (IntentId) op.args().get(0);
- @SuppressWarnings("unchecked")
- List<Intent> installableIntents = (List<Intent>) op.args().get(1);
- setInstallableIntents(intentId, installableIntents);
- break;
-
- case SET_STATE:
- checkArgument(op.args().size() == 2,
- "SET_STATE takes 2 arguments. %s", op);
- intent = (Intent) op.args().get(0);
- IntentState newState = (IntentState) op.args().get(1);
- setState(intent, newState);
- break;
-
- default:
- break;
- }
- }
- return failed;
- */
- }
-
/**
- * TODO.
- * @param currentData
- * @param newData
- * @return
+ * Determines whether an intent data update is allowed. The update must
+ * either have a higher version than the current data, or the state
+ * transition between two updates of the same version must be sane.
+ *
+ * @param currentData existing intent data in the store
+ * @param newData new intent data update proposal
+ * @return true if we can apply the update, otherwise false
*/
private boolean isUpdateAcceptable(IntentData currentData, IntentData newData) {
diff --git a/core/store/trivial/src/main/java/org/onosproject/store/trivial/impl/SimpleIntentStore.java b/core/store/trivial/src/main/java/org/onosproject/store/trivial/impl/SimpleIntentStore.java
index 906b942..7e5eb12 100644
--- a/core/store/trivial/src/main/java/org/onosproject/store/trivial/impl/SimpleIntentStore.java
+++ b/core/store/trivial/src/main/java/org/onosproject/store/trivial/impl/SimpleIntentStore.java
@@ -20,8 +20,6 @@
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Service;
-import org.onosproject.net.intent.BatchWrite;
-import org.onosproject.net.intent.BatchWrite.Operation;
import org.onosproject.net.intent.Intent;
import org.onosproject.net.intent.IntentData;
import org.onosproject.net.intent.IntentEvent;
@@ -87,70 +85,6 @@
return (data != null) ? data.installables() : null;
}
- /*
- * Execute writes in a batch.
- *
- * @param batch BatchWrite to execute
- * @return failed operations
- */
- @Override
- public List<Operation> batchWrite(BatchWrite batch) {
- throw new UnsupportedOperationException("deprecated");
- /*
- if (batch.isEmpty()) {
- return Collections.emptyList();
- }
-
- List<Operation> failed = Lists.newArrayList();
- for (Operation op : batch.operations()) {
- switch (op.type()) {
- case CREATE_INTENT:
- checkArgument(op.args().size() == 1,
- "CREATE_INTENT takes 1 argument. %s", op);
- Intent intent = (Intent) op.args().get(0);
- // TODO: what if it failed?
-// createIntent(intent); FIXME
- break;
-
- case REMOVE_INTENT:
- checkArgument(op.args().size() == 1,
- "REMOVE_INTENT takes 1 argument. %s", op);
- IntentId intentId = (IntentId) op.args().get(0);
-// removeIntent(intentId); FIXME
- break;
-
- case REMOVE_INSTALLED:
- checkArgument(op.args().size() == 1,
- "REMOVE_INSTALLED takes 1 argument. %s", op);
- intentId = (IntentId) op.args().get(0);
- removeInstalledIntents(intentId);
- break;
-
- case SET_INSTALLABLE:
- checkArgument(op.args().size() == 2,
- "SET_INSTALLABLE takes 2 arguments. %s", op);
- intentId = (IntentId) op.args().get(0);
- @SuppressWarnings("unchecked")
- List<Intent> installableIntents = (List<Intent>) op.args().get(1);
- setInstallableIntents(intentId, installableIntents);
- break;
-
- case SET_STATE:
- checkArgument(op.args().size() == 2,
- "SET_STATE takes 2 arguments. %s", op);
- intent = (Intent) op.args().get(0);
- IntentState newState = (IntentState) op.args().get(1);
- setState(intent, newState);
- break;
-
- default:
- break;
- }
- }
- return failed;
- */
- }
-
@Override
public void write(IntentData newData) {
//FIXME need to compare the versions