summaryrefslogtreecommitdiffstats
path: root/infra/translate-utils/src/main
diff options
context:
space:
mode:
authorMichal Cmarada <mcmarada@cisco.com>2019-04-08 11:37:45 +0200
committerMichal Cmarada <mcmarada@cisco.com>2019-04-08 11:37:45 +0200
commitb16cea20258ba537db7c0755208c82ab93331ff7 (patch)
tree8a5a3c87069b9ce700c34323e75ff434e7acae97 /infra/translate-utils/src/main
parent23979469bcf8cd312cb3ec9e9e548003110f68f4 (diff)
HONEYCOMB-443: ODL bump to Neon
- bumps ODL dependencies to neon - migrates guava optional to java.utils.optional Change-Id: Ibdaa365c7e21a341103aba88dfd67277e40d2969 Signed-off-by: Michal Cmarada <mcmarada@cisco.com>
Diffstat (limited to 'infra/translate-utils/src/main')
-rw-r--r--infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/RWUtils.java6
-rw-r--r--infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/RealtimeMappingContext.java35
-rw-r--r--infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/ReflectionUtils.java6
-rw-r--r--infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/TransactionMappingContext.java22
-rw-r--r--infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/AbstractGenericReader.java6
-rw-r--r--infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/BindingBrokerReader.java23
-rw-r--r--infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/DelegatingReader.java2
-rw-r--r--infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/KeepaliveReaderWrapper.java4
-rw-r--r--infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/ReflexiveListReaderCustomizer.java2
-rw-r--r--infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/ReflexiveReaderCustomizer.java2
-rw-r--r--infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/cache/DumpCacheManager.java6
-rw-r--r--infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/write/BindingBrokerWriter.java26
-rw-r--r--infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/write/LegacyBindingBrokerWriter.java70
-rw-r--r--infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/write/TransactionWriteContext.java29
14 files changed, 154 insertions, 85 deletions
diff --git a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/RWUtils.java b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/RWUtils.java
index 71bcd9def..2bd2de1ec 100644
--- a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/RWUtils.java
+++ b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/RWUtils.java
@@ -101,7 +101,7 @@ public final class RWUtils {
@Nonnull
public static <D extends DataObject & Identifiable<K>, K extends Identifier<D>> InstanceIdentifier.IdentifiableItem<D, K> getCurrentIdItem(
@Nonnull final InstanceIdentifier<D> id, final K key) {
- return new InstanceIdentifier.IdentifiableItem<>(id.getTargetType(), key);
+ return InstanceIdentifier.IdentifiableItem.of(id.getTargetType(), key);
}
/**
@@ -160,7 +160,7 @@ public final class RWUtils {
*/
@SuppressWarnings("unchecked")
public static <D extends DataObject> InstanceIdentifier<D> makeIidLastWildcarded(final InstanceIdentifier<D> id) {
- final InstanceIdentifier.Item<D> wildcardedItem = new InstanceIdentifier.Item<>(id.getTargetType());
+ final InstanceIdentifier.Item<D> wildcardedItem = InstanceIdentifier.Item.of(id.getTargetType());
final Iterable<InstanceIdentifier.PathArgument> pathArguments = id.getPathArguments();
return (InstanceIdentifier<D>) InstanceIdentifier.create(
Iterables.concat(
@@ -170,7 +170,7 @@ public final class RWUtils {
private static InstanceIdentifier.PathArgument cleanPathArgumentFromKeys(final InstanceIdentifier.PathArgument pathArgument) {
return pathArgument instanceof InstanceIdentifier.IdentifiableItem<?, ?>
- ? new InstanceIdentifier.Item<>(pathArgument.getType())
+ ? InstanceIdentifier.Item.of(pathArgument.getType())
: pathArgument;
}
}
diff --git a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/RealtimeMappingContext.java b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/RealtimeMappingContext.java
index f10d312f1..09dba79da 100644
--- a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/RealtimeMappingContext.java
+++ b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/RealtimeMappingContext.java
@@ -16,15 +16,14 @@
package io.fd.honeycomb.translate.util;
-import com.google.common.base.Optional;
import io.fd.honeycomb.translate.MappingContext;
+import java.util.Optional;
+import java.util.concurrent.ExecutionException;
import javax.annotation.Nonnull;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.ReadTransaction;
+import org.opendaylight.mdsal.binding.api.WriteTransaction;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -38,10 +37,10 @@ public final class RealtimeMappingContext implements MappingContext {
@Override
public <T extends DataObject> Optional<T> read(@Nonnull final InstanceIdentifier<T> currentId) {
- try (ReadOnlyTransaction tx = contextBindingBrokerDependency.newReadOnlyTransaction()) {
+ try (ReadTransaction tx = contextBindingBrokerDependency.newReadOnlyTransaction()) {
try {
- return tx.read(LogicalDatastoreType.OPERATIONAL, currentId).checkedGet();
- } catch (ReadFailedException e) {
+ return tx.read(LogicalDatastoreType.OPERATIONAL, currentId).get();
+ } catch (InterruptedException | ExecutionException e) {
throw new IllegalStateException("Unable to perform read of " + currentId, e);
}
}
@@ -52,8 +51,8 @@ public final class RealtimeMappingContext implements MappingContext {
final WriteTransaction writeTx = contextBindingBrokerDependency.newWriteOnlyTransaction();
writeTx.delete(LogicalDatastoreType.OPERATIONAL, path);
try {
- writeTx.submit().checkedGet();
- } catch (TransactionCommitFailedException e) {
+ writeTx.commit().get();
+ } catch (InterruptedException | ExecutionException e) {
throw new IllegalStateException("Unable to perform delete of " + path, e);
}
}
@@ -61,10 +60,10 @@ public final class RealtimeMappingContext implements MappingContext {
@Override
public <T extends DataObject> void merge(final InstanceIdentifier<T> path, final T data) {
final WriteTransaction writeTx = contextBindingBrokerDependency.newWriteOnlyTransaction();
- writeTx.merge(LogicalDatastoreType.OPERATIONAL, path, data, true);
+ writeTx.mergeParentStructureMerge(LogicalDatastoreType.OPERATIONAL, path, data);
try {
- writeTx.submit().checkedGet();
- } catch (TransactionCommitFailedException e) {
+ writeTx.commit().get();
+ } catch (InterruptedException | ExecutionException e) {
throw new IllegalStateException("Unable to perform merge of " + path, e);
}
}
@@ -72,10 +71,10 @@ public final class RealtimeMappingContext implements MappingContext {
@Override
public <T extends DataObject> void put(final InstanceIdentifier<T> path, final T data) {
final WriteTransaction writeTx = contextBindingBrokerDependency.newWriteOnlyTransaction();
- writeTx.put(LogicalDatastoreType.OPERATIONAL, path, data, true);
+ writeTx.mergeParentStructurePut(LogicalDatastoreType.OPERATIONAL, path, data);
try {
- writeTx.submit().checkedGet();
- } catch (TransactionCommitFailedException e) {
+ writeTx.commit().get();
+ } catch (InterruptedException | ExecutionException e) {
throw new IllegalStateException("Unable to perform put of " + path, e);
}
}
diff --git a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/ReflectionUtils.java b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/ReflectionUtils.java
index 74c7be97c..7e1099ab7 100644
--- a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/ReflectionUtils.java
+++ b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/ReflectionUtils.java
@@ -16,9 +16,9 @@
package io.fd.honeycomb.translate.util;
-import com.google.common.base.Optional;
import java.lang.reflect.Method;
import java.util.List;
+import java.util.Optional;
import javax.annotation.Nonnull;
/**
@@ -36,7 +36,7 @@ public final class ReflectionUtils {
* @param paramTypes List of input argument types
* @param retType Return type
*
- * @return Found method or Optional.absent() if there's no such method
+ * @return Found method or Optional.empty() if there's no such method
*/
@Nonnull
public static Optional<Method> findMethodReflex(@Nonnull final Class<?> managedType,
@@ -49,7 +49,7 @@ public final class ReflectionUtils {
}
}
- return Optional.absent();
+ return Optional.empty();
}
private static boolean isMethodMatch(final @Nonnull String prefix,
diff --git a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/TransactionMappingContext.java b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/TransactionMappingContext.java
index 4d4e9fddd..33753bbca 100644
--- a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/TransactionMappingContext.java
+++ b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/TransactionMappingContext.java
@@ -16,14 +16,14 @@
package io.fd.honeycomb.translate.util;
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FluentFuture;
import io.fd.honeycomb.translate.MappingContext;
+import java.util.Optional;
+import java.util.concurrent.ExecutionException;
import javax.annotation.Nonnull;
-import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.mdsal.binding.api.ReadWriteTransaction;
+import org.opendaylight.mdsal.common.api.CommitInfo;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -43,9 +43,9 @@ public class TransactionMappingContext implements MappingContext {
@Override
public <T extends DataObject> Optional<T> read(@Nonnull final InstanceIdentifier<T> currentId) {
try {
- return readWriteTransaction.read(LogicalDatastoreType.OPERATIONAL, currentId).checkedGet();
- } catch (ReadFailedException e) {
- throw new IllegalStateException("Unable to perform read", e);
+ return readWriteTransaction.read(LogicalDatastoreType.OPERATIONAL, currentId).get();
+ } catch (InterruptedException | ExecutionException ex) {
+ throw new IllegalStateException("Unable to perform read", ex);
}
}
@@ -64,8 +64,8 @@ public class TransactionMappingContext implements MappingContext {
readWriteTransaction.put(LogicalDatastoreType.OPERATIONAL, path, data, true);
}
- public CheckedFuture<Void, TransactionCommitFailedException> submit() {
- return readWriteTransaction.submit();
+ public FluentFuture<? extends CommitInfo> commit() {
+ return readWriteTransaction.commit();
}
@Override
diff --git a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/AbstractGenericReader.java b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/AbstractGenericReader.java
index b19b72ecf..897174e1f 100644
--- a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/AbstractGenericReader.java
+++ b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/AbstractGenericReader.java
@@ -19,11 +19,11 @@ package io.fd.honeycomb.translate.util.read;
import static com.google.common.base.Preconditions.checkArgument;
import com.google.common.annotations.Beta;
-import com.google.common.base.Optional;
import io.fd.honeycomb.translate.read.ReadContext;
+import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.read.Reader;
import io.fd.honeycomb.translate.util.RWUtils;
-import io.fd.honeycomb.translate.read.ReadFailedException;
+import java.util.Optional;
import javax.annotation.Nonnull;
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
@@ -64,7 +64,7 @@ public abstract class AbstractGenericReader<D extends DataObject, B extends Buil
final D built = builder.build();
final Optional<D> read = isPresent(id, built, ctx)
? Optional.of(built)
- : Optional.absent();
+ : Optional.empty();
LOG.debug("{}: Current node read successfully. Result: {}", this, read);
return read;
diff --git a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/BindingBrokerReader.java b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/BindingBrokerReader.java
index e59e642c4..843175878 100644
--- a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/BindingBrokerReader.java
+++ b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/BindingBrokerReader.java
@@ -16,15 +16,16 @@
package io.fd.honeycomb.translate.util.read;
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FluentFuture;
import io.fd.honeycomb.translate.read.ReadContext;
-import io.fd.honeycomb.translate.read.Reader;
import io.fd.honeycomb.translate.read.ReadFailedException;
+import io.fd.honeycomb.translate.read.Reader;
+import java.util.Optional;
+import java.util.concurrent.ExecutionException;
import javax.annotation.Nonnull;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.ReadTransaction;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -59,13 +60,13 @@ public final class BindingBrokerReader<D extends DataObject, B extends Builder<D
@Override
public Optional<? extends DataObject> read(@Nonnull final InstanceIdentifier<? extends DataObject> id,
@Nonnull final ReadContext ctx) throws ReadFailedException {
- try (final ReadOnlyTransaction readOnlyTransaction = dataBroker.newReadOnlyTransaction()) {
- final CheckedFuture<? extends Optional<? extends DataObject>, org.opendaylight.controller.md.sal.common.api.data.ReadFailedException>
+ try (final ReadTransaction readOnlyTransaction = dataBroker.newReadOnlyTransaction()) {
+ final FluentFuture<? extends Optional<? extends DataObject>>
read = readOnlyTransaction.read(datastoreType, id);
try {
- return read.checkedGet();
- } catch (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException e) {
- throw new ReadFailedException(id, e);
+ return read.get();
+ } catch (InterruptedException | ExecutionException ex) {
+ throw new ReadFailedException(id, ex);
}
}
}
diff --git a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/DelegatingReader.java b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/DelegatingReader.java
index 5e2e7062e..8d3eb4cbc 100644
--- a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/DelegatingReader.java
+++ b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/DelegatingReader.java
@@ -16,12 +16,12 @@
package io.fd.honeycomb.translate.util.read;
-import com.google.common.base.Optional;
import io.fd.honeycomb.translate.read.ListReader;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.read.Reader;
import java.util.List;
+import java.util.Optional;
import javax.annotation.Nonnull;
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
diff --git a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/KeepaliveReaderWrapper.java b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/KeepaliveReaderWrapper.java
index b4d8be495..249fca642 100644
--- a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/KeepaliveReaderWrapper.java
+++ b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/KeepaliveReaderWrapper.java
@@ -16,13 +16,13 @@
package io.fd.honeycomb.translate.util.read;
-import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import io.fd.honeycomb.translate.MappingContext;
import io.fd.honeycomb.translate.ModificationCache;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.Reader;
import java.io.Closeable;
+import java.util.Optional;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
@@ -110,7 +110,7 @@ public final class KeepaliveReaderWrapper<D extends DataObject, B extends Builde
private static final class NoopMappingContext implements MappingContext {
@Override
public <T extends DataObject> Optional<T> read(@Nonnull final InstanceIdentifier<T> currentId) {
- return Optional.absent();
+ return Optional.empty();
}
@Override
diff --git a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/ReflexiveListReaderCustomizer.java b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/ReflexiveListReaderCustomizer.java
index daf6f3566..7ad04399f 100644
--- a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/ReflexiveListReaderCustomizer.java
+++ b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/ReflexiveListReaderCustomizer.java
@@ -20,7 +20,6 @@ import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
-import com.google.common.base.Optional;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer;
@@ -29,6 +28,7 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.List;
+import java.util.Optional;
import javax.annotation.Nonnull;
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
diff --git a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/ReflexiveReaderCustomizer.java b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/ReflexiveReaderCustomizer.java
index 087873306..a70ccef53 100644
--- a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/ReflexiveReaderCustomizer.java
+++ b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/ReflexiveReaderCustomizer.java
@@ -18,12 +18,12 @@ package io.fd.honeycomb.translate.util.read;
import static com.google.common.base.Preconditions.checkArgument;
-import com.google.common.base.Optional;
import com.google.common.collect.Lists;
import io.fd.honeycomb.translate.util.ReflectionUtils;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Collections;
+import java.util.Optional;
import javax.annotation.Nonnull;
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.Augmentation;
diff --git a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/cache/DumpCacheManager.java b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/cache/DumpCacheManager.java
index a0856793d..a9e958240 100644
--- a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/cache/DumpCacheManager.java
+++ b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/cache/DumpCacheManager.java
@@ -20,10 +20,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static java.util.Objects.nonNull;
-import com.google.common.base.Optional;
import io.fd.honeycomb.translate.ModificationCache;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.util.read.cache.noop.NoopDumpPostProcessingFunction;
+import java.util.Optional;
import javax.annotation.Nonnull;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
@@ -59,7 +59,7 @@ public final class DumpCacheManager<T, U> {
* @param cache modification cache of current transaction
* @throws ReadFailedException if execution of dumping request failed
* @returns If present in cache ,returns cached instance, if not, tries to dump data using provided executor,
- * otherwise Optional.absent()
+ * otherwise Optional.empty()
*/
public Optional<T> getDump(@Nonnull final InstanceIdentifier<?> identifier,
@Nonnull final ModificationCache cache)
@@ -75,7 +75,7 @@ public final class DumpCacheManager<T, U> {
* @param dumpParams parameters to configure dump request
* @throws ReadFailedException if execution of dumping request failed
* @returns If present in cache ,returns cached instance, if not, tries to dump data using provided executor,
- * otherwise Optional.absent()
+ * otherwise Optional.empty()
*/
public Optional<T> getDump(@Nonnull final InstanceIdentifier<?> identifier,
@Nonnull final ModificationCache cache, final U dumpParams)
diff --git a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/write/BindingBrokerWriter.java b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/write/BindingBrokerWriter.java
index 60a81a77a..22e30bd9e 100644
--- a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/write/BindingBrokerWriter.java
+++ b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/write/BindingBrokerWriter.java
@@ -16,20 +16,20 @@
package io.fd.honeycomb.translate.util.write;
-import com.google.common.util.concurrent.CheckedFuture;
+import static org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION;
+
+import com.google.common.util.concurrent.FluentFuture;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.honeycomb.translate.write.Writer;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
+import java.util.concurrent.ExecutionException;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-
-import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.WriteTransaction;
+import org.opendaylight.mdsal.common.api.CommitInfo;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
/**
* Simple DataBroker backed writer allowing to delegate writes to different brokers.
@@ -55,11 +55,11 @@ public final class BindingBrokerWriter<D extends DataObject> implements Writer<D
@Nonnull final WriteContext ctx) throws WriteFailedException {
final WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
writeTransaction.put(CONFIGURATION, (InstanceIdentifier<DataObject>) id, dataAfter);
- final CheckedFuture<Void, TransactionCommitFailedException> result = writeTransaction.submit();
+ final FluentFuture<? extends CommitInfo> result = writeTransaction.commit();
try {
- result.checkedGet();
- } catch (TransactionCommitFailedException e) {
- throw new WriteFailedException(id, e);
+ result.get();
+ } catch (InterruptedException | ExecutionException ex) {
+ throw new WriteFailedException(id, ex);
}
}
diff --git a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/write/LegacyBindingBrokerWriter.java b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/write/LegacyBindingBrokerWriter.java
new file mode 100644
index 000000000..f6c2f0ffa
--- /dev/null
+++ b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/write/LegacyBindingBrokerWriter.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2019 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.translate.util.write;
+
+import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION;
+
+import com.google.common.util.concurrent.FluentFuture;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import io.fd.honeycomb.translate.write.Writer;
+import java.util.concurrent.ExecutionException;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.mdsal.common.api.CommitInfo;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * Simple DataBroker backed writer allowing to delegate writes to different brokers.
+ */
+public final class LegacyBindingBrokerWriter<D extends DataObject> implements Writer<D> {
+ private final InstanceIdentifier<D> instanceIdentifier;
+ private final DataBroker dataBroker;
+
+ public LegacyBindingBrokerWriter(final InstanceIdentifier<D> instanceIdentifier, final DataBroker dataBroker) {
+ this.instanceIdentifier = instanceIdentifier;
+ this.dataBroker = dataBroker;
+ }
+
+ @Nonnull
+ @Override
+ public InstanceIdentifier<D> getManagedDataObjectType() {
+ return instanceIdentifier;
+ }
+
+ @Override
+ public void processModification(@Nonnull final InstanceIdentifier<? extends DataObject> id,
+ @Nullable final DataObject dataBefore, @Nullable final DataObject dataAfter,
+ @Nonnull final WriteContext ctx) throws WriteFailedException {
+ final WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
+ writeTransaction.put(CONFIGURATION, (InstanceIdentifier<DataObject>) id, dataAfter);
+ final FluentFuture<? extends CommitInfo> result = writeTransaction.commit();
+ try {
+ result.get();
+ } catch (InterruptedException | ExecutionException ex) {
+ throw new WriteFailedException(id, ex);
+ }
+ }
+
+ @Override
+ public boolean supportsDirectUpdate() {
+ return false;
+ }
+}
diff --git a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/write/TransactionWriteContext.java b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/write/TransactionWriteContext.java
index e853d8632..d97b5b715 100644
--- a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/write/TransactionWriteContext.java
+++ b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/write/TransactionWriteContext.java
@@ -18,17 +18,17 @@ package io.fd.honeycomb.translate.util.write;
import static com.google.common.base.Preconditions.checkState;
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FluentFuture;
import io.fd.honeycomb.translate.MappingContext;
import io.fd.honeycomb.translate.ModificationCache;
import io.fd.honeycomb.translate.write.WriteContext;
import java.util.Map;
+import java.util.Optional;
+import java.util.concurrent.ExecutionException;
import javax.annotation.Nonnull;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -39,15 +39,15 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
*/
public final class TransactionWriteContext implements WriteContext {
- private final DOMDataReadOnlyTransaction beforeTx;
- private final DOMDataReadOnlyTransaction afterTx;
+ private final DOMDataTreeReadTransaction beforeTx;
+ private final DOMDataTreeReadTransaction afterTx;
private final ModificationCache ctx;
private final BindingNormalizedNodeSerializer serializer;
private final MappingContext mappingContext;
public TransactionWriteContext(final BindingNormalizedNodeSerializer serializer,
- final DOMDataReadOnlyTransaction beforeTx,
- final DOMDataReadOnlyTransaction afterTx,
+ final DOMDataTreeReadTransaction beforeTx,
+ final DOMDataTreeReadTransaction afterTx,
final MappingContext mappingContext) {
this.serializer = serializer;
this.beforeTx = beforeTx;
@@ -70,18 +70,17 @@ public final class TransactionWriteContext implements WriteContext {
private <T extends DataObject> Optional<T> read(final InstanceIdentifier<T> currentId,
- final DOMDataReadOnlyTransaction tx) {
+ final DOMDataTreeReadTransaction tx) {
final YangInstanceIdentifier path = serializer.toYangInstanceIdentifier(currentId);
- final CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read =
- tx.read(LogicalDatastoreType.CONFIGURATION, path);
+ final FluentFuture<Optional<NormalizedNode<?, ?>>> read = tx.read(LogicalDatastoreType.CONFIGURATION, path);
try {
// TODO HONEYCOMB-169 once the APIs are asynchronous use just Futures.transform
- final Optional<NormalizedNode<?, ?>> optional = read.checkedGet();
+ final Optional<NormalizedNode<?, ?>> optional = read.get();
if (!optional.isPresent()) {
- return Optional.absent();
+ return Optional.empty();
}
final NormalizedNode<?, ?> data = optional.get();
@@ -91,7 +90,7 @@ public final class TransactionWriteContext implements WriteContext {
checkState(targetType.isAssignableFrom(entry.getValue().getClass()),
"Unexpected data object type, should be: %s, but was: %s", targetType, entry.getValue().getClass());
return Optional.of(targetType.cast(entry.getValue()));
- } catch (ReadFailedException e) {
+ } catch (InterruptedException | ExecutionException e) {
throw new IllegalStateException("Unable to perform read", e);
}
}