From e96e3a4484228f03cec420c97b7493ae3cb5f5e8 Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Mon, 21 Mar 2016 17:47:55 +0100 Subject: Prepare for integration with VPP API <-> YANG translation layer. Package trans was renamed to trans0. Change-Id: I849cbe528362a63cfce653b04c48db8819d255bd Signed-off-by: Marek Gradzki --- .../v3po/impl/data/VppConfigDataTree.java | 4 +- .../data/VppDataBrokerInitializationProvider.java | 4 +- .../fd/honeycomb/v3po/impl/data/VppDataTree.java | 2 +- .../v3po/impl/data/VppOperationalDataTree.java | 2 +- .../v3po/impl/data/VppWriteTransaction.java | 2 +- .../v3po/impl/trans/DefaultVppWriter.java | 43 ------------ .../v3po/impl/trans/VppApiInvocationException.java | 76 ---------------------- .../v3po/impl/trans/VppInterfacesReader.java | 56 ---------------- .../io/fd/honeycomb/v3po/impl/trans/VppReader.java | 30 --------- .../io/fd/honeycomb/v3po/impl/trans/VppWriter.java | 27 -------- .../v3po/impl/trans0/DefaultVppWriter.java | 43 ++++++++++++ .../impl/trans0/VppApiInvocationException.java | 76 ++++++++++++++++++++++ .../v3po/impl/trans0/VppInterfacesReader.java | 56 ++++++++++++++++ .../fd/honeycomb/v3po/impl/trans0/VppReader.java | 30 +++++++++ .../fd/honeycomb/v3po/impl/trans0/VppWriter.java | 27 ++++++++ .../v3po/impl/data/VPPConfigDataTreeTest.java | 4 +- .../v3po/impl/data/VppOperationalDataTreeTest.java | 2 +- .../impl/trans/VppApiInvocationExceptionTest.java | 46 ------------- .../impl/trans0/VppApiInvocationExceptionTest.java | 46 +++++++++++++ 19 files changed, 288 insertions(+), 288 deletions(-) delete mode 100644 v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/DefaultVppWriter.java delete mode 100644 v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/VppApiInvocationException.java delete mode 100644 v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/VppInterfacesReader.java delete mode 100644 v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/VppReader.java delete mode 100644 v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/VppWriter.java create mode 100644 v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans0/DefaultVppWriter.java create mode 100644 v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans0/VppApiInvocationException.java create mode 100644 v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans0/VppInterfacesReader.java create mode 100644 v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans0/VppReader.java create mode 100644 v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans0/VppWriter.java delete mode 100644 v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/trans/VppApiInvocationExceptionTest.java create mode 100644 v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/trans0/VppApiInvocationExceptionTest.java (limited to 'v3po/impl') 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 e1f356592..66bcf489d 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 @@ -20,8 +20,8 @@ import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.Futures; -import io.fd.honeycomb.v3po.impl.trans.VppApiInvocationException; -import io.fd.honeycomb.v3po.impl.trans.VppWriter; +import io.fd.honeycomb.v3po.impl.trans0.VppApiInvocationException; +import io.fd.honeycomb.v3po.impl.trans0.VppWriter; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppDataBrokerInitializationProvider.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppDataBrokerInitializationProvider.java index 9a643564a..50181e2fb 100644 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppDataBrokerInitializationProvider.java +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppDataBrokerInitializationProvider.java @@ -22,8 +22,8 @@ import com.google.common.util.concurrent.AsyncFunction; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import io.fd.honeycomb.v3po.impl.LoggingFuturesCallBack; -import io.fd.honeycomb.v3po.impl.trans.DefaultVppWriter; -import io.fd.honeycomb.v3po.impl.trans.VppInterfacesReader; +import io.fd.honeycomb.v3po.impl.trans0.DefaultVppWriter; +import io.fd.honeycomb.v3po.impl.trans0.VppInterfacesReader; import java.util.Collection; import java.util.Collections; import javassist.ClassPool; diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppDataTree.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppDataTree.java index a3a4fae65..17d3b7149 100644 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppDataTree.java +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppDataTree.java @@ -17,7 +17,7 @@ package io.fd.honeycomb.v3po.impl.data; import com.google.common.annotations.Beta; -import io.fd.honeycomb.v3po.impl.trans.VppApiInvocationException; +import io.fd.honeycomb.v3po.impl.trans0.VppApiInvocationException; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException; 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 0e6bc7d34..fbfd9104d 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 @@ -20,7 +20,7 @@ import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.Futures; -import io.fd.honeycomb.v3po.impl.trans.VppReader; +import io.fd.honeycomb.v3po.impl.trans0.VppReader; import java.util.Map; import javax.annotation.Nonnull; import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppWriteTransaction.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppWriteTransaction.java index b7aa2f854..8cdd10b7e 100644 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppWriteTransaction.java +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppWriteTransaction.java @@ -26,7 +26,7 @@ import com.google.common.base.Preconditions; import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; -import io.fd.honeycomb.v3po.impl.trans.VppApiInvocationException; +import io.fd.honeycomb.v3po.impl.trans0.VppApiInvocationException; import javax.annotation.Nonnull; import javax.annotation.concurrent.NotThreadSafe; import org.opendaylight.controller.md.sal.common.api.TransactionStatus; diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/DefaultVppWriter.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/DefaultVppWriter.java deleted file mode 100644 index 10fede190..000000000 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/DefaultVppWriter.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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; - -import java.util.Objects; -import javax.annotation.Nullable; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class DefaultVppWriter implements VppWriter { - private static final Logger LOG = LoggerFactory.getLogger(DefaultVppWriter.class); - - @Override - public void process(@Nullable final DataObject dataBefore, @Nullable final DataObject dataAfter) - throws VppApiInvocationException { - LOG.debug("Processing modification: dataBefore={}, dataAfter={}", dataBefore, dataAfter); - - if (Objects.equals(dataBefore, dataAfter)) { - LOG.debug("No modification"); - } else if (dataBefore == null) { - LOG.debug("modification type: CREATE"); - } else if (dataAfter == null) { - LOG.debug("modification type: DELETE"); - } else { - LOG.debug("modification type: UPDATE"); - } - } -} diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/VppApiInvocationException.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/VppApiInvocationException.java deleted file mode 100644 index b0076cd9c..000000000 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/VppApiInvocationException.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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; - -import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; -import javax.annotation.Nonnull; - -/** - * Throws when Vpp jAPI method invocation failed. - */ -@Beta -public class VppApiInvocationException extends Exception { - 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/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/VppInterfacesReader.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/VppInterfacesReader.java deleted file mode 100644 index 5db7ab8a8..000000000 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/VppInterfacesReader.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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; - -import java.util.Collections; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.EthernetCsmacd; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class VppInterfacesReader implements VppReader { - private static final Logger LOG = LoggerFactory.getLogger(VppInterfacesReader.class); - - @Override - public Interfaces read(final InstanceIdentifier id) { - LOG.info("VppInterfacesReader.read, id={}", id); - - InterfaceBuilder ifaceBuilder = new InterfaceBuilder(); - final String interfaceName = "eth0"; - ifaceBuilder.setName(interfaceName); - ifaceBuilder.setDescription("eth0 description"); - ifaceBuilder.setEnabled(false); - ifaceBuilder.setKey(new InterfaceKey(interfaceName)); - ifaceBuilder.setType(EthernetCsmacd.class); - ifaceBuilder.setLinkUpDownTrapEnable(Interface.LinkUpDownTrapEnable.Disabled); - - InterfacesBuilder ifacesBuilder = new InterfacesBuilder(); - ifacesBuilder.setInterface(Collections.singletonList(ifaceBuilder.build())); - return ifacesBuilder.build(); - } - - @Override - public Class getManagedDataObjectType() { - return null; - } -} diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/VppReader.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/VppReader.java deleted file mode 100644 index 31275f07a..000000000 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/VppReader.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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; - -import com.google.common.annotations.Beta; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -@Beta -public interface VppReader { - - C read(InstanceIdentifier id); - - Class getManagedDataObjectType(); - -} \ No newline at end of file diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/VppWriter.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/VppWriter.java deleted file mode 100644 index ffd576b04..000000000 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans/VppWriter.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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; - -import com.google.common.annotations.Beta; -import javax.annotation.Nullable; -import org.opendaylight.yangtools.yang.binding.DataObject; - -@Beta -public interface VppWriter { - - void process(@Nullable C dataBefore, @Nullable C dataAfter) throws VppApiInvocationException; -} \ No newline at end of file diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans0/DefaultVppWriter.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans0/DefaultVppWriter.java new file mode 100644 index 000000000..573353b55 --- /dev/null +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans0/DefaultVppWriter.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.impl.trans0; + +import java.util.Objects; +import javax.annotation.Nullable; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class DefaultVppWriter implements VppWriter { + private static final Logger LOG = LoggerFactory.getLogger(DefaultVppWriter.class); + + @Override + public void process(@Nullable final DataObject dataBefore, @Nullable final DataObject dataAfter) + throws VppApiInvocationException { + LOG.debug("Processing modification: dataBefore={}, dataAfter={}", dataBefore, dataAfter); + + if (Objects.equals(dataBefore, dataAfter)) { + LOG.debug("No modification"); + } else if (dataBefore == null) { + LOG.debug("modification type: CREATE"); + } else if (dataAfter == null) { + LOG.debug("modification type: DELETE"); + } else { + LOG.debug("modification type: UPDATE"); + } + } +} diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans0/VppApiInvocationException.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans0/VppApiInvocationException.java new file mode 100644 index 000000000..119563bdd --- /dev/null +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans0/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.impl.trans0; + +import com.google.common.annotations.Beta; +import com.google.common.base.Preconditions; +import javax.annotation.Nonnull; + +/** + * Throws when Vpp jAPI method invocation failed. + */ +@Beta +public class VppApiInvocationException extends Exception { + 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/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans0/VppInterfacesReader.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans0/VppInterfacesReader.java new file mode 100644 index 000000000..39b5f0208 --- /dev/null +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans0/VppInterfacesReader.java @@ -0,0 +1,56 @@ +/* + * 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.trans0; + +import java.util.Collections; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.EthernetCsmacd; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class VppInterfacesReader implements VppReader { + private static final Logger LOG = LoggerFactory.getLogger(VppInterfacesReader.class); + + @Override + public Interfaces read(final InstanceIdentifier id) { + LOG.info("VppInterfacesReader.read, id={}", id); + + InterfaceBuilder ifaceBuilder = new InterfaceBuilder(); + final String interfaceName = "eth0"; + ifaceBuilder.setName(interfaceName); + ifaceBuilder.setDescription("eth0 description"); + ifaceBuilder.setEnabled(false); + ifaceBuilder.setKey(new InterfaceKey(interfaceName)); + ifaceBuilder.setType(EthernetCsmacd.class); + ifaceBuilder.setLinkUpDownTrapEnable(Interface.LinkUpDownTrapEnable.Disabled); + + InterfacesBuilder ifacesBuilder = new InterfacesBuilder(); + ifacesBuilder.setInterface(Collections.singletonList(ifaceBuilder.build())); + return ifacesBuilder.build(); + } + + @Override + public Class getManagedDataObjectType() { + return null; + } +} diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans0/VppReader.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans0/VppReader.java new file mode 100644 index 000000000..5a4215edb --- /dev/null +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans0/VppReader.java @@ -0,0 +1,30 @@ +/* + * 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.trans0; + +import com.google.common.annotations.Beta; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +@Beta +public interface VppReader { + + C read(InstanceIdentifier id); + + Class getManagedDataObjectType(); + +} \ No newline at end of file diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans0/VppWriter.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans0/VppWriter.java new file mode 100644 index 000000000..ee6e1f4be --- /dev/null +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/trans0/VppWriter.java @@ -0,0 +1,27 @@ +/* + * 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.trans0; + +import com.google.common.annotations.Beta; +import javax.annotation.Nullable; +import org.opendaylight.yangtools.yang.binding.DataObject; + +@Beta +public interface VppWriter { + + void process(@Nullable C dataBefore, @Nullable C dataAfter) throws VppApiInvocationException; +} \ No newline at end of file diff --git a/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VPPConfigDataTreeTest.java b/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VPPConfigDataTreeTest.java index 3f78150f9..4e855f447 100644 --- a/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VPPConfigDataTreeTest.java +++ b/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VPPConfigDataTreeTest.java @@ -31,8 +31,8 @@ import static org.mockito.MockitoAnnotations.initMocks; import com.google.common.base.Optional; import com.google.common.util.concurrent.CheckedFuture; -import io.fd.honeycomb.v3po.impl.trans.VppApiInvocationException; -import io.fd.honeycomb.v3po.impl.trans.VppWriter; +import io.fd.honeycomb.v3po.impl.trans0.VppApiInvocationException; +import io.fd.honeycomb.v3po.impl.trans0.VppWriter; import java.util.AbstractMap; import java.util.ArrayList; import java.util.Arrays; 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 32b218233..9a3377563 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 @@ -26,7 +26,7 @@ import static org.mockito.MockitoAnnotations.initMocks; import com.google.common.base.Optional; import com.google.common.util.concurrent.CheckedFuture; -import io.fd.honeycomb.v3po.impl.trans.VppReader; +import io.fd.honeycomb.v3po.impl.trans0.VppReader; import java.util.Map; import org.junit.Before; import org.junit.Test; diff --git a/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/trans/VppApiInvocationExceptionTest.java b/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/trans/VppApiInvocationExceptionTest.java deleted file mode 100644 index fed792a3b..000000000 --- a/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/trans/VppApiInvocationExceptionTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.Random; -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); - assertEquals(apiMethodName, e.getMethodName()); - assertEquals(ctxId, e.getCtxId()); - assertEquals(code, e.getErrorCode()); - assertTrue(e.getMessage().contains(apiMethodName)); - assertTrue(e.getMessage().contains(String.valueOf(code))); - 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); - } -} diff --git a/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/trans0/VppApiInvocationExceptionTest.java b/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/trans0/VppApiInvocationExceptionTest.java new file mode 100644 index 000000000..e83e541d1 --- /dev/null +++ b/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/trans0/VppApiInvocationExceptionTest.java @@ -0,0 +1,46 @@ +/* + * 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.trans0; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.Random; +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); + assertEquals(apiMethodName, e.getMethodName()); + assertEquals(ctxId, e.getCtxId()); + assertEquals(code, e.getErrorCode()); + assertTrue(e.getMessage().contains(apiMethodName)); + assertTrue(e.getMessage().contains(String.valueOf(code))); + 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); + } +} -- cgit 1.2.3-korg