Proxy MD-SAL interfaces in DOMMountPointServiceImpl 80/77580/16
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 7 Nov 2018 12:49:48 +0000 (13:49 +0100)
committerTom Pantelis <tompantelis@gmail.com>
Sat, 17 Nov 2018 02:54:55 +0000 (02:54 +0000)
This patch deals with the case where a mount point is registered
via Controller interfaces and then accessed via MD-SAL interfaces
by providing any missing MD-SAL services via proxies built on top
of their Controller counterparts.

This also adds utility convertors to DOM{DataTree,Rpc}Identifier,
so they are readily available.

JIRA: CONTROLLER-1869
Change-Id: Iece3f1d2a2bba58669114f6f8b8abf89fd188690
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
17 files changed:
opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/LogicalDatastoreType.java
opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataTreeIdentifier.java
opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcIdentifier.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMRpcRouter.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/mount/DOMMountPointServiceImpl.java
opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMDataBrokerAdapter.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMDataTreeChangeServiceAdapter.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMDataTreeReadTransactionAdapter.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMDataTreeReadWriteTransactionAdapter.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMDataTreeWriteTransactionAdapter.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMNotificationServiceAdapter.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMRpcServiceAdapter.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMTransactionChainAdapter.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/LegacyDOMDataBrokerAdapter.java
opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/RpcAvailabilityListenerAdapter.java
opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/TransactionUtils.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/broker/spi/mount/SimpleDOMMountPoint.java

index 651c919..ed99552 100644 (file)
@@ -48,4 +48,21 @@ public enum LogicalDatastoreType {
      * @return MD-SAL counterpart of this type.
      */
     public abstract org.opendaylight.mdsal.common.api.LogicalDatastoreType toMdsal();
+
+    /**
+     * Convert MD-SAL logical datastore type to this counterpart.
+     *
+     * @param type MD-SAL counterpart of this type.
+     * @return Corresponding value in this type.
+     */
+    public static LogicalDatastoreType fromMdsal(final org.opendaylight.mdsal.common.api.LogicalDatastoreType type) {
+        switch (type) {
+            case CONFIGURATION:
+                return CONFIGURATION;
+            case OPERATIONAL:
+                return OPERATIONAL;
+            default:
+                throw new IllegalArgumentException("Unhandled type " + type);
+        }
+    }
 }
index 0f015d1..f9a96ba 100644 (file)
@@ -35,6 +35,25 @@ public final class DOMDataTreeIdentifier implements Immutable,
         this.rootIdentifier = Preconditions.checkNotNull(rootIdentifier);
     }
 
+    /**
+     * Return a counterpart to an MD-SAL data tree identifier.
+     *
+     * @return Controller data tree identifier.
+     */
+    public static DOMDataTreeIdentifier fromMdsal(final org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier mdsal) {
+        return new DOMDataTreeIdentifier(LogicalDatastoreType.fromMdsal(mdsal.getDatastoreType()),
+            mdsal.getRootIdentifier());
+    }
+
+    /**
+     * Return MD-SAL counterpart of this object.
+     *
+     * @return MD-SAL data tree identifier.
+     */
+    public org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier toMdsal() {
+        return new org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier(datastoreType.toMdsal(), rootIdentifier);
+    }
+
     /**
      * Return the logical data store type.
      *
index 60fae67..63e646d 100644 (file)
@@ -79,6 +79,14 @@ public abstract class DOMRpcIdentifier {
         return new Local(type, contextReference);
     }
 
+    public static DOMRpcIdentifier fromMdsal(final org.opendaylight.mdsal.dom.api.DOMRpcIdentifier mdsal) {
+        return create(mdsal.getType(), mdsal.getContextReference());
+    }
+
+    public org.opendaylight.mdsal.dom.api.DOMRpcIdentifier toMdsal() {
+        return org.opendaylight.mdsal.dom.api.DOMRpcIdentifier.create(type, getContextReference());
+    }
+
     /**
      * Return the RPC type.
      *
index 87ba273..b660423 100644 (file)
@@ -15,7 +15,6 @@ import java.util.Collections;
 import java.util.Map;
 import java.util.Set;
 import java.util.WeakHashMap;
-import java.util.stream.Collectors;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcAvailabilityListener;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier;
@@ -25,6 +24,7 @@ import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
 import org.opendaylight.controller.md.sal.dom.spi.AbstractDOMRpcImplementationRegistration;
+import org.opendaylight.controller.sal.core.compat.DOMRpcServiceAdapter;
 import org.opendaylight.controller.sal.core.compat.LegacyDOMRpcResultFutureAdapter;
 import org.opendaylight.controller.sal.core.compat.MdsalDOMRpcResultFutureAdapter;
 import org.opendaylight.controller.sal.core.compat.RpcAvailabilityListenerAdapter;
@@ -78,9 +78,11 @@ public final class DOMRpcRouter implements AutoCloseable, DOMRpcService, DOMRpcP
                 @Override
                 public FluentFuture<org.opendaylight.mdsal.dom.api.DOMRpcResult> invokeRpc(
                         final org.opendaylight.mdsal.dom.api.DOMRpcIdentifier rpc, final NormalizedNode<?, ?> input) {
-                    return new MdsalDOMRpcResultFutureAdapter(implementation.invokeRpc(convert(rpc), input));
+                    return new MdsalDOMRpcResultFutureAdapter(implementation.invokeRpc(DOMRpcIdentifier.fromMdsal(rpc),
+                        input));
                 }
 
+
                 @Override
                 public long invocationCost() {
                     return implementation.invocationCost();
@@ -91,8 +93,7 @@ public final class DOMRpcRouter implements AutoCloseable, DOMRpcService, DOMRpcP
 
         final org.opendaylight.mdsal.dom.api.DOMRpcImplementationRegistration
             <org.opendaylight.mdsal.dom.api.DOMRpcImplementation> reg = delegateRpcProviderService
-                .registerRpcImplementation(delegateImpl,
-                        rpcs.stream().map(DOMRpcRouter::convert).collect(Collectors.toSet()));
+                .registerRpcImplementation(delegateImpl, DOMRpcServiceAdapter.convert(rpcs));
 
         return new AbstractDOMRpcImplementationRegistration<T>(implementation) {
             @Override
@@ -103,14 +104,6 @@ public final class DOMRpcRouter implements AutoCloseable, DOMRpcService, DOMRpcP
         };
     }
 
-    private static org.opendaylight.mdsal.dom.api.DOMRpcIdentifier convert(final DOMRpcIdentifier from) {
-        return org.opendaylight.mdsal.dom.api.DOMRpcIdentifier.create(from.getType(), from.getContextReference());
-    }
-
-    private static DOMRpcIdentifier convert(final org.opendaylight.mdsal.dom.api.DOMRpcIdentifier from) {
-        return DOMRpcIdentifier.create(from.getType(), from.getContextReference());
-    }
-
     @Override
     public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final SchemaPath type,
                                                                   final NormalizedNode<?, ?> input) {
index 27a4a78..6cfdb5a 100644 (file)
@@ -7,23 +7,93 @@
  */
 package org.opendaylight.controller.md.sal.dom.broker.impl.mount;
 
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ClassToInstanceMap;
+import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.MutableClassToInstanceMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import org.opendaylight.controller.md.sal.dom.api.DOMActionService;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
 import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
 import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
+import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
 import org.opendaylight.controller.md.sal.dom.api.DOMService;
 import org.opendaylight.controller.md.sal.dom.broker.spi.mount.SimpleDOMMountPoint;
+import org.opendaylight.controller.sal.core.compat.DOMDataBrokerAdapter;
 import org.opendaylight.controller.sal.core.compat.DOMMountPointAdapter;
+import org.opendaylight.controller.sal.core.compat.DOMNotificationServiceAdapter;
+import org.opendaylight.controller.sal.core.compat.DOMRpcServiceAdapter;
 import org.opendaylight.mdsal.dom.api.DOMMountPointListener;
+import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.concepts.ObjectRegistration;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
 public class DOMMountPointServiceImpl implements DOMMountPointService {
+    private abstract static class CompatFactory<M extends org.opendaylight.mdsal.dom.api.DOMService,
+            C extends DOMService> {
+        private final Class<C> controllerClass;
+        private final Class<M> mdsalClass;
+
+        CompatFactory(final Class<C> controllerClass, final Class<M> mdsalClass) {
+            this.controllerClass = requireNonNull(controllerClass);
+            this.mdsalClass = requireNonNull(mdsalClass);
+        }
+
+        final void addService(final org.opendaylight.mdsal.dom.api.DOMMountPointService.DOMMountPointBuilder builder,
+                final ClassToInstanceMap<DOMService> services) {
+            if (!services.containsKey(mdsalClass)) {
+                final C controllerService = services.getInstance(controllerClass);
+                if (controllerService != null) {
+                    final M mdsalService = createService(controllerService);
+                    if (mdsalService != null) {
+                        builder.addService(mdsalClass, mdsalService);
+                    }
+                }
+            }
+        }
+
+        abstract M createService(C delegate);
+    }
+
+    private static final Map<Class<? extends DOMService>, CompatFactory<?, ?>> KNOWN_SERVICES = ImmutableMap.of(
+        DOMActionService.class, new CompatFactory<org.opendaylight.mdsal.dom.api.DOMActionService, DOMActionService>(
+                DOMActionService.class, org.opendaylight.mdsal.dom.api.DOMActionService.class) {
+            @Override
+            org.opendaylight.mdsal.dom.api.DOMActionService createService(final DOMActionService delegate) {
+                return delegate;
+            }
+        },
+        DOMDataBroker.class, new CompatFactory<org.opendaylight.mdsal.dom.api.DOMDataBroker, DOMDataBroker>(
+                DOMDataBroker.class, org.opendaylight.mdsal.dom.api.DOMDataBroker.class) {
+            @Override
+            org.opendaylight.mdsal.dom.api.DOMDataBroker createService(final DOMDataBroker delegate) {
+                return new DOMDataBrokerAdapter(delegate);
+            }
+        },
+        DOMNotificationService.class, new CompatFactory<org.opendaylight.mdsal.dom.api.DOMNotificationService,
+                DOMNotificationService>(DOMNotificationService.class,
+                        org.opendaylight.mdsal.dom.api.DOMNotificationService.class) {
+            @Override
+            org.opendaylight.mdsal.dom.api.DOMNotificationService createService(final DOMNotificationService delegate) {
+                return new DOMNotificationServiceAdapter(delegate);
+            }
+        },
+        DOMRpcService.class, new CompatFactory<org.opendaylight.mdsal.dom.api.DOMRpcService, DOMRpcService>(
+                DOMRpcService.class, org.opendaylight.mdsal.dom.api.DOMRpcService.class) {
+            @Override
+            org.opendaylight.mdsal.dom.api.DOMRpcService createService(final DOMRpcService delegate) {
+                return new DOMRpcServiceAdapter(delegate);
+            }
+        });
+
     private final org.opendaylight.mdsal.dom.api.DOMMountPointService delegate;
 
     @VisibleForTesting
@@ -59,28 +129,29 @@ public class DOMMountPointServiceImpl implements DOMMountPointService {
             delegateBuilder.addInitialSchemaContext(mountPoint.getSchemaContext());
         }
 
-        mountPoint.getAllServices().forEach(
-            entry -> delegateBuilder.addService((Class<DOMService>)entry.getKey(), entry.getValue()));
+        final ClassToInstanceMap<DOMService> myServices = mountPoint.getServices();
+        for (Entry<Class<? extends DOMService>, DOMService> entry : myServices.entrySet()) {
+            delegateBuilder.addService((Class<DOMService>)entry.getKey(), entry.getValue());
 
-        final ObjectRegistration<org.opendaylight.mdsal.dom.api.DOMMountPoint> delegateReg = delegateBuilder.register();
-        return new ObjectRegistration<DOMMountPoint>() {
-            @Override
-            public void close() {
-                delegateReg.close();
+            final CompatFactory<?, ?> compat = KNOWN_SERVICES.get(entry.getKey());
+            if (compat != null) {
+                compat.addService(delegateBuilder, myServices);
             }
+        }
 
+        final ObjectRegistration<org.opendaylight.mdsal.dom.api.DOMMountPoint> delegateReg = delegateBuilder.register();
+        return new AbstractObjectRegistration<DOMMountPoint>(mountPoint) {
             @Override
-            public DOMMountPoint getInstance() {
-                return mountPoint;
+            protected void removeRegistration() {
+                delegateReg.close();
             }
         };
     }
 
     public class DOMMountPointBuilderImpl implements DOMMountPointBuilder {
-
-        ClassToInstanceMap<DOMService> services = MutableClassToInstanceMap.create();
-        private SimpleDOMMountPoint mountPoint;
+        private final ClassToInstanceMap<DOMService> services = MutableClassToInstanceMap.create();
         private final YangInstanceIdentifier path;
+        private SimpleDOMMountPoint mountPoint;
         private SchemaContext schemaContext;
 
         public DOMMountPointBuilderImpl(final YangInstanceIdentifier path) {
diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMDataBrokerAdapter.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMDataBrokerAdapter.java
new file mode 100644 (file)
index 0000000..a5a47bb
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.sal.core.compat;
+
+import static java.util.Objects.requireNonNull;
+
+import com.google.common.collect.ClassToInstanceMap;
+import com.google.common.collect.ForwardingObject;
+import com.google.common.collect.ImmutableClassToInstanceMap;
+import com.google.common.collect.ImmutableClassToInstanceMap.Builder;
+import java.util.Map;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBrokerExtension;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeCommitCohortRegistry;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
+import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
+import org.opendaylight.mdsal.dom.api.DOMTransactionChainListener;
+
+@Deprecated
+public class DOMDataBrokerAdapter extends ForwardingObject implements org.opendaylight.mdsal.dom.api.DOMDataBroker {
+    private final ClassToInstanceMap<org.opendaylight.mdsal.dom.api.DOMDataBrokerExtension> extensions;
+    private final DOMDataBroker delegate;
+
+    public DOMDataBrokerAdapter(final DOMDataBroker delegate) {
+        this.delegate = requireNonNull(delegate);
+
+        Map<Class<? extends DOMDataBrokerExtension>, DOMDataBrokerExtension> delegateExtensions =
+                delegate.getSupportedExtensions();
+        Builder<org.opendaylight.mdsal.dom.api.DOMDataBrokerExtension> extBuilder =
+                ImmutableClassToInstanceMap.builder();
+
+        final DOMDataTreeChangeService delegateTreeChangeService = (DOMDataTreeChangeService) delegateExtensions.get(
+            DOMDataTreeChangeService.class);
+        if (delegateTreeChangeService != null) {
+            extBuilder.put(org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService.class,
+                new DOMDataTreeChangeServiceAdapter(delegateTreeChangeService));
+        }
+
+        final DOMDataTreeCommitCohortRegistry delegateCohortRegistry =
+                (DOMDataTreeCommitCohortRegistry) delegateExtensions.get(DOMDataTreeCommitCohortRegistry.class);
+        if (delegateCohortRegistry != null) {
+            extBuilder.put(DOMDataTreeCommitCohortRegistry.class, delegateCohortRegistry::registerCommitCohort);
+        }
+
+        extensions = extBuilder.build();
+    }
+
+    @Override
+    public DOMDataTreeReadTransaction newReadOnlyTransaction() {
+        return new DOMDataTreeReadTransactionAdapter(delegate.newReadOnlyTransaction());
+    }
+
+    @Override
+    public DOMDataTreeWriteTransaction newWriteOnlyTransaction() {
+        return new DOMDataTreeWriteTransactionAdapter(delegate.newWriteOnlyTransaction());
+    }
+
+    @Override
+    public DOMDataTreeReadWriteTransaction newReadWriteTransaction() {
+        return new DOMDataTreeReadWriteTransactionAdapter(delegate.newReadWriteTransaction());
+    }
+
+    @Override
+    public ClassToInstanceMap<org.opendaylight.mdsal.dom.api.DOMDataBrokerExtension> getExtensions() {
+        return extensions;
+    }
+
+    @Override
+    public DOMTransactionChain createTransactionChain(final DOMTransactionChainListener listener) {
+        return new DOMTransactionChainAdapter(listener, delegate::createTransactionChain);
+    }
+
+    @Override
+    protected DOMDataBroker delegate() {
+        return delegate;
+    }
+}
diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMDataTreeChangeServiceAdapter.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMDataTreeChangeServiceAdapter.java
new file mode 100644 (file)
index 0000000..aa2011b
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.sal.core.compat;
+
+import static java.util.Objects.requireNonNull;
+
+import com.google.common.collect.ForwardingObject;
+import org.opendaylight.controller.md.sal.dom.api.ClusteredDOMDataTreeChangeListener;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeIdentifier;
+import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+
+@Deprecated
+public class DOMDataTreeChangeServiceAdapter extends ForwardingObject
+        implements org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService {
+
+    private final DOMDataTreeChangeService delegate;
+
+    DOMDataTreeChangeServiceAdapter(final DOMDataTreeChangeService delegate) {
+        this.delegate = requireNonNull(delegate);
+    }
+
+    @Override
+    public <L extends org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener> ListenerRegistration<L>
+            registerDataTreeChangeListener(final org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier treeId,
+                    final L listener) {
+        final DOMDataTreeChangeListener delegateListener;
+        if (listener instanceof org.opendaylight.mdsal.dom.api.ClusteredDOMDataTreeChangeListener) {
+            delegateListener = (ClusteredDOMDataTreeChangeListener) listener::onDataTreeChanged;
+        } else {
+            delegateListener = listener::onDataTreeChanged;
+        }
+        final ListenerRegistration<?> reg = delegate().registerDataTreeChangeListener(
+            DOMDataTreeIdentifier.fromMdsal(treeId), delegateListener);
+
+        return new AbstractListenerRegistration<L>(listener) {
+            @Override
+            protected void removeRegistration() {
+                reg.close();
+            }
+        };
+    }
+
+    @Override
+    protected DOMDataTreeChangeService delegate() {
+        return delegate;
+    }
+}
diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMDataTreeReadTransactionAdapter.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMDataTreeReadTransactionAdapter.java
new file mode 100644 (file)
index 0000000..786177a
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.sal.core.compat;
+
+import static java.util.Objects.requireNonNull;
+
+import com.google.common.collect.ForwardingObject;
+import com.google.common.util.concurrent.FluentFuture;
+import java.util.Optional;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+
+public class DOMDataTreeReadTransactionAdapter extends ForwardingObject implements DOMDataTreeReadTransaction {
+    private final DOMDataReadOnlyTransaction delegate;
+
+    public DOMDataTreeReadTransactionAdapter(final DOMDataReadOnlyTransaction delegate) {
+        this.delegate = requireNonNull(delegate);
+    }
+
+    @Override
+    public Object getIdentifier() {
+        return delegate().getIdentifier();
+    }
+
+    @Override
+    public FluentFuture<Optional<NormalizedNode<?, ?>>> read(final LogicalDatastoreType store,
+            final YangInstanceIdentifier path) {
+        return TransactionUtils.read(delegate(), store, path);
+    }
+
+    @Override
+    public FluentFuture<Boolean> exists(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
+        return TransactionUtils.exists(delegate(), store, path);
+    }
+
+    @Override
+    public void close() {
+        delegate().close();
+    }
+
+    @Override
+    protected DOMDataReadOnlyTransaction delegate() {
+        return delegate;
+    }
+}
diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMDataTreeReadWriteTransactionAdapter.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMDataTreeReadWriteTransactionAdapter.java
new file mode 100644 (file)
index 0000000..d35ce44
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.sal.core.compat;
+
+import static java.util.Objects.requireNonNull;
+
+import com.google.common.collect.ForwardingObject;
+import com.google.common.util.concurrent.FluentFuture;
+import java.util.Optional;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
+import org.opendaylight.mdsal.common.api.CommitInfo;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+
+public class DOMDataTreeReadWriteTransactionAdapter extends ForwardingObject
+        implements DOMDataTreeReadWriteTransaction {
+    private final DOMDataReadWriteTransaction delegate;
+
+    public DOMDataTreeReadWriteTransactionAdapter(final DOMDataReadWriteTransaction delegate) {
+        this.delegate = requireNonNull(delegate);
+    }
+
+    @Override
+    public Object getIdentifier() {
+        return delegate().getIdentifier();
+    }
+
+    @Override
+    public FluentFuture<Optional<NormalizedNode<?, ?>>> read(final LogicalDatastoreType store,
+            final YangInstanceIdentifier path) {
+        return TransactionUtils.read(delegate(), store, path);
+    }
+
+    @Override
+    public FluentFuture<Boolean> exists(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
+        return TransactionUtils.exists(delegate(), store, path);
+    }
+
+    @Override
+    public void close() {
+        cancel();
+    }
+
+    @Override
+    public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path,
+            final NormalizedNode<?, ?> data) {
+        TransactionUtils.put(delegate(), store, path, data);
+    }
+
+    @Override
+    public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path,
+            final NormalizedNode<?, ?> data) {
+        TransactionUtils.merge(delegate(), store, path, data);
+    }
+
+    @Override
+    public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
+        TransactionUtils.delete(delegate(), store, path);
+    }
+
+    @Override
+    public FluentFuture<? extends CommitInfo> commit() {
+        return delegate().commit();
+    }
+
+    @Override
+    public boolean cancel() {
+        return delegate().cancel();
+    }
+
+    @Override
+    protected DOMDataReadWriteTransaction delegate() {
+        return delegate;
+    }
+}
diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMDataTreeWriteTransactionAdapter.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMDataTreeWriteTransactionAdapter.java
new file mode 100644 (file)
index 0000000..7affc35
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.sal.core.compat;
+
+import static java.util.Objects.requireNonNull;
+
+import com.google.common.collect.ForwardingObject;
+import com.google.common.util.concurrent.FluentFuture;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
+import org.opendaylight.mdsal.common.api.CommitInfo;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+
+public class DOMDataTreeWriteTransactionAdapter extends ForwardingObject
+        implements DOMDataTreeWriteTransaction {
+    private final DOMDataWriteTransaction delegate;
+
+    public DOMDataTreeWriteTransactionAdapter(final DOMDataWriteTransaction delegate) {
+        this.delegate = requireNonNull(delegate);
+    }
+
+    @Override
+    public Object getIdentifier() {
+        return delegate().getIdentifier();
+    }
+
+    @Override
+    public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path,
+            final NormalizedNode<?, ?> data) {
+        TransactionUtils.put(delegate(), store, path, data);
+    }
+
+    @Override
+    public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path,
+            final NormalizedNode<?, ?> data) {
+        TransactionUtils.merge(delegate(), store, path, data);
+    }
+
+    @Override
+    public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
+        TransactionUtils.delete(delegate(), store, path);
+    }
+
+    @Override
+    public FluentFuture<? extends CommitInfo> commit() {
+        return delegate().commit();
+    }
+
+    @Override
+    public boolean cancel() {
+        return delegate().cancel();
+    }
+
+    @Override
+    protected DOMDataWriteTransaction delegate() {
+        return delegate;
+    }
+}
diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMNotificationServiceAdapter.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMNotificationServiceAdapter.java
new file mode 100644 (file)
index 0000000..61b596b
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.sal.core.compat;
+
+import static java.util.Objects.requireNonNull;
+
+import com.google.common.collect.ForwardingObject;
+import java.util.Arrays;
+import java.util.Collection;
+import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService;
+import org.opendaylight.mdsal.dom.api.DOMNotificationListener;
+import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+
+@Deprecated
+public class DOMNotificationServiceAdapter extends ForwardingObject
+        implements org.opendaylight.mdsal.dom.api.DOMNotificationService {
+
+    private final DOMNotificationService delegate;
+
+    public DOMNotificationServiceAdapter(final DOMNotificationService delegate) {
+        this.delegate = requireNonNull(delegate);
+    }
+
+    @Override
+    public <T extends DOMNotificationListener> ListenerRegistration<T> registerNotificationListener(final T listener,
+            final Collection<SchemaPath> types) {
+        // Controller events are sub-interfaces of MD-SAL events, hence direct routing is okay
+        final ListenerRegistration<?> reg = delegate().registerNotificationListener(listener::onNotification, types);
+
+        return new AbstractListenerRegistration<T>(listener) {
+            @Override
+            protected void removeRegistration() {
+                reg.close();
+
+            }
+        };
+    }
+
+    @Override
+    public <T extends DOMNotificationListener> ListenerRegistration<T> registerNotificationListener(final T listener,
+            final SchemaPath... types) {
+        return registerNotificationListener(listener, Arrays.asList(types));
+    }
+
+    @Override
+    protected DOMNotificationService delegate() {
+        return delegate;
+    }
+}
diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMRpcServiceAdapter.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMRpcServiceAdapter.java
new file mode 100644 (file)
index 0000000..06cf6bc
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.sal.core.compat;
+
+import static java.util.Objects.requireNonNull;
+
+import com.google.common.collect.ForwardingObject;
+import com.google.common.util.concurrent.FluentFuture;
+import java.util.Collection;
+import java.util.Set;
+import java.util.stream.Collectors;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcAvailabilityListener;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
+import org.opendaylight.mdsal.dom.api.DOMRpcResult;
+import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+
+@Deprecated
+public class DOMRpcServiceAdapter extends ForwardingObject implements org.opendaylight.mdsal.dom.api.DOMRpcService {
+    private final DOMRpcService delegate;
+
+    public DOMRpcServiceAdapter(final DOMRpcService delegate) {
+        this.delegate = requireNonNull(delegate);
+    }
+
+    @Override
+    public FluentFuture<DOMRpcResult> invokeRpc(final SchemaPath type, final NormalizedNode<?, ?> input) {
+        return new MdsalDOMRpcResultFutureAdapter(delegate().invokeRpc(type, input));
+    }
+
+    @Override
+    public <T extends org.opendaylight.mdsal.dom.api.DOMRpcAvailabilityListener> ListenerRegistration<T>
+            registerRpcListener(final T listener) {
+        final ListenerRegistration<?> reg = delegate().registerRpcListener(new DOMRpcAvailabilityListener() {
+            @Override
+            public void onRpcAvailable(final Collection<DOMRpcIdentifier> rpcs) {
+                listener.onRpcAvailable(convert(rpcs));
+            }
+
+            @Override
+            public void onRpcUnavailable(final Collection<DOMRpcIdentifier> rpcs) {
+                listener.onRpcUnavailable(convert(rpcs));
+            }
+        });
+
+        return new AbstractListenerRegistration<T>(listener) {
+            @Override
+            protected void removeRegistration() {
+                reg.close();
+            }
+        };
+    }
+
+    @Override
+    protected DOMRpcService delegate() {
+        return delegate;
+    }
+
+    public static Set<org.opendaylight.mdsal.dom.api.DOMRpcIdentifier> convert(
+            final Collection<DOMRpcIdentifier> rpcs) {
+        return rpcs.stream().map(DOMRpcIdentifier::toMdsal).collect(Collectors.toSet());
+    }
+}
diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMTransactionChainAdapter.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMTransactionChainAdapter.java
new file mode 100644 (file)
index 0000000..685986c
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.sal.core.compat;
+
+import static java.util.Objects.requireNonNull;
+
+import com.google.common.cache.Cache;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.collect.ForwardingObject;
+import java.util.function.Function;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChain;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeTransaction;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
+import org.opendaylight.mdsal.dom.api.DOMTransactionChainListener;
+
+@Deprecated
+public class DOMTransactionChainAdapter extends ForwardingObject
+        implements org.opendaylight.mdsal.dom.api.DOMTransactionChain, TransactionChainListener {
+    private final Cache<AsyncTransaction<?, ?>, DOMDataTreeTransaction> transactions = CacheBuilder.newBuilder()
+            .weakKeys().weakValues().build();
+
+    private final DOMTransactionChainListener listener;
+    private final DOMTransactionChain delegate;
+
+    public DOMTransactionChainAdapter(final DOMTransactionChainListener listener,
+            final Function<TransactionChainListener, DOMTransactionChain> function) {
+        this.listener = requireNonNull(listener);
+        this.delegate = function.apply(this);
+    }
+
+    @Override
+    public void close() {
+        delegate().close();
+        transactions.invalidateAll();
+    }
+
+    @Override
+    public DOMDataTreeReadTransaction newReadOnlyTransaction() {
+        final DOMDataReadOnlyTransaction tx = delegate.newReadOnlyTransaction();
+        return track(tx, new DOMDataTreeReadTransactionAdapter(tx) {
+            @Override
+            public void close() {
+                untrack(delegate());
+                super.close();
+            }
+        });
+    }
+
+    @Override
+    public DOMDataTreeWriteTransaction newWriteOnlyTransaction() {
+        final DOMDataWriteTransaction tx = delegate.newWriteOnlyTransaction();
+        return track(tx, new DOMDataTreeWriteTransactionAdapter(tx) {
+            @Override
+            public boolean cancel() {
+                untrack(delegate());
+                return super.cancel();
+            }
+        });
+    }
+
+    @Override
+    public DOMDataTreeReadWriteTransaction newReadWriteTransaction() {
+        final DOMDataReadWriteTransaction tx = delegate.newReadWriteTransaction();
+        return track(tx, new DOMDataTreeReadWriteTransactionAdapter(tx) {
+            @Override
+            public boolean cancel() {
+                untrack(delegate());
+                return super.cancel();
+            }
+
+            @Override
+            public void close() {
+                untrack(delegate());
+                super.close();
+            }
+        });
+    }
+
+    @Override
+    public void onTransactionChainFailed(final TransactionChain<?, ?> chain, final AsyncTransaction<?, ?> transaction,
+            final Throwable cause) {
+        listener.onTransactionChainFailed(this, null, cause);
+    }
+
+    @Override
+    public void onTransactionChainSuccessful(final TransactionChain<?, ?> chain) {
+        listener.onTransactionChainSuccessful(this);
+    }
+
+    @Override
+    protected DOMTransactionChain delegate() {
+        return delegate;
+    }
+
+    private <T extends DOMDataTreeTransaction> T track(final AsyncTransaction<?, ?> controllerTx, final T mdsalTx) {
+        transactions.put(controllerTx, mdsalTx);
+        return mdsalTx;
+    }
+
+    void untrack(final AsyncTransaction<?, ?> controllerTx) {
+        transactions.invalidate(controllerTx);
+    }
+}
index d0f42b7..b9cd447 100644 (file)
@@ -106,9 +106,7 @@ public class LegacyDOMDataBrokerAdapter extends ForwardingObject implements DOMD
                     }
 
                     final ListenerRegistration<org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener> reg =
-                        delegateTreeChangeService.registerDataTreeChangeListener(
-                            new org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier(
-                                treeId.getDatastoreType().toMdsal(), treeId.getRootIdentifier()), delegateListener);
+                        delegateTreeChangeService.registerDataTreeChangeListener(treeId.toMdsal(), delegateListener);
 
                     return new ListenerRegistration<L>() {
                         @Override
@@ -252,31 +250,33 @@ public class LegacyDOMDataBrokerAdapter extends ForwardingObject implements DOMD
         }
 
         @Override
-        public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(LogicalDatastoreType store,
-                YangInstanceIdentifier path) {
+        public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final LogicalDatastoreType store,
+                final YangInstanceIdentifier path) {
             return MappingCheckedFuture.create(readDelegate().read(store.toMdsal(), path).transform(
                 Optional::fromJavaUtil, MoreExecutors.directExecutor()), ReadFailedExceptionAdapter.INSTANCE);
         }
 
         @Override
-        public CheckedFuture<Boolean, ReadFailedException> exists(LogicalDatastoreType store,
-                YangInstanceIdentifier path) {
+        public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store,
+                final YangInstanceIdentifier path) {
             return MappingCheckedFuture.create(readDelegate().exists(store.toMdsal(), path),
                     ReadFailedExceptionAdapter.INSTANCE);
         }
 
         @Override
-        public void delete(LogicalDatastoreType store, YangInstanceIdentifier path) {
+        public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
             writeDelegate().delete(store.toMdsal(), path);
         }
 
         @Override
-        public void put(LogicalDatastoreType store, YangInstanceIdentifier path, NormalizedNode<?, ?> data) {
+        public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path,
+                final NormalizedNode<?, ?> data) {
             writeDelegate().put(store.toMdsal(), path, data);
         }
 
         @Override
-        public void merge(LogicalDatastoreType store, YangInstanceIdentifier path, NormalizedNode<?, ?> data) {
+        public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path,
+                final NormalizedNode<?, ?> data) {
             writeDelegate().merge(store.toMdsal(), path, data);
         }
 
index d5d472a..717eda2 100644 (file)
@@ -42,10 +42,6 @@ public class RpcAvailabilityListenerAdapter<T extends DOMRpcAvailabilityListener
 
     private static @NonNull Collection<DOMRpcIdentifier> convert(
             final Collection<org.opendaylight.mdsal.dom.api.DOMRpcIdentifier> from) {
-        return from.stream().map(RpcAvailabilityListenerAdapter::convert).collect(Collectors.toList());
-    }
-
-    private static @NonNull DOMRpcIdentifier convert(final org.opendaylight.mdsal.dom.api.DOMRpcIdentifier from) {
-        return DOMRpcIdentifier.create(from.getType(), from.getContextReference());
+        return from.stream().map(DOMRpcIdentifier::fromMdsal).collect(Collectors.toList());
     }
 }
diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/TransactionUtils.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/TransactionUtils.java
new file mode 100644 (file)
index 0000000..50e697a
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.sal.core.compat;
+
+import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.fromMdsal;
+
+import com.google.common.util.concurrent.FluentFuture;
+import com.google.common.util.concurrent.MoreExecutors;
+import java.util.Optional;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+
+final class TransactionUtils {
+    private TransactionUtils() {
+
+    }
+
+    static FluentFuture<Boolean> exists(final DOMDataReadTransaction tx,
+            final LogicalDatastoreType store, final YangInstanceIdentifier path) {
+        return FluentFuture.from(tx.exists(fromMdsal(store), path));
+    }
+
+    static FluentFuture<Optional<NormalizedNode<?, ?>>> read(final DOMDataReadTransaction tx,
+            final LogicalDatastoreType store, final YangInstanceIdentifier path) {
+        return FluentFuture.from(tx.read(fromMdsal(store), path)).transform(opt -> opt.toJavaUtil(),
+            MoreExecutors.directExecutor());
+    }
+
+    static void delete(final DOMDataWriteTransaction tx, final LogicalDatastoreType store,
+            final YangInstanceIdentifier path) {
+        tx.delete(fromMdsal(store), path);
+    }
+
+    static void merge(final DOMDataWriteTransaction tx, final LogicalDatastoreType store,
+            final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
+        tx.merge(fromMdsal(store), path, data);
+    }
+
+    static void put(final DOMDataWriteTransaction tx, final LogicalDatastoreType store,
+            final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
+        tx.put(fromMdsal(store), path, data);
+    }
+}
index bd0b6fb..65aeb89 100644 (file)
@@ -55,6 +55,10 @@ public final class SimpleDOMMountPoint implements DOMMountPoint {
         return services.entrySet();
     }
 
+    public ClassToInstanceMap<DOMService> getServices() {
+        return services;
+    }
+
     @Override
     public int hashCode() {
         return identifier.hashCode();

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.