WIP: Revamped transaction API. Introduces a transaction context for running blocks of code that can be committed
atomically.
Change-Id: I6ba21050a2644a42f3c073fa04ff776ef2c5ff4c
diff --git a/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/ConsistentMapImpl.java b/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/ConsistentMapImpl.java
index eb18071..a5b6656 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/ConsistentMapImpl.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/ConsistentMapImpl.java
@@ -20,7 +20,6 @@
import java.util.Collection;
import java.util.Collections;
-import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.CompletableFuture;
@@ -35,7 +34,6 @@
import org.onosproject.store.service.ConsistentMap;
import org.onosproject.store.service.ConsistentMapException;
import org.onosproject.store.service.Serializer;
-import org.onosproject.store.service.UpdateOperation;
import org.onosproject.store.service.Versioned;
import com.google.common.cache.CacheBuilder;
@@ -73,7 +71,7 @@
return serializer.decode(HexString.fromHexString(key));
}
- ConsistentMapImpl(String name,
+ public ConsistentMapImpl(String name,
DatabaseProxy<String, byte[]> proxy,
Serializer serializer) {
this.name = checkNotNull(name, "map name cannot be null");
@@ -196,15 +194,6 @@
return complete(proxy.replace(name, keyCache.getUnchecked(key), oldVersion, serializer.encode(newValue)));
}
- @Override
- public boolean batchUpdate(List<UpdateOperation<K, V>> updates) {
- checkNotNull(updates, "updates cannot be null");
- return complete(proxy.atomicBatchUpdate(updates
- .stream()
- .map(this::toRawUpdateOperation)
- .collect(Collectors.toList())));
- }
-
private static <T> T complete(CompletableFuture<T> future) {
try {
return future.get(OPERATION_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
@@ -225,31 +214,4 @@
serializer.decode(e.getValue().value()),
e.getValue().version()));
}
-
- private UpdateOperation<String, byte[]> toRawUpdateOperation(UpdateOperation<K, V> update) {
-
- checkArgument(name.equals(update.tableName()), "Unexpected table name");
-
- UpdateOperation.Builder<String, byte[]> rawUpdate = UpdateOperation.<String, byte[]>newBuilder();
-
- rawUpdate = rawUpdate.withKey(keyCache.getUnchecked(update.key()))
- .withCurrentVersion(update.currentVersion())
- .withType(update.type());
-
- rawUpdate = rawUpdate.withTableName(update.tableName());
-
- if (update.value() != null) {
- rawUpdate = rawUpdate.withValue(serializer.encode(update.value()));
- } else {
- checkState(update.type() == UpdateOperation.Type.REMOVE
- || update.type() == UpdateOperation.Type.REMOVE_IF_VERSION_MATCH,
- ERROR_NULL_VALUE);
- }
-
- if (update.currentValue() != null) {
- rawUpdate = rawUpdate.withCurrentValue(serializer.encode(update.currentValue()));
- }
-
- return rawUpdate.build();
- }
}
\ No newline at end of file