diff options
author | Maros Marsalek <mmarsale@cisco.com> | 2016-04-09 16:22:06 +0200 |
---|---|---|
committer | Maros Marsalek <mmarsale@cisco.com> | 2016-06-10 11:04:21 +0200 |
commit | 0e517a26e69ff3d1b04ba19c4539cb8dee60b097 (patch) | |
tree | 29819b80acba85d45ea8d4b90a9b1ed7e0926e12 /v3po/translate-utils | |
parent | 5440823dbe280d3f6c6c94074e86db0c11596686 (diff) |
HONEYCOMB-33: Add notification service to Hc
Implement VPP interface notification translator as part
of v3po2vpp plugin
Change-Id: I69cfad9668ae9e4d79ed30bb8d54d294faa4c54a
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Diffstat (limited to 'v3po/translate-utils')
3 files changed, 118 insertions, 0 deletions
diff --git a/v3po/translate-utils/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/translate/utils/rev160406/RealtimeMappingContextModule.java b/v3po/translate-utils/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/translate/utils/rev160406/RealtimeMappingContextModule.java new file mode 100644 index 000000000..99cf4b4e1 --- /dev/null +++ b/v3po/translate-utils/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/translate/utils/rev160406/RealtimeMappingContextModule.java @@ -0,0 +1,84 @@ +package org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.translate.utils.rev160406; + +import com.google.common.base.Optional; +import io.fd.honeycomb.v3po.translate.MappingContext; +import javax.annotation.Nonnull; +import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; +import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; +import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +public class RealtimeMappingContextModule extends org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.translate.utils.rev160406.AbstractRealtimeMappingContextModule { + public RealtimeMappingContextModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + super(identifier, dependencyResolver); + } + + public RealtimeMappingContextModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.translate.utils.rev160406.RealtimeMappingContextModule oldModule, java.lang.AutoCloseable oldInstance) { + super(identifier, dependencyResolver, oldModule, oldInstance); + } + + @Override + public void customValidation() { + // add custom validation form module attributes here. + } + + @Override + public java.lang.AutoCloseable createInstance() { + // Provides real time CRUD on top of Context data broker + return new MappingContext() { + + @Override + public <T extends DataObject> Optional<T> read(@Nonnull final InstanceIdentifier<T> currentId) { + try(ReadOnlyTransaction tx = getContextBindingBrokerDependency().newReadOnlyTransaction()) { + try { + return tx.read(LogicalDatastoreType.OPERATIONAL, currentId).checkedGet(); + } catch (ReadFailedException e) { + throw new IllegalStateException("Unable to perform read of " + currentId, e); + } + } + } + + @Override + public void delete(final InstanceIdentifier<?> path) { + final WriteTransaction writeTx = getContextBindingBrokerDependency().newWriteOnlyTransaction(); + writeTx.delete(LogicalDatastoreType.OPERATIONAL, path); + try { + writeTx.submit().checkedGet(); + } catch (TransactionCommitFailedException e) { + throw new IllegalStateException("Unable to perform delete of " + path, e); + } + } + + @Override + public <T extends DataObject> void merge(final InstanceIdentifier<T> path, final T data) { + final WriteTransaction writeTx = getContextBindingBrokerDependency().newWriteOnlyTransaction(); + writeTx.merge(LogicalDatastoreType.OPERATIONAL, path, data); + try { + writeTx.submit().checkedGet(); + } catch (TransactionCommitFailedException e) { + throw new IllegalStateException("Unable to perform merge of " + path, e); + } + } + + @Override + public <T extends DataObject> void put(final InstanceIdentifier<T> path, final T data) { + final WriteTransaction writeTx = getContextBindingBrokerDependency().newWriteOnlyTransaction(); + writeTx.put(LogicalDatastoreType.OPERATIONAL, path, data); + try { + writeTx.submit().checkedGet(); + } catch (TransactionCommitFailedException e) { + throw new IllegalStateException("Unable to perform put of " + path, e); + } + } + + @Override + public void close() { + // Noop + } + }; + } + +} diff --git a/v3po/translate-utils/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/translate/utils/rev160406/RealtimeMappingContextModuleFactory.java b/v3po/translate-utils/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/translate/utils/rev160406/RealtimeMappingContextModuleFactory.java new file mode 100644 index 000000000..76647eace --- /dev/null +++ b/v3po/translate-utils/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/translate/utils/rev160406/RealtimeMappingContextModuleFactory.java @@ -0,0 +1,13 @@ +/* +* Generated file +* +* Generated from: yang module name: translate-utils yang module local name: realtime-mapping-context +* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator +* Generated at: Fri Jun 03 16:04:29 CEST 2016 +* +* Do not modify this file unless it is present under src/main directory +*/ +package org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.translate.utils.rev160406; +public class RealtimeMappingContextModuleFactory extends org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.translate.utils.rev160406.AbstractRealtimeMappingContextModuleFactory { + +} diff --git a/v3po/translate-utils/src/main/yang/translate-utils.yang b/v3po/translate-utils/src/main/yang/translate-utils.yang index 238528d56..1219648c3 100644 --- a/v3po/translate-utils/src/main/yang/translate-utils.yang +++ b/v3po/translate-utils/src/main/yang/translate-utils.yang @@ -5,6 +5,7 @@ module translate-utils { import config { prefix config; revision-date 2013-04-05; } import translate-api { prefix tapi; revision-date 2016-04-06; } + import opendaylight-md-sal-binding { prefix md-sal-binding; revision-date 2013-10-28;} description "This module contains translation layer utilities"; @@ -69,4 +70,24 @@ module translate-utils { when "/config:modules/config:module/config:type = 'noop-writer-registry'"; } } + + identity realtime-mapping-context { + base config:module-type; + config:provided-service tapi:honeycomb-mapping-context; + } + + augment "/config:modules/config:module/config:configuration" { + case realtime-mapping-context { + when "/config:modules/config:module/config:type = 'realtime-mapping-context'"; + + container context-binding-broker { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity md-sal-binding:binding-async-data-broker; + } + } + } + } + } }
\ No newline at end of file |