From 4a3dce3e0e59df4e091b4f8d4efc3e20831bf22f Mon Sep 17 00:00:00 2001 From: Maros Marsalek Date: Tue, 12 Apr 2016 10:13:06 +0200 Subject: HONEYCOMB-9: Add Read context Change-Id: I42179d5c7244bfe4c62ee1efffad414a1cfe4b0b Signed-off-by: Maros Marsalek --- .../v3po/impl/data/VppConfigDataTree.java | 4 +-- .../v3po/impl/data/VppOperationalDataTree.java | 33 +++++++++++++++---- .../v3po/impl/data/VppReaderRegistry.java | 13 ++++---- .../v3po/impl/trans/r/ChildVppReader.java | 5 ++- .../honeycomb/v3po/impl/trans/r/ListVppReader.java | 4 ++- .../honeycomb/v3po/impl/trans/r/ReadContext.java | 37 ++++++++++++++++++++++ .../v3po/impl/trans/r/ReaderRegistry.java | 4 ++- .../fd/honeycomb/v3po/impl/trans/r/VppReader.java | 8 ++--- .../trans/r/impl/AbstractCompositeVppReader.java | 30 +++++++++++------- .../impl/trans/r/impl/CompositeChildVppReader.java | 11 ++++--- .../impl/trans/r/impl/CompositeListVppReader.java | 18 +++++++---- .../impl/trans/r/impl/CompositeRootVppReader.java | 6 ++-- .../trans/r/impl/spi/ListVppReaderCustomizer.java | 6 ++-- .../trans/r/impl/spi/RootVppReaderCustomizer.java | 5 +-- .../trans/r/util/DelegatingReaderRegistry.java | 15 +++++---- .../impl/trans/r/util/NoopReaderCustomizer.java | 3 +- .../fd/honeycomb/v3po/impl/trans/util/Context.java | 5 +-- .../honeycomb/v3po/impl/trans/w/WriteContext.java | 5 ++- .../impl/trans/w/util/TransactionWriteContext.java | 4 +-- .../v3po/impl/vppstate/BridgeDomainCustomizer.java | 7 ++-- .../v3po/impl/vppstate/VersionCustomizer.java | 4 ++- .../v3po/impl/data/VppOperationalDataTreeTest.java | 18 +++++++---- .../honeycomb/v3po/impl/vppstate/VppStateTest.java | 31 ++++++++++-------- 23 files changed, 189 insertions(+), 87 deletions(-) create mode 100644 v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/ReadContext.java diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppConfigDataTree.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppConfigDataTree.java index 9f34fcbd1..1982bc707 100644 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppConfigDataTree.java +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppConfigDataTree.java @@ -107,9 +107,7 @@ public final class VppConfigDataTree implements VppDataTree { final DOMDataReadOnlyTransaction beforeTx = new VppReadOnlyTransaction(EMPTY_OPERATIONAL, takeSnapshot()); final ConfigSnapshot modificationSnapshot = new ConfigSnapshot(modification); final DOMDataReadOnlyTransaction afterTx = new VppReadOnlyTransaction(EMPTY_OPERATIONAL, modificationSnapshot); - final WriteContext ctx = new TransactionWriteContext(serializer, beforeTx, afterTx); - - try { + try(final WriteContext ctx = new TransactionWriteContext(serializer, beforeTx, afterTx)) { writer.update(nodesBefore, nodesAfter, ctx); } catch (WriterRegistry.BulkUpdateException e) { LOG.warn("Failed to apply all changes", e); diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppOperationalDataTree.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppOperationalDataTree.java index d0acd05a8..d73c22a6d 100644 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppOperationalDataTree.java +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppOperationalDataTree.java @@ -27,7 +27,9 @@ import com.google.common.collect.Multimap; import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.Futures; import io.fd.honeycomb.v3po.impl.trans.ReadFailedException; +import io.fd.honeycomb.v3po.impl.trans.r.ReadContext; import io.fd.honeycomb.v3po.impl.trans.r.ReaderRegistry; +import io.fd.honeycomb.v3po.impl.trans.util.Context; import java.util.Collection; import java.util.Map; import javax.annotation.Nonnull; @@ -82,11 +84,11 @@ public final class VppOperationalDataTree implements ReadableVppDataTree { org.opendaylight.controller.md.sal.common.api.data.ReadFailedException> read( @Nonnull final YangInstanceIdentifier yangInstanceIdentifier) { - try { + try(ReadContext ctx = new ReadContextImpl()) { if (checkNotNull(yangInstanceIdentifier).equals(YangInstanceIdentifier.EMPTY)) { - return Futures.immediateCheckedFuture(readRoot()); + return Futures.immediateCheckedFuture(readRoot(ctx)); } else { - return Futures.immediateCheckedFuture(readNode(yangInstanceIdentifier)); + return Futures.immediateCheckedFuture(readNode(yangInstanceIdentifier, ctx)); } } catch (ReadFailedException e) { return Futures.immediateFailedCheckedFuture( @@ -95,7 +97,8 @@ public final class VppOperationalDataTree implements ReadableVppDataTree { } } - private Optional> readNode(final YangInstanceIdentifier yangInstanceIdentifier) + private Optional> readNode(final YangInstanceIdentifier yangInstanceIdentifier, + final ReadContext ctx) throws ReadFailedException { LOG.debug("VppOperationalDataTree.readNode(), yangInstanceIdentifier={}", yangInstanceIdentifier); final InstanceIdentifier path = serializer.fromYangInstanceIdentifier(yangInstanceIdentifier); @@ -104,7 +107,7 @@ public final class VppOperationalDataTree implements ReadableVppDataTree { final Optional dataObject; - dataObject = readerRegistry.read(path); + dataObject = readerRegistry.read(path, ctx); if (dataObject.isPresent()) { final NormalizedNode value = toNormalizedNodeFunction(path).apply(dataObject.get()); return Optional.>fromNullable(value); @@ -113,7 +116,7 @@ public final class VppOperationalDataTree implements ReadableVppDataTree { } } - private Optional> readRoot() throws ReadFailedException { + private Optional> readRoot(final ReadContext ctx) throws ReadFailedException { LOG.debug("VppOperationalDataTree.readRoot()"); final DataContainerNodeAttrBuilder dataNodeBuilder = @@ -121,7 +124,7 @@ public final class VppOperationalDataTree implements ReadableVppDataTree { .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(SchemaContext.NAME)); final Multimap, ? extends DataObject> dataObjects = - readerRegistry.readAll(); + readerRegistry.readAll(ctx); for (final InstanceIdentifier instanceIdentifier : dataObjects.keySet()) { final YangInstanceIdentifier rootElementId = serializer.toYangInstanceIdentifier(instanceIdentifier); @@ -187,4 +190,20 @@ public final class VppOperationalDataTree implements ReadableVppDataTree { } }; } + + private static final class ReadContextImpl implements ReadContext { + public final Context ctx = new Context(); + + @Nonnull + @Override + public Context getContext() { + return ctx; + } + + @Override + public void close() { + // Make sure to clear the storage in case some customizer stored it to prevent memory leaks + ctx.close(); + } + } } diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppReaderRegistry.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppReaderRegistry.java index 72d17b7e2..fc6a51add 100644 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppReaderRegistry.java +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppReaderRegistry.java @@ -20,6 +20,7 @@ import com.google.common.base.Optional; import com.google.common.collect.Multimap; import io.fd.honeycomb.v3po.impl.trans.ReadFailedException; import io.fd.honeycomb.v3po.impl.trans.r.ChildVppReader; +import io.fd.honeycomb.v3po.impl.trans.r.ReadContext; import io.fd.honeycomb.v3po.impl.trans.r.ReaderRegistry; import io.fd.honeycomb.v3po.impl.trans.r.VppReader; import io.fd.honeycomb.v3po.impl.trans.r.impl.CompositeChildVppReader; @@ -96,16 +97,16 @@ public class VppReaderRegistry implements ReaderRegistry { @Nonnull @Override - public Multimap, ? extends DataObject> readAll() - throws io.fd.honeycomb.v3po.impl.trans.ReadFailedException { - return reader.readAll(); + public Multimap, ? extends DataObject> readAll( + @Nonnull final ReadContext ctx) throws io.fd.honeycomb.v3po.impl.trans.ReadFailedException { + return reader.readAll(ctx); } @Nonnull @Override - public Optional read(@Nonnull final InstanceIdentifier id) - throws ReadFailedException { - return reader.read(id); + public Optional read(@Nonnull final InstanceIdentifier id, + @Nonnull final ReadContext ctx) throws ReadFailedException { + return reader.read(id, ctx); } @Nonnull diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/ChildVppReader.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/ChildVppReader.java index aad3080d4..8135e8cd2 100644 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/ChildVppReader.java +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/ChildVppReader.java @@ -39,10 +39,13 @@ public interface ChildVppReader extends VppReader { * determine the exact position within more complex subtrees. * @param parentBuilder Builder of parent DataObject. Objects read on this level (if any) must be placed into the * parent builder. + * @param ctx Read context + * * @throws ReadFailedException if read was unsuccessful */ void read(@Nonnull final InstanceIdentifier id, - @Nonnull final Builder parentBuilder) throws ReadFailedException; + @Nonnull final Builder parentBuilder, + @Nonnull final ReadContext ctx) throws ReadFailedException; } diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/ListVppReader.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/ListVppReader.java index ce392c6bc..e37c76634 100644 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/ListVppReader.java +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/ListVppReader.java @@ -37,10 +37,12 @@ public interface ListVppReader, K extends * Read all elements in this list * * @param id Wildcarded identifier of list managed by this reader + * @param ctx Read context * * @return List of all entries in this list * @throws ReadFailedException if read was unsuccessful */ @Nonnull - List readList(@Nonnull final InstanceIdentifier id) throws ReadFailedException; + List readList(@Nonnull final InstanceIdentifier id, + @Nonnull final ReadContext ctx) throws ReadFailedException; } diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/ReadContext.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/ReadContext.java new file mode 100644 index 000000000..6aa64b3b9 --- /dev/null +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/ReadContext.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2016 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.v3po.impl.trans.r; + +import io.fd.honeycomb.v3po.impl.trans.util.Context; +import javax.annotation.Nonnull; + +/** + * Read Context + */ +public interface ReadContext extends AutoCloseable { + + /** + * Get key value storage for customizers + * + * @return Context for customizers + */ + @Nonnull + Context getContext(); + + @Override + void close(); +} diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/ReaderRegistry.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/ReaderRegistry.java index 6a9937679..a1175533b 100644 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/ReaderRegistry.java +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/ReaderRegistry.java @@ -33,10 +33,12 @@ public interface ReaderRegistry extends VppReader { * Performs read on all registered root readers and merges the results into a Multimap. Keys represent identifiers * for root DataObjects from the data tree modeled by YANG. * + * @param ctx Read context + * * @return multimap that preserves deterministic iteration order across non-distinct key values * @throws ReadFailedException if read was unsuccessful */ @Nonnull - Multimap, ? extends DataObject> readAll() + Multimap, ? extends DataObject> readAll(@Nonnull final ReadContext ctx) throws ReadFailedException; } diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/VppReader.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/VppReader.java index 02189e42d..ff42b57f0 100644 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/VppReader.java +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/VppReader.java @@ -32,8 +32,6 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; @Beta public interface VppReader extends SubtreeManager { - // TODO add vpp read context that will be shared by all readers during a single read to keep useful information - // preventing possible duplicate reads from VPP // TODO make async /** @@ -42,11 +40,13 @@ public interface VppReader extends SubtreeManager { * @param id unique identifier of subtree to be read. The subtree must contain managed data object type. For * identifiers pointing below node managed by this reader, it's reader's responsibility to filter out the * right node or to delegate the read to a child reader. + * @param ctx Read context + * * @return List of DataObjects identified by id. If the ID points to a single node, it will be wrapped in a list * @throws ReadFailedException if read was unsuccessful */ @Nonnull - Optional read(@Nonnull final InstanceIdentifier id) throws - ReadFailedException; + Optional read(@Nonnull final InstanceIdentifier id, + @Nonnull ReadContext ctx) throws ReadFailedException; } diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/impl/AbstractCompositeVppReader.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/impl/AbstractCompositeVppReader.java index 061cfc9f3..436aace84 100644 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/impl/AbstractCompositeVppReader.java +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/impl/AbstractCompositeVppReader.java @@ -24,6 +24,7 @@ import com.google.common.base.Predicate; import com.google.common.collect.Iterables; import io.fd.honeycomb.v3po.impl.trans.ReadFailedException; import io.fd.honeycomb.v3po.impl.trans.r.ChildVppReader; +import io.fd.honeycomb.v3po.impl.trans.r.ReadContext; import io.fd.honeycomb.v3po.impl.trans.r.VppReader; import io.fd.honeycomb.v3po.impl.trans.util.ReflectionUtils; import io.fd.honeycomb.v3po.impl.trans.util.VppRWUtils; @@ -68,8 +69,10 @@ abstract class AbstractCompositeVppReader readCurrent(final InstanceIdentifier id) throws + protected Optional readCurrent(final InstanceIdentifier id, + @Nonnull final ReadContext ctx) throws ReadFailedException { LOG.debug("{}: Reading current: {}", this, id); final B builder = getBuilder(id); @@ -77,17 +80,17 @@ abstract class AbstractCompositeVppReader> child : childReaders.values()) { LOG.debug("{}: Reading child from: {}", this, child); - child.read(id, builder); + child.read(id, builder, ctx); } for (ChildVppReader> child : augReaders.values()) { LOG.debug("{}: Reading augment from: {}", this, child); - child.read(id, builder); + child.read(id, builder, ctx); } // Need to check whether anything was filled in to determine if data is present or not. @@ -103,17 +106,19 @@ abstract class AbstractCompositeVppReader read(@Nonnull final InstanceIdentifier id) + public Optional read(@Nonnull final InstanceIdentifier id, + @Nonnull final ReadContext ctx) throws ReadFailedException { LOG.trace("{}: Reading : {}", this, id); if (id.getTargetType().equals(getManagedDataObjectType().getTargetType())) { - return readCurrent((InstanceIdentifier) id); + return readCurrent((InstanceIdentifier) id, ctx); } else { - return readSubtree(id); + return readSubtree(id, ctx); } } - private Optional readSubtree(final InstanceIdentifier id) + private Optional readSubtree(final InstanceIdentifier id, + @Nonnull final ReadContext ctx) throws ReadFailedException { LOG.debug("{}: Reading subtree: {}", this, id); final Class next = VppRWUtils.getNextId(id, getManagedDataObjectType()).getType(); @@ -121,12 +126,12 @@ abstract class AbstractCompositeVppReader currentId = VppRWUtils.cutId(id, getManagedDataObjectType()); - final Optional current = readCurrent(currentId); + final Optional current = readCurrent(currentId, ctx); // then perform post-reading filtering (return only requested sub-node) final Optional readSubtree = current.isPresent() ? filterSubtree(current.get(), id, getManagedDataObjectType().getTargetType()) @@ -142,9 +147,10 @@ abstract class AbstractCompositeVppReader id, B builder) throws - ReadFailedException; + protected abstract void readCurrentAttributes(@Nonnull final InstanceIdentifier id, @Nonnull final B builder, + @Nonnull final ReadContext ctx) throws ReadFailedException; /** * Return new instance of a builder object for current node diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/impl/CompositeChildVppReader.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/impl/CompositeChildVppReader.java index f18a5b38a..e6872d131 100644 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/impl/CompositeChildVppReader.java +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/impl/CompositeChildVppReader.java @@ -20,6 +20,7 @@ import com.google.common.annotations.Beta; import com.google.common.base.Optional; import io.fd.honeycomb.v3po.impl.trans.ReadFailedException; import io.fd.honeycomb.v3po.impl.trans.r.ChildVppReader; +import io.fd.honeycomb.v3po.impl.trans.r.ReadContext; import io.fd.honeycomb.v3po.impl.trans.r.impl.spi.ChildVppReaderCustomizer; import io.fd.honeycomb.v3po.impl.trans.util.VppRWUtils; import java.util.List; @@ -79,8 +80,9 @@ public final class CompositeChildVppReader parentId, - @Nonnull final Builder parentBuilder) throws ReadFailedException { - final Optional read = readCurrent(VppRWUtils.appendTypeToId(parentId, getManagedDataObjectType())); + @Nonnull final Builder parentBuilder, + @Nonnull final ReadContext ctx) throws ReadFailedException { + final Optional read = readCurrent(VppRWUtils.appendTypeToId(parentId, getManagedDataObjectType()), ctx); if(read.isPresent()) { customizer.merge(parentBuilder, read.get()); @@ -88,9 +90,10 @@ public final class CompositeChildVppReader id, @Nonnull final B builder) + protected void readCurrentAttributes(@Nonnull final InstanceIdentifier id, @Nonnull final B builder, + @Nonnull final ReadContext ctx) throws ReadFailedException { - customizer.readCurrentAttributes(id, builder); + customizer.readCurrentAttributes(id, builder, ctx.getContext()); } @Override diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/impl/CompositeListVppReader.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/impl/CompositeListVppReader.java index a9ca3e788..9d7ad3446 100644 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/impl/CompositeListVppReader.java +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/impl/CompositeListVppReader.java @@ -23,6 +23,7 @@ import com.google.common.base.Optional; import io.fd.honeycomb.v3po.impl.trans.ReadFailedException; import io.fd.honeycomb.v3po.impl.trans.r.ChildVppReader; import io.fd.honeycomb.v3po.impl.trans.r.ListVppReader; +import io.fd.honeycomb.v3po.impl.trans.r.ReadContext; import io.fd.honeycomb.v3po.impl.trans.r.impl.spi.ListVppReaderCustomizer; import io.fd.honeycomb.v3po.impl.trans.util.VppRWUtils; import java.util.ArrayList; @@ -91,19 +92,21 @@ public final class CompositeListVppReader @Override public void read(@Nonnull final InstanceIdentifier id, - @Nonnull final Builder parentBuilder) throws ReadFailedException { + @Nonnull final Builder parentBuilder, + @Nonnull final ReadContext ctx) throws ReadFailedException { // Create ID pointing to current node final InstanceIdentifier currentId = VppRWUtils.appendTypeToId(id, getManagedDataObjectType()); // Read all, since current ID is definitely wildcarded - final List ifcs = readList(currentId); + final List ifcs = readList(currentId, ctx); customizer.merge(parentBuilder, ifcs); } @Override @Nonnull - public List readList(@Nonnull final InstanceIdentifier id) throws ReadFailedException { + public List readList(@Nonnull final InstanceIdentifier id, + @Nonnull final ReadContext ctx) throws ReadFailedException { LOG.trace("{}: Reading all list entries", this); - final List allIds = customizer.getAllIds(id); + final List allIds = customizer.getAllIds(id, ctx.getContext()); LOG.debug("{}: Reading list entries for: {}", this, allIds); final ArrayList allEntries = new ArrayList<>(allIds.size()); @@ -111,7 +114,7 @@ public final class CompositeListVppReader final InstanceIdentifier.IdentifiableItem currentBdItem = VppRWUtils.getCurrentIdItem(id, key); final InstanceIdentifier keyedId = VppRWUtils.replaceLastInId(id, currentBdItem); - final Optional read = readCurrent(keyedId); + final Optional read = readCurrent(keyedId, ctx); final DataObject singleItem = read.get(); checkArgument(getManagedDataObjectType().getTargetType().isAssignableFrom(singleItem.getClass())); allEntries.add(getManagedDataObjectType().getTargetType().cast(singleItem)); @@ -120,9 +123,10 @@ public final class CompositeListVppReader } @Override - protected void readCurrentAttributes(@Nonnull final InstanceIdentifier id, @Nonnull final B builder) + protected void readCurrentAttributes(@Nonnull final InstanceIdentifier id, @Nonnull final B builder, + @Nonnull final ReadContext ctx) throws ReadFailedException { - customizer.readCurrentAttributes(id, builder); + customizer.readCurrentAttributes(id, builder, ctx.getContext()); } @Override diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/impl/CompositeRootVppReader.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/impl/CompositeRootVppReader.java index d5d82e7dd..34d4dce74 100644 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/impl/CompositeRootVppReader.java +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/impl/CompositeRootVppReader.java @@ -19,6 +19,7 @@ package io.fd.honeycomb.v3po.impl.trans.r.impl; import com.google.common.annotations.Beta; import io.fd.honeycomb.v3po.impl.trans.ReadFailedException; import io.fd.honeycomb.v3po.impl.trans.r.ChildVppReader; +import io.fd.honeycomb.v3po.impl.trans.r.ReadContext; import io.fd.honeycomb.v3po.impl.trans.r.VppReader; import io.fd.honeycomb.v3po.impl.trans.r.impl.spi.RootVppReaderCustomizer; import io.fd.honeycomb.v3po.impl.trans.util.VppRWUtils; @@ -77,9 +78,10 @@ public final class CompositeRootVppReader id, @Nonnull final B builder) + protected void readCurrentAttributes(@Nonnull final InstanceIdentifier id, @Nonnull final B builder, + @Nonnull final ReadContext ctx) throws ReadFailedException { - customizer.readCurrentAttributes(id, builder); + customizer.readCurrentAttributes(id, builder, ctx.getContext()); } @Override diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/impl/spi/ListVppReaderCustomizer.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/impl/spi/ListVppReaderCustomizer.java index 694f21c9d..c87050bd6 100644 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/impl/spi/ListVppReaderCustomizer.java +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/impl/spi/ListVppReaderCustomizer.java @@ -17,6 +17,7 @@ package io.fd.honeycomb.v3po.impl.trans.r.impl.spi; import com.google.common.annotations.Beta; +import io.fd.honeycomb.v3po.impl.trans.util.Context; import java.util.List; import javax.annotation.Nonnull; import org.opendaylight.yangtools.concepts.Builder; @@ -39,10 +40,11 @@ public interface ListVppReaderCustomizer, /** * Return list with IDs of all list nodes to be read. * - * @param id wildcarded ID pointing to list node managed by enclosing reader + * @param id Wildcarded ID pointing to list node managed by enclosing reader + * @param context Read context */ @Nonnull - List getAllIds(@Nonnull final InstanceIdentifier id); + List getAllIds(@Nonnull final InstanceIdentifier id, @Nonnull final Context context); // TODO does it make sense with vpp APIs ? Should we replace it with a simple readAll ? /** diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/impl/spi/RootVppReaderCustomizer.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/impl/spi/RootVppReaderCustomizer.java index 299e94367..b35a1c66c 100644 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/impl/spi/RootVppReaderCustomizer.java +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/impl/spi/RootVppReaderCustomizer.java @@ -18,6 +18,7 @@ package io.fd.honeycomb.v3po.impl.trans.r.impl.spi; import com.google.common.annotations.Beta; import io.fd.honeycomb.v3po.impl.trans.ReadFailedException; +import io.fd.honeycomb.v3po.impl.trans.util.Context; import javax.annotation.Nonnull; import org.opendaylight.yangtools.concepts.Builder; import org.opendaylight.yangtools.yang.binding.DataObject; @@ -46,6 +47,6 @@ public interface RootVppReaderCustomizer id, @Nonnull final B builder) throws - ReadFailedException; + void readCurrentAttributes(@Nonnull final InstanceIdentifier id, @Nonnull final B builder, + @Nonnull final Context ctx) throws ReadFailedException; } diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/util/DelegatingReaderRegistry.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/util/DelegatingReaderRegistry.java index 20524073e..51334e6db 100644 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/util/DelegatingReaderRegistry.java +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/util/DelegatingReaderRegistry.java @@ -24,6 +24,7 @@ import com.google.common.collect.LinkedListMultimap; import com.google.common.collect.Multimap; import io.fd.honeycomb.v3po.impl.trans.ReadFailedException; import io.fd.honeycomb.v3po.impl.trans.r.ListVppReader; +import io.fd.honeycomb.v3po.impl.trans.r.ReadContext; import io.fd.honeycomb.v3po.impl.trans.r.ReaderRegistry; import io.fd.honeycomb.v3po.impl.trans.r.VppReader; import io.fd.honeycomb.v3po.impl.trans.util.VppRWUtils; @@ -59,8 +60,9 @@ public final class DelegatingReaderRegistry implements ReaderRegistry { @Override @Nonnull - public Multimap, ? extends DataObject> readAll() - throws ReadFailedException { + public Multimap, ? extends DataObject> readAll( + @Nonnull final ReadContext ctx) throws ReadFailedException { + LOG.debug("Reading from all delegates: {}", this); LOG.trace("Reading from all delegates: {}", rootReaders.values()); @@ -70,12 +72,12 @@ public final class DelegatingReaderRegistry implements ReaderRegistry { if (rootReader instanceof ListVppReader) { final List listEntries = - ((ListVppReader) rootReader).readList(rootReader.getManagedDataObjectType()); + ((ListVppReader) rootReader).readList(rootReader.getManagedDataObjectType(), ctx); if (!listEntries.isEmpty()) { objects.putAll(rootReader.getManagedDataObjectType(), listEntries); } } else { - final Optional read = rootReader.read(rootReader.getManagedDataObjectType()); + final Optional read = rootReader.read(rootReader.getManagedDataObjectType(), ctx); if (read.isPresent()) { objects.putAll(rootReader.getManagedDataObjectType(), Collections.singletonList(read.get())); } @@ -87,7 +89,8 @@ public final class DelegatingReaderRegistry implements ReaderRegistry { @Nonnull @Override - public Optional read(@Nonnull final InstanceIdentifier id) + public Optional read(@Nonnull final InstanceIdentifier id, + @Nonnull final ReadContext ctx) throws ReadFailedException { final InstanceIdentifier.PathArgument first = checkNotNull( Iterables.getFirst(id.getPathArguments(), null), "Empty id"); @@ -95,7 +98,7 @@ public final class DelegatingReaderRegistry implements ReaderRegistry { checkNotNull(vppReader, "Unable to read %s. Missing reader. Current readers for: %s", id, rootReaders.keySet()); LOG.debug("Reading from delegate: {}", vppReader); - return vppReader.read(id); + return vppReader.read(id, ctx); } /** diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/util/NoopReaderCustomizer.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/util/NoopReaderCustomizer.java index 1ce09308a..657af97f4 100644 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/util/NoopReaderCustomizer.java +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/r/util/NoopReaderCustomizer.java @@ -17,6 +17,7 @@ package io.fd.honeycomb.v3po.impl.trans.r.util; import io.fd.honeycomb.v3po.impl.trans.r.impl.spi.RootVppReaderCustomizer; +import io.fd.honeycomb.v3po.impl.trans.util.Context; import org.opendaylight.yangtools.concepts.Builder; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; @@ -24,7 +25,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public abstract class NoopReaderCustomizer> implements RootVppReaderCustomizer { @Override - public void readCurrentAttributes(InstanceIdentifier id, final B builder) { + public void readCurrentAttributes(InstanceIdentifier id, final B builder, final Context context) { // Noop } } diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/util/Context.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/util/Context.java index 6efcf2e28..089d22957 100644 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/util/Context.java +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/util/Context.java @@ -22,7 +22,7 @@ import java.util.HashMap; /** * Simple context class that provides transient storage during one or more read/write operations */ -public class Context { +public class Context implements AutoCloseable { protected final HashMap map; @@ -42,7 +42,8 @@ public class Context { return map.put(o, o2); } - public void close() throws Exception { + @Override + public void close() { map.clear(); } } diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/w/WriteContext.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/w/WriteContext.java index 3aaf83250..191fdf857 100644 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/w/WriteContext.java +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/w/WriteContext.java @@ -27,7 +27,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; * Context providing information about current state of DataTree to writers */ @Beta -public interface WriteContext { +public interface WriteContext extends AutoCloseable { /** * Read any data object before current modification was applied @@ -54,4 +54,7 @@ public interface WriteContext { */ @Nonnull Context getContext(); + + @Override + void close(); } diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/w/util/TransactionWriteContext.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/w/util/TransactionWriteContext.java index 8efcc6189..21e5f19ce 100644 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/w/util/TransactionWriteContext.java +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/w/util/TransactionWriteContext.java @@ -34,7 +34,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; /** * Transaction based WriteContext */ -public final class TransactionWriteContext implements WriteContext, AutoCloseable { +public final class TransactionWriteContext implements WriteContext { private final DOMDataReadOnlyTransaction beforeTx; private final DOMDataReadOnlyTransaction afterTx; @@ -95,7 +95,7 @@ public final class TransactionWriteContext implements WriteContext, AutoCloseabl * Does not close the transactions */ @Override - public void close() throws Exception { + public void close() { ctx.close(); } } diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/vppstate/BridgeDomainCustomizer.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/vppstate/BridgeDomainCustomizer.java index 8784175b4..08daa4e40 100644 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/vppstate/BridgeDomainCustomizer.java +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/vppstate/BridgeDomainCustomizer.java @@ -18,6 +18,7 @@ package io.fd.honeycomb.v3po.impl.vppstate; import com.google.common.collect.Lists; import io.fd.honeycomb.v3po.impl.trans.r.impl.spi.ListVppReaderCustomizer; +import io.fd.honeycomb.v3po.impl.trans.util.Context; import io.fd.honeycomb.v3po.impl.trans.util.VppApiCustomizer; import java.util.ArrayList; import java.util.List; @@ -48,7 +49,7 @@ public final class BridgeDomainCustomizer extends VppApiCustomizer @Override public void readCurrentAttributes(@Nonnull final InstanceIdentifier id, - @Nonnull final BridgeDomainBuilder builder) { + @Nonnull final BridgeDomainBuilder builder, @Nonnull final Context context) { final BridgeDomainKey key = id.firstKeyOf(id.getTargetType()); // TODO find out if bd exists based on name and if not return @@ -113,11 +114,13 @@ public final class BridgeDomainCustomizer extends VppApiCustomizer @Nonnull @Override - public List getAllIds(@Nonnull final InstanceIdentifier id) { + public List getAllIds(@Nonnull final InstanceIdentifier id, @Nonnull final Context context) { final int[] bIds = getVppApi().bridgeDomainDump(-1); final List allIds = new ArrayList<>(bIds.length); for (int bId : bIds) { // FIXME this is highly inefficient having to dump all of the bridge domain details + // Use context to store already read information + // TODO Or just remove the getAllIds method and replace with a simple readAll final vppBridgeDomainDetails bridgeDomainDetails = getVppApi().getBridgeDomainDetails(bId); final String bName = bridgeDomainDetails.name; allIds.add(new BridgeDomainKey(bName)); diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/vppstate/VersionCustomizer.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/vppstate/VersionCustomizer.java index d56c4e5a9..4cdacaa1b 100644 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/vppstate/VersionCustomizer.java +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/vppstate/VersionCustomizer.java @@ -17,6 +17,7 @@ package io.fd.honeycomb.v3po.impl.vppstate; import io.fd.honeycomb.v3po.impl.trans.r.impl.spi.ChildVppReaderCustomizer; +import io.fd.honeycomb.v3po.impl.trans.util.Context; import io.fd.honeycomb.v3po.impl.trans.util.VppApiCustomizer; import javax.annotation.Nonnull; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppStateBuilder; @@ -47,7 +48,8 @@ public final class VersionCustomizer } @Override - public void readCurrentAttributes(@Nonnull InstanceIdentifier id, @Nonnull final VersionBuilder builder) { + public void readCurrentAttributes(@Nonnull InstanceIdentifier id, @Nonnull final VersionBuilder builder, + @Nonnull final Context context) { final vppVersion vppVersion = getVppApi().getVppVersion(); builder.setBranch(vppVersion.gitBranch); builder.setName(vppVersion.programName); diff --git a/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VppOperationalDataTreeTest.java b/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VppOperationalDataTreeTest.java index 8939f8f52..493a01912 100644 --- a/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VppOperationalDataTreeTest.java +++ b/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VppOperationalDataTreeTest.java @@ -21,6 +21,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.Matchers.any; +import static org.mockito.Matchers.same; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; @@ -33,6 +34,7 @@ import com.google.common.collect.Iterables; import com.google.common.collect.LinkedListMultimap; import com.google.common.collect.Multimap; import com.google.common.util.concurrent.CheckedFuture; +import io.fd.honeycomb.v3po.impl.trans.r.ReadContext; import io.fd.honeycomb.v3po.impl.trans.r.ReaderRegistry; import java.util.Map; import org.junit.Before; @@ -68,6 +70,8 @@ public class VppOperationalDataTreeTest { private SchemaContext globalContext; @Mock private DataSchemaNode schemaNode; + @Mock + private ReadContext readCtx; @Before public void setUp() { @@ -86,7 +90,7 @@ public class VppOperationalDataTreeTest { doReturn(id).when(serializer).fromYangInstanceIdentifier(yangId); final DataObject dataObject = mock(DataObject.class); - doReturn(Optional.of(dataObject)).when(reader).read(id); + doReturn(Optional.of(dataObject)).when(reader).read(same(id), any(ReadContext.class)); when(serializer.toNormalizedNode(id, dataObject)).thenReturn(entry); final DataContainerChild expectedValue = mock(DataContainerChild.class); @@ -95,7 +99,7 @@ public class VppOperationalDataTreeTest { final CheckedFuture>, ReadFailedException> future = operationalData.read(yangId); verify(serializer).fromYangInstanceIdentifier(yangId); - verify(reader).read(id); + verify(reader).read(same(id), any(ReadContext.class)); final Optional> result = future.get(); assertTrue(result.isPresent()); assertEquals(expectedValue, result.get()); @@ -105,19 +109,19 @@ public class VppOperationalDataTreeTest { public void testReadNonExistingNode() throws Exception { final YangInstanceIdentifier yangId = mock(YangInstanceIdentifier.class); doReturn(id).when(serializer).fromYangInstanceIdentifier(yangId); - doReturn(Optional.absent()).when(reader).read(id); + doReturn(Optional.absent()).when(reader).read(same(id), any(ReadContext.class)); final CheckedFuture>, ReadFailedException> future = operationalData.read(yangId); verify(serializer).fromYangInstanceIdentifier(yangId); - verify(reader).read(id); + verify(reader).read(same(id), any(ReadContext.class)); final Optional> result = future.get(); assertFalse(result.isPresent()); } @Test public void testReadFailed() throws Exception{ - doThrow(io.fd.honeycomb.v3po.impl.trans.ReadFailedException.class).when(reader).readAll(); + doThrow(io.fd.honeycomb.v3po.impl.trans.ReadFailedException.class).when(reader).readAll(any(ReadContext.class)); final CheckedFuture>, ReadFailedException> future = operationalData.read( YangInstanceIdentifier.EMPTY); @@ -138,7 +142,7 @@ public class VppOperationalDataTreeTest { final VppState vppState = mock(VppState.class); Multimap, DataObject> dataObjects = LinkedListMultimap.create(); dataObjects.put(vppStateII, vppState); - doReturn(dataObjects).when(reader).readAll(); + doReturn(dataObjects).when(reader).readAll(any(ReadContext.class)); // Init serializer final YangInstanceIdentifier vppYangId = YangInstanceIdentifier.builder().node(VppState.QNAME).build(); @@ -152,7 +156,7 @@ public class VppOperationalDataTreeTest { final CheckedFuture>, ReadFailedException> future = operationalData.read(YangInstanceIdentifier.EMPTY); - verify(reader).readAll(); + verify(reader).readAll(any(ReadContext.class)); verify(serializer).toYangInstanceIdentifier(vppStateII); verify(serializer).toNormalizedNode(vppStateII, vppState); diff --git a/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/vppstate/VppStateTest.java b/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/vppstate/VppStateTest.java index f44ca52c8..5cb678e3a 100644 --- a/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/vppstate/VppStateTest.java +++ b/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/vppstate/VppStateTest.java @@ -20,11 +20,13 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.mock; import com.google.common.base.Optional; import com.google.common.base.Predicate; import com.google.common.collect.Iterables; import com.google.common.collect.Multimap; +import io.fd.honeycomb.v3po.impl.trans.r.ReadContext; import io.fd.honeycomb.v3po.impl.trans.r.VppReader; import io.fd.honeycomb.v3po.impl.trans.r.impl.CompositeListVppReader; import io.fd.honeycomb.v3po.impl.trans.r.impl.CompositeRootVppReader; @@ -73,11 +75,14 @@ public class VppStateTest { private DelegatingReaderRegistry readerRegistry; private vppBridgeDomainDetails bdDetails; private vppBridgeDomainDetails bdDetails2; + private ReadContext ctx; @Before public void setUp() throws Exception { api = PowerMockito.mock(vppApi.class); + ctx = mock(ReadContext.class); + bdDetails = new vppBridgeDomainDetails(); setIfcs(bdDetails); setBaseAttrs(bdDetails, "bdn1", 1); @@ -145,7 +150,7 @@ public class VppStateTest { @Test public void testReadAll() throws Exception { - final Multimap, ? extends DataObject> dataObjects = readerRegistry.readAll(); + final Multimap, ? extends DataObject> dataObjects = readerRegistry.readAll(ctx); assertEquals(dataObjects.size(), 1); final DataObject dataObject = Iterables.getOnlyElement(dataObjects.get(Iterables.getOnlyElement(dataObjects.keySet()))); assertTrue(dataObject instanceof VppState); @@ -166,17 +171,17 @@ public class VppStateTest { @Test public void testReadSpecific() throws Exception { - final Optional read = readerRegistry.read(InstanceIdentifier.create(VppState.class)); + final Optional read = readerRegistry.read(InstanceIdentifier.create(VppState.class), ctx); assertTrue(read.isPresent()); assertVersion((VppState) read.get()); } @Test public void testReadBridgeDomains() throws Exception { - VppState readRoot = (VppState) readerRegistry.read(InstanceIdentifier.create(VppState.class)).get(); + VppState readRoot = (VppState) readerRegistry.read(InstanceIdentifier.create(VppState.class), ctx).get(); Optional read = - readerRegistry.read(InstanceIdentifier.create(VppState.class).child(BridgeDomains.class)); + readerRegistry.read(InstanceIdentifier.create(VppState.class).child(BridgeDomains.class), ctx); assertTrue(read.isPresent()); assertEquals(readRoot.getBridgeDomains(), read.get()); } @@ -190,38 +195,38 @@ public class VppStateTest { Optional read = readerRegistry.read(InstanceIdentifier.create(VppState.class).child(BridgeDomains.class).child( BridgeDomain.class, new BridgeDomainKey("bdn1")) - .child(L2Fib.class, new L2FibKey(new PhysAddress("01:02:03:04:05:06")))); + .child(L2Fib.class, new L2FibKey(new PhysAddress("01:02:03:04:05:06"))), ctx); assertTrue(read.isPresent()); // non existing l2fib read = readerRegistry.read(InstanceIdentifier.create(VppState.class).child(BridgeDomains.class).child( BridgeDomain.class, new BridgeDomainKey("bdn1")) - .child(L2Fib.class, new L2FibKey(new PhysAddress("FF:FF:FF:04:05:06")))); + .child(L2Fib.class, new L2FibKey(new PhysAddress("FF:FF:FF:04:05:06"))), ctx); assertFalse(read.isPresent()); } @Test public void testReadBridgeDomainAll() throws Exception { - VppState readRoot = (VppState) readerRegistry.read(InstanceIdentifier.create(VppState.class)).get(); + VppState readRoot = (VppState) readerRegistry.read(InstanceIdentifier.create(VppState.class), ctx).get(); final CompositeListVppReader bridgeDomainReader = VppStateUtils.getBridgeDomainReader(api); final List read = bridgeDomainReader.readList(InstanceIdentifier.create(VppState.class).child(BridgeDomains.class).child( - BridgeDomain.class)); + BridgeDomain.class), ctx); assertEquals(readRoot.getBridgeDomains().getBridgeDomain(), read); } @Test public void testReadBridgeDomain() throws Exception { - VppState readRoot = (VppState) readerRegistry.read(InstanceIdentifier.create(VppState.class)).get(); + VppState readRoot = (VppState) readerRegistry.read(InstanceIdentifier.create(VppState.class), ctx).get(); final Optional read = readerRegistry.read(InstanceIdentifier.create(VppState.class).child(BridgeDomains.class).child( - BridgeDomain.class, new BridgeDomainKey("bdn1"))); + BridgeDomain.class, new BridgeDomainKey("bdn1")), ctx); assertTrue(read.isPresent()); assertEquals(Iterables.find(readRoot.getBridgeDomains().getBridgeDomain(), new Predicate() { @@ -238,16 +243,16 @@ public class VppStateTest { public void testReadBridgeDomainNotExisting() throws Exception { final Optional read = readerRegistry.read(InstanceIdentifier.create(VppState.class).child(BridgeDomains.class).child( - BridgeDomain.class, new BridgeDomainKey("NOT EXISTING"))); + BridgeDomain.class, new BridgeDomainKey("NOT EXISTING")), ctx); assertFalse(read.isPresent()); } @Test public void testReadVersion() throws Exception { - VppState readRoot = (VppState) readerRegistry.read(InstanceIdentifier.create(VppState.class)).get(); + VppState readRoot = (VppState) readerRegistry.read(InstanceIdentifier.create(VppState.class), ctx).get(); Optional read = - readerRegistry.read(InstanceIdentifier.create(VppState.class).child(Version.class)); + readerRegistry.read(InstanceIdentifier.create(VppState.class).child(Version.class), ctx); assertTrue(read.isPresent()); assertEquals(readRoot.getVersion(), read.get()); } -- cgit 1.2.3-korg