summaryrefslogtreecommitdiffstats
path: root/v3po/vpp-facade-api
diff options
context:
space:
mode:
Diffstat (limited to 'v3po/vpp-facade-api')
-rw-r--r--v3po/vpp-facade-api/pom.xml73
-rw-r--r--v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/Context.java49
-rw-r--r--v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/SubtreeManager.java39
-rw-r--r--v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/VppApiInvocationException.java76
-rw-r--r--v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/VppException.java38
-rw-r--r--v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/ChildVppReader.java50
-rw-r--r--v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/ListVppReader.java47
-rw-r--r--v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/ReadContext.java37
-rw-r--r--v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/ReadFailedException.java61
-rw-r--r--v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/ReaderRegistry.java43
-rw-r--r--v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/VppReader.java51
-rw-r--r--v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/write/ChildVppWriter.java66
-rw-r--r--v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/write/VppWriter.java49
-rw-r--r--v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/write/WriteContext.java60
-rw-r--r--v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/write/WriterRegistry.java135
-rw-r--r--v3po/vpp-facade-api/src/test/java/io/fd/honeycomb/v3po/vpp/facade/ReadFailedExceptionTest.java51
-rw-r--r--v3po/vpp-facade-api/src/test/java/io/fd/honeycomb/v3po/vpp/facade/VppApiInvocationExceptionTest.java44
17 files changed, 969 insertions, 0 deletions
diff --git a/v3po/vpp-facade-api/pom.xml b/v3po/vpp-facade-api/pom.xml
new file mode 100644
index 000000000..0406f1e80
--- /dev/null
+++ b/v3po/vpp-facade-api/pom.xml
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2015 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <groupId>io.fd.honeycomb.common</groupId>
+ <artifactId>api-parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../../common/api-parent</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>io.fd.honeycomb.v3po</groupId>
+ <artifactId>vpp-facade-api</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-artifacts</artifactId>
+ <version>2.0.0-Beryllium</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-binding-api</artifactId>
+ </dependency>
+
+ <!-- Testing Dependencies -->
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>v3po-api</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/Context.java b/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/Context.java
new file mode 100644
index 000000000..16808db1f
--- /dev/null
+++ b/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/Context.java
@@ -0,0 +1,49 @@
+/*
+ * 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.vpp.facade;
+
+import com.google.common.collect.Maps;
+import java.util.HashMap;
+
+/**
+ * Simple context class that provides transient storage during one or more read/write operations
+ */
+public class Context implements AutoCloseable {
+
+ protected final HashMap<Object, Object> map;
+
+ public Context() {
+ map = Maps.newHashMap();
+ }
+
+ public Object get(final Object o) {
+ return map.get(o);
+ }
+
+ public boolean containsKey(final Object o) {
+ return map.containsKey(o);
+ }
+
+ public Object put(final Object o, final Object o2) {
+ return map.put(o, o2);
+ }
+
+ @Override
+ public void close() {
+ map.clear();
+ }
+}
diff --git a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/SubtreeManager.java b/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/SubtreeManager.java
new file mode 100644
index 000000000..28eee203b
--- /dev/null
+++ b/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/SubtreeManager.java
@@ -0,0 +1,39 @@
+/*
+ * 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.vpp.facade;
+
+import com.google.common.annotations.Beta;
+import javax.annotation.Nonnull;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * Base identifiable subtree manager(reader, writer etc.)
+ *
+ * @param <D> Specific DataObject derived type, that is managed by this manager
+ */
+@Beta
+public interface SubtreeManager<D extends DataObject> {
+
+ /**
+ * Gets the type of node managed by this reader
+ *
+ * @return Class object for node managed by this reader
+ */
+ @Nonnull
+ InstanceIdentifier<D> getManagedDataObjectType();
+}
diff --git a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/VppApiInvocationException.java b/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/VppApiInvocationException.java
new file mode 100644
index 000000000..ac1d7f7db
--- /dev/null
+++ b/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/VppApiInvocationException.java
@@ -0,0 +1,76 @@
+/*
+ * 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.vpp.facade;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Preconditions;
+import javax.annotation.Nonnull;
+
+/**
+ * Thrown when Vpp jAPI method invocation failed.
+ */
+@Beta
+public class VppApiInvocationException extends VppException {
+ private final String methodName;
+ private final int ctxId;
+ private final int errorCode;
+
+ /**
+ * Constructs an VppApiInvocationFailedException with the specified api method name and error code.
+ *
+ * @param methodName method name that failed to invoke
+ * @param ctxId api request context identifier
+ * @param errorCode negative error code value associated with this failure
+ * @throws NullPointerException if apiMethodName is null
+ * @throws IllegalArgumentException if errorCode is nonnegative
+ */
+ public VppApiInvocationException(@Nonnull final String methodName, final int ctxId, final int errorCode) {
+ super(String.format("vppApi.%s failed with error code: %d (ctxId=%d) ", methodName, errorCode, ctxId));
+ this.methodName = Preconditions.checkNotNull(methodName, "apiMethodName is null!");
+ this.ctxId = ctxId;
+ Preconditions.checkArgument(errorCode < 0);
+ this.errorCode = errorCode;
+ }
+
+ /**
+ * Returns method name that failed to invoke.
+ *
+ * @return method name
+ */
+ public String getMethodName() {
+ return methodName;
+ }
+
+ /**
+ * Returns api request context identifier.
+ *
+ * @return value of context identifier
+ */
+ public int getCtxId() {
+ return ctxId;
+ }
+
+ /**
+ * Returns the error code associated with this failure.
+ *
+ * @return a negative integer error code
+ */
+ public int getErrorCode() {
+ return errorCode;
+ }
+}
+
diff --git a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/VppException.java b/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/VppException.java
new file mode 100644
index 000000000..ff6101bb8
--- /dev/null
+++ b/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/VppException.java
@@ -0,0 +1,38 @@
+/*
+ * 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.vpp.facade;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * Base exception for Vpp translation layer
+ */
+@Beta
+public class VppException extends Exception {
+
+ public VppException(final String s) {
+ super(s);
+ }
+
+ public VppException(final String s, final Throwable cause) {
+ super(s, cause);
+ }
+
+ public VppException(final Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/ChildVppReader.java b/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/ChildVppReader.java
new file mode 100644
index 000000000..1608db4b2
--- /dev/null
+++ b/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/ChildVppReader.java
@@ -0,0 +1,50 @@
+/*
+ * 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.vpp.facade.read;
+
+import com.google.common.annotations.Beta;
+import javax.annotation.Nonnull;
+import org.opendaylight.yangtools.concepts.Builder;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * Child VPP reader allowing its parent to pass the builder object
+ *
+ * @param <C> Specific DataObject derived type, that is handled by this reader
+ */
+@Beta
+public interface ChildVppReader<C extends DataObject> extends VppReader<C> {
+
+ /**
+ * Reads subtree starting from node managed by this reader and place the subtree within parent builder object if the
+ * data exists.
+ *
+ * @param id Unique identifier pointing to the node managed by this reader. Useful when necessary to
+ * 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<? extends DataObject> id,
+ @Nonnull final Builder<? extends DataObject> parentBuilder,
+ @Nonnull final ReadContext ctx) throws ReadFailedException;
+
+}
+
diff --git a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/ListVppReader.java b/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/ListVppReader.java
new file mode 100644
index 000000000..950014574
--- /dev/null
+++ b/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/ListVppReader.java
@@ -0,0 +1,47 @@
+/*
+ * 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.vpp.facade.read;
+
+import com.google.common.annotations.Beta;
+import java.util.List;
+import javax.annotation.Nonnull;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.Identifiable;
+import org.opendaylight.yangtools.yang.binding.Identifier;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * List VPP reader, allowing read of all the elements
+ *
+ * @param <D> Specific DataObject derived type, that is handled by this reader
+ */
+@Beta
+public interface ListVppReader<D extends DataObject & Identifiable<K>, K extends Identifier<D>> extends VppReader<D> {
+
+ /**
+ * 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<D> readList(@Nonnull final InstanceIdentifier<D> id,
+ @Nonnull final ReadContext ctx) throws ReadFailedException;
+}
diff --git a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/ReadContext.java b/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/ReadContext.java
new file mode 100644
index 000000000..527888ab1
--- /dev/null
+++ b/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/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.vpp.facade.read;
+
+import io.fd.honeycomb.v3po.vpp.facade.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/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/ReadFailedException.java b/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/ReadFailedException.java
new file mode 100644
index 000000000..3e87b925b
--- /dev/null
+++ b/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/ReadFailedException.java
@@ -0,0 +1,61 @@
+/*
+ * 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.vpp.facade.read;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import io.fd.honeycomb.v3po.vpp.facade.VppException;
+import javax.annotation.Nonnull;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * Thrown when Vpp reader or customizer is not able to read data for the given id.
+ */
+public class ReadFailedException extends VppException {
+
+ private final InstanceIdentifier<?> failedId;
+
+ /**
+ * Constructs an ReadFailedException given data id and exception cause.
+ *
+ * @param failedId instance identifier of the data object that could not be read
+ * @param cause the cause of read failure
+ */
+ public ReadFailedException(@Nonnull final InstanceIdentifier<?> failedId, final Throwable cause) {
+ super("Failed to read " + failedId, cause);
+ this.failedId = checkNotNull(failedId, "failedId should not be null");
+ }
+
+ /**
+ * Constructs an ReadFailedException given data id.
+ *
+ * @param failedId instance identifier of the data object that could not be read
+ */
+ public ReadFailedException(@Nonnull final InstanceIdentifier<?> failedId) {
+ this(failedId, null);
+ }
+
+ /**
+ * Returns id of the data object that could not be read.
+ *
+ * @return data object instance identifier
+ */
+ @Nonnull
+ public InstanceIdentifier<?> getFailedId() {
+ return failedId;
+ }
+}
diff --git a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/ReaderRegistry.java b/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/ReaderRegistry.java
new file mode 100644
index 000000000..2bd51254f
--- /dev/null
+++ b/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/ReaderRegistry.java
@@ -0,0 +1,43 @@
+/*
+ * 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.vpp.facade.read;
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.Multimap;
+import javax.annotation.Nonnull;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * Simple delegating reader suitable as a holder for all other root readers, providing readAll feature.
+ */
+@Beta
+public interface ReaderRegistry extends VppReader<DataObject> {
+
+ /**
+ * 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<InstanceIdentifier<? extends DataObject>, ? extends DataObject> readAll(@Nonnull final ReadContext ctx)
+ throws ReadFailedException;
+}
diff --git a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/VppReader.java b/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/VppReader.java
new file mode 100644
index 000000000..6eea594b4
--- /dev/null
+++ b/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/read/VppReader.java
@@ -0,0 +1,51 @@
+/*
+ * 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.vpp.facade.read;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Optional;
+import io.fd.honeycomb.v3po.vpp.facade.SubtreeManager;
+import javax.annotation.Nonnull;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * Base VPP reader, responsible for translation between DataObjects and VPP APIs
+ *
+ * @param <D> Specific DataObject derived type, that is handled by this reader
+ */
+@Beta
+public interface VppReader<D extends DataObject> extends SubtreeManager<D> {
+
+ // TODO make async
+
+ /**
+ * Reads from VPP data identified by id
+ *
+ * @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<? extends DataObject> read(@Nonnull final InstanceIdentifier<? extends DataObject> id,
+ @Nonnull ReadContext ctx) throws ReadFailedException;
+
+}
diff --git a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/write/ChildVppWriter.java b/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/write/ChildVppWriter.java
new file mode 100644
index 000000000..017f5d9aa
--- /dev/null
+++ b/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/write/ChildVppWriter.java
@@ -0,0 +1,66 @@
+/*
+ * 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.vpp.facade.write;
+
+import com.google.common.annotations.Beta;
+import javax.annotation.Nonnull;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * Child VPP writer allowing its parent to pass the builder object
+ *
+ * @param <C> Specific DataObject derived type, that is handled by this writer
+ */
+@Beta
+public interface ChildVppWriter<D extends DataObject> extends VppWriter<D> {
+
+ /**
+ * Extract data object managed by this writer from parent data and perform write.
+ *
+ * @param parentId Id of parent node
+ * @param parentDataAfter Parent data from modification to extract data object from
+ * @param ctx Write context for current modification
+ */
+ void writeChild(@Nonnull final InstanceIdentifier<? extends DataObject> parentId,
+ @Nonnull final DataObject parentDataAfter,
+ @Nonnull final WriteContext ctx);
+
+ /**
+ * Extract data object managed by this writer(if necessary) from parent data and perform delete.
+ *
+ * @param parentId Id of parent node
+ * @param parentDataBefore Parent data before modification to extract data object from
+ * @param ctx Write context for current modification
+ */
+ void deleteChild(@Nonnull final InstanceIdentifier<? extends DataObject> parentId,
+ @Nonnull final DataObject parentDataBefore,
+ @Nonnull final WriteContext ctx);
+
+ /**
+ * Extract data object managed by this writer(if necessary) from parent data and perform delete.
+ *
+ * @param parentId Id of parent node
+ * @param parentDataBefore Parent data before modification to extract data object from
+ * @param parentDataAfter Parent data from modification to extract data object from
+ * @param ctx Write context for current modification
+ */
+ void updateChild(@Nonnull final InstanceIdentifier<? extends DataObject> parentId,
+ @Nonnull final DataObject parentDataBefore,
+ @Nonnull final DataObject parentDataAfter,
+ @Nonnull final WriteContext ctx);
+}
diff --git a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/write/VppWriter.java b/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/write/VppWriter.java
new file mode 100644
index 000000000..83f600f5b
--- /dev/null
+++ b/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/write/VppWriter.java
@@ -0,0 +1,49 @@
+/*
+ * 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.vpp.facade.write;
+
+import com.google.common.annotations.Beta;
+import io.fd.honeycomb.v3po.vpp.facade.SubtreeManager;
+import io.fd.honeycomb.v3po.vpp.facade.VppException;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * Base VPP writer, responsible for translation between DataObjects and VPP APIs. Handling all update operations(create,
+ * update, delete)
+ *
+ * @param <D> Specific DataObject derived type, that is handled by this writer
+ */
+@Beta
+public interface VppWriter<D extends DataObject> extends SubtreeManager<D> {
+
+ /**
+ * Handle update operation. U from CRUD.
+ *
+ * @param id Identifier(from root) of data being written
+ * @param dataBefore Old data
+ * @param dataAfter New, updated data
+ * @param ctx Write context enabling writer to get information about candidate data as well as current data
+ * @throws VppException if update failed
+ */
+ void update(@Nonnull final InstanceIdentifier<? extends DataObject> id,
+ @Nullable final DataObject dataBefore,
+ @Nullable final DataObject dataAfter,
+ @Nonnull final WriteContext ctx) throws VppException;
+}
diff --git a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/write/WriteContext.java b/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/write/WriteContext.java
new file mode 100644
index 000000000..ffc9f20f7
--- /dev/null
+++ b/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/write/WriteContext.java
@@ -0,0 +1,60 @@
+/*
+ * 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.vpp.facade.write;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Optional;
+import io.fd.honeycomb.v3po.vpp.facade.Context;
+import javax.annotation.Nonnull;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * Context providing information about current state of DataTree to writers
+ */
+@Beta
+public interface WriteContext extends AutoCloseable {
+
+ /**
+ * Read any data object before current modification was applied
+ *
+ * @param currentId Id of an object to read
+ *
+ * @return Data before the modification was applied
+ */
+ Optional<DataObject> readBefore(@Nonnull final InstanceIdentifier<? extends DataObject> currentId);
+
+ /**
+ * Read any data object from current modification
+ *
+ * @param currentId Id of an object to read
+ *
+ * @return Data from the modification
+ */
+ Optional<DataObject> readAfter(@Nonnull final InstanceIdentifier<? extends DataObject> currentId);
+
+ /**
+ * Get key value storage for customizers
+ *
+ * @return Context for customizers
+ */
+ @Nonnull
+ Context getContext();
+
+ @Override
+ void close();
+}
diff --git a/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/write/WriterRegistry.java b/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/write/WriterRegistry.java
new file mode 100644
index 000000000..0d3c17451
--- /dev/null
+++ b/v3po/vpp-facade-api/src/main/java/io/fd/honeycomb/v3po/vpp/facade/write/WriterRegistry.java
@@ -0,0 +1,135 @@
+/*
+ * 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.vpp.facade.write;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.ImmutableList;
+import io.fd.honeycomb.v3po.vpp.facade.VppException;
+import java.util.List;
+import java.util.Map;
+import javax.annotation.Nonnull;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * Special {@link VppWriter} capable of performing bulk updates
+ */
+@Beta
+public interface WriterRegistry extends VppWriter<DataObject> {
+
+ /**
+ * Performs bulk update
+ *
+ * @throws BulkUpdateException in case bulk update fails
+ * @throws VppException in case some other error occurs while processing update request
+ */
+ void update(@Nonnull final Map<InstanceIdentifier<?>, DataObject> dataBefore,
+ @Nonnull final Map<InstanceIdentifier<?>, DataObject> dataAfter,
+ @Nonnull final WriteContext ctx) throws VppException;
+
+ /**
+ * Thrown when bulk update failed.
+ */
+ @Beta
+ class BulkUpdateException extends VppException {
+
+ private final Reverter reverter;
+ private final InstanceIdentifier<?> failedId; // TODO change to VppDataModification
+
+ /**
+ * Constructs an BulkUpdateException.
+ *
+ * @param failedId instance identifier of the data object that caused bulk update to fail.
+ * @param cause the cause of bulk update failure
+ */
+ public BulkUpdateException(@Nonnull final InstanceIdentifier<?> failedId, @Nonnull final Reverter reverter,
+ final Throwable cause) {
+ super("Bulk update failed at " + failedId, cause);
+ this.failedId = checkNotNull(failedId, "failedId should not be null");
+ this.reverter = checkNotNull(reverter, "reverter should not be null");
+ }
+
+ /**
+ * Reverts changes that were successfully applied during bulk update before failure occurred.
+ *
+ * @throws Reverter.RevertFailedException if revert fails
+ */
+ public void revertChanges() throws Reverter.RevertFailedException {
+ reverter.revert();
+ }
+
+ /**
+ * Returns instance identifier of the data object that caused bulk update to fail.
+ *
+ * @return data object's instance identifier
+ */
+ @Nonnull
+ public InstanceIdentifier<?> getFailedId() {
+ return failedId;
+ }
+ }
+
+ /**
+ * Abstraction over revert mechanism in cast of a bulk update failure
+ */
+ @Beta
+ interface Reverter {
+
+ /**
+ * Reverts changes that were successfully applied during bulk update before failure occurred. Changes are
+ * reverted in reverse order they were applied.
+ *
+ * @throws RevertFailedException if not all of applied changes were successfully reverted
+ */
+ void revert() throws RevertFailedException;
+
+ /**
+ * Thrown when some of the changes applied during bulk update were not reverted.
+ */
+ @Beta
+ class RevertFailedException extends VppException {
+
+ // TODO change to list of VppDataModifications to make debugging easier
+ private final List<InstanceIdentifier<?>> notRevertedChanges;
+
+ /**
+ * Constructs an RevertFailedException with the list of changes that were not reverted.
+ *
+ * @param notRevertedChanges list of changes that were not reverted
+ * @param cause the cause of revert failure
+ */
+ public RevertFailedException(@Nonnull final List<InstanceIdentifier<?>> notRevertedChanges,
+ final Throwable cause) {
+ super(cause);
+ checkNotNull(notRevertedChanges, "notRevertedChanges should not be null");
+ this.notRevertedChanges = ImmutableList.copyOf(notRevertedChanges);
+ }
+
+ /**
+ * Returns the list of changes that were not reverted.
+ *
+ * @return list of changes that were not reverted
+ */
+ @Nonnull
+ public List<InstanceIdentifier<?>> getNotRevertedChanges() {
+ return notRevertedChanges;
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/v3po/vpp-facade-api/src/test/java/io/fd/honeycomb/v3po/vpp/facade/ReadFailedExceptionTest.java b/v3po/vpp-facade-api/src/test/java/io/fd/honeycomb/v3po/vpp/facade/ReadFailedExceptionTest.java
new file mode 100644
index 000000000..594168df2
--- /dev/null
+++ b/v3po/vpp-facade-api/src/test/java/io/fd/honeycomb/v3po/vpp/facade/ReadFailedExceptionTest.java
@@ -0,0 +1,51 @@
+/*
+ * 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.vpp.facade;
+
+import io.fd.honeycomb.v3po.vpp.facade.read.ReadFailedException;
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.bridge.domains.BridgeDomain;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.bridge.domains.bridge.domain.Interface;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class ReadFailedExceptionTest {
+
+ @Test
+ public void testInstantiation() {
+ final InstanceIdentifier<BridgeDomain> id = InstanceIdentifier.create(BridgeDomain.class);
+ ReadFailedException e = new ReadFailedException(id);
+ Assert.assertEquals(id, e.getFailedId());
+ Assert.assertNull(e.getCause());
+ Assert.assertTrue(e.getMessage().contains(id.toString()));
+ }
+
+ @Test
+ public void testInstantiationWithCause() {
+ final InstanceIdentifier<Interface> id = InstanceIdentifier.create(Interface.class);
+ final RuntimeException cause = new RuntimeException();
+ ReadFailedException e = new ReadFailedException(id, cause);
+ Assert.assertEquals(id, e.getFailedId());
+ Assert.assertEquals(cause, e.getCause());
+ Assert.assertTrue(e.getMessage().contains(id.toString()));
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testInstantiationFailed() {
+ new ReadFailedException(null);
+ }
+} \ No newline at end of file
diff --git a/v3po/vpp-facade-api/src/test/java/io/fd/honeycomb/v3po/vpp/facade/VppApiInvocationExceptionTest.java b/v3po/vpp-facade-api/src/test/java/io/fd/honeycomb/v3po/vpp/facade/VppApiInvocationExceptionTest.java
new file mode 100644
index 000000000..a3a37c192
--- /dev/null
+++ b/v3po/vpp-facade-api/src/test/java/io/fd/honeycomb/v3po/vpp/facade/VppApiInvocationExceptionTest.java
@@ -0,0 +1,44 @@
+/*
+ * 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.vpp.facade;
+
+import java.util.Random;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class VppApiInvocationExceptionTest {
+
+ @Test
+ public void testInstantiation() {
+ final String apiMethodName = "methodName";
+ final int ctxId = 1;
+ final int code = -1;
+ VppApiInvocationException e = new VppApiInvocationException(apiMethodName, ctxId, code);
+ Assert.assertEquals(apiMethodName, e.getMethodName());
+ Assert.assertEquals(ctxId, e.getCtxId());
+ Assert.assertEquals(code, e.getErrorCode());
+ Assert.assertTrue(e.getMessage().contains(apiMethodName));
+ Assert.assertTrue(e.getMessage().contains(String.valueOf(code)));
+ Assert.assertTrue(e.getMessage().contains(String.valueOf(ctxId)));
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testInstantiationFailed() {
+ final int code = new Random().nextInt(Integer.MAX_VALUE);
+ VppApiInvocationException e = new VppApiInvocationException("apiMethodName", 1, code);
+ }
+}