summaryrefslogtreecommitdiffstats
path: root/v3po/impl/src/main/java
diff options
context:
space:
mode:
authorMaros Marsalek <mmarsale@cisco.com>2016-03-22 17:57:16 +0100
committerMarek Gradzki <mgradzki@cisco.com>2016-03-31 14:27:54 +0000
commit4c4f1743dc29e87b0ab4b39087f79f7f01befa49 (patch)
treeb339f6bed0337eb78fe9db81463fb66e2a42724c /v3po/impl/src/main/java
parent41efda74f2d306399208b2a5d1f9ea85c8fbda43 (diff)
Dedicated NETCONF north interface for v3po
Change-Id: I3a001ef68f7ff43ec1b2a935dd474ec966cea878 Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Diffstat (limited to 'v3po/impl/src/main/java')
-rw-r--r--v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/V3poProvider.java90
-rw-r--r--v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/data/VppDataBrokerInitializationProvider.java12
-rw-r--r--v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/NetconfBindingBrokerModule.java117
-rw-r--r--v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/NetconfBindingBrokerModuleFactory.java13
4 files changed, 230 insertions, 2 deletions
diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/V3poProvider.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/V3poProvider.java
index 8a0dead0e..4afd86099 100644
--- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/V3poProvider.java
+++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/V3poProvider.java
@@ -23,20 +23,26 @@ import com.google.common.util.concurrent.Futures;
import io.fd.honeycomb.v3po.impl.data.VppDataBrokerInitializationProvider;
import io.fd.honeycomb.v3po.impl.data.VppReaderRegistry;
import java.io.IOException;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import javax.annotation.Nonnull;
+import javax.annotation.concurrent.NotThreadSafe;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
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.TransactionCommitFailedException;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
import org.opendaylight.controller.sal.core.api.Broker;
+import org.opendaylight.controller.sal.core.api.BrokerService;
+import org.opendaylight.controller.sal.core.api.Consumer;
+import org.opendaylight.controller.sal.core.api.Provider;
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.iana._if.type.rev140508.SoftwareLoopback;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType;
@@ -54,10 +60,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.openvpp.vppjapi.vppApi;
import org.openvpp.vppjapi.vppInterfaceDetails;
+import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class V3poProvider implements BindingAwareProvider, AutoCloseable {
+public class V3poProvider implements BindingAwareProvider, AutoCloseable, Broker {
private static final Logger LOG = LoggerFactory.getLogger(V3poProvider.class);
private final Broker domBroker;
@@ -209,4 +216,85 @@ public class V3poProvider implements BindingAwareProvider, AutoCloseable {
vppDataBrokerInitializationProvider.close();
}
}
+
+ // DomBroker functionality below. Should go out of here. TODO do that when cleaning up this provider
+
+ @Override
+ public ConsumerSession registerConsumer(final Consumer consumer) {
+ final SimpleConsumerSession session = new SimpleConsumerSession(
+ Collections.<Class<? extends BrokerService>, BrokerService>singletonMap(DOMDataBroker.class,
+ vppDataBrokerInitializationProvider.getBroker().get()));
+ consumer.onSessionInitiated(session);
+ return session;
+ }
+
+ @Deprecated
+ @Override
+ public ConsumerSession registerConsumer(final Consumer consumer, final BundleContext bundleContext) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public ProviderSession registerProvider(final Provider provider) {
+ final SimpleProviderSession session = new SimpleProviderSession(
+ Collections.<Class<? extends BrokerService>, BrokerService>singletonMap(DOMDataBroker.class,
+ vppDataBrokerInitializationProvider.getBroker().get()));
+ provider.onSessionInitiated(session);
+ return session;
+ }
+
+ @Override
+ public ProviderSession registerProvider(final Provider provider, final BundleContext bundleContext) {
+ throw new UnsupportedOperationException();
+ }
+
+ @NotThreadSafe
+ private static class SimpleConsumerSession implements ConsumerSession {
+ private boolean closed;
+ private final Map<Class<? extends BrokerService>, BrokerService> services;
+
+ private SimpleConsumerSession(final Map<Class<? extends BrokerService>, BrokerService> services) {
+ this.services = services;
+ }
+
+ @Override
+ public boolean isClosed() {
+ return closed;
+ }
+
+ @Override
+ public <T extends BrokerService> T getService(final Class<T> aClass) {
+ return (T)services.get(aClass);
+ }
+
+ @Override
+ public void close() {
+ closed = true;
+ }
+ }
+
+ @NotThreadSafe
+ private static class SimpleProviderSession implements ProviderSession {
+ private boolean closed;
+ private final Map<Class<? extends BrokerService>, BrokerService> services;
+
+ private SimpleProviderSession(final Map<Class<? extends BrokerService>, BrokerService> services) {
+ this.services = services;
+ }
+
+ @Override
+ public boolean isClosed() {
+ return closed;
+ }
+
+ @Override
+ public <T extends BrokerService> T getService(final Class<T> aClass) {
+ return (T)services.get(aClass);
+ }
+
+ @Override
+ public void close() {
+ closed = true;
+ }
+ }
}
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 b7a24ea90..129a1b84b 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
@@ -85,6 +85,7 @@ public final class VppDataBrokerInitializationProvider implements Provider, Auto
private final ReaderRegistry readerRegistry;
private final InstanceIdentifier<Node> mountPointPath;
private ObjectRegistration<DOMMountPoint> mountPointRegistration;
+ private DOMDataBroker broker;
public VppDataBrokerInitializationProvider(@Nonnull final DataBroker bindingBroker, final ReaderRegistry readerRegistry) {
this.bindingBroker = Preconditions.checkNotNull(bindingBroker, "bindingBroker should not be null");
@@ -116,7 +117,7 @@ public final class VppDataBrokerInitializationProvider implements Provider, Auto
final DOMMountPointService.DOMMountPointBuilder mountPointBuilder = mountPointService.createMountPoint(path);
mountPointBuilder.addInitialSchemaContext(globalContext);
- final DOMDataBroker broker = initVppDataBroker(globalContext, serializer);
+ broker = initVppDataBroker(globalContext, serializer);
mountPointBuilder.addService(DOMDataBroker.class, broker);
mountPointRegistration = mountPointBuilder.register();
@@ -245,11 +246,20 @@ public final class VppDataBrokerInitializationProvider implements Provider, Auto
new LoggingFuturesCallBack<Void>("Initializing VPP config DataTree failed", LOG));
}
+ public Optional<DOMDataBroker> getBroker() {
+ return Optional.fromNullable(broker);
+ }
+
@Override
public void close() throws Exception {
if (mountPointRegistration != null) {
mountPointRegistration.close();
}
+
+ if (broker != null) {
+ broker = null;
+ }
+
// remove MD-SAL placeholder data for VPP mount point:
final WriteTransaction rwTx = bindingBroker.newWriteOnlyTransaction();
// does not fail if data is not present:
diff --git a/v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/NetconfBindingBrokerModule.java b/v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/NetconfBindingBrokerModule.java
new file mode 100644
index 000000000..48d227d01
--- /dev/null
+++ b/v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/NetconfBindingBrokerModule.java
@@ -0,0 +1,117 @@
+package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.impl.rev141210;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer;
+import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
+import org.opendaylight.controller.sal.binding.api.BindingAwareService;
+import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+import org.osgi.framework.BundleContext;
+
+public class NetconfBindingBrokerModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.impl.rev141210.AbstractNetconfBindingBrokerModule {
+ public NetconfBindingBrokerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ super(identifier, dependencyResolver);
+ }
+
+ public NetconfBindingBrokerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.impl.rev141210.NetconfBindingBrokerModule 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() {
+ return new FakeBindingAwareBroker(getNetconfBindingBrokerDependency());
+ }
+
+ private static class FakeBindingAwareBroker implements BindingAwareBroker, AutoCloseable {
+
+ private DataBroker netconfBindingBrokerDependency;
+
+ public FakeBindingAwareBroker(final DataBroker netconfBindingBrokerDependency) {
+
+ this.netconfBindingBrokerDependency = netconfBindingBrokerDependency;
+ }
+
+ @Deprecated
+ @Override
+ public ConsumerContext registerConsumer(final BindingAwareConsumer bindingAwareConsumer,
+ final BundleContext bundleContext) {
+ throw new UnsupportedOperationException("Unsupported");
+ }
+
+ @Override
+ public ConsumerContext registerConsumer(final BindingAwareConsumer bindingAwareConsumer) {
+ final ConsumerContext consumerContext = new ConsumerContext() {
+ @Override
+ public <T extends BindingAwareService> T getSALService(final Class<T> aClass) {
+ return aClass.equals(DataBroker.class)
+ ? (T) netconfBindingBrokerDependency
+ : null;
+ }
+
+ @Override
+ public <T extends RpcService> T getRpcService(final Class<T> aClass) {
+ return null;
+ }
+ };
+ bindingAwareConsumer.onSessionInitialized(consumerContext);
+ return consumerContext;
+ }
+
+ @Override
+ public ProviderContext registerProvider(final BindingAwareProvider bindingAwareProvider,
+ final BundleContext bundleContext) {
+ throw new UnsupportedOperationException("Unsupported");
+ }
+
+ @Override
+ public ProviderContext registerProvider(final BindingAwareProvider bindingAwareProvider) {
+ final ProviderContext context = new ProviderContext() {
+ @Override
+ public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L> registerRouteChangeListener(
+ final L l) {
+ throw new UnsupportedOperationException("Unsupported");
+ }
+
+ @Override
+ public <T extends RpcService> T getRpcService(final Class<T> aClass) {
+ throw new UnsupportedOperationException("Unsupported");
+ }
+
+ @Override
+ public <T extends RpcService> RpcRegistration<T> addRpcImplementation(final Class<T> aClass, final T t)
+ throws IllegalStateException {
+ throw new UnsupportedOperationException("Unsupported");
+ }
+
+ @Override
+ public <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(
+ final Class<T> aClass, final T t) throws IllegalStateException {
+ throw new UnsupportedOperationException("Unsupported");
+ }
+
+ @Override
+ public <T extends BindingAwareService> T getSALService(final Class<T> aClass) {
+ return aClass.equals(DataBroker.class)
+ ? (T) netconfBindingBrokerDependency
+ : null; }
+ };
+ bindingAwareProvider.onSessionInitiated(context);
+ return context;
+ }
+
+ @Override
+ public void close() throws Exception {
+ netconfBindingBrokerDependency = null;
+ }
+ }
+}
+
diff --git a/v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/NetconfBindingBrokerModuleFactory.java b/v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/NetconfBindingBrokerModuleFactory.java
new file mode 100644
index 000000000..b64b0b1e1
--- /dev/null
+++ b/v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/NetconfBindingBrokerModuleFactory.java
@@ -0,0 +1,13 @@
+/*
+* Generated file
+*
+* Generated from: yang module name: v3po-impl yang module local name: binding-broker-netconf
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Wed Mar 23 10:45:48 CET 2016
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.impl.rev141210;
+public class NetconfBindingBrokerModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.impl.rev141210.AbstractNetconfBindingBrokerModuleFactory {
+
+}