summaryrefslogtreecommitdiffstats
path: root/infra/translate-impl/src/main/java
diff options
context:
space:
mode:
authorMichal Cmarada <michal.cmarada@pantheon.tech>2018-09-25 11:15:35 +0200
committerMichal Cmarada <michal.cmarada@pantheon.tech>2018-09-25 11:22:18 +0200
commit556a0f59abc9b09005d40945bc20948d69e4f98e (patch)
tree76d795ae59aba49521fc4fdc7d65062c946147be /infra/translate-impl/src/main/java
parent46bcceb927b1bce07c1c9517f45470703293eb84 (diff)
Bump ODL dependencies to Fluorine (HONEYCOMB-433)
Change-Id: I142ebd2899272feff00abe7d4bae708f093ee3ec Signed-off-by: Michal Cmarada <michal.cmarada@pantheon.tech>
Diffstat (limited to 'infra/translate-impl/src/main/java')
-rw-r--r--infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/GenericInitReader.java18
-rw-r--r--infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/GenericListWriter.java2
-rw-r--r--infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/registry/SubtreeWriter.java16
3 files changed, 33 insertions, 3 deletions
diff --git a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/GenericInitReader.java b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/GenericInitReader.java
index e55bc8ab6..147cbd3cc 100644
--- a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/GenericInitReader.java
+++ b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/GenericInitReader.java
@@ -19,6 +19,9 @@ package io.fd.honeycomb.translate.impl.read;
import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION;
import com.google.common.base.Optional;
+import com.google.common.util.concurrent.FluentFuture;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.MoreExecutors;
import io.fd.honeycomb.translate.read.InitFailedException;
import io.fd.honeycomb.translate.read.InitReader;
import io.fd.honeycomb.translate.read.ReadContext;
@@ -26,8 +29,10 @@ import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.Initialized;
import io.fd.honeycomb.translate.spi.read.InitializingReaderCustomizer;
import javax.annotation.Nonnull;
+import org.checkerframework.checker.nullness.compatqual.NullableDecl;
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.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -68,6 +73,17 @@ public final class GenericInitReader<O extends DataObject, B extends Builder<O>>
static void writeInit(final DataBroker broker, final Initialized<? extends DataObject> init) {
final WriteTransaction writeTx = broker.newWriteOnlyTransaction();
writeTx.merge(CONFIGURATION, (InstanceIdentifier) init.getId(), init.getData(), true);
- writeTx.submit();
+ FluentFuture<? extends CommitInfo> future = writeTx.commit();
+ future.addCallback(new FutureCallback<CommitInfo>() {
+ @Override
+ public void onSuccess(@NullableDecl final CommitInfo commitInfo) {
+ LOG.debug("Transaction: {} successfully committed.", writeTx);
+ }
+
+ @Override
+ public void onFailure(final Throwable throwable) {
+ LOG.warn("Transaction: {} failed.", writeTx);
+ }
+ }, MoreExecutors.directExecutor());
}
}
diff --git a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/GenericListWriter.java b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/GenericListWriter.java
index ff683b810..cc4800a65 100644
--- a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/GenericListWriter.java
+++ b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/GenericListWriter.java
@@ -92,7 +92,7 @@ public final class GenericListWriter<D extends DataObject & Identifiable<K>, K e
// Make sure the key is present
if (isWildcarded(id)) {
return RWUtils.replaceLastInId(id,
- new InstanceIdentifier.IdentifiableItem<>(id.getTargetType(), current.getKey()));
+ new InstanceIdentifier.IdentifiableItem<>(id.getTargetType(), current.key()));
} else {
return id;
}
diff --git a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/registry/SubtreeWriter.java b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/registry/SubtreeWriter.java
index e510bc33c..bdda21611 100644
--- a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/registry/SubtreeWriter.java
+++ b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/registry/SubtreeWriter.java
@@ -24,6 +24,7 @@ import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.honeycomb.translate.write.Writer;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -99,7 +100,20 @@ final class SubtreeWriter<D extends DataObject> implements Writer<D> {
}
return false;
}
- return handledChildTypes.contains(instanceIdentifier);
+ return handledChildTypes.parallelStream()
+ .filter(childIiD -> instanceIdentifier.getTargetType().equals(childIiD.getTargetType()))
+ .anyMatch(instanceIdentifier1 -> isPathEqual(instanceIdentifier, instanceIdentifier1));
+ }
+
+ private boolean isPathEqual(@Nonnull final InstanceIdentifier<?> iid, final InstanceIdentifier<?> childIiD) {
+ // Verifying path because the same type can be used in several places.
+ Iterator<InstanceIdentifier.PathArgument> pathArguments = iid.getPathArguments().iterator();
+ for (final InstanceIdentifier.PathArgument pathArgument : childIiD.getPathArguments()) {
+ if (!pathArguments.hasNext() || !pathArgument.getType().equals(pathArguments.next().getType())) {
+ return false;
+ }
+ }
+ return true;
}
@Override