<artifactId>benchmark-api</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-core-api</artifactId>
- </dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-data-impl</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-binding-api</artifactId>
+ </dependency>
</dependencies>
</project>
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicLong;
-import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.GlobalRpcBenchInput;
import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.GlobalRpcBenchInputBuilder;
import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.GlobalRpcBenchOutput;
* 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 rpcbenchmark.impl;
import java.util.ArrayList;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicLong;
-import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.RoutedRpcBenchInput;
import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.RoutedRpcBenchInputBuilder;
import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.RoutedRpcBenchOutput;
private final List<RoutedRpcBenchInput> inVal;
private final int inSize;
- @Override
- public long getRpcOk() {
- return rpcOk.get();
- }
-
- @Override
- public long getRpcError() {
- return rpcError.get();
- }
-
public RoutedBindingRTClient(final RpcConsumerRegistry registry, final int inSize,
final List<InstanceIdentifier<?>> routeIid) {
if (registry != null) {
}
+ @Override
+ public long getRpcOk() {
+ return rpcOk.get();
+ }
+
+ @Override
+ public long getRpcError() {
+ return rpcError.get();
+ }
+
@Override
public void runTest(final int iterations) {
int ok = 0;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.NodeContext;
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.RpcbenchPayloadService;
import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.RpcbenchRpcRoutes;
import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.rpcbench.rpc.routes.RpcRoute;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rpcbenchmark.rev150702.TestStatusOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rpcbenchmark.rev150702.TestStatusOutput.ExecStatus;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rpcbenchmark.rev150702.TestStatusOutputBuilder;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcResult;
private final GlobalBindingRTCServer globalServer;
private final AtomicReference<ExecStatus> execStatus = new AtomicReference<>(ExecStatus.Idle);
- private final RpcProviderRegistry providerRegistry;
+ private final RpcProviderService providerRegistry;
+ private final RpcConsumerRegistry consumerRegistry;
- public RpcbenchmarkProvider(final RpcProviderRegistry providerRegistry, final GlobalBindingRTCServer globalServer) {
+ public RpcbenchmarkProvider(final RpcProviderService providerRegistry, final RpcConsumerRegistry consumerRegistry,
+ final GlobalBindingRTCServer globalServer) {
this.providerRegistry = providerRegistry;
+ this.consumerRegistry = consumerRegistry;
this.globalServer = globalServer;
}
LOG.debug("startTest {}", input);
final RTCClient client;
- final List<RoutedRpcRegistration<?>> rpcRegs = new ArrayList<>();
+ final List<ObjectRegistration<?>> rpcRegs = new ArrayList<>();
switch (input.getOperation()) {
case ROUTEDRTC:
List<InstanceIdentifier<?>> routeIid = new ArrayList<>();
for (int i = 0; i < input.getNumServers().intValue(); i++) {
GlobalBindingRTCServer server = new GlobalBindingRTCServer();
- RoutedRpcRegistration<RpcbenchPayloadService> routedReg =
- providerRegistry.addRoutedRpcImplementation(RpcbenchPayloadService.class, server);
-
KeyedInstanceIdentifier<RpcRoute, RpcRouteKey> iid =
- InstanceIdentifier
- .create(RpcbenchRpcRoutes.class)
- .child(RpcRoute.class, new RpcRouteKey(Integer.toString(i)));
+ InstanceIdentifier.create(RpcbenchRpcRoutes.class)
+ .child(RpcRoute.class, new RpcRouteKey(Integer.toString(i)));
routeIid.add(iid);
- routedReg.registerPath(NodeContext.class, iid);
+
+ ObjectRegistration<?> routedReg = providerRegistry.registerRpcImplementation(
+ RpcbenchPayloadService.class, server, Set.of(iid));
+
rpcRegs.add(routedReg);
}
- client = new RoutedBindingRTClient(providerRegistry, input.getPayloadSize().intValue(), routeIid);
+ client = new RoutedBindingRTClient(consumerRegistry, input.getPayloadSize().intValue(), routeIid);
break;
case GLOBALRTC:
- client = new GlobalBindingRTCClient(providerRegistry, input.getPayloadSize().intValue());
+ client = new GlobalBindingRTCClient(consumerRegistry, input.getPayloadSize().intValue());
break;
default:
.build();
return RpcResultBuilder.success(output).buildFuture();
} finally {
- for (RoutedRpcRegistration<?> routedRpcRegistration : rpcRegs) {
- routedRpcRegistration.close();
- }
+ rpcRegs.forEach(ObjectRegistration::close);
}
}
<bean id="globalServer" class="rpcbenchmark.impl.GlobalBindingRTCServer"/>
- <reference id="rpcRegistry" interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry"/>
+ <reference id="rpcProviderService" interface="org.opendaylight.mdsal.binding.api.RpcProviderService"/>
+ <reference id="rpcConsumerRegistry" interface="org.opendaylight.mdsal.binding.api.RpcConsumerRegistry"/>
<bean id="provider" class="rpcbenchmark.impl.RpcbenchmarkProvider"
init-method="init" destroy-method="close">
- <argument ref="rpcRegistry"/>
+ <argument ref="rpcProviderService"/>
+ <argument ref="rpcConsumerRegistry"/>
<argument ref="globalServer"/>
</bean>
<artifactId>threadpool-config-impl</artifactId>
</dependency>
- <!-- MD-SAL artifacts -->
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-common-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-common-impl</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-common-util</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-core-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-core-spi</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-core-compat</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-broker-impl</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-broker-impl</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-util</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-inmemory-datastore</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-trace-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-trace-dom-impl</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-trace-binding-impl</artifactId>
- </dependency>
-
<!-- Base model augmentations -->
<dependency>
<groupId>org.opendaylight.controller.model</groupId>
<title>Distributed Datastore DOM API extensions</title>
<packages>org.opendaylight.controller.cluster.dom.api</packages>
</group>
- <group>
- <title>MD-SAL Common API (deprecated)</title>
- <packages>org.opendaylight.controller.md.sal.common.*</packages>
- </group>
- <group>
- <title>MD-SAL Low-level (DOM) API (deprecated)</title>
- <packages>org.opendaylight.controller.md.sal.dom.api:org.opendaylight.controller.md.sal.dom.spi:org.opendaylight.controller.sal.core.*</packages>
- </group>
- <group>
- <title>MD-SAL Binding API (deprecated)</title>
- <packages>org.opendaylight.controller.sal.binding.api*:org.opendaylight.controller.md.sal.binding.api*:org.opendaylight.controller.md.sal.binding.spi:org.opendaylight.controller.md.sal.binding.compat:org.opendaylight.controller.md.sal.binding.util</packages>
- </group>
<group>
<title>Akka RAFT implementation</title>
<packages>org.opendaylight.controller.cluster.raft*</packages>
<type>xml</type>
<classifier>features</classifier>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>odl-controller-dom-api</artifactId>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-event-executor-config</artifactId>
<type>xml</type>
<classifier>features</classifier>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>odl-mdsal-clustering</artifactId>
- <version>${project.version}</version>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>odl-mdsal-clustering-commons</artifactId>
<type>xml</type>
<classifier>features</classifier>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>odl-controller-binding-api</artifactId>
- <version>${project.version}</version>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>odl-controller-dom-api</artifactId>
- <version>${project.version}</version>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>odl-mdsal-distributed-datastore</artifactId>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright © 2019 PANTHEON.tech, s.r.o. and others.
-
- 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
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
- <relativePath/>
- </parent>
-
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>odl-controller-binding-api</artifactId>
- <version>1.12.0-SNAPSHOT</version>
- <packaging>feature</packaging>
-
- <name>OpenDaylight :: Controller :: Binding API</name>
- <description>Controller Java Binding APIs</description>
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-artifacts</artifactId>
- <version>5.0.9</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>mdsal-artifacts</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>odl-mdsal-binding-api</artifactId>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>odl-controller-mdsal-common</artifactId>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>sal-binding-api</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>sal-binding-util</artifactId>
- </dependency>
- </dependencies>
-</project>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright © 2019 PANTHEON.tech, s.r.o. and others.
-
- 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
- -->
-<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="odl-controller-binding-api-${project.version}">
- <feature name="odl-controller-binding-api" version="${project.version}">
- <feature version="[5,6)">odl-mdsal-binding-api</feature>
- </feature>
-</features>
<scope>import</scope>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
+ <groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-artifacts</artifactId>
- <version>1.12.0-SNAPSHOT</version>
+ <version>5.0.9</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<classifier>features</classifier>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>odl-controller-binding-api</artifactId>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>odl-mdsal-binding-api</artifactId>
<type>xml</type>
<classifier>features</classifier>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>odl-controller-dom-api</artifactId>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>odl-mdsal-binding-runtime</artifactId>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>odl-mdsal-dom-api</artifactId>
<type>xml</type>
<classifier>features</classifier>
</dependency>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="odl-controller-blueprint-${project.version}">
<feature name="odl-controller-blueprint" version="${project.version}">
<feature version="[4,5)">odl-yangtools-codec</feature>
+ <feature version="[5,6)">odl-mdsal-binding-api</feature>
+ <feature version="[5,6)">odl-mdsal-binding-runtime</feature>
+ <feature version="[5,6)">odl-mdsal-dom-api</feature>
<bundle start-level="40">mvn:org.opendaylight.controller/blueprint/${blueprint.version}</bundle>
</feature>
</features>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright © 2019 PANTHEON.tech, s.r.o. and others.
-
- 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
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
- <relativePath/>
- </parent>
-
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>odl-controller-dom-api</artifactId>
- <version>1.12.0-SNAPSHOT</version>
- <packaging>feature</packaging>
-
- <name>OpenDaylight :: Controller :: DOM API and SPI</name>
- <description>Controller DOM APIs</description>
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-artifacts</artifactId>
- <version>5.0.9</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>mdsal-artifacts</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>odl-mdsal-dom-api</artifactId>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>odl-controller-mdsal-common</artifactId>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>sal-core-api</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>sal-core-spi</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>sal-core-compat</artifactId>
- </dependency>
- </dependencies>
-</project>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright © 2019 PANTHEON.tech, s.r.o. and others.
-
- 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
- -->
-<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="odl-controller-dom-api-${project.version}">
- <feature name="odl-controller-dom-api" version="${project.version}">
- <feature version="[5,6)">odl-mdsal-dom-api</feature>
- </feature>
-</features>
<type>xml</type>
<classifier>features</classifier>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>sal-common-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>sal-common-impl</artifactId>
- <version>${project.version}</version>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>sal-common-util</artifactId>
</dependency>
<dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>sal-broker-impl</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>sal-binding-broker-impl</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>sal-inmemory-datastore</artifactId>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-dom-inmemory-datastore</artifactId>
</dependency>
</dependencies>
<type>xml</type>
<classifier>features</classifier>
</dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>sal-broker-impl</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>sal-binding-broker-impl</artifactId>
- </dependency>
</dependencies>
</project>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright © 2016, 2017 Red Hat, Inc. and others.
-
- 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
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
- <relativePath/>
- </parent>
-
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>odl-mdsal-clustering</artifactId>
- <version>1.12.0-SNAPSHOT</version>
- <packaging>feature</packaging>
-
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>odl-mdsal-broker</artifactId>
- <version>${project.version}</version>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
- </dependencies>
-
-</project>
<module>odl-clustering-test-app</module>
<module>odl-controller-mdsal-common</module>
- <module>odl-controller-binding-api</module>
- <module>odl-controller-dom-api</module>
<module>odl-mdsal-clustering-commons</module>
<module>odl-controller-blueprint</module>
<module>odl-mdsal-broker</module>
<module>odl-mdsal-broker-local</module>
- <module>odl-mdsal-clustering</module>
<module>odl-mdsal-distributed-datastore</module>
<module>odl-mdsal-model-inventory</module>
<module>odl-controller-model-topology</module>
<artifactId>org.apache.aries.util</artifactId>
<version>1.1.3</version>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-core-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-core-spi</artifactId>
- </dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-dom-spi</artifactId>
import org.apache.aries.blueprint.mutable.MutableServiceReferenceMetadata;
import org.apache.aries.blueprint.mutable.MutableValueMetadata;
import org.opendaylight.controller.blueprint.BlueprintContainerRestartService;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.opendaylight.mdsal.binding.api.NotificationService;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
if (nodeNameEquals(element, RpcImplementationBean.RPC_IMPLEMENTATION)) {
return parseRpcImplementation(element, context);
- } else if (nodeNameEquals(element, RoutedRpcMetadata.ROUTED_RPC_IMPLEMENTATION)) {
- return parseRoutedRpcImplementation(element, context);
} else if (nodeNameEquals(element, RPC_SERVICE)) {
return parseRpcService(element, context);
} else if (nodeNameEquals(element, NotificationListenerBean.NOTIFICATION_LISTENER)) {
return metadata;
}
- private static Metadata parseRoutedRpcImplementation(final Element element, final ParserContext context) {
- registerRefBean(context, RPC_REGISTRY_NAME, RpcProviderRegistry.class);
- registerRoutedRpcRegistrationConverter(context);
-
- ComponentFactoryMetadata metadata = new RoutedRpcMetadata(getId(context, element),
- element.getAttribute(INTERFACE), element.getAttribute(REF_ATTR));
-
- LOG.debug("parseRoutedRpcImplementation returning {}", metadata);
-
- return metadata;
- }
-
private static Metadata parseActionService(final Element element, final ParserContext context) {
ComponentFactoryMetadata metadata = new ActionServiceMetadata(getId(context, element),
element.getAttribute(INTERFACE));
return metadata;
}
- private static void registerRoutedRpcRegistrationConverter(final ParserContext context) {
- ComponentDefinitionRegistry registry = context.getComponentDefinitionRegistry();
- if (registry.getComponentDefinition(ROUTED_RPC_REG_CONVERTER_NAME) == null) {
- MutableBeanMetadata metadata = createBeanMetadata(context, ROUTED_RPC_REG_CONVERTER_NAME,
- RoutedRpcRegistrationConverter.class, false, false);
- metadata.setActivation(ReferenceMetadata.ACTIVATION_LAZY);
- registry.registerTypeConverter(metadata);
- }
- }
-
private static void registerDomRpcProviderServiceRefBean(final ParserContext context) {
registerRefBean(context, DOM_RPC_PROVIDER_SERVICE_NAME, DOMRpcProviderService.class);
}
+++ /dev/null
-/*
- * Copyright (c) 2016 Brocade Communications Systems, Inc. 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.blueprint.ext;
-
-import java.util.Arrays;
-import java.util.List;
-import org.apache.aries.blueprint.ext.ComponentFactoryMetadata;
-import org.apache.aries.blueprint.services.ExtendedBlueprintContainer;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-import org.osgi.service.blueprint.container.ComponentDefinitionException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Factory metadata corresponding to the "routed-rpc-implementation" element that registers an RPC
- * implementation with the RpcProviderRegistry and provides the RoutedRpcRegistration instance to the
- * Blueprint container.
- *
- * @author Thomas Pantelis
- */
-class RoutedRpcMetadata implements ComponentFactoryMetadata {
- private static final Logger LOG = LoggerFactory.getLogger(RoutedRpcMetadata.class);
- static final String ROUTED_RPC_IMPLEMENTATION = "routed-rpc-implementation";
-
- private final String id;
- private final String interfaceName;
- private final String implementationRefId;
- private ExtendedBlueprintContainer container;
-
- RoutedRpcMetadata(final String id, final String interfaceName, final String implementationRefId) {
- this.id = id;
- this.interfaceName = interfaceName;
- this.implementationRefId = implementationRefId;
- }
-
- @Override
- public String getId() {
- return id;
- }
-
- @Override
- public int getActivation() {
- return ACTIVATION_LAZY;
- }
-
- @Override
- public List<String> getDependsOn() {
- return Arrays.asList(OpendaylightNamespaceHandler.RPC_REGISTRY_NAME, implementationRefId);
- }
-
- @Override
- public void init(final ExtendedBlueprintContainer newContainer) {
- this.container = newContainer;
-
- LOG.debug("{}: In init", logName());
- }
-
- @SuppressWarnings("checkstyle:IllegalCatch")
- @Override
- public Object create() throws ComponentDefinitionException {
- RpcProviderRegistry rpcRegistry = (RpcProviderRegistry) container.getComponentInstance(
- OpendaylightNamespaceHandler.RPC_REGISTRY_NAME);
-
- Object implementation = container.getComponentInstance(implementationRefId);
-
- try {
- if (!RpcService.class.isAssignableFrom(implementation.getClass())) {
- throw new ComponentDefinitionException(String.format(
- "Implementation \"ref\" instance %s for \"%s\" is not an RpcService",
- implementation.getClass(), ROUTED_RPC_IMPLEMENTATION));
- }
-
- List<Class<RpcService>> rpcInterfaces = RpcImplementationBean.getImplementedRpcServiceInterfaces(
- interfaceName, implementation.getClass(), container.getBundleContext().getBundle(),
- ROUTED_RPC_IMPLEMENTATION);
-
- if (rpcInterfaces.size() > 1) {
- throw new ComponentDefinitionException(String.format(
- "Implementation \"ref\" instance %s for \"%s\" implements more than one RpcService "
- + "interface (%s). Please specify the exact \"interface\"", implementation.getClass(),
- ROUTED_RPC_IMPLEMENTATION, rpcInterfaces));
- }
-
- Class<RpcService> rpcInterface = rpcInterfaces.iterator().next();
-
- LOG.debug("{}: create - adding routed implementation {} for RpcService {}", logName(),
- implementation, rpcInterface);
-
- return rpcRegistry.addRoutedRpcImplementation(rpcInterface, (RpcService)implementation);
- } catch (final ComponentDefinitionException e) {
- throw e;
- } catch (final Exception e) {
- throw new ComponentDefinitionException(String.format(
- "Error processing \"%s\" for %s", ROUTED_RPC_IMPLEMENTATION, implementation.getClass()), e);
- }
- }
-
- @Override
- public void destroy(final Object instance) {
- LOG.debug("{}: In destroy: instance: {}", logName(), instance);
-
- ((RoutedRpcRegistration<?>)instance).close();
- }
-
- private String logName() {
- return (container != null ? container.getBundleContext().getBundle().getSymbolicName() : "") + " (" + id + ")";
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Brocade Communications Systems, Inc. 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.blueprint.ext;
-
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
-import org.osgi.service.blueprint.container.Converter;
-import org.osgi.service.blueprint.container.ReifiedType;
-
-/**
- * Implements a Converter that converts RoutedRpcRegistration instances. This is to work around an issue
- * when injecting a RoutedRpcRegistration instance into a bean where Aries is not able to convert the instance
- * returned from the RpcRegistryProvider to the desired generic RoutedRpcRegistration type specified in the
- * bean's setter method. This is because the actual instance class specifies a generic type variable T and,
- * even though it extends RpcService and should match, Aries doesn't handle it correctly.
- *
- * @author Thomas Pantelis
- */
-public class RoutedRpcRegistrationConverter implements Converter {
- @Override
- public boolean canConvert(final Object sourceObject, final ReifiedType targetType) {
- return sourceObject instanceof RoutedRpcRegistration
- && RoutedRpcRegistration.class.isAssignableFrom(targetType.getRawClass());
- }
-
- @Override
- public Object convert(final Object sourceObject, final ReifiedType targetType) {
- return sourceObject;
- }
-}
</xsd:complexType>
<xsd:element name="rpc-implementation" type="TrpcImplementation"/>
- <!--
- To be deprecated. This interface contract is fulfilled by
- action-implementation instead
- -->
- <xsd:complexType name="TroutedRpcImplementation">
- <xsd:attribute name="interface" type="bp:Tclass" use="optional"/>
- <xsd:attribute name="ref" type="bp:Tidref" use="required"/>
- <xsd:attribute name="id" type="xsd:ID"/>
- </xsd:complexType>
- <xsd:element name="routed-rpc-implementation" type="TroutedRpcImplementation"/>
-
<xsd:complexType name="TrpcService">
<xsd:attribute name="interface" type="bp:Tclass" use="required"/>
<xsd:attribute name="id" type="xsd:ID"/>
<dependencyManagement>
<dependencies>
<!-- Core API/implementation -->
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>sal-common-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>sal-common-impl</artifactId>
- <version>${project.version}</version>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>sal-common-util</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>sal-core-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>sal-core-spi</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>sal-core-compat</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>sal-broker-impl</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>sal-binding-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>sal-binding-broker-impl</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>sal-binding-util</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>sal-inmemory-datastore</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>mdsal-trace-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>mdsal-trace-dom-impl</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>mdsal-trace-binding-impl</artifactId>
- <version>${project.version}</version>
- </dependency>
<!-- Test support -->
<dependency>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>sal-binding-broker-impl</artifactId>
- <version>${project.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
<!-- Features -->
<dependency>
<type>xml</type>
<scope>runtime</scope>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>features-mdsal-trace</artifactId>
- <version>${project.version}</version>
- <classifier>features</classifier>
- <type>xml</type>
- <scope>runtime</scope>
- </dependency>
<!-- Base model augmentations -->
<dependency>
<type>xml</type>
<classifier>features</classifier>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>odl-mdsal-clustering</artifactId>
- <version>${project.version}</version>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>odl-mdsal-clustering-commons</artifactId>
<type>xml</type>
<classifier>features</classifier>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>odl-controller-binding-api</artifactId>
- <version>${project.version}</version>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>odl-controller-dom-api</artifactId>
- <version>${project.version}</version>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>odl-controller-blueprint</artifactId>
<dependencyManagement>
<dependencies>
+ <dependency>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-artifacts</artifactId>
+ <version>5.0.9</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>mdsal-artifacts</artifactId>
<type>zip</type>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-api</artifactId>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-binding-api</artifactId>
</dependency>
<!-- Dependencies for pax exam karaf container -->
<dependency>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Copyright © 2016 Red Hat 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
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-parent</artifactId>
- <version>1.12.0-SNAPSHOT</version>
- <relativePath>../../parent</relativePath>
- </parent>
-
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-trace-api</artifactId>
- <version>1.12.0-SNAPSHOT</version>
- <packaging>bundle</packaging>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-core-api</artifactId>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-artifacts</id>
- <goals>
- <goal>attach-artifact</goal>
- </goals>
- <phase>package</phase>
- <configuration>
- <artifacts>
- <artifact>
- <file>${project.build.directory}/classes/initial/mdsaltrace_config.xml</file>
- <type>xml</type>
- <classifier>config</classifier>
- </artifact>
- </artifacts>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-/*
- * Copyright (c) 2016 Red Hat, Inc. 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.md.sal.trace.api;
-
-import java.io.PrintStream;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-
-/**
- * Interface so that the tracing broker service can be more explicitly imported.
- */
-public interface TracingDOMDataBroker extends DOMDataBroker {
-
- /**
- * Prints a human-readable "report" of all opened but not closed transactions,
- * including transactions chains and transactions opened by them, onto the printStream.
- * @param minOpenTransactions minimum open number of transactions (leaks with fewer are not printed)
- * @return true if there were any open transactions, false if none
- */
- boolean printOpenTransactions(PrintStream printStream, int minOpenTransactions);
-
-}
+++ /dev/null
-<config xmlns="urn:opendaylight:params:xml:ns:yang:mdsaltrace">
- <!-- Both registration-watches as well as write-watches will
- log EVERYTHING by default, if we do not constrain any paths;
- therefore we set a fake one to get nothing out-of-the-box;
- please remove this first fake one when you configure this
- to watch what you are really interested in instead: -->
- <registration-watches>/this/will/never/exist</registration-watches>
- <!-- <registration-watches>/neutron-router-dpns/router-dpn-list</registration-watches> -->
- <!-- <registration-watches>/tunnels_state/state-tunnel-list</registration-watches> -->
-
- <write-watches>/this/will/never/exist</write-watches>
- <!-- <write-watches> /NetworkTopology/Topology</write-watches> -->
-
- <!-- Enable or disable transaction context debug. This will preserve the call site trace for
- transactions, so that the original caller of un-close'd() transaction can be identified.
- NB: This is a different property from the equally named one in etc/org.opendaylight.controller.cluster.datastore.cfg;
- that one does something somewhat similar, but serves to include the stack trace on failed transaction submit,
- whereas this one is specific to odl-mdsal-trace's trace:transaction leak troubleshooting command.
- [This documentation has been copy/pasted from mdsaltrace.yang, and should be kept in line.] -->
- <transaction-debug-context-enabled>true</transaction-debug-context-enabled>
-</config>
+++ /dev/null
-module mdsaltrace {
- yang-version 1;
- namespace "urn:opendaylight:params:xml:ns:yang:mdsaltrace";
- prefix "mdsaltrace";
-
- organization
- "Red Hat, Inc.";
-
- description
- "Copyright (c) 2016 Red Hat, Inc. 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";
-
- revision "2016-09-08" {
- description "Initial revision of mdsaltrace model";
- }
-
- container config {
- leaf-list registration-watches {
- type string;
- }
- leaf-list write-watches {
- type string;
- }
- leaf transaction-debug-context-enabled {
- default false;
- type boolean;
- description "Enable or disable transaction context debug. This will preserve the call site trace for
- transactions, so that the original caller of un-close'd() transaction can be identified.
- NB: This is a different property from the equally named one in etc/org.opendaylight.controller.cluster.datastore.cfg;
- that one does something somewhat similar, but serves to include the stack trace on failed transaction submit,
- whereas this one is specific to odl-mdsal-trace's trace:transaction leak troubleshooting command.";
- // This ^^^ description is also copy/pasted in mdsaltrace_config.xml, and should be kept in line.]
- }
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-<!--
-Copyright © 2016 Red Hat 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
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-parent</artifactId>
- <version>1.12.0-SNAPSHOT</version>
- <relativePath>../../parent</relativePath>
- </parent>
-
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-trace-binding-impl</artifactId>
- <version>1.12.0-SNAPSHOT</version>
- <packaging>bundle</packaging>
-
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>mdsal-trace-api</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>mdsal-trace-dom-impl</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-broker-impl</artifactId>
- </dependency>
-
- <!-- Testing Dependencies -->
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Import-Package>
- org.opendaylight.controller.md.sal.trace.api,
- org.opendaylight.controller.md.sal.dom.api,
- org.opendaylight.controller.md.sal.binding.api,
- org.opendaylight.controller.md.sal.binding.spi,
- *
- </Import-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-/*
- * Copyright (c) 2018 Red Hat, Inc. 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.md.sal.trace.binding.impl;
-
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.spi.AdapterFactory;
-import org.opendaylight.controller.md.sal.trace.api.TracingDOMDataBroker;
-
-/**
- * Programmatic "wiring" for dependency injection.
- *
- * <p>See org.opendaylight.controller.md.sal.binding.impl.BindingBrokerWiring.
- *
- * @author Michael Vorburger.ch
- */
-public class TracingBindingBrokerWiring {
-
- private final DataBroker dataBroker;
- private final DataBroker pingPongDataBroker;
-
- public TracingBindingBrokerWiring(TracingDOMDataBroker tracingDOMDataBroker,
- TracingDOMDataBroker tracingPingPongDOMDataBroker, AdapterFactory adapterFactory) {
-
- dataBroker = adapterFactory.createDataBroker(tracingDOMDataBroker);
- pingPongDataBroker = adapterFactory.createDataBroker(tracingPingPongDOMDataBroker);
- }
-
- public DataBroker getTracingDataBroker() {
- return dataBroker;
- }
-
- public DataBroker getTracingPingPongDataBroker() {
- return pingPongDataBroker;
- }
-
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-<!--
-Copyright © 2016 Red Hat 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
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0"
- xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
- odl:use-default-for-reference-types="true">
-
- <reference id="adapterFactory" interface="org.opendaylight.controller.md.sal.binding.spi.AdapterFactory"/>
-
- <reference id="tracingDefaultDOMBroker"
- interface="org.opendaylight.controller.md.sal.trace.api.TracingDOMDataBroker"
- odl:type="default" />
-
- <reference id="tracingPingPongDOMDataBroker"
- interface="org.opendaylight.controller.md.sal.trace.api.TracingDOMDataBroker"
- odl:type="pingpong"/>
-
- <bean id="wiring" class="org.opendaylight.controller.md.sal.trace.binding.impl.TracingBindingBrokerWiring">
- <argument ref="tracingDefaultDOMBroker"/>
- <argument ref="tracingPingPongDOMDataBroker"/>
- <argument ref="adapterFactory"/>
- </bean>
-
- <bean id="tracingBindingDataBroker" factory-ref="wiring" factory-method="getTracingDataBroker" />
- <service id="tracingBindingDataBrokerSvc" ref="tracingBindingDataBroker"
- interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
- odl:type="default" ranking="10"/>
-
- <bean id="bindingTracingPingPongDataBroker" factory-ref="wiring" factory-method="getTracingPingPongDataBroker" />
- <service ref="bindingTracingPingPongDataBroker"
- interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
- odl:type="pingpong" ranking="10"/>
-</blueprint>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Copyright © 2017 Red Hat 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
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-parent</artifactId>
- <version>1.12.0-SNAPSHOT</version>
- <relativePath>../../parent</relativePath>
- </parent>
-
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-trace-cli</artifactId>
- <version>1.12.0-SNAPSHOT</version>
- <packaging>bundle</packaging>
-
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>mdsal-trace-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.karaf.shell</groupId>
- <artifactId>org.apache.karaf.shell.core</artifactId>
- <exclusions>
- <exclusion>
- <groupId>*</groupId>
- <artifactId>*</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Karaf-Commands>*</Karaf-Commands>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-/*
- * Copyright (c) 2017 Red Hat, Inc. 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.md.sal.trace.cli;
-
-import java.util.List;
-import org.apache.karaf.shell.api.action.Action;
-import org.apache.karaf.shell.api.action.Argument;
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.lifecycle.Reference;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.opendaylight.controller.md.sal.trace.api.TracingDOMDataBroker;
-
-/**
- * Karaf CLI command to dump all open transactions.
- *
- * @author Michael Vorburger.ch
- */
-@Service
-@Command(scope = "trace", name = "transactions",
- description = "Show all (still) open transactions; including stack trace of creator, "
- + "if transaction-debug-context-enabled is true in mdsaltrace_config.xml")
-public class PrintOpenTransactionsCommand implements Action {
-
- @Argument(index = 0, name = "minOpenTransactions", required = false, multiValued = false,
- description = "Minimum open number of transactions (leaks with fewer are suppressed)")
- Integer minOpenTransactions = 1;
-
- @Reference
- private List<TracingDOMDataBroker> tracingDOMDataBrokers;
-
- // NB: Do NOT have a non-default constructor for injection of @Reference
- // Karaf needs a default constructor to create the command - and it works as is.
-
- @Override
- @SuppressWarnings("checkstyle:RegexpSingleLineJava")
- public Object execute() {
- boolean hasFound = false;
- for (TracingDOMDataBroker tracingDOMDataBroker : tracingDOMDataBrokers) {
- hasFound |= tracingDOMDataBroker.printOpenTransactions(System.out, minOpenTransactions);
- }
- if (hasFound) {
- System.out.println(
- "Actually did find real leaks with more than " + minOpenTransactions + " open transactions");
- } else {
- System.out.println(
- "Did not find any real leaks with more than " + minOpenTransactions + " open transactions");
- }
- return hasFound;
- }
-
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=2 tabstop=2: -->
-<!--
- Copyright (c) 2016 Red Hat 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
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>deploy-site</artifactId>
- <version>0.1.0-SNAPSHOT</version>
- <packaging>pom</packaging>
-
- <properties>
- <stream>latest</stream>
- <nexus.site.url>dav:https://nexus.opendaylight.org/content/sites/site/${project.groupId}/${stream}/</nexus.site.url>
- </properties>
-
- <build>
- <extensions>
- <extension>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-webdav-jackrabbit</artifactId>
- <version>2.9</version>
- </extension>
- </extensions>
-
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-site-plugin</artifactId>
- <version>3.4</version>
- <configuration>
- <inputDirectory>${project.build.directory}/staged-site</inputDirectory>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <distributionManagement>
- <site>
- <id>opendaylight-site</id>
- <url>${nexus.site.url}</url>
- </site>
- </distributionManagement>
-</project>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-<!--
-Copyright © 2016 Red Hat 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
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-parent</artifactId>
- <version>1.12.0-SNAPSHOT</version>
- <relativePath>../../parent</relativePath>
- </parent>
-
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-trace-dom-impl</artifactId>
- <version>1.12.0-SNAPSHOT</version>
- <packaging>bundle</packaging>
-
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>mdsal-trace-api</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>sal-binding-api</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>sal-core-api</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>sal-broker-impl</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-binding-dom-codec</artifactId>
- </dependency>
-
- <!-- Testing Dependencies -->
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>sal-binding-broker-impl</artifactId>
- <version>${project.version}</version>
- <classifier>tests</classifier>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>sal-binding-broker-impl</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.google.truth</groupId>
- <artifactId>truth</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Import-Package>
- org.opendaylight.controller.md.sal.dom.broker.impl,
- *
- </Import-Package>
- <Export-Package>org.opendaylight.controller.md.sal.trace.dom.impl</Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-/*
- * Copyright (c) 2017 Red Hat, Inc. 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.md.sal.trace.closetracker.impl;
-
-import org.eclipse.jdt.annotation.Nullable;
-
-/**
- * Convenience abstract base class for {@link CloseTracked} implementors.
- *
- * @author Michael Vorburger.ch
- */
-@Deprecated(forRemoval = true)
-public abstract class AbstractCloseTracked<T extends AbstractCloseTracked<T>> implements CloseTracked<T> {
-
- private final CloseTrackedTrait<T> closeTracker;
-
- protected AbstractCloseTracked(CloseTrackedRegistry<T> transactionChainRegistry) {
- this.closeTracker = new CloseTrackedTrait<>(transactionChainRegistry, this);
- }
-
- protected void removeFromTrackedRegistry() {
- closeTracker.removeFromTrackedRegistry();
- }
-
- @Override
- public @Nullable StackTraceElement[] getAllocationContextStackTrace() {
- return closeTracker.getAllocationContextStackTrace();
- }
-
- @Override
- public final CloseTracked<T> getRealCloseTracked() {
- return this;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Red Hat, Inc. 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.md.sal.trace.closetracker.impl;
-
-import org.eclipse.jdt.annotation.Nullable;
-
-/**
- * Object which can track where something has been created, and if it has been correctly "closed".
- *
- * <p>Includes preserving the context of the call stack which created an object, and the instant it was created.
- *
- * @author Michael Vorburger.ch
- */
-@Deprecated(forRemoval = true)
-public interface CloseTracked<T extends CloseTracked<T>> {
-
- /**
- * This returns the allocation context as {@link StackTraceElement}s. NB that
- * this is a relatively <b>EXPENSIVE</b> operation! You should only ever call
- * this when you really need to, e.g. when you actually produce output for
- * humans, but not too early.
- */
- // TODO When we're on Java 9, then instead return a StackWalker.StackFrame[] here?
- @Nullable StackTraceElement[] getAllocationContextStackTrace();
-
- CloseTracked<T> getRealCloseTracked();
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Red Hat, Inc. 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.md.sal.trace.closetracker.impl;
-
-import static java.util.Arrays.asList;
-import static java.util.Collections.emptyList;
-
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentSkipListSet;
-
-/**
- * Registry of {@link CloseTracked} instances. This class is thread-safe.
- *
- * @author Michael Vorburger.ch
- */
-@Deprecated(forRemoval = true)
-public class CloseTrackedRegistry<T extends CloseTracked<T>> {
-
- private final Object anchor;
- private final String createDescription;
-
- private final Set<CloseTracked<T>> tracked =
- new ConcurrentSkipListSet<>(Comparator.comparingInt(System::identityHashCode));
-
- private final boolean isDebugContextEnabled;
-
- /**
- * Constructor.
- *
- * @param anchor
- * object where this registry is stored in, used for human output in
- * logging and other output
- * @param createDescription
- * description of creator of instances of this registry, typically
- * e.g. name of method in the anchor class
- * @param isDebugContextEnabled
- * whether or not the call stack should be preserved; this is (of
- * course) an expensive operation, and should only be used during
- * troubleshooting
- */
- public CloseTrackedRegistry(Object anchor, String createDescription, boolean isDebugContextEnabled) {
- this.anchor = anchor;
- this.createDescription = createDescription;
- this.isDebugContextEnabled = isDebugContextEnabled;
- }
-
- public boolean isDebugContextEnabled() {
- return isDebugContextEnabled;
- }
-
- public Object getAnchor() {
- return anchor;
- }
-
- public String getCreateDescription() {
- return createDescription;
- }
-
- // package protected, not public; only CloseTrackedTrait invokes this
- void add(CloseTracked<T> closeTracked) {
- tracked.add(closeTracked);
- }
-
- // package protected, not public; only CloseTrackedTrait invokes this
- void remove(CloseTracked<T> closeTracked) {
- tracked.remove(closeTracked);
- }
-
- /**
- * Creates and returns a "report" of (currently) tracked but not (yet) closed
- * instances.
- *
- * @return Set of CloseTrackedRegistryReportEntry, of which each the stack trace
- * element identifies a unique allocation context (or an empty List if
- * debugContextEnabled is false), and value is the number of open
- * instances created at that place in the code.
- */
- // For some reason, FB sees 'map' as useless but it clearly isn't.
- @SuppressFBWarnings("UC_USELESS_OBJECT")
- public Set<CloseTrackedRegistryReportEntry<T>> getAllUnique() {
- Map<List<StackTraceElement>, Long> map = new HashMap<>();
- Set<CloseTracked<T>> copyOfTracked = new HashSet<>(tracked);
- for (CloseTracked<T> closeTracked : copyOfTracked) {
- final StackTraceElement[] stackTraceArray = closeTracked.getAllocationContextStackTrace();
- List<StackTraceElement> stackTraceElements =
- stackTraceArray != null ? Arrays.asList(stackTraceArray) : Collections.emptyList();
- map.merge(stackTraceElements, 1L, (oldValue, value) -> oldValue + 1);
- }
-
- Set<CloseTrackedRegistryReportEntry<T>> report = new HashSet<>();
- map.forEach((stackTraceElements, number) -> copyOfTracked.stream().filter(closeTracked -> {
- StackTraceElement[] closeTrackedStackTraceArray = closeTracked.getAllocationContextStackTrace();
- List<StackTraceElement> closeTrackedStackTraceElements =
- closeTrackedStackTraceArray != null ? asList(closeTrackedStackTraceArray) : emptyList();
- return closeTrackedStackTraceElements.equals(stackTraceElements);
- }).findAny().ifPresent(exampleCloseTracked -> report.add(
- new CloseTrackedRegistryReportEntry<>(exampleCloseTracked, number, stackTraceElements))));
- return report;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Red Hat, Inc. 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.md.sal.trace.closetracker.impl;
-
-import static java.util.Objects.requireNonNull;
-
-import java.util.List;
-
-/**
- * Element of a "report" created by a {@link CloseTrackedRegistry}.
- *
- * @author Michael Vorburger.ch
- */
-@Deprecated(forRemoval = true)
-public class CloseTrackedRegistryReportEntry<T extends CloseTracked<T>> {
-
- private final CloseTracked<T> exampleCloseTracked;
- private final long numberAddedNotRemoved;
- private final List<StackTraceElement> stackTraceElements;
-
- public CloseTrackedRegistryReportEntry(CloseTracked<T> exampleCloseTracked, long numberAddedNotRemoved,
- List<StackTraceElement> stackTraceElements) {
- this.exampleCloseTracked = requireNonNull(exampleCloseTracked, "closeTracked");
- this.numberAddedNotRemoved = requireNonNull(numberAddedNotRemoved, "numberAddedNotRemoved");
- this.stackTraceElements = requireNonNull(stackTraceElements, "stackTraceElements");
- }
-
- public long getNumberAddedNotRemoved() {
- return numberAddedNotRemoved;
- }
-
- public CloseTracked<T> getExampleCloseTracked() {
- return exampleCloseTracked;
- }
-
- public List<StackTraceElement> getStackTraceElements() {
- return stackTraceElements;
- }
-
- @Override
- public String toString() {
- return "CloseTrackedRegistryReportEntry [numberAddedNotRemoved=" + numberAddedNotRemoved + ", closeTracked="
- + exampleCloseTracked + ", stackTraceElements.size=" + stackTraceElements.size() + "]";
- }
-
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Red Hat, Inc. 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.md.sal.trace.closetracker.impl;
-
-import static java.util.Objects.requireNonNull;
-
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import org.eclipse.jdt.annotation.Nullable;
-
-/**
- * Implementation of {@link CloseTracked} which can be used as a field in
- * another class which implements {@link CloseTracked} and delegates its methods
- * to this.
- *
- * <p>This is useful if that class already has another parent class.
- * If it does not, then it's typically more convenient to just extend AbstractCloseTracked.
- *
- * @author Michael Vorburger.ch
- */
-@Deprecated(forRemoval = true)
-public class CloseTrackedTrait<T extends CloseTracked<T>> implements CloseTracked<T> {
-
- // NB: It's important that we keep a Throwable here, and not directly the StackTraceElement[] !
- // This is because creating a new Throwable() is a lot less expensive in terms of runtime overhead
- // than actually calling its getStackTrace(), which we can delay until we really need to.
- // see also e.g. https://stackoverflow.com/a/26122232/421602
- private final @Nullable Throwable allocationContext;
- private final CloseTrackedRegistry<T> closeTrackedRegistry;
- private final CloseTracked<T> realCloseTracked;
-
- @SuppressFBWarnings(value = "NP_STORE_INTO_NONNULL_FIELD", justification = "SpotBugs and JDT annotations")
- public CloseTrackedTrait(CloseTrackedRegistry<T> transactionChainRegistry, CloseTracked<T> realCloseTracked) {
- if (transactionChainRegistry.isDebugContextEnabled()) {
- // NB: We're NOT doing the (expensive) getStackTrace() here just yet (only below)
- // TODO When we're on Java 9, then instead use the new java.lang.StackWalker API..
- this.allocationContext = new Throwable();
- } else {
- this.allocationContext = null;
- }
- this.realCloseTracked = requireNonNull(realCloseTracked, "realCloseTracked");
- this.closeTrackedRegistry = requireNonNull(transactionChainRegistry, "transactionChainRegistry");
- this.closeTrackedRegistry.add(this);
- }
-
- @Override
- @SuppressFBWarnings("PZLA_PREFER_ZERO_LENGTH_ARRAYS")
- public StackTraceElement[] getAllocationContextStackTrace() {
- return allocationContext != null ? allocationContext.getStackTrace() : null;
- }
-
- public void removeFromTrackedRegistry() {
- closeTrackedRegistry.remove(this);
- }
-
- @Override
- public CloseTracked<T> getRealCloseTracked() {
- return realCloseTracked;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Red Hat, Inc. 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
- */
-
-/**
- * Utilities to track (non) "closing" of objects.
- */
-// This generic infra may be moved somewhere else, later
-@org.eclipse.jdt.annotation.NonNullByDefault
-@Deprecated(forRemoval = true)
-package org.opendaylight.controller.md.sal.trace.closetracker.impl;
+++ /dev/null
-/*
- * Copyright (c) 2016 Red Hat, Inc. 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.md.sal.trace.dom.impl;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.common.util.concurrent.FluentFuture;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
-import org.opendaylight.mdsal.common.api.CommitInfo;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-@Deprecated(forRemoval = true)
-abstract class AbstractTracingWriteTransaction implements DOMDataWriteTransaction {
-
- private final DOMDataWriteTransaction delegate;
- private final TracingBroker tracingBroker;
- private final List<String> logs = new ArrayList<>();
-
- AbstractTracingWriteTransaction(DOMDataWriteTransaction delegate, TracingBroker tracingBroker) {
- this.delegate = requireNonNull(delegate);
- this.tracingBroker = requireNonNull(tracingBroker);
- recordOp(null, null, "instantiate", null);
- }
-
- private void recordOp(LogicalDatastoreType store, YangInstanceIdentifier yiid, String method,
- NormalizedNode<?, ?> node) {
- if (yiid != null && !tracingBroker.isWriteWatched(yiid, store)) {
- return;
- }
-
- final Object value = node != null ? node.getValue() : null;
-
- if (value != null && value instanceof ImmutableSet && ((Set<?>)value).isEmpty()) {
- if (TracingBroker.LOG.isDebugEnabled()) {
- TracingBroker.LOG.debug("Empty data set write to {}", tracingBroker.toPathString(yiid));
- }
- } else {
- StringBuilder sb = new StringBuilder();
- sb.append("Method \"").append(method).append('"');
- if (store != null) {
- sb.append(" to ").append(store);
- }
- if (yiid != null) {
- sb.append(" at ").append(tracingBroker.toPathString(yiid));
- }
- sb.append('.');
- if (yiid != null) {
- // If we don’t have an id, we don’t expect data either
- sb.append(" Data: ");
- if (node != null) {
- sb.append(node.getValue());
- } else {
- sb.append("null");
- }
- }
- sb.append(" Stack:").append(tracingBroker.getStackSummary());
- synchronized (this) {
- logs.add(sb.toString());
- }
- }
- }
-
- private synchronized void logOps() {
- synchronized (this) {
- if (TracingBroker.LOG.isWarnEnabled()) {
- TracingBroker.LOG.warn("Transaction {} contains the following operations:", getIdentifier());
- logs.forEach(TracingBroker.LOG::warn);
- }
- logs.clear();
- }
- }
-
- @Override
- public void put(LogicalDatastoreType store, YangInstanceIdentifier yiid, NormalizedNode<?, ?> node) {
- recordOp(store, yiid, "put", node);
- delegate.put(store, yiid, node);
- }
-
- @Override
- public void merge(LogicalDatastoreType store, YangInstanceIdentifier yiid, NormalizedNode<?, ?> node) {
- recordOp(store, yiid, "merge", node);
- delegate.merge(store, yiid, node);
- }
-
- @Override
- public boolean cancel() {
- synchronized (this) {
- logs.clear();
- }
- return delegate.cancel();
- }
-
- @Override
- public void delete(LogicalDatastoreType store, YangInstanceIdentifier yiid) {
- recordOp(store, yiid, "delete", null);
- delegate.delete(store, yiid);
- }
-
- @Override
- public FluentFuture<? extends CommitInfo> commit() {
- recordOp(null, null, "commit", null);
- logOps();
- return delegate.commit();
- }
-
- @Override
- public Object getIdentifier() {
- return delegate.getIdentifier();
- }
-
- // https://jira.opendaylight.org/browse/CONTROLLER-1792
-
- @Override
- public final boolean equals(Object object) {
- return object == this || delegate.equals(object);
- }
-
- @Override
- public final int hashCode() {
- return delegate.hashCode();
- }
-
- @Override
- public final String toString() {
- return getClass().getName() + "; delegate=" + delegate;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Red Hat, Inc. 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.md.sal.trace.dom.impl;
-
-import static java.util.Objects.requireNonNull;
-
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
-import org.opendaylight.controller.md.sal.dom.api.ClusteredDOMDataTreeChangeListener;
-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.DOMDataReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
-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.controller.md.sal.dom.api.DOMDataWriteTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
-import org.opendaylight.controller.md.sal.trace.api.TracingDOMDataBroker;
-import org.opendaylight.controller.md.sal.trace.closetracker.impl.CloseTracked;
-import org.opendaylight.controller.md.sal.trace.closetracker.impl.CloseTrackedRegistry;
-import org.opendaylight.controller.md.sal.trace.closetracker.impl.CloseTrackedRegistryReportEntry;
-import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsaltrace.rev160908.Config;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@SuppressWarnings("checkstyle:JavadocStyle")
-//...because otherwise it whines about the elements in the @code block even though it's completely valid Javadoc
-
-/**
- * TracingBroker logs "write" operations and listener registrations to the md-sal. It logs the instance identifier path,
- * the objects themselves, as well as the stack trace of the call invoking the registration or write operation.
- * It works by operating as a "bump on the stack" between the application and actual DataBroker, intercepting write
- * and registration calls and writing to the log.
- *
- * <p>In addition, it (optionally) can also keep track of the stack trace of all new transaction allocations
- * (including TransactionChains, and transactions created in turn from them), in order to detect and report leaks
- * from transactions which were not closed.
- *
- * <h1>Wiring:</h1>
- * TracingBroker is designed to be easy to use. In fact, for bundles using Blueprint to inject their DataBroker
- * TracingBroker can be used without modifying your code at all in two simple steps:
- * <ol>
- * <li>
- * Simply add the dependency "mdsaltrace-features" to
- * your Karaf pom:
- * <pre>
- * {@code
- * <dependency>
- * <groupId>org.opendaylight.controller</groupId>
- * <artifactId>features-mdsal-trace</artifactId>
- * <version>1.7.0-SNAPSHOT</version>
- * <classifier>features</classifier>
- * <type>xml</type>
- * <scope>runtime</scope>
- * </dependency>
- * }
- * </pre>
- * </li>
- * <li>
- * Then just "feature:install odl-mdsal-trace" before you install your "real" feature(s) and you're done.
- * Beware that with Karaf 4 due to <a href="https://bugs.opendaylight.org/show_bug.cgi?id=9068">Bug 9068</a>
- * you'll probably have to use feature:install's --no-auto-refresh flag when installing your "real" feature.
- * </li>
- * </ol>
- * This works because the mdsaltrace-impl bundle registers its service implementing DOMDataBroker with a higher
- * rank than sal-binding-broker. As such, any OSGi service lookup for DataBroker will receive the TracingBroker.
- * <p> </p>
- * <h1>Avoiding log bloat:</h1>
- * TracingBroker can be configured to only print registrations or write ops pertaining to certain subtrees of the
- * md-sal. This can be done in the code via the methods of this class or via a config file. TracingBroker uses a more
- * convenient but non-standard representation of the instance identifiers. Each instance identifier segment's
- * class.getSimpleName() is used separated by a '/'.
- * <p> </p>
- * <h1>Known issues</h1>
- * <ul>
- * <li>
- * Filtering by paths. For some registrations the codec that converts back from the DOM to binding paths is
- * busted. As such, an aproximated path is used in the output. For now it is recommended not to use
- * watchRegistrations and allow all registrations to be logged.
- * </li>
- * </ul>
- *
- */
-@Deprecated(forRemoval = true)
-public class TracingBroker implements TracingDOMDataBroker {
- @SuppressFBWarnings("SLF4J_LOGGER_SHOULD_BE_PRIVATE")
- static final Logger LOG = LoggerFactory.getLogger(TracingBroker.class);
-
- private static final int STACK_TRACE_FIRST_RELEVANT_FRAME = 2;
-
- private final String type; // "default" VS "pingpong"
- private final BindingNormalizedNodeSerializer codec;
- private final DOMDataBroker delegate;
- private final List<Watch> registrationWatches = new ArrayList<>();
- private final List<Watch> writeWatches = new ArrayList<>();
-
- private final boolean isDebugging;
- private final CloseTrackedRegistry<TracingTransactionChain> transactionChainsRegistry;
- private final CloseTrackedRegistry<TracingReadOnlyTransaction> readOnlyTransactionsRegistry;
- private final CloseTrackedRegistry<TracingWriteTransaction> writeTransactionsRegistry;
- private final CloseTrackedRegistry<TracingReadWriteTransaction> readWriteTransactionsRegistry;
-
- private class Watch {
- final String iidString;
- final LogicalDatastoreType store;
-
- Watch(String iidString, LogicalDatastoreType storeOrNull) {
- this.store = storeOrNull;
- this.iidString = iidString;
- }
-
- private String toIidCompString(YangInstanceIdentifier iid) {
- StringBuilder builder = new StringBuilder();
- toPathString(iid, builder);
- builder.append('/');
- return builder.toString();
- }
-
- private boolean isParent(String parent, String child) {
- int parentOffset = 0;
- if (parent.length() > 0 && parent.charAt(0) == '<') {
- parentOffset = parent.indexOf('>') + 1;
- }
-
- int childOffset = 0;
- if (child.length() > 0 && child.charAt(0) == '<') {
- childOffset = child.indexOf('>') + 1;
- }
-
- return child.startsWith(parent.substring(parentOffset), childOffset);
- }
-
- @SuppressWarnings({ "checkstyle:hiddenField", "hiding" })
- public boolean subtreesOverlap(YangInstanceIdentifier iid, LogicalDatastoreType store) {
- if (this.store != null && !this.store.equals(store)) {
- return false;
- }
-
- String otherIidString = toIidCompString(iid);
- return isParent(iidString, otherIidString) || isParent(otherIidString, iidString);
- }
-
- @SuppressWarnings({ "checkstyle:hiddenField", "hiding" })
- public boolean eventIsOfInterest(YangInstanceIdentifier iid, LogicalDatastoreType store) {
- if (this.store != null && !this.store.equals(store)) {
- return false;
- }
-
- return isParent(iidString, toPathString(iid));
- }
- }
-
- public TracingBroker(String type, DOMDataBroker delegate, Config config, BindingNormalizedNodeSerializer codec) {
- this.type = requireNonNull(type, "type");
- this.delegate = requireNonNull(delegate, "delegate");
- this.codec = requireNonNull(codec, "codec");
- configure(config);
-
- if (config.isTransactionDebugContextEnabled() != null) {
- this.isDebugging = config.isTransactionDebugContextEnabled();
- } else {
- this.isDebugging = false;
- }
- final String db = "DataBroker";
- this.transactionChainsRegistry = new CloseTrackedRegistry<>(db, "createTransactionChain()", isDebugging);
- this.readOnlyTransactionsRegistry = new CloseTrackedRegistry<>(db, "newReadOnlyTransaction()", isDebugging);
- this.writeTransactionsRegistry = new CloseTrackedRegistry<>(db, "newWriteOnlyTransaction()", isDebugging);
- this.readWriteTransactionsRegistry = new CloseTrackedRegistry<>(db, "newReadWriteTransaction()", isDebugging);
- }
-
- private void configure(Config config) {
- registrationWatches.clear();
- List<String> paths = config.getRegistrationWatches();
- if (paths != null) {
- for (String path : paths) {
- watchRegistrations(path, null);
- }
- }
-
- writeWatches.clear();
- paths = config.getWriteWatches();
- if (paths != null) {
- for (String path : paths) {
- watchWrites(path, null);
- }
- }
- }
-
- /**
- * Log registrations to this subtree of the md-sal.
- * @param iidString the iid path of the root of the subtree
- * @param store Which LogicalDataStore? or null for both
- */
- public void watchRegistrations(String iidString, LogicalDatastoreType store) {
- LOG.info("Watching registrations to {} in {}", iidString, store);
- registrationWatches.add(new Watch(iidString, store));
- }
-
- /**
- * Log writes to this subtree of the md-sal.
- * @param iidString the iid path of the root of the subtree
- * @param store Which LogicalDataStore? or null for both
- */
- public void watchWrites(String iidString, LogicalDatastoreType store) {
- LOG.info("Watching writes to {} in {}", iidString, store);
- Watch watch = new Watch(iidString, store);
- writeWatches.add(watch);
- }
-
- @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
- justification = "https://github.com/spotbugs/spotbugs/issues/811")
- private boolean isRegistrationWatched(YangInstanceIdentifier iid, LogicalDatastoreType store) {
- if (registrationWatches.isEmpty()) {
- return true;
- }
-
- for (Watch regInterest : registrationWatches) {
- if (regInterest.subtreesOverlap(iid, store)) {
- return true;
- }
- }
-
- return false;
- }
-
- boolean isWriteWatched(YangInstanceIdentifier iid, LogicalDatastoreType store) {
- if (writeWatches.isEmpty()) {
- return true;
- }
-
- for (Watch watch : writeWatches) {
- if (watch.eventIsOfInterest(iid, store)) {
- return true;
- }
- }
-
- return false;
- }
-
- static void toPathString(InstanceIdentifier<? extends DataObject> iid, StringBuilder builder) {
- for (InstanceIdentifier.PathArgument pathArg : iid.getPathArguments()) {
- builder.append('/').append(pathArg.getType().getSimpleName());
- }
- }
-
- String toPathString(YangInstanceIdentifier yiid) {
- StringBuilder sb = new StringBuilder();
- toPathString(yiid, sb);
- return sb.toString();
- }
-
-
- private void toPathString(YangInstanceIdentifier yiid, StringBuilder sb) {
- InstanceIdentifier<?> iid = codec.fromYangInstanceIdentifier(yiid);
- if (null == iid) {
- reconstructIidPathString(yiid, sb);
- } else {
- toPathString(iid, sb);
- }
- }
-
- private static void reconstructIidPathString(YangInstanceIdentifier yiid, StringBuilder sb) {
- sb.append("<RECONSTRUCTED FROM: \"").append(yiid.toString()).append("\">");
- for (YangInstanceIdentifier.PathArgument pathArg : yiid.getPathArguments()) {
- if (pathArg instanceof YangInstanceIdentifier.AugmentationIdentifier) {
- sb.append('/').append("AUGMENTATION");
- continue;
- }
- sb.append('/').append(pathArg.getNodeType().getLocalName());
- }
- }
-
- String getStackSummary() {
- StackTraceElement[] stack = Thread.currentThread().getStackTrace();
-
- StringBuilder sb = new StringBuilder();
- for (int i = STACK_TRACE_FIRST_RELEVANT_FRAME; i < stack.length; i++) {
- StackTraceElement frame = stack[i];
- sb.append("\n\t(TracingBroker)\t").append(frame.getClassName()).append('.').append(frame.getMethodName());
- }
-
- return sb.toString();
- }
-
- @Override
- public DOMDataReadWriteTransaction newReadWriteTransaction() {
- return new TracingReadWriteTransaction(delegate.newReadWriteTransaction(), this, readWriteTransactionsRegistry);
- }
-
- @Override
- public DOMDataWriteTransaction newWriteOnlyTransaction() {
- return new TracingWriteTransaction(delegate.newWriteOnlyTransaction(), this, writeTransactionsRegistry);
- }
-
- @Override
- public DOMTransactionChain createTransactionChain(TransactionChainListener transactionChainListener) {
- return new TracingTransactionChain(
- delegate.createTransactionChain(transactionChainListener), this, transactionChainsRegistry);
- }
-
- @Override
- public DOMDataReadOnlyTransaction newReadOnlyTransaction() {
- return new TracingReadOnlyTransaction(delegate.newReadOnlyTransaction(), readOnlyTransactionsRegistry);
- }
-
- @Override
- public Map<Class<? extends DOMDataBrokerExtension>, DOMDataBrokerExtension> getSupportedExtensions() {
- Map<Class<? extends DOMDataBrokerExtension>, DOMDataBrokerExtension> res = delegate.getSupportedExtensions();
- DOMDataTreeChangeService treeChangeSvc = (DOMDataTreeChangeService) res.get(DOMDataTreeChangeService.class);
- if (treeChangeSvc == null) {
- return res;
- }
-
- res = new HashMap<>(res);
-
- res.put(DOMDataTreeChangeService.class, new DOMDataTreeChangeService() {
- @Override
- public <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerDataTreeChangeListener(
- DOMDataTreeIdentifier domDataTreeIdentifier, L listener) {
- if (isRegistrationWatched(domDataTreeIdentifier.getRootIdentifier(),
- domDataTreeIdentifier.getDatastoreType())) {
- LOG.warn("{} registration (registerDataTreeChangeListener) for {} from {}.",
- listener instanceof ClusteredDOMDataTreeChangeListener ? "Clustered" : "Non-clustered",
- toPathString(domDataTreeIdentifier.getRootIdentifier()), getStackSummary());
- }
- return treeChangeSvc.registerDataTreeChangeListener(domDataTreeIdentifier, listener);
- }
- });
-
- return res;
- }
-
- @Override
- public boolean printOpenTransactions(PrintStream ps, int minOpenTXs) {
- if (transactionChainsRegistry.getAllUnique().isEmpty()
- && readOnlyTransactionsRegistry.getAllUnique().isEmpty()
- && writeTransactionsRegistry.getAllUnique().isEmpty()
- && readWriteTransactionsRegistry.getAllUnique().isEmpty()) {
-
- ps.println(type + ": No open transactions, great!");
- return false;
- }
-
- ps.println(type + ": " + getClass().getSimpleName()
- + " found some not yet (or never..) closed transaction[chain]s!");
- ps.println("[NB: If no stack traces are shown below, then "
- + "enable transaction-debug-context-enabled in mdsaltrace_config.xml]");
- ps.println();
- // Flag to track if we really found any real leaks with more (or equal) to minOpenTXs
- boolean hasFound = print(readOnlyTransactionsRegistry, ps, " ", minOpenTXs);
- hasFound |= print(writeTransactionsRegistry, ps, " ", minOpenTXs);
- hasFound |= print(readWriteTransactionsRegistry, ps, " ", minOpenTXs);
-
- // Now print details for each non-closed TransactionChain
- // incl. in turn each ones own read/Write[Only]TransactionsRegistry
- Set<CloseTrackedRegistryReportEntry<TracingTransactionChain>>
- entries = transactionChainsRegistry.getAllUnique();
- if (!entries.isEmpty()) {
- ps.println(" " + transactionChainsRegistry.getAnchor() + " : "
- + transactionChainsRegistry.getCreateDescription());
- }
- for (CloseTrackedRegistryReportEntry<TracingTransactionChain> entry : entries) {
- ps.println(" " + entry.getNumberAddedNotRemoved() + "x TransactionChains opened but not closed here:");
- printStackTraceElements(ps, " ", entry.getStackTraceElements());
- @SuppressWarnings("resource")
- TracingTransactionChain txChain = (TracingTransactionChain) entry
- .getExampleCloseTracked().getRealCloseTracked();
- hasFound |= print(txChain.getReadOnlyTransactionsRegistry(), ps, " ", minOpenTXs);
- hasFound |= print(txChain.getWriteTransactionsRegistry(), ps, " ", minOpenTXs);
- hasFound |= print(txChain.getReadWriteTransactionsRegistry(), ps, " ", minOpenTXs);
- }
- ps.println();
-
- return hasFound;
- }
-
- private <T extends CloseTracked<T>> boolean print(
- CloseTrackedRegistry<T> registry, PrintStream ps, String indent, int minOpenTransactions) {
- Set<CloseTrackedRegistryReportEntry<T>> unsorted = registry.getAllUnique();
- if (unsorted.size() < minOpenTransactions) {
- return false;
- }
-
- List<CloseTrackedRegistryReportEntry<T>> entries = new ArrayList<>(unsorted);
- entries.sort((o1, o2) -> Long.compare(o2.getNumberAddedNotRemoved(), o1.getNumberAddedNotRemoved()));
-
- if (!entries.isEmpty()) {
- ps.println(indent + registry.getAnchor() + " : " + registry.getCreateDescription());
- }
- entries.forEach(entry -> {
- ps.println(indent + " " + entry.getNumberAddedNotRemoved()
- + "x transactions opened here, which are not closed:");
- printStackTraceElements(ps, indent + " ", entry.getStackTraceElements());
- });
- if (!entries.isEmpty()) {
- ps.println();
- }
- return true;
- }
-
- private void printStackTraceElements(PrintStream ps, String indent, List<StackTraceElement> stackTraceElements) {
- boolean ellipsis = false;
- for (final StackTraceElement stackTraceElement : stackTraceElements) {
- if (isStackTraceElementInteresting(stackTraceElement)) {
- ps.println(indent + stackTraceElement);
- ellipsis = false;
- } else if (!ellipsis) {
- ps.println(indent + "(...)");
- ellipsis = true;
- }
- }
- }
-
- private boolean isStackTraceElementInteresting(StackTraceElement element) {
- final String className = element.getClassName();
- return !className.startsWith(getClass().getPackage().getName())
- && !className.startsWith(CloseTracked.class.getPackage().getName())
- && !className.startsWith("Proxy")
- && !className.startsWith("akka")
- && !className.startsWith("scala")
- && !className.startsWith("sun.reflect")
- && !className.startsWith("java.lang.reflect")
- && !className.startsWith("org.apache.aries.blueprint")
- && !className.startsWith("org.osgi.util.tracker");
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Red Hat, Inc. 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.md.sal.trace.dom.impl;
-
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
-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.dom.api.DOMDataReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.trace.closetracker.impl.AbstractCloseTracked;
-import org.opendaylight.controller.md.sal.trace.closetracker.impl.CloseTrackedRegistry;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-@Deprecated(forRemoval = true)
-class TracingReadOnlyTransaction
- extends AbstractCloseTracked<TracingReadOnlyTransaction>
- implements DOMDataReadOnlyTransaction {
-
- private final DOMDataReadOnlyTransaction delegate;
-
- TracingReadOnlyTransaction(DOMDataReadOnlyTransaction delegate,
- CloseTrackedRegistry<TracingReadOnlyTransaction> readOnlyTransactionsRegistry) {
- super(readOnlyTransactionsRegistry);
- this.delegate = delegate;
- }
-
- @Override
- public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(LogicalDatastoreType store,
- YangInstanceIdentifier path) {
- return delegate.read(store, path);
- }
-
- @Override
- public CheckedFuture<Boolean, ReadFailedException> exists(LogicalDatastoreType store, YangInstanceIdentifier path) {
- return delegate.exists(store, path);
- }
-
- @Override
- public Object getIdentifier() {
- return delegate.getIdentifier();
- }
-
- @Override
- public void close() {
- delegate.close();
- super.removeFromTrackedRegistry();
- }
-
-
- // https://jira.opendaylight.org/browse/CONTROLLER-1792
-
- @Override
- public final boolean equals(Object object) {
- return object == this || delegate.equals(object);
- }
-
- @Override
- public final int hashCode() {
- return delegate.hashCode();
- }
-
- @Override
- public final String toString() {
- return getClass().getName() + "; delegate=" + delegate;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Red Hat, Inc. 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.md.sal.trace.dom.impl;
-
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.FluentFuture;
-import java.util.Objects;
-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.dom.api.DOMDataReadWriteTransaction;
-import org.opendaylight.controller.md.sal.trace.closetracker.impl.CloseTracked;
-import org.opendaylight.controller.md.sal.trace.closetracker.impl.CloseTrackedRegistry;
-import org.opendaylight.controller.md.sal.trace.closetracker.impl.CloseTrackedTrait;
-import org.opendaylight.mdsal.common.api.CommitInfo;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-@Deprecated(forRemoval = true)
-class TracingReadWriteTransaction
- extends AbstractTracingWriteTransaction
- implements DOMDataReadWriteTransaction, CloseTracked<TracingReadWriteTransaction> {
-
- private final CloseTrackedTrait<TracingReadWriteTransaction> closeTracker;
- private final DOMDataReadWriteTransaction delegate;
-
- TracingReadWriteTransaction(DOMDataReadWriteTransaction delegate, TracingBroker tracingBroker,
- CloseTrackedRegistry<TracingReadWriteTransaction> readWriteTransactionsRegistry) {
- super(delegate, tracingBroker);
- this.closeTracker = new CloseTrackedTrait<>(readWriteTransactionsRegistry, this);
- this.delegate = Objects.requireNonNull(delegate);
- }
-
- @Override
- public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(
- LogicalDatastoreType store, YangInstanceIdentifier yiid) {
- return delegate.read(store, yiid);
- }
-
- @Override
- public CheckedFuture<Boolean, ReadFailedException> exists(LogicalDatastoreType store, YangInstanceIdentifier yiid) {
- return delegate.exists(store, yiid);
- }
-
- @Override
- public FluentFuture<? extends CommitInfo> commit() {
- closeTracker.removeFromTrackedRegistry();
- return super.commit();
- }
-
- @Override
- public boolean cancel() {
- closeTracker.removeFromTrackedRegistry();
- return super.cancel();
- }
-
- @Override
- public StackTraceElement[] getAllocationContextStackTrace() {
- return closeTracker.getAllocationContextStackTrace();
- }
-
- @Override
- public CloseTracked<TracingReadWriteTransaction> getRealCloseTracked() {
- return this;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Red Hat, Inc. 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.md.sal.trace.dom.impl;
-
-import java.util.Objects;
-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.controller.md.sal.trace.closetracker.impl.AbstractCloseTracked;
-import org.opendaylight.controller.md.sal.trace.closetracker.impl.CloseTrackedRegistry;
-
-@Deprecated(forRemoval = true)
-class TracingTransactionChain extends AbstractCloseTracked<TracingTransactionChain> implements DOMTransactionChain {
-
- private final DOMTransactionChain delegate;
- private final TracingBroker tracingBroker;
- private final CloseTrackedRegistry<TracingReadOnlyTransaction> readOnlyTransactionsRegistry;
- private final CloseTrackedRegistry<TracingWriteTransaction> writeTransactionsRegistry;
- private final CloseTrackedRegistry<TracingReadWriteTransaction> readWriteTransactionsRegistry;
-
- TracingTransactionChain(DOMTransactionChain delegate, TracingBroker tracingBroker,
- CloseTrackedRegistry<TracingTransactionChain> transactionChainsRegistry) {
- super(transactionChainsRegistry);
- this.delegate = Objects.requireNonNull(delegate);
- this.tracingBroker = Objects.requireNonNull(tracingBroker);
-
- final boolean isDebug = transactionChainsRegistry.isDebugContextEnabled();
- String anchor = "TransactionChain@" + Integer.toHexString(hashCode());
- this.readOnlyTransactionsRegistry = new CloseTrackedRegistry<>(anchor, "newReadOnlyTransaction()", isDebug);
- this.writeTransactionsRegistry = new CloseTrackedRegistry<>(anchor, "newWriteOnlyTransaction()", isDebug);
- this.readWriteTransactionsRegistry = new CloseTrackedRegistry<>(anchor, "newReadWriteTransaction()", isDebug);
- }
-
- @Override
- @SuppressWarnings("resource")
- public DOMDataReadOnlyTransaction newReadOnlyTransaction() {
- final DOMDataReadOnlyTransaction tx = delegate.newReadOnlyTransaction();
- return new TracingReadOnlyTransaction(tx, readOnlyTransactionsRegistry);
- }
-
- @Override
- public DOMDataReadWriteTransaction newReadWriteTransaction() {
- return new TracingReadWriteTransaction(delegate.newReadWriteTransaction(), tracingBroker,
- readWriteTransactionsRegistry);
- }
-
- @Override
- public DOMDataWriteTransaction newWriteOnlyTransaction() {
- final DOMDataWriteTransaction tx = delegate.newWriteOnlyTransaction();
- return new TracingWriteTransaction(tx, tracingBroker, writeTransactionsRegistry);
- }
-
- @Override
- public void close() {
- delegate.close();
- super.removeFromTrackedRegistry();
- }
-
- public CloseTrackedRegistry<TracingReadOnlyTransaction> getReadOnlyTransactionsRegistry() {
- return readOnlyTransactionsRegistry;
- }
-
- public CloseTrackedRegistry<TracingReadWriteTransaction> getReadWriteTransactionsRegistry() {
- return readWriteTransactionsRegistry;
- }
-
- public CloseTrackedRegistry<TracingWriteTransaction> getWriteTransactionsRegistry() {
- return writeTransactionsRegistry;
- }
-
-
- // https://jira.opendaylight.org/browse/CONTROLLER-1792
-
- @Override
- public final boolean equals(Object object) {
- return object == this || delegate.equals(object);
- }
-
- @Override
- public final int hashCode() {
- return delegate.hashCode();
- }
-
- @Override
- public final String toString() {
- return getClass().getName() + "; delegate=" + delegate;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Red Hat, Inc. 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.md.sal.trace.dom.impl;
-
-import com.google.common.util.concurrent.FluentFuture;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
-import org.opendaylight.controller.md.sal.trace.closetracker.impl.CloseTracked;
-import org.opendaylight.controller.md.sal.trace.closetracker.impl.CloseTrackedRegistry;
-import org.opendaylight.controller.md.sal.trace.closetracker.impl.CloseTrackedTrait;
-import org.opendaylight.mdsal.common.api.CommitInfo;
-
-@Deprecated(forRemoval = true)
-class TracingWriteTransaction extends AbstractTracingWriteTransaction
- implements CloseTracked<TracingWriteTransaction> {
-
- private final CloseTrackedTrait<TracingWriteTransaction> closeTracker;
-
- TracingWriteTransaction(DOMDataWriteTransaction delegate, TracingBroker tracingBroker,
- CloseTrackedRegistry<TracingWriteTransaction> writeTransactionsRegistry) {
- super(delegate, tracingBroker);
- this.closeTracker = new CloseTrackedTrait<>(writeTransactionsRegistry, this);
- }
-
- @Override
- public FluentFuture<? extends CommitInfo> commit() {
- closeTracker.removeFromTrackedRegistry();
- return super.commit();
- }
-
- @Override
- public boolean cancel() {
- closeTracker.removeFromTrackedRegistry();
- return super.cancel();
- }
-
- @Override
- public StackTraceElement[] getAllocationContextStackTrace() {
- return closeTracker.getAllocationContextStackTrace();
- }
-
- @Override
- public CloseTracked<TracingWriteTransaction> getRealCloseTracked() {
- return this;
- }
-
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-<!--
-Copyright © 2016 Red Hat 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
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
- odl:use-default-for-reference-types="true">
-
- <odl:clustered-app-config id="mdsalConfig"
- binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsaltrace.rev160908.Config">
- </odl:clustered-app-config>
-
- <reference id="codec"
- interface="org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer"
- odl:type="default" />
-
- <!-- Tracing Binding DataBroker -->
-
- <reference id="realDefaultDOMBroker"
- interface="org.opendaylight.controller.md.sal.dom.api.DOMDataBroker"
- odl:type="default" />
-
- <bean id="tracingDefaultDOMBroker" class="org.opendaylight.controller.md.sal.trace.dom.impl.TracingBroker">
- <argument value="default" />
- <argument ref="realDefaultDOMBroker" />
- <argument ref="mdsalConfig" />
- <argument ref="codec" />
- </bean>
-
- <service id="tracingDefaultDOMBrokerSvc" ref="tracingDefaultDOMBroker" ranking="10" odl:type="default">
- <interfaces>
- <value>org.opendaylight.controller.md.sal.dom.api.DOMDataBroker</value>
- <value>org.opendaylight.controller.md.sal.trace.api.TracingDOMDataBroker</value>
- </interfaces>
- </service>
-
- <!-- Tracing Binding PingPong DataBroker -->
-
- <reference id="realPingPongDOMDataBroker"
- interface="org.opendaylight.controller.md.sal.dom.api.DOMDataBroker"
- odl:type="pingpong"/>
-
- <bean id="tracingPingPongDOMBroker" class="org.opendaylight.controller.md.sal.trace.dom.impl.TracingBroker">
- <argument value="pingpong" />
- <argument ref="realPingPongDOMDataBroker" />
- <argument ref="mdsalConfig" />
- <argument ref="codec" />
- </bean>
-
- <service id="tracingPingPongDOMBrokerSvc" ref="tracingPingPongDOMBroker" ranking="10" odl:type="pingpong">
- <interfaces>
- <value>org.opendaylight.controller.md.sal.dom.api.DOMDataBroker</value>
- <value>org.opendaylight.controller.md.sal.trace.api.TracingDOMDataBroker</value>
- </interfaces>
- </service>
-</blueprint>
+++ /dev/null
-/*
- * Copyright (c) 2017 Red Hat, Inc. 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.md.sal.trace.tests;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.fail;
-
-import java.util.Set;
-import java.util.function.Predicate;
-import org.junit.Test;
-import org.opendaylight.controller.md.sal.trace.closetracker.impl.AbstractCloseTracked;
-import org.opendaylight.controller.md.sal.trace.closetracker.impl.CloseTrackedRegistry;
-import org.opendaylight.controller.md.sal.trace.closetracker.impl.CloseTrackedRegistryReportEntry;
-
-@Deprecated
-public class CloseTrackedRegistryTest {
-
- private static class SomethingClosable extends AbstractCloseTracked<SomethingClosable> implements AutoCloseable {
- SomethingClosable(CloseTrackedRegistry<SomethingClosable> transactionChainRegistry) {
- super(transactionChainRegistry);
- }
-
- @Override
- public void close() {
- removeFromTrackedRegistry();
- }
- }
-
- @Test
- public void testDuplicateAllocationContexts() {
- final CloseTrackedRegistry<SomethingClosable> registry =
- new CloseTrackedRegistry<>(this, "testDuplicateAllocationContexts", true);
-
- for (int i = 0; i < 100; i++) {
- SomethingClosable isClosedManyTimes = new SomethingClosable(registry);
- isClosedManyTimes.close();
- someOtherMethodWhichDoesNotClose(registry);
- }
- @SuppressWarnings({ "resource", "unused" })
- SomethingClosable forgotToCloseOnce = new SomethingClosable(registry);
-
- Set<CloseTrackedRegistryReportEntry<SomethingClosable>> uniqueNonClosed = registry.getAllUnique();
- assertThat(uniqueNonClosed).hasSize(2);
- assertThatIterableContains(uniqueNonClosed, entry ->
- entry.getNumberAddedNotRemoved() == 100 || entry.getNumberAddedNotRemoved() == 1);
- uniqueNonClosed.forEach(entry -> {
- if (entry.getNumberAddedNotRemoved() == 100) {
- assertThatIterableContains(entry.getStackTraceElements(),
- element -> element.getMethodName().equals("someOtherMethodWhichDoesNotClose"));
- } else if (entry.getNumberAddedNotRemoved() == 1) {
- assertThatIterableContains(entry.getStackTraceElements(),
- element -> element.getMethodName().equals("testDuplicateAllocationContexts"));
- } else {
- fail("Unexpected number of added, not removed: " + entry.getNumberAddedNotRemoved());
- }
- });
- }
-
- // Something like this really should be in Google Truth...
- private <T> void assertThatIterableContains(Iterable<T> iterable, Predicate<T> predicate) {
- for (T element : iterable) {
- if (predicate.test(element)) {
- return;
- }
- }
- fail("Iterable did not contain any element matching predicate");
- }
-
- @SuppressWarnings({ "resource", "unused" })
- private void someOtherMethodWhichDoesNotClose(CloseTrackedRegistry<SomethingClosable> registry) {
- new SomethingClosable(registry);
- }
-
- @Test
- @SuppressWarnings({ "unused", "resource" })
- public void testDebugContextDisabled() {
- final CloseTrackedRegistry<SomethingClosable> debugContextDisabledRegistry =
- new CloseTrackedRegistry<>(this, "testDebugContextDisabled", false);
-
- SomethingClosable forgotToCloseOnce = new SomethingClosable(debugContextDisabledRegistry);
-
- Set<CloseTrackedRegistryReportEntry<SomethingClosable>>
- closeRegistryReport = debugContextDisabledRegistry.getAllUnique();
- assertThat(closeRegistryReport).hasSize(1);
-
- CloseTrackedRegistryReportEntry<SomethingClosable>
- closeRegistryReportEntry1 = closeRegistryReport.iterator().next();
- assertThat(closeRegistryReportEntry1.getNumberAddedNotRemoved()).isEqualTo(1);
- assertThat(closeRegistryReportEntry1.getStackTraceElements()).isEmpty();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Red Hat, Inc. 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.md.sal.trace.tests;
-
-import static com.google.common.truth.Truth.assertThat;
-import static java.nio.charset.StandardCharsets.UTF_8;
-import static java.util.Collections.singletonList;
-import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
-import static org.mockito.Mockito.mock;
-
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
-import org.junit.Test;
-import org.opendaylight.controller.md.sal.binding.test.DataBrokerTestModule;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
-import org.opendaylight.controller.md.sal.trace.dom.impl.TracingBroker;
-import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsaltrace.rev160908.Config;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsaltrace.rev160908.ConfigBuilder;
-
-/**
- * Test of {@link TracingBroker}.
- *
- * @author Michael Vorburger.ch
- */
-@Deprecated
-public class TracingBrokerTest {
-
- @Test
- public void testEnd2End() {
- DataBrokerTestModule wiring = new DataBrokerTestModule(true);
- wiring.getDataBroker(); // required so DataBrokerTestModule creates the DOMDataBroker
- DOMDataBroker realDomBroker = wiring.getDOMDataBroker();
- TracingBroker tracingDomBroker = new TracingBroker("Test", realDomBroker, new ConfigBuilder()
- // CONTROLLER-1877: configure it like the default/initial mdsaltrace_config.xml in mdsal-trace-api
- .setTransactionDebugContextEnabled(true)
- .setWriteWatches(singletonList("/this/will/never/exist"))
- .setRegistrationWatches(singletonList("/this/will/never/exist"))
- .build(),
- wiring.getBindingToNormalizedNodeCodec());
- tracingDomBroker.newWriteOnlyTransaction().cancel();
- }
-
- @Test
- @SuppressWarnings({ "resource", "unused" }) // Finding resource leaks is the point of this test
- public void testPrintOpenTransactions() {
- DOMDataBroker domDataBroker = mock(DOMDataBroker.class, RETURNS_DEEP_STUBS);
- Config config = new ConfigBuilder().setTransactionDebugContextEnabled(true).build();
- BindingNormalizedNodeSerializer codec = mock(BindingNormalizedNodeSerializer.class);
- TracingBroker tracingBroker = new TracingBroker("mock", domDataBroker, config, codec);
-
- for (int i = 0; i < 3; i++) {
- DOMDataReadWriteTransaction tx = tracingBroker.newReadWriteTransaction();
- }
- DOMDataReadWriteTransaction anotherTx = tracingBroker.newReadWriteTransaction();
-
- DOMTransactionChain txChain = tracingBroker.createTransactionChain(null);
- DOMDataReadWriteTransaction txFromChain = txChain.newReadWriteTransaction();
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(baos);
- boolean printReturnValue = tracingBroker.printOpenTransactions(ps, 1);
- String output = new String(baos.toByteArray(), UTF_8);
-
- assertThat(printReturnValue).isTrue();
- // Assert expectations about stack trace
- assertThat(output).contains("testPrintOpenTransactions(TracingBrokerTest.java");
- assertThat(output).doesNotContain(TracingBroker.class.getName());
-
- String previousLine = "";
- for (String line : output.split("\n")) {
- if (line.contains("(...")) {
- assertThat(previousLine.contains("(...)")).isFalse();
- }
- previousLine = line;
- }
-
- // assert that the sorting works - the x3 is shown before the x1
- assertThat(output).contains(" DataBroker : newReadWriteTransaction()\n 3x");
-
- // We don't do any verify/times on the mocks,
- // because the main point of the test is just to verify that
- // printOpenTransactions runs through without any exceptions
- // (e.g. it used to have a ClassCastException).
- }
-
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>feature-repo-parent</artifactId>
- <version>6.0.4</version>
- <relativePath/>
- </parent>
-
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>features-mdsal-trace</artifactId>
- <version>1.12.0-SNAPSHOT</version>
- <name>OpenDaylight :: TracingBroker</name>
- <packaging>feature</packaging>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>odl-mdsal-trace</artifactId>
- <version>${project.version}</version>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
- </dependencies>
-</project>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
- <relativePath/>
- </parent>
-
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>odl-mdsal-trace</artifactId>
- <version>1.12.0-SNAPSHOT</version>
- <name>OpenDaylight :: TracingBroker</name>
- <packaging>feature</packaging>
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-artifacts</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
-
- </dependencyManagement>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>odl-mdsal-broker</artifactId>
- <version>${project.version}</version>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-trace-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-trace-dom-impl</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-trace-binding-impl</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-trace-cli</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-</project>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<features name="odl-mdsal-trace-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0">
- <feature name="odl-mdsal-trace" version="${project.version}">
- <configfile finalname="etc/opendaylight/datastore/initial/config/mdsaltrace_config.xml">mvn:org.opendaylight.controller/mdsal-trace-api/${project.version}/xml/config</configfile>
- </feature>
-</features>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Copyright © 2016 Red Hat 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
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>odlparent-lite</artifactId>
- <version>6.0.4</version>
- <relativePath/>
- </parent>
-
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-trace-feature-aggregator</artifactId>
- <version>1.12.0-SNAPSHOT</version>
- <packaging>pom</packaging>
-
- <modules>
- <module>features-mdsal-trace</module>
- <module>odl-mdsal-trace</module>
- </modules>
-</project>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Copyright © 2016 Red Hat 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
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>odlparent-lite</artifactId>
- <version>6.0.4</version>
- <relativePath/>
- </parent>
-
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-trace-aggregator</artifactId>
- <version>1.12.0-SNAPSHOT</version>
- <name>mdsaltrace</name>
- <packaging>pom</packaging>
-
- <modules>
- <module>api</module>
- <module>dom-impl</module>
- <module>binding-impl</module>
- <module>cli</module>
- <module>features</module>
- </modules>
-
- <!-- DO NOT install or deploy the repo root pom as it's only needed to initiate a build -->
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-deploy-plugin</artifactId>
- <configuration>
- <skip>true</skip>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-install-plugin</artifactId>
- <configuration>
- <skip>true</skip>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <profiles>
- <profile>
- <!--
- This profile is to ensure we only build javadocs reports
- when we plan to deploy Maven site for our project.
- -->
- <id>maven-site</id>
- <activation>
- <file>
- <exists>${user.dir}/deploy-site.xml</exists>
- </file>
- </activation>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <inherited>false</inherited>
- <executions>
- <execution>
- <id>aggregate</id>
- <goals>
- <goal>aggregate</goal>
- </goals>
- <phase>package</phase>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
-</project>
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.messagebus.spi.EventSource;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
import org.opendaylight.mdsal.binding.api.ReadTransaction;
Map<NodeKey, Registration> localMap = eventSourceTopology.getRoutedRpcRegistrations();
NodeKey nodeKeyMock = mock(NodeKey.class);
doReturn(nodeKeyMock).when(eventSourceMock).getSourceNodeKey();
- BindingAwareBroker.RoutedRpcRegistration<EventSourceService> routedRpcRegistrationMock =
- mock(BindingAwareBroker.RoutedRpcRegistration.class);
+ ObjectRegistration routedRpcRegistrationMock = mock(ObjectRegistration.class);
localMap.put(nodeKeyMock, routedRpcRegistrationMock);
eventSourceTopology.unRegister(eventSourceMock);
verify(routedRpcRegistrationMock, times(1)).close();
<dependencies>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-core-api</artifactId>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-binding-api</artifactId>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-api</artifactId>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-dom-api</artifactId>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
* 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.messagebus.app.util;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
+import org.opendaylight.mdsal.dom.api.DOMNotification;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.TopicNotification;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
<module>parent</module>
<!-- Common APIs & Implementation -->
- <module>sal-common-api</module>
- <module>sal-common-impl</module>
<module>sal-common-util</module>
- <!-- Binding Independent -->
- <module>sal-dom-api</module>
- <module>sal-dom-broker</module>
- <module>sal-dom-spi</module>
- <module>sal-dom-compat</module>
-
- <!-- Binding Aware -->
- <module>sal-binding-api</module>
- <module>sal-binding-broker</module>
-
- <module>sal-binding-util</module>
-
<!-- Samples -->
<module>samples</module>
<module>sal-akka-raft</module>
<module>sal-akka-raft-example</module>
- <!--InMemory DOM DataStore-->
- <module>sal-inmemory-datastore</module>
-
<module>sal-clustering-commons</module>
<module>cds-access-api</module>
<module>cds-access-client</module>
<!-- PAX EXAM ITs -->
<module>sal-binding-it</module>
- <module>sal-binding-dom-it</module>
<!-- IT Base and Parent -->
<module>mdsal-it-base</module>
<module>mdsal-it-parent</module>
-
- <!-- Debug utils -->
- <module>mdsal-trace</module>
-
</modules>
<scm>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-parent</artifactId>
- <version>1.12.0-SNAPSHOT</version>
- <relativePath>../parent</relativePath>
- </parent>
-
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-api</artifactId>
- <version>1.12.0-SNAPSHOT</version>
- <packaging>bundle</packaging>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-common-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-binding-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>concepts</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>yang-binding</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-common</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
- </dependencies>
-
- <scm>
- <connection>scm:git:http://git.opendaylight.org/gerrit/controller.git</connection>
- <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
- <tag>HEAD</tag>
- <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
- </scm>
-
-</project>
+++ /dev/null
-/*
- * 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.md.sal.binding.api;
-
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-
-/**
- * Bridge to action registration.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.binding.api.ActionProviderService} instead
- */
-@Deprecated(forRemoval = true)
-@SuppressFBWarnings(value = "NM_SAME_SIMPLE_NAME_AS_INTERFACE", justification = "Migration")
-public interface ActionProviderService
- extends BindingService, org.opendaylight.mdsal.binding.api.ActionProviderService {
-
-}
+++ /dev/null
-/*
- * 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.md.sal.binding.api;
-
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-
-/**
- * Bridge to action invocation.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.binding.api.ActionService} instead
- */
-@Deprecated(forRemoval = true)
-@SuppressFBWarnings(value = "NM_SAME_SIMPLE_NAME_AS_INTERFACE", justification = "Migration")
-public interface ActionService extends BindingService, org.opendaylight.mdsal.binding.api.ActionService {
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.api;
-
-import org.opendaylight.controller.sal.binding.api.BindingAwareService;
-
-/**
- * Marker interface for MD-SAL services which are available for users of MD-SAL.
- *
- * <p>
- * BindingService is marker interface for infrastructure services provided by
- * the SAL. These services may be session-specific, and wrapped by custom
- * delegator patterns in order to introduce additional semantics / checks
- * to the system.
- *
- * <p>
- * This interface extends {@link BindingAwareService}, order to be make
- * new services available via
- * {@link org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext}
- * and via
- * {@link org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext}
- *
- * @deprecated Use {@link BindingService} instead.
- */
-@Deprecated(forRemoval = true)
-public interface BindingService extends BindingAwareService {
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.api;
-
-import org.opendaylight.controller.md.sal.common.api.data.TransactionChain;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * A chain of transactions.
- *
- * <p>
- * For more information about transaction chaining and transaction chains
- * see {@link TransactionChain}.
- *
- * @see TransactionChain
- *
- * @deprecated Use {@link org.opendaylight.mdsal.binding.api.TransactionChain} instead.
- */
-@Deprecated(forRemoval = true)
-public interface BindingTransactionChain extends TransactionFactory,
- TransactionChain<InstanceIdentifier<?>, DataObject> {
- @Override
- ReadOnlyTransaction newReadOnlyTransaction();
-
- @Override
- ReadWriteTransaction newReadWriteTransaction();
-
- @Override
- WriteTransaction newWriteOnlyTransaction();
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Brocade Communications Systems, Inc. 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.md.sal.binding.api;
-
-import org.opendaylight.yangtools.yang.binding.DataObject;
-
-/**
- * ClusteredDataTreeChangeListener is a marker interface to enable data tree change notifications on all
- * instances in a cluster where this listener is registered.
- *
- * <p>
- * Applications should implement ClusteredDataTreeChangeListener instead of {@link DataTreeChangeListener},
- * if they want to listen for data tree change notifications on any node of a clustered data store.
- * {@link DataTreeChangeListener} enables notifications only at the leader of the data store.
- *
- * @author Thomas Pantelis
- *
- * @param <T> the DataObject type
- *
- * @deprecated Use {@link org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener} instead.
- */
-@Deprecated(forRemoval = true)
-public interface ClusteredDataTreeChangeListener<T extends DataObject> extends DataTreeChangeListener<T> {
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.api;
-
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionChainFactory;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * Provides access to a conceptual data tree store and also provides the ability to
- * subscribe for changes to data under a given branch of the tree.
- *
- * <p>
- * For more information on usage, please see the documentation in {@link AsyncDataBroker}.
- *
- * @see AsyncDataBroker
- * @see TransactionChainFactory
- *
- * @deprecated Use {@link org.opendaylight.mdsal.binding.api.DataBroker} instead
- */
-@Deprecated(forRemoval = true)
-public interface DataBroker extends AsyncDataBroker<InstanceIdentifier<?>, DataObject>,
- TransactionChainFactory<InstanceIdentifier<?>, DataObject>, TransactionFactory, BindingService,
- DataTreeChangeService {
- @Override
- ReadOnlyTransaction newReadOnlyTransaction();
-
- @Override
- ReadWriteTransaction newReadWriteTransaction();
-
- @Override
- WriteTransaction newWriteOnlyTransaction();
-
- @Override
- BindingTransactionChain createTransactionChain(TransactionChainListener listener);
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.api;
-
-import com.google.common.collect.Collections2;
-import java.util.Collection;
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.yangtools.yang.binding.Augmentation;
-import org.opendaylight.yangtools.yang.binding.ChildOf;
-import org.opendaylight.yangtools.yang.binding.ChoiceIn;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.Identifiable;
-import org.opendaylight.yangtools.yang.binding.Identifier;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.IdentifiableItem;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.Item;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
-
-/**
- * Represents a modification of DataObject.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.binding.api.DataObjectModification} instead.
- */
-@Deprecated(forRemoval = true)
-public interface DataObjectModification<T extends DataObject>
- extends org.opendaylight.yangtools.concepts.Identifiable<PathArgument> {
-
- enum ModificationType {
- /**
- * Child node (direct or indirect) was modified.
- *
- */
- SUBTREE_MODIFIED,
-
- /**
- * Node was explicitly created / overwritten.
- *
- */
-
- WRITE,
- /**
- * Node was deleted.
- *
- */
- DELETE
- }
-
- @Override
- PathArgument getIdentifier();
-
- /**
- * Returns type of modified object.
- *
- * @return type of modified object.
- */
- @NonNull Class<T> getDataType();
-
- /**
- * Returns type of modification.
- *
- * @return type Type of performed modification.
- */
- @NonNull ModificationType getModificationType();
-
- /**
- * Returns before-state of top level container. Implementations are encouraged,
- * but not required to provide this state.
- *
- * @return State of object before modification. Null if subtree was not present,
- * or the implementation cannot provide the state.
- */
- @Nullable T getDataBefore();
-
- /**
- * Returns after-state of top level container.
- *
- * @return State of object after modification. Null if subtree is not present.
- */
- @Nullable T getDataAfter();
-
- /**
- * Returns unmodifiable collection of modified direct children.
- *
- * @return unmodifiable collection of modified direct children.
- */
- @NonNull Collection<? extends DataObjectModification<? extends DataObject>> getModifiedChildren();
-
- /**
- * Returns child list item modification if {@code child} was modified by this modification. This method should be
- * used if the child is defined in a grouping brought into a case inside this object.
- *
- * @param caseType Case type class
- * @param childType Type of list item - must be list item with key
- * @return Modification of {@code child} if {@code child} was modified, null otherwise.
- * @throws IllegalArgumentException If supplied {@code childType} class is not valid child according
- * to generated model.
- */
- default <H extends ChoiceIn<? super T> & DataObject, C extends ChildOf<? super H>>
- Collection<DataObjectModification<C>> getModifiedChildren(final @NonNull Class<H> caseType,
- final @NonNull Class<C> childType) {
- final Item<C> item = Item.of(caseType, childType);
- return (Collection<DataObjectModification<C>>) Collections2.filter(getModifiedChildren(),
- mod -> item.equals(mod.getIdentifier()));
- }
-
- /**
- * Returns container child modification if {@code child} was modified by this modification. This method should be
- * used if the child is defined in a grouping brought into a case inside this object.
- *
- * <p>
- * For accessing all modified list items consider iterating over {@link #getModifiedChildren()}.
- *
- * @param caseType Case type class
- * @param child Type of child - must be only container
- * @return Modification of {@code child} if {@code child} was modified, null otherwise.
- * @throws IllegalArgumentException If supplied {@code child} class is not valid child according
- * to generated model.
- */
- default @Nullable <H extends ChoiceIn<? super T> & DataObject, C extends ChildOf<? super H>>
- DataObjectModification<C> getModifiedChildContainer(final @NonNull Class<H> caseType,
- final @NonNull Class<C> child) {
- return (DataObjectModification<C>) getModifiedChild(Item.of(caseType, child));
- }
-
- /**
- * Returns container child modification if {@code child} was modified by this modification.
- *
- * <p>
- * For accessing all modified list items consider iterating over {@link #getModifiedChildren()}.
- *
- * @param child Type of child - must be only container
- * @return Modification of {@code child} if {@code child} was modified, null otherwise.
- * @throws IllegalArgumentException If supplied {@code child} class is not valid child according
- * to generated model.
- */
- @Nullable <C extends ChildOf<? super T>> DataObjectModification<C> getModifiedChildContainer(
- @NonNull Class<C> child);
-
- /**
- * Returns augmentation child modification if {@code augmentation} was modified by this modification.
- *
- * <p>
- * For accessing all modified list items consider iterating over {@link #getModifiedChildren()}.
- *
- * @param augmentation Type of augmentation - must be only container
- * @return Modification of {@code augmentation} if {@code augmentation} was modified, null otherwise.
- * @throws IllegalArgumentException If supplied {@code augmentation} class is not valid augmentation
- * according to generated model.
- */
- @Nullable <C extends Augmentation<T> & DataObject> DataObjectModification<C> getModifiedAugmentation(
- @NonNull Class<C> augmentation);
-
- /**
- * Returns child list item modification if {@code child} was modified by this modification.
- *
- * @param listItem Type of list item - must be list item with key
- * @param listKey List item key
- * @return Modification of {@code child} if {@code child} was modified, null otherwise.
- * @throws IllegalArgumentException If supplied {@code listItem} class is not valid child according
- * to generated model.
- */
- <N extends Identifiable<K> & ChildOf<? super T>, K extends Identifier<N>> DataObjectModification<N>
- getModifiedChildListItem(@NonNull Class<N> listItem, @NonNull K listKey);
-
- /**
- * Returns child list item modification if {@code child} was modified by this modification.
- *
- * @param caseType Case type class
- * @param listItem Type of list item - must be list item with key
- * @param listKey List item key
- * @return Modification of {@code child} if {@code child} was modified, null otherwise.
- * @throws IllegalArgumentException If supplied {@code listItem} class is not valid child according
- * to generated model.
- */
- default <H extends ChoiceIn<? super T> & DataObject, C extends Identifiable<K> & ChildOf<? super H>,
- K extends Identifier<C>> DataObjectModification<C> getModifiedChildListItem(
- final @NonNull Class<H> caseType, final @NonNull Class<C> listItem, final @NonNull K listKey) {
- return (DataObjectModification<C>) getModifiedChild(IdentifiableItem.of(caseType, listItem, listKey));
- }
-
- /**
- * Returns a child modification if a node identified by {@code childArgument} was modified by
- * this modification.
- *
- * @param childArgument Path Argument of child node
- * @return Modification of child identified by {@code childArgument} if {@code childArgument}
- * was modified, null otherwise.
- * @throws IllegalArgumentException If supplied path argument is not valid child according to
- * generated model.
- *
- */
- @Nullable DataObjectModification<? extends DataObject> getModifiedChild(PathArgument childArgument);
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.api;
-
-import java.util.Collection;
-import java.util.EventListener;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-
-/**
- * Interface implemented by classes interested in receiving notifications about
- * data tree changes. This interface provides a cursor-based view of the change, which has potentially
- * lower overhead and allow more flexible consumption of change event.
- *
- * <p>
- * Note: this interface enables notifications only at the leader of the data store, if clustered. If you want
- * notifications on all instances in a cluster, use the {@link ClusteredDataTreeChangeListener}.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.binding.api.DataTreeChangeListener} instead.
- */
-@Deprecated(forRemoval = true)
-public interface DataTreeChangeListener<T extends DataObject> extends EventListener {
- /**
- * Invoked when there was data change for the supplied path, which was used
- * to register this listener.
- *
- * <p>
- * This method may be also invoked during registration of the listener if
- * there is any pre-existing data in the conceptual data tree for supplied
- * path. This initial event will contain all pre-existing data as created.
- *
- * <p>
- * A data change event may be triggered spuriously, e.g. such that data before
- * and after compare as equal. Implementations of this interface are expected
- * to recover from such events. Event producers are expected to exert reasonable
- * effort to suppress such events.
- *
- * <p>
- * In other words, it is completely acceptable to observe
- * a {@link DataObjectModification}, while the state observed before and
- * after- data items compare as equal.
- *
- * @param changes Collection of change events, may not be null or empty.
- */
- void onDataTreeChanged(@NonNull Collection<DataTreeModification<T>> changes);
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.api;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-
-/**
- * A {@link BindingService} which allows users to register for changes to a subtree.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.binding.api.DataTreeChangeService} instead.
- */
-@Deprecated(forRemoval = true)
-public interface DataTreeChangeService extends BindingService {
- /**
- * Registers a {@link DataTreeChangeListener} to receive
- * notifications when data changes under a given path in the conceptual data
- * tree.
- *
- * <p>
- * You are able to register for notifications for any node or subtree
- * which can be represented using {@link DataTreeIdentifier}.
- *
- * <p>
- * You are able to register for data change notifications for a subtree or leaf
- * even if it does not exist. You will receive notification once that node is
- * created.
- *
- * <p>
- * If there is any pre-existing data in the data tree for the path for which you are
- * registering, you will receive an initial data change event, which will
- * contain all pre-existing data, marked as created.
- *
- * <p>
- * This method returns a {@link ListenerRegistration} object. To
- * "unregister" your listener for changes call the {@link ListenerRegistration#close()}
- * method on the returned object.
- *
- * <p>
- * You MUST explicitly unregister your listener when you no longer want to receive
- * notifications. This is especially true in OSGi environments, where failure to
- * do so during bundle shutdown can lead to stale listeners being still registered.
- *
- * @param treeId
- * Data tree identifier of the subtree which should be watched for
- * changes.
- * @param listener
- * Listener instance which is being registered
- * @return Listener registration object, which may be used to unregister
- * your listener using {@link ListenerRegistration#close()} to stop
- * delivery of change events.
- */
- <T extends DataObject, L extends DataTreeChangeListener<T>> @NonNull ListenerRegistration<L>
- registerDataTreeChangeListener(@NonNull DataTreeIdentifier<T> treeId, @NonNull L listener);
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.api;
-
-import static java.util.Objects.requireNonNull;
-
-import java.io.Serializable;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.yangtools.concepts.Immutable;
-import org.opendaylight.yangtools.concepts.Path;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * A unique identifier for a particular subtree. It is composed of the logical
- * data store type and the instance identifier of the root node.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.binding.api.DataTreeIdentifier} instead.
- */
-@Deprecated(forRemoval = true)
-public final class DataTreeIdentifier<T extends DataObject> implements Immutable,
- Path<DataTreeIdentifier<?>>, Serializable {
- private static final long serialVersionUID = 1L;
-
- private final @NonNull InstanceIdentifier<T> rootIdentifier;
- private final @NonNull LogicalDatastoreType datastoreType;
-
- public DataTreeIdentifier(final LogicalDatastoreType datastoreType, final InstanceIdentifier<T> rootIdentifier) {
- this.datastoreType = requireNonNull(datastoreType);
- this.rootIdentifier = requireNonNull(rootIdentifier);
- }
-
- /**
- * Return the logical data store type.
- *
- * @return Logical data store type. Guaranteed to be non-null.
- */
- public @NonNull LogicalDatastoreType getDatastoreType() {
- return datastoreType;
- }
-
- /**
- * Return the {@link InstanceIdentifier} of the root node.
- *
- * @return Instance identifier corresponding to the root node.
- */
- public @NonNull InstanceIdentifier<T> getRootIdentifier() {
- return rootIdentifier;
- }
-
- @Override
- public boolean contains(final DataTreeIdentifier<?> other) {
- return datastoreType == other.datastoreType && rootIdentifier.contains(other.rootIdentifier);
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + datastoreType.hashCode();
- result = prime * result + rootIdentifier.hashCode();
- return result;
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (!(obj instanceof DataTreeIdentifier)) {
- return false;
- }
- final DataTreeIdentifier<?> other = (DataTreeIdentifier<?>) obj;
- if (datastoreType != other.datastoreType) {
- return false;
- }
- return rootIdentifier.equals(other.rootIdentifier);
- }
-
- @Override
- public String toString() {
- return getClass().getSimpleName() + "{datastoreType = " + datastoreType + ", rootIdentifier = "
- + rootIdentifier + "}";
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.api;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-
-/**
- * Represent root of modification.
- *
- * @author Tony Tkacik <ttkacik@cisco.com>
- *
- * @deprecated Use {@link org.opendaylight.mdsal.binding.api.DataTreeModification} instead.
- */
-@Deprecated(forRemoval = true)
-public interface DataTreeModification<T extends DataObject> {
-
- /**
- * Get the modification root path. This is the path of the root node
- * relative to the root of InstanceIdentifier namespace.
- *
- * @return absolute path of the root node
- */
- @NonNull DataTreeIdentifier<T> getRootPath();
-
- /**
- * Get the modification root node.
- *
- * @return modification root node
- */
- @NonNull DataObjectModification<T> getRootNode();
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Red Hat, Inc. 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.md.sal.binding.api;
-
-import com.google.common.collect.ForwardingObject;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-
-/**
- * Utility {@link DataBroker} implementation which forwards all interface method
- * invocation to a delegate instance.
- *
- * @deprecated Use org.opendaylight.mdsal.binding.spi.ForwardingDataBroker instead.
- */
-@Deprecated(forRemoval = true)
-public abstract class ForwardingDataBroker extends ForwardingObject implements DataBroker {
-
- @Override
- protected abstract @NonNull DataBroker delegate();
-
- @Override
- public ReadOnlyTransaction newReadOnlyTransaction() {
- return delegate().newReadOnlyTransaction();
- }
-
- @Override
- public ReadWriteTransaction newReadWriteTransaction() {
- return delegate().newReadWriteTransaction();
- }
-
- @Override
- public WriteTransaction newWriteOnlyTransaction() {
- return delegate().newWriteOnlyTransaction();
- }
-
- @Override
- public <T extends DataObject, L extends DataTreeChangeListener<T>> ListenerRegistration<L>
- registerDataTreeChangeListener(DataTreeIdentifier<T> treeId, L listener) {
- return delegate().registerDataTreeChangeListener(treeId, listener);
- }
-
- @Override
- public BindingTransactionChain createTransactionChain(TransactionChainListener listener) {
- return delegate().createTransactionChain(listener);
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Red Hat, Inc. 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.md.sal.binding.api;
-
-import com.google.common.base.Optional;
-import com.google.common.collect.ForwardingObject;
-import com.google.common.util.concurrent.CheckedFuture;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * Utility {@link ReadOnlyTransaction} implementation which forwards all interface method
- * invocation to a delegate instance.
- *
- * @deprecated Use org.opendaylight.mdsal.binding.spi.ForwardingReadTransaction instead.
- */
-@Deprecated(forRemoval = true)
-public class ForwardingReadOnlyTransaction extends ForwardingObject implements ReadOnlyTransaction {
-
- private final ReadOnlyTransaction delegate;
-
- protected ForwardingReadOnlyTransaction(final ReadOnlyTransaction delegate) {
- this.delegate = delegate;
- }
-
- @Override
- protected ReadTransaction delegate() {
- return delegate;
- }
-
- @Override
- public <T extends DataObject> CheckedFuture<Optional<T>, ReadFailedException> read(final LogicalDatastoreType store,
- final InstanceIdentifier<T> path) {
- return delegate.read(store, path);
- }
-
- @Override
- public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store,
- final InstanceIdentifier<?> path) {
- return delegate.exists(store, path);
- }
-
- @Override
- public Object getIdentifier() {
- return delegate.getIdentifier();
- }
-
- @Override
- public void close() {
- delegate.close();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Red Hat, Inc. 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.md.sal.binding.api;
-
-import com.google.common.base.Optional;
-import com.google.common.collect.ForwardingObject;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.FluentFuture;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.mdsal.common.api.CommitInfo;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * Utility {@link ReadWriteTransaction} implementation which forwards all interface method
- * invocation to a delegate instance.
- *
- * @deprecated Use org.opendaylight.mdsal.binding.spi.ForwardingReadWriteTransaction instead.
- */
-@Deprecated(forRemoval = true)
-public class ForwardingReadWriteTransaction extends ForwardingObject implements ReadWriteTransaction {
-
- private final ReadWriteTransaction delegate;
-
- protected ForwardingReadWriteTransaction(final ReadWriteTransaction delegate) {
- this.delegate = delegate;
- }
-
- @Override
- protected ReadWriteTransaction delegate() {
- return delegate;
- }
-
- @Override
- public <T extends DataObject> void put(final LogicalDatastoreType store, final InstanceIdentifier<T> path,
- final T data) {
- delegate.put(store, path, data);
- }
-
- @Override
- public <T extends DataObject> void put(final LogicalDatastoreType store, final InstanceIdentifier<T> path,
- final T data, final boolean createMissingParents) {
- delegate.put(store, path, data, createMissingParents);
- }
-
- @Override
- public <T extends DataObject> CheckedFuture<Optional<T>, ReadFailedException> read(final LogicalDatastoreType store,
- final InstanceIdentifier<T> path) {
- return delegate.read(store, path);
- }
-
- @Override
- public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store,
- final InstanceIdentifier<?> path) {
- return delegate.exists(store, path);
- }
-
- @Override
- public Object getIdentifier() {
- return delegate.getIdentifier();
- }
-
- @Override
- public boolean cancel() {
- return delegate.cancel();
- }
-
- @Override
- public <T extends DataObject> void merge(final LogicalDatastoreType store, final InstanceIdentifier<T> path,
- final T data) {
- delegate.merge(store, path, data);
- }
-
- @Override
- public <T extends DataObject> void merge(final LogicalDatastoreType store, final InstanceIdentifier<T> path,
- final T data, final boolean createMissingParents) {
- delegate.merge(store, path, data, createMissingParents);
- }
-
- @Override
- public FluentFuture<? extends CommitInfo> commit() {
- return delegate.commit();
- }
-
- @Override
- public void delete(final LogicalDatastoreType store, final InstanceIdentifier<?> path) {
- delegate.delete(store, path);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Red Hat, Inc. 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.md.sal.binding.api;
-
-import com.google.common.collect.ForwardingObject;
-import com.google.common.util.concurrent.FluentFuture;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.mdsal.common.api.CommitInfo;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * Utility {@link WriteTransaction} implementation which forwards all interface method
- * invocation to a delegate instance.
- *
- * @deprecated Use org.opendaylight.mdsal.binding.spi.ForwardingWriteTransaction instead.
- */
-@Deprecated(forRemoval = true)
-public class ForwardingWriteTransaction extends ForwardingObject implements WriteTransaction {
-
- private final WriteTransaction delegate;
-
- protected ForwardingWriteTransaction(WriteTransaction delegate) {
- this.delegate = delegate;
- }
-
- @Override
- protected WriteTransaction delegate() {
- return delegate;
- }
-
- @Override
- public <T extends DataObject> void put(LogicalDatastoreType store, InstanceIdentifier<T> path, T data) {
- delegate.put(store, path, data);
- }
-
- @Override
- public <T extends DataObject> void put(LogicalDatastoreType store, InstanceIdentifier<T> path, T data,
- boolean createMissingParents) {
- delegate.put(store, path, data, createMissingParents);
- }
-
- @Override
- public <T extends DataObject> void merge(LogicalDatastoreType store, InstanceIdentifier<T> path, T data) {
- delegate.merge(store, path, data);
- }
-
- @Override
- public <T extends DataObject> void merge(LogicalDatastoreType store, InstanceIdentifier<T> path, T data,
- boolean createMissingParents) {
- delegate.merge(store, path, data, createMissingParents);
- }
-
- @Override
- public void delete(LogicalDatastoreType store, InstanceIdentifier<?> path) {
- delegate.delete(store, path);
- }
-
- @Override
- public boolean cancel() {
- return delegate.cancel();
- }
-
- @Override
- public FluentFuture<? extends CommitInfo> commit() {
- return delegate.commit();
- }
-
- @Override
- public Object getIdentifier() {
- return delegate.getIdentifier();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.api;
-
-import com.google.common.base.Optional;
-import org.opendaylight.yangtools.concepts.Identifiable;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-@Deprecated(forRemoval = true)
-public interface MountPoint extends Identifiable<InstanceIdentifier<?>> {
- <T extends BindingService> Optional<T> getService(Class<T> service);
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.api;
-
-import com.google.common.base.Optional;
-import java.util.EventListener;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * Deprecated.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.binding.api.MountPointService} instead
- */
-@Deprecated(forRemoval = true)
-public interface MountPointService extends BindingService {
-
- Optional<MountPoint> getMountPoint(InstanceIdentifier<?> mountPoint);
-
- <T extends MountPointListener> ListenerRegistration<T> registerListener(InstanceIdentifier<?> path, T listener);
-
-
- interface MountPointListener extends EventListener {
-
- void onMountPointCreated(InstanceIdentifier<?> path);
-
- void onMountPointRemoved(InstanceIdentifier<?> path);
-
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.api;
-
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import java.util.concurrent.TimeUnit;
-import org.opendaylight.yangtools.yang.binding.Notification;
-
-/**
- * A {@link NotificationService} which also allows its users to
- * submit YANG-modeled notifications for delivery. There are three
- * methods of submission, following the patters from {@link java.util.concurrent.BlockingQueue}:
- * - {@link #putNotification(Notification)}, which may block indefinitely
- * if the implementation cannot allocate resources to accept the notification,
- * - {@link #offerNotification(Notification)}, which does not block if face
- * of resource starvation,
- * - {@link #offerNotification(Notification, int, TimeUnit)}, which may block
- * for specified time if resources are thin.
- *
- * <p>
- * The actual delivery to listeners is asynchronous and implementation-specific.
- * Users of this interface should not make any assumptions as to whether the
- * notification has or has not been seen.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.binding.api.NotificationPublishService} instead
- */
-@Deprecated(forRemoval = true)
-public interface NotificationPublishService extends BindingService {
-
- /**
- * Well-known value indicating that the binding-aware implementation is currently not
- * able to accept a notification.
- */
- ListenableFuture<Object> REJECTED = Futures.immediateFailedFuture(new NotificationRejectedException(
- "Rejected due to resource constraints."));
-
- /**
- * Publishes a notification to subscribed listeners. This initiates
- * the process of sending the notification, but delivery to the
- * listeners can happen asynchronously, potentially after a call to
- * this method returns.
- *
- * <b>Note:</b> This call will block when the notification queue is full.
- *
- * @param notification
- * the notification to publish.
- * @throws InterruptedException if interrupted while waiting
- * @throws NullPointerException if the notification is null
- */
- void putNotification(Notification notification) throws InterruptedException;
-
- /**
- * Publishes a notification to subscribed listeners. This initiates
- * the process of sending the notification, but delivery to the
- * listeners can happen asynchronously, potentially after a call to
- * this method returns.
- *
- * <p>
- * Still guaranteed not to block. Returns Listenable Future which will complete once.
- *
- * @param notification
- * the notification to publish.
- * @return A listenable future which will report completion when the service has finished
- * propagating the notification to its immediate registrants, or {@link #REJECTED} if resource
- * constraints prevent
- * @throws NullPointerException if the notification is null
- */
- ListenableFuture<?> offerNotification(Notification notification);
-
- /**
- * Publishes a notification to subscribed listeners. This initiates
- * the process of sending the notification, but delivery to the
- * listeners can happen asynchronously, potentially after a call to
- * this method returns. This method is guaranteed not to block more
- * than the specified timeout.
- *
- * @param notification
- * the notification to publish.
- * @param timeout how long to wait before giving up, in units of unit
- * @param unit a TimeUnit determining how to interpret the
- * timeout parameter
- * @return A listenable future which will report completion when the service has finished
- * propagating the notification to its immediate registrants, or {@link #REJECTED} if resource
- * constraints prevent
- * @throws InterruptedException if interrupted while waiting
- * @throws NullPointerException if the notification or unit is null
- * @throws IllegalArgumentException if timeout is negative.
- */
- ListenableFuture<?> offerNotification(Notification notification, int timeout, TimeUnit unit)
- throws InterruptedException;
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.api;
-
-/**
- * <p>
- * This exception indicates that given notification can not be processed by corresponding mechanism.
- * More info can be provided in message.
- * </p>
- * <p>
- * Expected use: {@link NotificationPublishService}
- * </p>
- *
- * @deprecated Use {@link org.opendaylight.mdsal.binding.api.NotificationRejectedException} instead.
- */
-@Deprecated(forRemoval = true)
-public class NotificationRejectedException extends Exception {
- private static final long serialVersionUID = 1L;
-
- public NotificationRejectedException(final String message) {
- super(message);
- }
-
- public NotificationRejectedException(final String message, final Throwable cause) {
- super(message, cause);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.api;
-
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.NotificationListener;
-
-/**
- * Notification broker which allows clients to subscribe for and publish YANG-modeled notifications.
- *
- * <p>
- * Each YANG module which defines notifications results in a generated interface <code>{ModuleName}Listener</code>
- * which handles all the notifications defined in the YANG model. Each notification type translates to
- * a specific method of the form <code>on{NotificationType}</code> on the generated interface.
- * The generated interface also extends the
- * {@link org.opendaylight.yangtools.yang.binding.NotificationListener} interface and implementations
- * are registered using
- * {@link #registerNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener)} method.
- *
- * <h3>Dispatch Listener Example</h3>
- *
- * <p>
- * Lets assume we have following YANG model:
- *
- * <pre>
- * module example {
- * ...
- *
- * notification start {
- * ...
- * }
- *
- * notification stop {
- * ...
- * }
- * }
- * </pre>
- *
- * <p>
- * The generated interface will be:
- * {@code
- * public interface ExampleListener extends NotificationListener {
- * void onStart(Start notification);
- * void onStop(Stop notification);
- * }
- * }
- * The following defines an implementation of the generated interface:
- * {@code
- * public class MyExampleListener implements ExampleListener {
- * public void onStart(Start notification) {
- * // do something
- * }
- *
- * public void onStop(Stop notification) {
- * // do something
- * }
- * }
- * }
- * The implementation is registered as follows:
- * {@code
- * MyExampleListener listener = new MyExampleListener();
- * ListenerRegistration<NotificationListener> reg = service.registerNotificationListener( listener );
- * }
- * The <code>onStart</code> method will be invoked when someone publishes a <code>Start</code> notification and
- * the <code>onStop</code> method will be invoked when someone publishes a <code>Stop</code> notification.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.binding.api.NotificationService} instead
- */
-@Deprecated(forRemoval = true)
-public interface NotificationService extends BindingService {
- /**
- * Registers a listener which implements a YANG-generated notification interface derived from
- * {@link NotificationListener}. The listener is registered for all notifications present in
- * the implemented interface.
- *
- * @param listener the listener implementation that will receive notifications.
- * @return a {@link ListenerRegistration} instance that should be used to unregister the listener
- * by invoking the {@link ListenerRegistration#close()} method when no longer needed.
- */
- <T extends NotificationListener> ListenerRegistration<T> registerNotificationListener(T listener);
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.api;
-
-import org.opendaylight.controller.md.sal.common.api.data.AsyncReadOnlyTransaction;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * A transaction that provides a stateful read-only view of the data tree.
- *
- * <p>
- * For more information on usage and examples, please see the documentation in
- * {@link org.opendaylight.controller.md.sal.common.api.data.AsyncReadTransaction}.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.binding.api.ReadTransaction} instead.
- */
-@Deprecated(forRemoval = true)
-public interface ReadOnlyTransaction extends ReadTransaction, AsyncReadOnlyTransaction<InstanceIdentifier<?>,
- DataObject> {
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.api;
-
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.MoreExecutors;
-import org.opendaylight.controller.md.sal.common.api.MappingCheckedFuture;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncReadTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * A transaction that provides read access to a logical data store.
- *
- * <p>
- * For more information on usage and examples, please see the documentation in {@link AsyncReadTransaction}.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.binding.api.ReadTransaction} instead.
- */
-@Deprecated(forRemoval = true)
-public interface ReadTransaction extends AsyncReadTransaction<InstanceIdentifier<?>, DataObject> {
- /**
- * Reads data from the provided logical data store located at the provided path.
- *
- * <p>
- * If the target is a subtree, then the whole subtree is read (and will be accessible from the returned data
- * object).
- *
- * @param store Logical data store from which read should occur.
- * @param path Path which uniquely identifies subtree which client want to read
- * @return a CheckFuture containing the result of the read. The Future blocks until the
- * commit operation is complete. Once complete:
- * <ul>
- * <li>If the data at the supplied path exists, the Future returns an Optional object
- * containing the data.</li>
- * <li>If the data at the supplied path does not exist, the Future returns
- * Optional#absent().</li>
- * <li>If the read of the data fails, the Future will fail with a
- * {@link ReadFailedException} or an exception derived from ReadFailedException.</li>
- * </ul>
- */
- <T extends DataObject> CheckedFuture<Optional<T>, ReadFailedException> read(
- LogicalDatastoreType store, InstanceIdentifier<T> path);
-
- /**
- * Checks if data is available in the logical data store located at provided path.
- *
- * <p>
- * Note: a successful result from this method makes no guarantee that a subsequent call to {@link #read}
- * will succeed. It is possible that the data resides in a data store on a remote node and, if that
- * node goes down or a network failure occurs, a subsequent read would fail. Another scenario is if
- * the data is deleted in between the calls to <code>exists</code> and <code>read</code>
- *
- * <p>
- * Default implementation delegates to {@link #read(LogicalDatastoreType, InstanceIdentifier)}, implementations
- * are advised to provide a more efficient override.
- *
- * @param store Logical data store from which read should occur.
- * @param path Path which uniquely identifies subtree which client want to check existence of
- * @return a CheckFuture containing the result of the check.
- * <ul>
- * <li>If the data at the supplied path exists, the Future returns a Boolean
- * whose value is true, false otherwise</li>
- * <li>If checking for the data fails, the Future will fail with a
- * {@link ReadFailedException} or an exception derived from ReadFailedException.</li>
- * </ul>
- */
- default CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store,
- final InstanceIdentifier<?> path) {
- return MappingCheckedFuture.create(Futures.transform(read(store, path), Optional::isPresent,
- MoreExecutors.directExecutor()), ReadFailedException.MAPPER);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.api;
-
-import org.opendaylight.controller.md.sal.common.api.data.AsyncReadWriteTransaction;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * A transaction that enables combined read/write capabilities.
- *
- * <p>
- * For more information on usage and examples, please see the documentation in {@link AsyncReadWriteTransaction}.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.binding.api.ReadWriteTransaction} instead.
- */
-@Deprecated(forRemoval = true)
-public interface ReadWriteTransaction extends ReadTransaction, WriteTransaction,
- AsyncReadWriteTransaction<InstanceIdentifier<?>, DataObject> {
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.api;
-
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataTransactionFactory;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-@Deprecated(forRemoval = true)
-public interface TransactionFactory extends AsyncDataTransactionFactory<InstanceIdentifier<?>, DataObject> {
- @Override
- ReadOnlyTransaction newReadOnlyTransaction();
-
- @Override
- ReadWriteTransaction newReadWriteTransaction();
-
- @Override
- WriteTransaction newWriteOnlyTransaction();
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.api;
-
-import org.opendaylight.controller.md.sal.common.api.data.AsyncWriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * A transaction that provides mutation capabilities on a data tree.
- *
- * <p>
- * For more information on usage and examples, please see the documentation in {@link AsyncWriteTransaction}.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.binding.api.WriteTransaction} instead.
- */
-@Deprecated(forRemoval = true)
-public interface WriteTransaction extends AsyncWriteTransaction<InstanceIdentifier<?>, DataObject> {
- /**
- * Stores a piece of data at the specified path. This acts as an add / replace operation, which is to say that whole
- * subtree will be replaced by the specified data.
- *
- * <p>
- * This method does not automatically create missing parent nodes. It is equivalent to invoking
- * {@link #put(LogicalDatastoreType, InstanceIdentifier, DataObject, boolean)} with {@code createMissingParents} set
- * to false.
- *
- * <p>
- * For more information on usage and examples, please see the documentation in {@link AsyncWriteTransaction}.
- *
- * <p>
- * If you need to make sure that a parent object exists but you do not want modify its pre-existing state by using
- * put, consider using {@link #merge} instead.
- *
- * @param store the logical data store which should be modified
- * @param path the data object path
- * @param data the data object to be written to the specified path
- * @throws IllegalStateException if the transaction has already been submitted
- */
- <T extends DataObject> void put(LogicalDatastoreType store, InstanceIdentifier<T> path, T data);
-
- /**
- * Stores a piece of data at the specified path. This acts as an add / replace operation, which is to say that whole
- * subtree will be replaced by the specified data.
- *
- * <p>
- * For more information on usage and examples, please see the documentation in {@link AsyncWriteTransaction}.
- *
- * <p>
- * If you need to make sure that a parent object exists but you do not want modify its pre-existing state by using
- * put, consider using {@link #merge} instead.
- *
- * <p>
- * Note: Using <code>createMissingParents</code> with value true, may introduce garbage in data store, or recreate
- * nodes, which were deleted by previous transaction.
- *
- * @param store the logical data store which should be modified
- * @param path the data object path
- * @param data the data object to be written to the specified path
- * @param createMissingParents if {@link #CREATE_MISSING_PARENTS} ({@code true}), any missing parent nodes will be
- * automatically created using a merge operation.
- * @throws IllegalStateException if the transaction has already been submitted
- */
- <T extends DataObject> void put(LogicalDatastoreType store, InstanceIdentifier<T> path, T data,
- boolean createMissingParents);
-
- /**
- * Merges a piece of data with the existing data at a specified path. Any pre-existing data which is not explicitly
- * overwritten will be preserved. This means that if you store a container, its child lists will be merged.
- *
- * <p>
- * This method does not automatically create missing parent nodes. It is equivalent to invoking
- * {@link #merge(LogicalDatastoreType, InstanceIdentifier, DataObject, boolean)} with {@code createMissingParents}
- * set to false.
- *
- * <p>
- * For more information on usage and examples, please see the documentation in {@link AsyncWriteTransaction}.
- *
- * <p>
- * If you require an explicit replace operation, use {@link #put} instead.
- *
- * @param store the logical data store which should be modified
- * @param path the data object path
- * @param data the data object to be merged to the specified path
- * @throws IllegalStateException if the transaction has already been submitted
- */
- <T extends DataObject> void merge(LogicalDatastoreType store, InstanceIdentifier<T> path, T data);
-
- /**
- * Merges a piece of data with the existing data at a specified path. Any pre-existing data which is not explicitly
- * overwritten will be preserved. This means that if you store a container, its child lists will be merged.
- *
- * <p>
- * For more information on usage and examples, please see the documentation in {@link AsyncWriteTransaction}.
- *
- * <p>
- * If you require an explicit replace operation, use {@link #put} instead.
- *
- * @param store the logical data store which should be modified
- * @param path the data object path
- * @param data the data object to be merged to the specified path
- * @param createMissingParents if {@link #CREATE_MISSING_PARENTS} ({@code true}), any missing parent nodes will be
- * automatically created using a merge operation.
- * @throws IllegalStateException if the transaction has already been submitted
- */
- <T extends DataObject> void merge(LogicalDatastoreType store, InstanceIdentifier<T> path, T data,
- boolean createMissingParents);
-
- @Override
- void delete(LogicalDatastoreType store, InstanceIdentifier<?> path);
-
- /**
- * Flag value indicating that missing parents should be created.
- */
- boolean CREATE_MISSING_PARENTS = true;
-
- /**
- * Flag value indicating that missing parents should cause an error.
- */
- boolean FAIL_ON_MISSING_PARENTS = false;
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.binding.api;
-
-import org.osgi.framework.BundleContext;
-
-@Deprecated(forRemoval = true)
-public abstract class AbstractBindingAwareConsumer extends AbstractBrokerAwareActivator
- implements BindingAwareConsumer {
- @Override
- protected final void onBrokerAvailable(BindingAwareBroker broker, BundleContext context) {
- broker.registerConsumer(this, context);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.binding.api;
-
-import org.osgi.framework.BundleContext;
-
-@Deprecated(forRemoval = true)
-public abstract class AbstractBindingAwareProvider extends AbstractBrokerAwareActivator
- implements BindingAwareProvider {
- @Override
- protected final void onBrokerAvailable(BindingAwareBroker broker, BundleContext context) {
- broker.registerProvider(this, context);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.binding.api;
-
-import static java.util.Objects.requireNonNull;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.util.tracker.ServiceTracker;
-import org.osgi.util.tracker.ServiceTrackerCustomizer;
-
-@Deprecated(forRemoval = true)
-public abstract class AbstractBrokerAwareActivator implements BundleActivator {
- private final class Customizer implements ServiceTrackerCustomizer<BindingAwareBroker, BindingAwareBroker> {
- private final BundleContext context;
-
- Customizer(final BundleContext context) {
- this.context = requireNonNull(context);
- }
-
- @Override
- public BindingAwareBroker addingService(final ServiceReference<BindingAwareBroker> reference) {
- final BindingAwareBroker broker = context.getService(reference);
- MD_ACTIVATION_POOL.execute(() -> onBrokerAvailable(broker, context));
- return broker;
- }
-
- @Override
- public void modifiedService(final ServiceReference<BindingAwareBroker> reference,
- final BindingAwareBroker service) {
- removedService(reference, service);
- addingService(reference);
- }
-
- @Override
- public void removedService(final ServiceReference<BindingAwareBroker> reference,
- final BindingAwareBroker service) {
- final BindingAwareBroker broker = context.getService(reference);
- MD_ACTIVATION_POOL.execute(() -> onBrokerRemoved(broker, context));
- }
- }
-
- private static final ExecutorService MD_ACTIVATION_POOL = Executors.newCachedThreadPool();
-
- private ServiceTracker<BindingAwareBroker, BindingAwareBroker> tracker;
-
- @Override
- public final void start(final BundleContext bundleContext) {
- startImpl(bundleContext);
- tracker = new ServiceTracker<>(bundleContext, BindingAwareBroker.class, new Customizer(bundleContext));
- tracker.open();
- }
-
- @Override
- public final void stop(final BundleContext bundleContext) {
- if (tracker != null) {
- tracker.close();
- }
- stopImpl(bundleContext);
- }
-
- /**
- * Called when this bundle is started (before
- * {@link BindingAwareProvider#onSessionInitiated(ProviderContext)} so the Framework can perform
- * the bundle-specific activities necessary to start this bundle. This
- * method can be used to register services or to allocate any resources that
- * this bundle needs.
- *
- * <p>
- * This method must complete and return to its caller in a timely manner.
- *
- * @param bundleContext
- * The execution context of the bundle being started.
- * @throws RuntimeException
- * If this method throws an exception, this bundle is marked as
- * stopped and the Framework will remove this bundle's
- * listeners, unregister all services registered by this bundle,
- * and release all services used by this bundle.
- */
- protected void startImpl(final BundleContext bundleContext) {
- // NOOP
- }
-
- /**
- * Called when this bundle is stopped so the Framework can perform the
- * bundle-specific activities necessary to stop the bundle. In general, this
- * method should undo the work that the {@code BundleActivator.start} method
- * started. There should be no active threads that were started by this
- * bundle when this bundle returns. A stopped bundle must not call any
- * Framework objects.
- *
- * <p>
- * This method must complete and return to its caller in a timely manner.
- *
- * @param bundleContext The execution context of the bundle being stopped.
- * @throws RuntimeException If this method throws an exception, the bundle is still
- * marked as stopped, and the Framework will remove the bundle's
- * listeners, unregister all services registered by the bundle, and
- * release all services used by the bundle.
- */
- protected void stopImpl(final BundleContext bundleContext) {
- // NOOP
- }
-
- protected abstract void onBrokerAvailable(BindingAwareBroker bindingBroker, BundleContext bundleContext);
-
- protected void onBrokerRemoved(final BindingAwareBroker bindingBroker, final BundleContext bundleContext) {
- stopImpl(bundleContext);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.binding.api;
-
-import org.opendaylight.controller.md.sal.common.api.routing.RoutedRegistration;
-import org.opendaylight.yangtools.concepts.ObjectRegistration;
-import org.opendaylight.yangtools.yang.binding.BaseIdentity;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-import org.osgi.framework.BundleContext;
-
-/**
- * Binding-aware core of the SAL layer responsible for wiring the SAL consumers.
- *
- * <p>
- * The responsibility of the broker is to maintain registration of SAL
- * functionality Consumers and Providers, store provider and
- * consumer specific context and functionality registration via
- * {@link ConsumerContext} and provide access to infrastructure services, which
- * removes direct dependencies between providers and consumers.
- *
- * <p>
- * The Binding-aware broker is also responsible for translation from Java
- * classes modeling the functionality and data to binding-independent form which
- * is used in SAL Core.
- *
- * <h3>Infrastructure services</h3> Some examples of infrastructure services:
- *
- * <ul>
- * <li>YANG Module service - see {@link ConsumerContext#getRpcService(Class)},
- * {@link ProviderContext}
- * <li>Notification Service - see {@link NotificationService} and
- * {@link NotificationProviderService}
- * </ul>
- *
- * <p>
- * The services are exposed via session.
- *
- * <h3>Session-based access</h3>
- *
- * <p>
- * The providers and consumers needs to register in order to use the
- * binding-independent SAL layer and to expose functionality via SAL layer.
- *
- * <p>
- * For more information about session-based access see {@link ConsumerContext}
- * and {@link ProviderContext}
- */
-@Deprecated(forRemoval = true)
-public interface BindingAwareBroker {
- @Deprecated
- ConsumerContext registerConsumer(BindingAwareConsumer consumer, BundleContext ctx);
-
- /**
- * Registers the {@link BindingAwareConsumer}, which will use the SAL layer.
- *
- * <p>
- * Note that consumer could register additional functionality at later point
- * by using service and functionality specific APIs.
- *
- * <p>
- * The consumer is required to use returned session for all communication
- * with broker or one of the broker services. The session is announced to
- * the consumer by invoking
- * {@link BindingAwareConsumer#onSessionInitialized(ConsumerContext)}.
- *
- * @param consumer
- * Consumer to be registered.
- * @return a session specific to consumer registration
- * @throws IllegalArgumentException
- * If the consumer is <code>null</code>.
- * @throws IllegalStateException
- * If the consumer is already registered.
- */
- @Deprecated
- ConsumerContext registerConsumer(BindingAwareConsumer consumer);
-
- /*
- * @deprecated Use registerProvider(BindingAwareProvider prov) instead (BundleContext is no longer used)
- */
- @Deprecated
- ProviderContext registerProvider(BindingAwareProvider provider, BundleContext ctx);
-
- /**
- * Registers the {@link BindingAwareProvider}, which will use the SAL layer.
- *
- * <p>
- * During the registration, the broker obtains the initial functionality
- * from consumer, using the
- * BindingAwareProvider#getImplementations(), and register that
- * functionality into system and concrete infrastructure services.
- *
- * <p>
- * Note that provider could register additional functionality at later point
- * by using service and functionality specific APIs.
- *
- * <p>
- * The consumer is <b>required to use</b> returned session for all
- * communication with broker or one of the broker services. The session is
- * announced to the consumer by invoking
- * {@link BindingAwareProvider#onSessionInitiated(ProviderContext)}.
- *
- *
- * @param provider
- * Provider to be registered.
- * @return a session unique to the provider registration.
- * @throws IllegalArgumentException
- * If the provider is <code>null</code>.
- * @throws IllegalStateException
- * If the consumer is already registered.
- */
- @Deprecated
- ProviderContext registerProvider(BindingAwareProvider provider);
-
- /**
- * {@link BindingAwareConsumer} specific access to the SAL functionality.
- *
- * <p>
- * ConsumerSession is {@link BindingAwareConsumer}-specific access to the
- * SAL functionality and infrastructure services.
- *
- * <p>
- * The session serves to store SAL context (e.g. registration of
- * functionality) for the consumer and provides access to the SAL
- * infrastructure services and other functionality provided by
- * {@link BindingAwareProvider}s.
- */
- @Deprecated
- interface ConsumerContext extends RpcConsumerRegistry {
-
- /**
- * Returns a session specific instance (implementation) of requested binding-aware infrastructure service.
- *
- * @param service
- * Broker service
- * @return Session specific implementation of service
- */
- <T extends BindingAwareService> T getSALService(Class<T> service);
- }
-
- /**
- * {@link BindingAwareProvider} specific access to the SAL functionality.
- *
- * <p>
- * ProviderSession is {@link BindingAwareProvider}-specific access to the
- * SAL functionality and infrastructure services, which also allows for
- * exposing the provider's functionality to the other
- * {@link BindingAwareConsumer}s.
- *
- * <p>
- * The session serves to store SAL context (e.g. registration of
- * functionality) for the providers and exposes access to the SAL
- * infrastructure services, dynamic functionality registration and any other
- * functionality provided by other {@link BindingAwareConsumer}s.
- *
- */
- @Deprecated
- interface ProviderContext extends ConsumerContext, RpcProviderRegistry {
-
- }
-
- /**
- * Represents an RPC implementation registration. Users should call the
- * {@link ObjectRegistration#close close} method when the registration is no longer needed.
- *
- * @param <T> the implemented RPC service interface
- */
- interface RpcRegistration<T extends RpcService> extends ObjectRegistration<T> {
-
- /**
- * Returns the implemented RPC service interface.
- */
- Class<T> getServiceType();
-
- @Override
- void close();
- }
-
- /**
- * Represents a routed RPC implementation registration. Users should call the
- * {@link RoutedRegistration#close close} method when the registration is no longer needed.
- *
- * @param <T> the implemented RPC service interface
- */
- interface RoutedRpcRegistration<T extends RpcService> extends RpcRegistration<T>,
- RoutedRegistration<Class<? extends BaseIdentity>, InstanceIdentifier<?>, T> {
-
- /**
- * Register particular instance identifier to be processed by this RpcService.
- *
- * @deprecated in favor of RoutedRegistration#registerPath(Object, Object).
- */
- @Deprecated
- void registerInstance(Class<? extends BaseIdentity> context, InstanceIdentifier<?> instance);
-
- /**
- * Unregister particular instance identifier to be processed by this RpcService.
- *
- * @deprecated in favor of RoutedRegistration#unregisterPath(Class, InstanceIdentifier).
- */
- @Deprecated
- void unregisterInstance(Class<? extends BaseIdentity> context, InstanceIdentifier<?> instance);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.binding.api;
-
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
-
-/**
- * A developer implemented component that gets registered with the Broker.
- *
- * <p>
- * Semantically, a consumer may:
- *
- * <ol>
- * <li>Subscribe for Notifications </li>
- * <li>Invoke RPCs</li>
- * <li>Read from either the operational or config data tree</li>
- * <li>Write to the config data tree</li>
- * </ol>
- * If you need to:
- * <ol>
- * <li> Emit Notifications</li>
- * <li> Provide the implementation of RPCs </li>
- * <li> Write to the operational data tree </li>
- * </ol>
- *
- * <p>
- * Consider using a BindingAwareProvider
- *
- * <p>
- * Examples:
- *
- * <p>
- * To get a NotificationService:
- *
- * <p>
- * {code
- * public void onSessionInitiated(ProviderContext session) {
- * NotificationProviderService notificationService = session.getSALService(NotificationProviderService.class);
- * notificationService.publish(notification)
- * }
- * where notification is an instance of a modeled Notification.
- * For more information on sending notifications via the NotificationProviderService
- * see org.opendaylight.controller.sal.binding.api.NotificationProviderService
- *
- * <p>
- * A consumer can *invoke* and RPC ( ie, call foo(fooArgs)) but it cannot register an RPC
- * implementation with the MD-SAL that others can invoke(call).
- * To get an invokable RPC:
- *
- * <p>
- * {code
- * public void onSessionInitiated(ProviderContext session) {
- * MyService rpcFlowSalService = session.getRpcService(MyService.class);
- * }
- *
- * <p>
- * Where MyService.class is a Service interface generated from a yang model with RPCs modeled in it. The returned
- * rpcFlowSalService can be used like any other object by invoking its methods. Note, nothing special needs to be done
- * for RoutedRPCs. They just work.
- *
- * <p>
- * To get a DataBroker to allow access to the data tree:
- *
- * <p>
- * {code
- * public void onSessionInitiated(final ProviderContext session) {
- * DataBroker databroker = session.getSALService(BindingDataBroker.class);
- * }
- * }
-*/
-@Deprecated(forRemoval = true)
-public interface BindingAwareConsumer {
-
- /**
- * Callback signaling initialization of the consumer session to the SAL.
- *
- * <p>
- * The consumer MUST use the session for all communication with SAL or
- * retrieving SAL infrastructure services.
- *
- * <p>
- * This method is invoked by {@link BindingAwareBroker#registerConsumer(BindingAwareConsumer)}
- *
- * @param session
- * Unique session between consumer and SAL.
- */
- void onSessionInitialized(ConsumerContext session);
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.binding.api;
-
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-
-/**
- * A developer implemented component that gets registered with the Broker.
- *
- * <p>
- * Semantically, a provider may:
- *
- * <ol>
- * <li> Emit Notifications</li>
- * <li> Provide the implementation of RPCs </li>
- * <li> Write to the operational data tree </li>
- * </ol>
- *
- * <p>
- * If a class is not doing at least one of those three, consider using
- * a BindingAwareConsumer instead:
- * see {@link org.opendaylight.controller.sal.binding.api.BindingAwareConsumer}
- *
- * <p>
- * In addition, a BindingAwareProvider can in pursuit of its goals:
- * <ol>
- * <li>Subscribe for Notifications </li>
- * <li>Invoke RPCs</li>
- * <li>Read from either the operational or config data tree</li>
- * <li>Write to the config data tree</li>
- * </ol>
- * (All of the above are things a Consumer can also do).
- *
- * <p>
- * Examples:
- *
- *<p>
- * To get a NotificationService:
- *
- * {@code
- * public void onSessionInitiated(ProviderContext session) {
- * NotificationProviderService notificationService = session.getSALService(NotificationProviderService.class);
- * }
- * }
- * For more information on sending notifications via the NotificationProviderService
- * see {@link org.opendaylight.controller.sal.binding.api.NotificationProviderService}
- *
- * <p>
- * To register an RPC implementation:
- *
- * {@code
- * public void onSessionInitiated(ProviderContext session) {
- * RpcRegistration<MyService> registration = session.addRpcImplementation(MyService.class, myImplementationInstance);
- * }
- * }
- *
- * <p>
- * Where MyService.class is a Service interface generated from a yang model with RPCs modeled in it and
- * myImplementationInstance is an instance of a class that implements MyService.
- *
- * <p>
- * To register a Routed RPC Implementation:
- * {@code
- * public void onSessionInitiated(ProviderContext session) {
- * RoutedRpcRegistration<SalFlowService> flowRegistration = session.addRoutedRpcImplementation(SalFlowService.class,
- * salFlowServiceImplementationInstance);
- flowRegistration.registerPath(NodeContext.class, nodeInstanceId);
- * }
- * }
- *
- * <p>
- * Where SalFlowService.class is a Service interface generated from a yang model with RPCs modeled in it and
- * salFlowServiceImplementationInstance is an instance of a class that implements SalFlowService.
- *
- * <p>
- * The line:
- * {@code
- * flowRegistration.registerPath(NodeContext.class, nodeInstanceId);
- * }
- * Is indicating that the RPC implementation is registered to handle RPC invocations that have their NodeContext
- * pointing to the node with instance id nodeInstanceId. This bears a bit of further explanation. RoutedRPCs can be
- * 'routed' to an implementation based upon 'context'. 'context' is a pointer (instanceId) to some place in the data
- * tree. In this example, the 'context' is a pointer to a Node. In this way, a provider can register its ability to
- * provide a service for a particular Node, but not *all* Nodes. The Broker routes the RPC by 'context' to the correct
- * implementation, without the caller having to do extra work. Because of this when a RoutedRPC is registered, it
- * needs to also be able to indicate for which 'contexts' it is providing an implementation.
- *
- * <p>
- * An example of a Routed RPC would be an updateFlow(node, flow) that would be routed based on node to the provider
- * which had registered to provide it *for that node*.
- *
- *<p>
- * To get a DataBroker to allow access to the data tree:
- *
- * {@code
- * public void onSessionInitiated(final ProviderContext session) {
- * DataBroker databroker = session.getSALService(BindingDataBroker.class);
- * }
- * }
- */
-@Deprecated(forRemoval = true)
-public interface BindingAwareProvider {
-
- /**
- * Callback signaling initialization of the consumer session to the SAL.
- *
- * <p>
- * The consumer MUST use the session for all communication with SAL or
- * retrieving SAL infrastructure services.
- *
- * <p>
- * This method is invoked by
- * {@link BindingAwareBroker#registerProvider(BindingAwareProvider)}
- *
- * @param session Unique session between consumer and SAL.
- */
- void onSessionInitiated(ProviderContext session);
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.binding.api;
-
-import org.opendaylight.controller.md.sal.binding.api.BindingService;
-
-/**
- * Session-specific instance of the broker functionality.
- *
- * <p>
- * BindingAwareService is marker interface for infrastructure services provided
- * by the SAL. These services are session-specific, each
- * {@link BindingAwareConsumer} and {@link BindingAwareProvider} usually has own
- * instance of the service with it's own context.
- *
- * <p>
- * The consumer's (or provider's) instance of specific service could be obtained by invoking
- * {@link org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext#getSALService(Class)}
- * method on session assigned to the consumer.
- *
- * <p>
- * {@link org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext}
- * and {@link BindingAwareProvider} may seem similar, but provider provides YANG model-based functionality and
- * {@link BindingAwareProvider} exposes the necessary supporting functionality
- * to implement specific functionality of YANG and to reuse it in the
- * development of {@link BindingAwareConsumer}s and {@link BindingAwareProvider}s.
- *
- * @deprecated Use {@link BindingService} instead.
- */
-@Deprecated(forRemoval = true)
-public interface BindingAwareService {
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.binding.api;
-
-import java.util.EventListener;
-import org.opendaylight.yangtools.yang.binding.Notification;
-
-/**
- * Interface for a generic listener that is interested in receiving YANG modeled notifications.
- * This interface acts as a base interface for specific listeners which usually are a type
- * capture of this interface.
- *
- * @param <T> the interested notification type
- * @deprecated Deprecated unused API.
- */
-@Deprecated(forRemoval = true)
-public interface NotificationListener<T extends Notification> extends EventListener {
- /**
- * Invoked to deliver a notification.
- *
- * <p>
- * Note that this method may be invoked from a shared thread pool, so implementations SHOULD NOT
- * perform CPU-intensive operations and MUST NOT invoke any potentially blocking operations.
- *
- * @param notification the notification.
- */
- void onNotification(T notification);
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.binding.api;
-
-import java.util.EventListener;
-import java.util.concurrent.ExecutorService;
-import org.opendaylight.controller.md.sal.common.api.notify.NotificationPublishService;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.Notification;
-
-/**
- * Interface for a notification service that provides publish/subscribe capabilities for YANG
- * modeled notifications. This interface is a combination of the {@link NotificationService} and
- * {@link NotificationPublishService} interfaces.
- *
- * @deprecated Please use {@link org.opendaylight.mdsal.binding.api.NotificationPublishService}.
- */
-@Deprecated(forRemoval = true)
-public interface NotificationProviderService extends NotificationService, NotificationPublishService<Notification> {
-
- @Override
- void publish(Notification notification);
-
- @Override
- void publish(Notification notification, ExecutorService executor);
-
- /**
- * Registers a listener to be notified about notification subscriptions. This
- * enables a component to know when there is a notification listener subscribed
- * for a particular notification type.
- *
- * <p>
- * On registration of this listener, the
- * {@link NotificationInterestListener#onNotificationSubscribtion(Class)} method
- * will be invoked for every notification type that currently has a notification listener
- * subscribed.
- *
- * @param interestListener the listener that will be notified when subscriptions
- * for new notification types occur.
- * @return a {@link ListenerRegistration} instance that should be used to unregister the listener
- * by invoking the {@link ListenerRegistration#close()} method when no longer needed.
- */
- ListenerRegistration<NotificationInterestListener> registerInterestListener(
- NotificationInterestListener interestListener);
-
- /**
- * Interface for a listener interested in being notified about notification subscriptions.
- */
- interface NotificationInterestListener extends EventListener {
-
- /**
- * Callback that is invoked when a notification listener subscribes for a particular notification type.
- *
- * <p>
- * This method is only called for the first subscription that occurs for a
- * particular notification type. Subsequent subscriptions for the same
- * notification type do not trigger invocation of this method.
- *
- * <p>
- * <b>Note:</b>This callback is delivered from thread not owned by this listener,
- * all processing should be as fast as possible and implementations should
- * not do any blocking calls or block this thread.
- *
- * @param notificationType the notification type for the subscription that occurred.
- */
- void onNotificationSubscribtion(Class<? extends Notification> notificationType);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.binding.api;
-
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.Notification;
-
-/**
- * Notification broker which allows clients to subscribe for and publish YANG-modeled notifications.
- *
- *<p>
- * Two styles of listeners are supported:
- * <ul>
- * <li>Generic listener</li>
- * <li>Dispatch listener - listener, which implements <code>{ModelName}Listener</code> interface,
- * which has dispatch methods for each defined notification. Methods are invoked based on notification type (class).
- * </li>
- * </ul>
- *
- * <h3>Generic Listener</h3>
- *
- * <p>
- * A generic listener implements the {@link NotificationListener} interface which has one callback method
- * <code>onNotification</code> that is invoked for any notification type the listener is subscribed to.
- *
- * <p>
- * A generic listener is subscribed using the {@link #registerNotificationListener(Class, NotificationListener)}
- * method by which you specify the type of notification to receive. A generic listener may be registered for
- * multiple notification types via multiple subscriptions.
- *
- * <p>
- * Generic listeners allow for a more flexible approach, allowing you to subscribe for just
- * one type of notification from a YANG model. You could also have a general subscription
- * for all notification in the system via
- * <pre>
- * service.registerNotificationListener(Notification.class, listener);
- * </pre>
- *
- * <h3>Dispatch Listener</h3>
- *
- * <p>
- * A dispatch listener implements a YANG-generated module interface <code>{ModuleName}Listener</code>
- * which handles all the notifications defined in the YANG model. Each notification type translates to
- * a specific method of the form <code>on{NotificationType}</code> on the generated interface.
- * The generated interface also extends the
- * {@link org.opendaylight.yangtools.yang.binding.NotificationListener} interface and implementations
- * are registered using
- * {@link #registerNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener)} method.
- *
- * <h4>Dispatch Listener Example</h4>
- *
- * <p>
- * Lets assume we have following YANG model:
- *
- * {@code
- * module example {
- * ...
- *
- * notification start {
- * ...
- * }
- *
- * notification stop {
- * ...
- * }
- * }
- * }
- *
- * <p>
- * The generated interface will be:
- * {@code
- * public interface ExampleListener extends NotificationListener {
- * void onStart(Start notification);
- * void onStop(Stop notification);
- * }
- * }
- * The following defines an implementation of the generated interface:
- * {@code
- * public class MyExampleListener implements ExampleListener {
- * public void onStart(Start notification) {
- * // do something
- * }
- *
- * public void onStop(Stop notification) {
- * // do something
- * }
- * }
- * }
- * The implementation is registered as follows:
- * {@code
- * MyExampleListener listener = new MyExampleListener();
- * ListenerRegistration<NotificationListener> reg = service.registerNotificationListener( listener );
- * }
- * The <code>onStart</code> method will be invoked when someone publishes a <code>Start</code> notification and
- * the <code>onStop</code> method will be invoked when someone publishes a <code>Stop</code> notification.
- *
- * @deprecated Please use {@link org.opendaylight.mdsal.binding.api.NotificationService} instead.
- */
-@Deprecated(forRemoval = true)
-public interface NotificationService extends BindingAwareService {
- /**
- * Registers a generic listener implementation for a specified notification type.
- *
- * @param notificationType the YANG-generated interface of the notification type.
- * @param listener the listener implementation that will receive notifications.
- * @return a {@link ListenerRegistration} instance that should be used to unregister the listener
- * by invoking the {@link ListenerRegistration#close()} method when no longer needed.
- */
- <T extends Notification> ListenerRegistration<NotificationListener<T>> registerNotificationListener(
- Class<T> notificationType, NotificationListener<T> listener);
-
- /**
- * Registers a listener which implements a YANG-generated notification interface derived from
- * {@link org.opendaylight.yangtools.yang.binding.NotificationListener}.
- * The listener is registered for all notifications present in the implemented interface.
- *
- * @param listener the listener implementation that will receive notifications.
- * @return a {@link ListenerRegistration} instance that should be used to unregister the listener
- * by invoking the {@link ListenerRegistration#close()} method when no longer needed.
- */
- ListenerRegistration<org.opendaylight.yangtools.yang.binding.NotificationListener> registerNotificationListener(
- org.opendaylight.yangtools.yang.binding.NotificationListener listener);
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.binding.api;
-
-@Deprecated(forRemoval = true)
-public interface RpcAvailabilityListener {
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.binding.api;
-
-import org.opendaylight.controller.md.sal.binding.api.BindingService;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-
-/**
- * Provides access to registered Remote Procedure Call (RPC) service implementations. The RPCs are
- * defined in YANG models.
- *
- * <p>
- * RPC implementations are registered using the {@link RpcProviderRegistry}.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.binding.api.RpcConsumerRegistry} instead
- */
-@Deprecated(forRemoval = true)
-public interface RpcConsumerRegistry extends BindingAwareService, BindingService {
- /**
- * Returns an implementation of a requested RPC service.
- *
- * <p>
- * The returned instance is not an actual implementation of the RPC service interface, but a proxy implementation
- * of the interface that forwards to an actual implementation, if any.
- *
- * <p>
- * The following describes the behavior of the proxy when invoking RPC methods:
- * <ul>
- * <li>If an actual implementation is registered with the MD-SAL, all invocations are
- * forwarded to the registered implementation.</li>
- * <li>If no actual implementation is registered, all invocations will fail by
- * throwing {@link IllegalStateException}.</li>
- * <li>Prior to invoking the actual implementation, the method arguments are are validated.
- * If any are invalid, an {@link IllegalArgumentException} is thrown.
- * </ul>
- *
- * <p>
- * The returned proxy is automatically updated with the most recent registered implementation.
- * {@code
- * final Future<RpcResult<SomeRpcOutput>> future = someRpcService.someRpc( ... );
- * Futures.addCallback(future,
- * new FutureCallback<RpcResult<SomeRpcOutput>>() {
- * public void onSuccess(RpcResult<SomeRpcOutput> result) {
- * // process result ...
- * }
- *
- * public void onFailure(Throwable t) {
- * // RPC failed
- * }
- * });
- * }
- *
- * @param serviceInterface the interface of the RPC Service. Typically this is an interface generated
- * from a YANG model.
- * @return the proxy for the requested RPC service. This method never returns null.
- */
- <T extends RpcService> T getRpcService(Class<T> serviceInterface);
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.binding.api;
-
-import org.opendaylight.controller.md.sal.common.api.routing.RouteChangePublisher;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
-import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-
-/**
- * Provides a registry for Remote Procedure Call (RPC) service implementations. The RPCs are
- * defined in YANG models.
- *
- * <p>
- * There are 2 types of RPCs:
- * <ul>
- * <li>Global</li>
- * <li>Routed</li>
- * </ul>
- *
- * <h2>Global RPC</h2>
- *
- * <p>
- * An RPC is global if there is intended to be only 1 registered implementation. A global RPC is not
- * explicitly declared as such, essentially any RPC that is not defined to be routed is considered global.
- *
- * <p>
- * Global RPCs are registered using the
- * {@link #addRpcImplementation(Class, RpcService)} method.
- *
- * <h2>Routed RPC</h2>
- *
- * <p>
- * MD-SAL supports routing of RPC between multiple implementations where the appropriate
- * implementation is selected at run time based on the content of the RPC message as described in
- * YANG model.
- *
- * <p>
- * RPC routing is based on:
- * <ul>
- * <li><b>Route identifier</b> -
- * An {@link org.opendaylight.yangtools.yang.binding.InstanceIdentifier InstanceIdentifier} value
- * which is part of the RPC input. This value is used to select the correct
- * implementation at run time.</li>
- * <li><b>Context Type</b> - A YANG-defined construct which constrains the subset of
- * valid route identifiers for a particular RPC.</li>
- * </ul>
- *
- * <h3>Context type</h3>
- *
- * <p>
- * A context type is modeled in YANG using a combination of a YANG <code>identity</code>
- * and Opendaylight specific extensions from <code>yang-ext</code> module. These extensions are:
- * <ul>
- * <li><b>context-instance</b> - This is used in the data tree part of a YANG model to
- * define a context type that associates nodes with a specified context <code>identity</code>.
- * Instance identifiers that reference these nodes are valid route identifiers for RPCs that
- * reference this context type.</li>
- * <li><b>context-reference</b> - This is used in RPC input to mark a leaf of type
- * <code>instance-identifier</code> as a reference to the particular context type defined by the
- * specified context <code>identity</code>. The value of this
- * leaf is used by the RPC broker at run time to route the RPC request to the correct implementation.
- * Note that <code>context-reference</code> may only be used on leaf elements of type
- * <code>instance-identifier</code> or a type derived from <code>instance-identifier</code>.</li>
- * </ul>
- *
- * <p><br>
- * <h4>1. Defining a Context Type</h4>
- *
- * <p>
- * The following snippet declares a simple YANG <code>identity</code> named <code>example-context</code>:
- *
- * {@code
- * module example {
- * ...
- * identity example-context {
- * description "Identity used to define an example-context type";
- * }
- * ...
- * }
- * }
- *
- * <p>
- * We then use the declared identity to define a context type by using it in combination
- * with the <code>context-instance</code> YANG extension. We'll associate the context type
- * with a list element in the data tree. This defines the set of nodes whose instance
- * identifiers are valid for the <code>example-context</code> context type.
- *
- * <p>
- * The following YANG snippet imports the <code>yang-ext</code> module and defines the list
- * element named <code>item</code> inside a container named <code>foo</code>:
- *
- * {@code
- * module foo {
- * ...
- * import yang-ext {prefix ext;}
- * ...
- * container foo {
- * list item {
- * key "id";
- * leaf id {type string;}
- * ext:context-instance "example-context";
- * }
- * }
- * ...
- * }
- * }
- *
- * <p>
- * The statement <code>ext:context-instance "example-context";</code> inside the list element
- * declares that any instance identifier referencing <code>item</code> in the data
- * tree is valid for <code>example-context</code>. For example, the following instance
- * identifier:
- * <pre>
- * InstanceIdentifier.create(Foo.class).child(Item.class,new ItemKey("Foo"))
- * </pre>
- * is valid for <code>example-context</code>. However the following:
- * <pre>
- * InstanceIdentifier.create(Example.class)
- * </pre>
- * is not valid.
- *
- * <p>
- * So using an <code>identity</code> in combination with <code>context-instance</code> we
- * have effectively defined a context type that can be referenced in a YANG RPC input.
- *
- * <p>
- * <h5>2. Defining an RPC to use the Context Type</h5>
- *
- * <p>
- * To define an RPC to be routed based on the context type we need to add an input leaf element
- * that references the context type which will hold an instance identifier value to be
- * used to route the RPC.
- *
- * <p>
- * The following snippet defines an RPC named <code>show-item</code> with 2 leaf elements
- * as input: <code>item</code> of type <code>instance-identifier</code> and <code>description</code>:
- *
- * <pre>
- * module foo {
- * ...
- * import yang-ext {prefix ext;}
- * ...
- * rpc show-item {
- * input {
- * leaf item {
- * type instance-identifier;
- * ext:context-reference example-context;
- * }
- * leaf description {
- * type "string";
- * }
- * }
- * }
- * }
- * </pre>
- *
- * <p>
- * We mark the <code>item</code> leaf with a <code>context-reference</code> statement that
- * references the <code>example-context</code> context type. RPC calls will then be routed
- * based on the instance identifier value contained in <code>item</code>. Only instance
- * identifiers that point to a <code>foo/item</code> node are valid as input.
- *
- * <p>
- * The generated RPC Service interface for the module is:
- *
- * <pre>
- * interface FooService implements RpcService {
- * Future<RpcResult<Void>> showItem(ShowItemInput input);
- * }
- * </pre>
- *
- * <p>
- * For constructing the RPC input, there are generated classes ShowItemInput and ShowItemInputBuilder.
- *
- * <h5>3. Registering a routed RPC implementation</h5>
- *
- * <p>
- * To register a routed implementation for the <code>show-item</code> RPC, we must use the
- * {@link #addRoutedRpcImplementation(Class, RpcService)} method. This
- * will return a {@link RoutedRpcRegistration} instance which can then be used to register /
- * unregister routed paths associated with the registered implementation.
- *
- * <p>
- * The following snippet registers <code>myImpl</code> as the RPC implementation for an
- * <code>item</code> with key <code>"foo"</code>:
- * <pre>
- * // Create the instance identifier path for item "foo"
- * InstanceIdentifier path = InstanceIdentifier.create(Foo.class).child(Item.class, new ItemKey("foo"));
- *
- * // Register myImpl as the implementation for the FooService RPC interface
- * RoutedRpcRegistration reg = rpcRegistry.addRoutedRpcImplementation(FooService.class, myImpl);
- *
- * // Now register for the context type and specific path ID. The context type is specified by the
- * // YANG-generated class for the example-context identity.
- * reg.registerPath(ExampleContext.class, path);
- * </pre>
- *
- * <p>
- * It is also possible to register the same implementation for multiple paths:
- *
- * <pre>
- * InstanceIdentifier one = InstanceIdentifier.create(Foo.class).child(Item.class, new ItemKey("One"));
- * InstanceIdentifier two = InstanceIdentifier.create(Foo.class).child(Item.class, new ItemKey("Two"));
- *
- * RoutedRpcRegistration reg = rpcRegistry.addRoutedRpcImplementation(FooService.class, myImpl);
- * reg.registerPath(ExampleContext.class, one);
- * reg.registerPath(ExampleContext.class, two);
- * </pre>
- *
- * <p>
- * When another client invokes the <code>showItem(ShowItemInput)</code> method on the proxy instance
- * retrieved via {@link RpcConsumerRegistry#getRpcService(Class)}, the proxy will inspect the
- * arguments in ShowItemInput, extract the InstanceIdentifier value of the <code>item</code> leaf and select
- * the implementation whose registered path matches the InstanceIdentifier value of the <code>item</code> leaf.
- *
- * <p><br>
- * <h2>Notes for RPC Implementations</h2>
- *
- * <p>
- * <h3>RpcResult</h3>
- *
- * <p>
- * The generated interfaces require implementors to return
- * {@link java.util.concurrent.Future Future}<{@link org.opendaylight.yangtools.yang.common.RpcResult RpcResult}
- * <{RpcName}Output>> instances.
- *
- * <p>
- * Implementations should do processing of RPC calls asynchronously and update the
- * returned {@link java.util.concurrent.Future Future} instance when processing is complete.
- * However using {@link com.google.common.util.concurrent.Futures#immediateFuture(Object) Futures.immediateFuture}
- * is valid only if the result is immediately available and asynchronous processing is unnecessary and
- * would only introduce additional complexity.
- *
- * <p>
- * The {@link org.opendaylight.yangtools.yang.common.RpcResult RpcResult} is a generic
- * wrapper for the RPC output payload, if any, and also allows for attaching error or
- * warning information (possibly along with the payload) should the RPC processing partially
- * or completely fail. This is intended to provide additional human readable information
- * for users of the API and to transfer warning / error information across the system
- * so it may be visible via other external APIs such as Restconf.
- *
- * <p>
- * It is recommended to use the {@link org.opendaylight.yangtools.yang.common.RpcResult RpcResult}
- * for conveying appropriate error information
- * on failure rather than purposely throwing unchecked exceptions if at all possible.
- * While unchecked exceptions will fail the returned {@link java.util.concurrent.Future Future},
- * using the intended RpcResult to convey the error information is more user-friendly.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.binding.api.RpcProviderService} instead
- */
-@Deprecated(forRemoval = true)
-public interface RpcProviderRegistry extends RpcConsumerRegistry,
- RouteChangePublisher<RpcContextIdentifier, InstanceIdentifier<?>> {
- /**
- * Registers a global implementation of the provided RPC service interface.
- * All methods of the interface are required to be implemented.
- *
- * @param serviceInterface the YANG-generated interface of the RPC Service for which to register.
- * @param implementation "the implementation of the RPC service interface.
- * @return an RpcRegistration instance that should be used to unregister the RPC implementation
- * when no longer needed by calling {@link RpcRegistration#close()}.
- *
- * @throws IllegalStateException
- * if the supplied RPC interface is a routed RPC type.
- */
- <T extends RpcService> RpcRegistration<T> addRpcImplementation(Class<T> serviceInterface, T implementation)
- throws IllegalStateException;
-
- /**
- * Registers an implementation of the given routed RPC service interface.
- *
- * <p>
- * See the {@link RpcProviderRegistry class} documentation for information and example on how to use routed RPCs.
- *
- * @param serviceInterface the YANG-generated interface of the RPC Service for which to register.
- * @param implementation the implementation instance to register.
- * @return a RoutedRpcRegistration instance which can be used to register paths for the RPC
- * implementation via invoking RoutedRpcRegistration#registerPath(Class, InstanceIdentifer).
- * {@link RoutedRpcRegistration#close()} should be called to unregister the implementation
- * and all previously registered paths when no longer needed.
- * @throws IllegalStateException if the supplied RPC interface is not a routed RPC type.
- */
- <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(Class<T> serviceInterface,
- T implementation) throws IllegalStateException;
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.binding.api;
-
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.binding.api.rpc;
-
-import org.opendaylight.yangtools.concepts.Immutable;
-import org.opendaylight.yangtools.yang.binding.BaseIdentity;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-
-@Deprecated(forRemoval = true)
-public final class RpcContextIdentifier implements Immutable {
-
- public final Class<? extends RpcService> rpcService;
- public final Class<? extends BaseIdentity> routingContext;
-
- private RpcContextIdentifier(Class<? extends RpcService> rpcService, Class<? extends BaseIdentity> routingContext) {
- this.rpcService = rpcService;
- this.routingContext = routingContext;
- }
-
- public Class<? extends RpcService> getRpcService() {
- return rpcService;
- }
-
- public Class<? extends BaseIdentity> getRoutingContext() {
- return routingContext;
- }
-
- public static RpcContextIdentifier contextForGlobalRpc(Class<? extends RpcService> serviceType) {
- return new RpcContextIdentifier(serviceType, null);
- }
-
- public static RpcContextIdentifier contextFor(Class<? extends RpcService> serviceType,
- Class<? extends BaseIdentity> routingContext) {
- return new RpcContextIdentifier(serviceType, routingContext);
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + (routingContext == null ? 0 : routingContext.hashCode());
- result = prime * result + (rpcService == null ? 0 : rpcService.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- RpcContextIdentifier other = (RpcContextIdentifier) obj;
- if (routingContext == null) {
- if (other.routingContext != null) {
- return false;
- }
- } else if (!routingContext.equals(other.routingContext)) {
- return false;
- }
- if (rpcService == null) {
- if (other.rpcService != null) {
- return false;
- }
- } else if (!rpcService.equals(other.rpcService)) {
- return false;
- }
- return true;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.binding.api.rpc;
-
-import org.opendaylight.yangtools.yang.binding.BaseIdentity;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-
-@Deprecated(forRemoval = true)
-public interface RpcRoutingContext<C extends BaseIdentity,S extends RpcService> {
-
- Class<C> getContextType();
-
- Class<S> getServiceType();
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-parent</artifactId>
- <version>1.12.0-SNAPSHOT</version>
- <relativePath>../parent</relativePath>
- </parent>
-
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-broker-impl</artifactId>
- <version>1.12.0-SNAPSHOT</version>
- <packaging>bundle</packaging>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-util</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-broker-impl</artifactId>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-common-impl</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-common-util</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-core-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-binding-generator-impl</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-binding-dom-codec</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-binding-dom-adapter</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-data-impl</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-model-util</artifactId>
- </dependency>
-
- <dependency>
- <!-- Required because BindingToNormalizedNodeCodec extends an annotated class and annotation
- processors have a hard time with that. -->
- <groupId>javax.inject</groupId>
- <artifactId>javax.inject</artifactId>
- <scope>provided</scope>
- <optional>true</optional>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-inmemory-datastore</artifactId>
- <!-- FIXME: this should be scope=test
- <scope>test</scope-->
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.google.truth</groupId>
- <artifactId>truth</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-test-model</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
-
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
- <Export-Package>
- org.opendaylight.controller.sal.binding.impl,
- org.opendaylight.controller.md.sal.binding.impl,
- org.opendaylight.controller.md.sal.binding.compat,
- org.opendaylight.controller.md.sal.binding.spi,
- org.opendaylight.controller.sal.binding.codegen.impl,
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>test-jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-sources</id>
- <phase>verify</phase>
- <goals>
- <goal>test-jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <scm>
- <connection>scm:git:http://git.opendaylight.org/gerrit/controller.git</connection>
- <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
- <tag>HEAD</tag>
- <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
- </scm>
-
-</project>
+++ /dev/null
-/xtend-gen
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.compat;
-
-import static java.util.Objects.requireNonNull;
-
-import org.opendaylight.controller.sal.binding.api.NotificationListener;
-import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.Notification;
-
-/**
- * Abstract implementation of {@link NotificationListenerRegistration}.
- *
- * @param <T> Notification type
- */
-@Deprecated(forRemoval = true)
-abstract class AbstractNotificationListenerRegistration<T extends Notification>
- extends AbstractListenerRegistration<NotificationListener<T>> implements NotificationListenerRegistration<T> {
- private final Class<? extends Notification> type;
-
- protected AbstractNotificationListenerRegistration(final Class<? extends Notification> type,
- final NotificationListener<T> listener) {
- super(listener);
- this.type = requireNonNull(type);
- }
-
- @Override
- public Class<? extends Notification> getType() {
- return type;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public void notify(final Notification notification) {
- if (!isClosed()) {
- getInstance().onNotification((T)notification);
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.compat;
-
-import static java.util.Objects.requireNonNull;
-
-import org.opendaylight.controller.sal.binding.api.NotificationListener;
-import org.opendaylight.yangtools.yang.binding.Notification;
-
-/**
- * An aggregated listener registration. This is a result of registering an invoker which can handle multiple
- * interfaces at the same time. In order to support correct delivery, we need to maintain per-type registrations
- * which get squashed if a notification which implements multiple interfaces is encountered.
- *
- * <p>
- * We take care of that by implementing alternate {@link #hashCode()}/{@link #equals(Object)}, which resolve
- * to the backing aggregator.
- *
- * @param <N> Notification type
- * @param <A> Aggregator type
- */
-@Deprecated(forRemoval = true)
-abstract class AggregatedNotificationListenerRegistration<N extends Notification, A>
- extends AbstractNotificationListenerRegistration<N> {
- private final A aggregator;
-
- protected AggregatedNotificationListenerRegistration(final Class<? extends Notification> type,
- final NotificationListener<N> listener, final A aggregator) {
- super(type, listener);
- this.aggregator = requireNonNull(aggregator);
- }
-
- protected A getAggregator() {
- return aggregator;
- }
-
- @Override
- public int hashCode() {
- return aggregator.hashCode();
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!this.getClass().equals(obj.getClass())) {
- return false;
- }
-
- return aggregator.equals(((AggregatedNotificationListenerRegistration<?, ?>)obj).aggregator);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.compat;
-
-import com.google.common.collect.ImmutableSet;
-import java.util.HashMap;
-import java.util.Map;
-import org.opendaylight.controller.md.sal.binding.impl.BindingDOMRpcProviderServiceAdapter;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
-import org.opendaylight.yangtools.concepts.ObjectRegistration;
-import org.opendaylight.yangtools.yang.binding.BaseIdentity;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-
-@Deprecated(forRemoval = true)
-final class CompositeRoutedRpcRegistration<T extends RpcService> implements RoutedRpcRegistration<T> {
-
- private final Class<T> type;
- private final T instance;
- private final BindingDOMRpcProviderServiceAdapter adapter;
- private final Map<InstanceIdentifier<?>, ObjectRegistration<T>> registrations = new HashMap<>(2);
-
- CompositeRoutedRpcRegistration(final Class<T> type, final T impl,
- final BindingDOMRpcProviderServiceAdapter providerAdapter) {
- this.type = type;
- this.instance = impl;
- this.adapter = providerAdapter;
- }
-
- @Override
- public Class<T> getServiceType() {
- return type;
- }
-
- @Override
- public T getInstance() {
- return instance;
- }
-
- @Deprecated
- @Override
- public void registerInstance(final Class<? extends BaseIdentity> context, final InstanceIdentifier<?> path) {
- registerPath(context, path);
- }
-
- @Override
- public synchronized void registerPath(final Class<? extends BaseIdentity> context,
- final InstanceIdentifier<?> path) {
- if (!registrations.containsKey(path)) {
- registrations.put(path,
- adapter.registerRpcImplementation(type, instance, ImmutableSet.<InstanceIdentifier<?>>of(path)));
- }
- }
-
-
- @Override
- @Deprecated
- public void unregisterInstance(final Class<? extends BaseIdentity> context, final InstanceIdentifier<?> path) {
- unregisterPath(context, path);
- }
-
- @Override
- public synchronized void unregisterPath(final Class<? extends BaseIdentity> context,
- final InstanceIdentifier<?> path) {
- final ObjectRegistration<T> reg = registrations.remove(path);
- if (reg != null) {
- reg.close();
- }
- }
-
- @Override
- public synchronized void close() {
- for (final ObjectRegistration<T> reg : registrations.values()) {
- reg.close();
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.compat;
-
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
-import org.opendaylight.yangtools.concepts.ObjectRegistration;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-
-@Deprecated(forRemoval = true)
-final class DelegatedRootRpcRegistration<T extends RpcService> implements RpcRegistration<T> {
-
- private final ObjectRegistration<T> delegate;
- private final Class<T> type;
-
- DelegatedRootRpcRegistration(final Class<T> type, final ObjectRegistration<T> impl) {
- this.delegate = impl;
- this.type = type;
- }
-
-
- @Override
- public void close() {
- delegate.close();
- }
-
- @Override
- public T getInstance() {
- return delegate.getInstance();
- }
-
- @Override
- public Class<T> getServiceType() {
- return type;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.compat;
-
-import org.opendaylight.controller.md.sal.binding.impl.LazySerializedDOMNotification;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener;
-import org.opendaylight.controller.sal.binding.api.NotificationListener;
-import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
-import org.opendaylight.yangtools.yang.binding.Notification;
-
-@Deprecated(forRemoval = true)
-final class FunctionalNotificationListenerAdapter<N extends Notification> implements DOMNotificationListener {
-
- private final BindingNormalizedNodeSerializer codec;
- private final NotificationListener<N> delegate;
- private final Class<N> type;
-
- FunctionalNotificationListenerAdapter(final BindingNormalizedNodeSerializer codec, final Class<N> type,
- final NotificationListener<N> delegate) {
- this.codec = codec;
- this.type = type;
- this.delegate = delegate;
- }
-
- @Override
- public void onNotification(final DOMNotification notification) {
- delegate.onNotification(type.cast(deserialize(notification)));
- }
-
- private Notification deserialize(final DOMNotification notification) {
- if (notification instanceof LazySerializedDOMNotification) {
- return ((LazySerializedDOMNotification) notification).getBindingData();
- }
- return codec.fromNormalizedNodeNotification(notification.getType(), notification.getBody());
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.compat;
-
-import java.util.concurrent.ExecutorService;
-import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
-import org.opendaylight.controller.md.sal.binding.api.NotificationService;
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.Notification;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Deprecated(forRemoval = true)
-public class HeliumNotificationProviderServiceAdapter extends HeliumNotificationServiceAdapter
- implements NotificationProviderService {
- private static final Logger LOG = LoggerFactory.getLogger(HeliumNotificationProviderServiceAdapter.class);
-
- private final NotificationPublishService notificationPublishService;
-
- public HeliumNotificationProviderServiceAdapter(final NotificationPublishService notificationPublishService,
- final NotificationService notificationService) {
- super(notificationService);
- this.notificationPublishService = notificationPublishService;
- }
-
- @Override
- public void publish(final Notification notification) {
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.error("Notification publication was interupted", e);
- }
- }
-
- @Override
- public void publish(final Notification notification, final ExecutorService executor) {
- try {
- notificationPublishService.putNotification(notification);
- } catch (InterruptedException e) {
- LOG.error("Notification publication was interupted", e);
- }
- }
-
- @Override
- public ListenerRegistration<NotificationInterestListener> registerInterestListener(
- final NotificationInterestListener interestListener) {
- throw new UnsupportedOperationException("InterestListener is not supported.");
- }
-
- @Override
- public void close() {
-
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.compat;
-
-import com.google.common.collect.Sets;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.Set;
-import org.opendaylight.controller.md.sal.binding.impl.BindingDOMNotificationPublishServiceAdapter;
-import org.opendaylight.controller.md.sal.binding.impl.BindingDOMNotificationServiceAdapter;
-import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService;
-import org.opendaylight.controller.md.sal.dom.spi.DOMNotificationSubscriptionListener;
-import org.opendaylight.controller.md.sal.dom.spi.DOMNotificationSubscriptionListenerRegistry;
-import org.opendaylight.controller.sal.binding.api.NotificationListener;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
-import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.util.ListenerRegistry;
-import org.opendaylight.yangtools.yang.binding.Notification;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Deprecated(forRemoval = true)
-public class HeliumNotificationProviderServiceWithInterestListeners extends HeliumNotificationProviderServiceAdapter {
-
- private static final Logger LOG = LoggerFactory.getLogger(
- HeliumNotificationProviderServiceWithInterestListeners.class);
-
- private final ListenerRegistry<NotificationInterestListener> interestListeners = ListenerRegistry.create();
- private final ListenerRegistration<Listener> domListener;
- private final DOMNotificationService domService;
- private final BindingToNormalizedNodeCodec codec;
-
- public HeliumNotificationProviderServiceWithInterestListeners(
- final BindingDOMNotificationPublishServiceAdapter publishService,
- final BindingDOMNotificationServiceAdapter listenService,
- final DOMNotificationSubscriptionListenerRegistry registry) {
- super(publishService, listenService);
- this.codec = publishService.getCodecRegistry();
- this.domListener = registry.registerSubscriptionListener(new Listener());
- this.domService = listenService.getDomService();
- }
-
- @Override
- public ListenerRegistration<NotificationInterestListener> registerInterestListener(
- final NotificationInterestListener listener) {
- notifyListener(listener, translate(domListener.getInstance().getAllObserved()));
- return interestListeners.register(listener);
- }
-
- private Set<Class<? extends Notification>> translate(final Set<SchemaPath> added) {
- return codec.getNotificationClasses(added);
- }
-
- @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
- justification = "https://github.com/spotbugs/spotbugs/issues/811")
- @SuppressWarnings("checkstyle:IllegalCatch")
- private void notifyAllListeners(final Set<SchemaPath> added) {
- final Iterator<? extends ListenerRegistration<? extends NotificationInterestListener>> listeners =
- interestListeners.getRegistrations().iterator();
- if (listeners.hasNext()) {
- final Set<Class<? extends Notification>> baEvent = translate(added);
- while (listeners.hasNext()) {
- final NotificationInterestListener listenerRef = listeners.next().getInstance();
- try {
- notifyListener(listenerRef, baEvent);
- } catch (RuntimeException e) {
- LOG.warn("Unhandled exception during invoking listener {}", listenerRef, e);
- }
- }
- }
- }
-
- @Override
- public <T extends Notification> ListenerRegistration<NotificationListener<T>> registerNotificationListener(
- final Class<T> type, final NotificationListener<T> listener) {
-
- final FunctionalNotificationListenerAdapter<T> adapter =
- new FunctionalNotificationListenerAdapter<>(codec, type, listener);
- final SchemaPath domType = SchemaPath.create(true, BindingReflections.findQName(type));
- final ListenerRegistration<?> domReg = domService.registerNotificationListener(adapter, domType);
- return new AbstractListenerRegistration<NotificationListener<T>>(listener) {
- @Override
- protected void removeRegistration() {
- domReg.close();
- }
- };
- }
-
- private static void notifyListener(final NotificationInterestListener listener,
- final Set<Class<? extends Notification>> baEvent) {
- for (final Class<? extends Notification> event: baEvent) {
- listener.onNotificationSubscribtion(event);
- }
- }
-
- private final class Listener implements DOMNotificationSubscriptionListener {
-
- private volatile Set<SchemaPath> allObserved = Collections.emptySet();
-
- @Override
- public void onSubscriptionChanged(final Set<SchemaPath> currentTypes) {
- final Set<SchemaPath> added = Sets.difference(currentTypes, allObserved).immutableCopy();
- notifyAllListeners(added);
- allObserved = Sets.union(allObserved, added).immutableCopy();
- }
-
- Set<SchemaPath> getAllObserved() {
- return allObserved;
- }
- }
-
- @Override
- public void close() {
- super.close();
- domListener.close();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.compat;
-
-import org.opendaylight.controller.md.sal.binding.api.NotificationService;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.Notification;
-import org.opendaylight.yangtools.yang.binding.NotificationListener;
-
-@Deprecated(forRemoval = true)
-public class HeliumNotificationServiceAdapter
- implements org.opendaylight.controller.sal.binding.api.NotificationService, AutoCloseable {
-
- private final NotificationService notificationService;
-
- public HeliumNotificationServiceAdapter(NotificationService notificationService) {
- this.notificationService = notificationService;
- }
-
- @Override
- public <T extends Notification> ListenerRegistration<
- org.opendaylight.controller.sal.binding.api.NotificationListener<T>> registerNotificationListener(
- final Class<T> notificationType,
- final org.opendaylight.controller.sal.binding.api.NotificationListener<T> listener) {
- throw new UnsupportedOperationException("Not supported type of listener.");
- }
-
- @Override
- public ListenerRegistration<NotificationListener> registerNotificationListener(
- final NotificationListener listener) {
- return notificationService.registerNotificationListener(listener);
- }
-
- @Override
- public void close() throws Exception {
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.compat;
-
-import org.opendaylight.controller.md.sal.binding.impl.BindingDOMRpcProviderServiceAdapter;
-import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
-import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.concepts.ObjectRegistration;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-
-@Deprecated(forRemoval = true)
-public class HeliumRpcProviderRegistry implements RpcProviderRegistry {
-
- private final RpcConsumerRegistry consumerRegistry;
- private final BindingDOMRpcProviderServiceAdapter providerAdapter;
-
- public HeliumRpcProviderRegistry(final RpcConsumerRegistry consumerRegistry,
- final BindingDOMRpcProviderServiceAdapter providerAdapter) {
- this.consumerRegistry = consumerRegistry;
- this.providerAdapter = providerAdapter;
- }
-
- @Override
- public <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(final Class<T> type, final T impl)
- throws IllegalStateException {
- return new CompositeRoutedRpcRegistration<>(type,impl,providerAdapter);
- }
-
- @Override
- public <T extends RpcService> RpcRegistration<T> addRpcImplementation(final Class<T> type, final T impl)
- throws IllegalStateException {
- final ObjectRegistration<T> reg = providerAdapter.registerRpcImplementation(type, impl);
- return new DelegatedRootRpcRegistration<>(type,reg);
- }
-
- @Override
- public <T extends RpcService> T getRpcService(final Class<T> type) {
- return consumerRegistry.getRpcService(type);
- }
-
- @Override
- public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L>
- registerRouteChangeListener(final L listener) {
- // FIXME: Implement this only if necessary
- return null;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.compat;
-
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
-import com.google.common.collect.ImmutableMultimap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Multimap;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.stream.Collectors;
-import org.opendaylight.yangtools.yang.binding.Notification;
-
-/**
- * An immutable view of the current generation of listeners.
- */
-@Deprecated(forRemoval = true)
-final class ListenerMapGeneration {
- private static final int CACHE_MAX_ENTRIES = 1000;
-
- /**
- * Constant map of notification type to subscribed listeners.
- */
- private final Multimap<Class<? extends Notification>, NotificationListenerRegistration<?>> typeToListeners;
-
- /**
- * Dynamic cache of notification implementation to matching listeners. This cache loads entries based on
- * the contents of the {@link #typeToListeners} map.
- */
- private final LoadingCache<Class<?>, Iterable<NotificationListenerRegistration<?>>> implementationToListeners =
- CacheBuilder.newBuilder()
- .weakKeys()
- .maximumSize(CACHE_MAX_ENTRIES)
- .build(new CacheLoader<Class<?>, Iterable<NotificationListenerRegistration<?>>>() {
- @Override
- public Iterable<NotificationListenerRegistration<?>> load(final Class<?> key) {
- final Set<NotificationListenerRegistration<?>> regs = new HashSet<>();
-
- for (final Class<?> type : getNotificationTypes(key)) {
- @SuppressWarnings("unchecked")
- final Collection<NotificationListenerRegistration<?>> l =
- typeToListeners.get((Class<? extends Notification>) type);
- if (l != null) {
- regs.addAll(l);
- }
- }
-
- return ImmutableSet.copyOf(regs);
- }
- });
-
- ListenerMapGeneration() {
- typeToListeners = ImmutableMultimap.of();
- }
-
- ListenerMapGeneration(final Multimap<Class<? extends Notification>,
- NotificationListenerRegistration<?>> listeners) {
- this.typeToListeners = ImmutableMultimap.copyOf(listeners);
- }
-
- /**
- * Current listeners. Exposed for creating the next generation.
- *
- * @return Current type-to-listener map.
- */
- Multimap<Class<? extends Notification>, NotificationListenerRegistration<?>> getListeners() {
- return typeToListeners;
- }
-
- /**
- * Look up the listeners which need to see this notification delivered.
- *
- * @param notification Notification object
- * @return Iterable of listeners, guaranteed to be nonnull.
- */
- public Iterable<NotificationListenerRegistration<?>> listenersFor(final Notification notification) {
- // Safe to use, as our loader does not throw checked exceptions
- return implementationToListeners.getUnchecked(notification.getClass());
- }
-
- public Iterable<Class<? extends Notification>> getKnownTypes() {
- return typeToListeners.keySet();
- }
-
- @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
- justification = "https://github.com/spotbugs/spotbugs/issues/811")
- private static Iterable<Class<?>> getNotificationTypes(final Class<?> cls) {
- return Arrays.stream(cls.getInterfaces())
- .filter(input -> !Notification.class.equals(input) && Notification.class.isAssignableFrom(input))
- .collect(Collectors.toList());
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.compat;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.reflect.TypeToken;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import org.opendaylight.mdsal.binding.dom.adapter.invoke.NotificationListenerInvoker;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
-import org.opendaylight.yangtools.yang.binding.Notification;
-import org.opendaylight.yangtools.yang.binding.NotificationListener;
-import org.opendaylight.yangtools.yang.common.QName;
-
-@Deprecated(forRemoval = true)
-final class NotificationInvoker
- implements org.opendaylight.controller.sal.binding.api.NotificationListener<Notification> {
-
- private final NotificationListener delegate;
- private final Map<Class<? extends Notification>,InvokerContext> invokers;
-
-
- private NotificationInvoker(final NotificationListener listener) {
- delegate = listener;
- final Map<Class<? extends Notification>, InvokerContext> builder = new HashMap<>();
- for (final TypeToken<?> ifaceToken : TypeToken.of(listener.getClass()).getTypes().interfaces()) {
- final Class<?> iface = ifaceToken.getRawType();
- if (NotificationListener.class.isAssignableFrom(iface) && BindingReflections.isBindingClass(iface)) {
- @SuppressWarnings("unchecked")
- final Class<? extends NotificationListener> listenerType =
- (Class<? extends NotificationListener>) iface;
- final NotificationListenerInvoker invoker = NotificationListenerInvoker.from(listenerType);
- for (final Class<? extends Notification> type : getNotificationTypes(listenerType)) {
- builder.put(type, new InvokerContext(BindingReflections.findQName(type), invoker));
- }
- }
- }
- invokers = ImmutableMap.copyOf(builder);
- }
-
- public static NotificationInvoker invokerFor(final NotificationListener listener) {
- return new NotificationInvoker(listener);
- }
-
- public Set<Class<? extends Notification>> getSupportedNotifications() {
- return invokers.keySet();
- }
-
- @Override
- public void onNotification(final Notification notification) {
- getContext(notification.implementedInterface()).invoke(notification);
- }
-
- private InvokerContext getContext(final Class<?> type) {
- return invokers.get(type);
- }
-
- @SuppressWarnings("unchecked")
- private static Set<Class<? extends Notification>> getNotificationTypes(
- final Class<? extends org.opendaylight.yangtools.yang.binding.NotificationListener> type) {
- // TODO: Investigate possibility and performance impact if we cache this or expose
- // it from NotificationListenerInvoker
- final Set<Class<? extends Notification>> ret = new HashSet<>();
- for (final Method method : type.getMethods()) {
- if (BindingReflections.isNotificationCallback(method)) {
- final Class<? extends Notification> notification =
- (Class<? extends Notification>) method.getParameterTypes()[0];
- ret.add(notification);
- }
- }
- return ret;
- }
-
- private final class InvokerContext {
-
- private final QName name;
- private final NotificationListenerInvoker invoker;
-
- private InvokerContext(final QName name, final NotificationListenerInvoker invoker) {
- this.name = name;
- this.invoker = invoker;
- }
-
- public void invoke(final Notification notification) {
- invoker.invokeNotification(delegate, name, notification);
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.compat;
-
-import org.opendaylight.controller.sal.binding.api.NotificationListener;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.Notification;
-
-/**
- * A registration of a {@link NotificationListener}. Allows query of the type
- * of the notification and dispatching the notification atomically with regard
- * to unregistration.
- *
- * @param <T> Type of notification
- */
-@Deprecated(forRemoval = true)
-interface NotificationListenerRegistration<T extends Notification>
- extends ListenerRegistration<NotificationListener<T>> {
- /**
- * Return the interface class of the notification type.
- *
- * @return Notification type.
- */
- Class<? extends Notification> getType();
-
- /**
- * Dispatch a notification to the listener.
- *
- * @param notification Notification to be dispatched
- */
- void notify(Notification notification);
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.impl;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Optional;
-import java.util.Set;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-import org.opendaylight.mdsal.dom.api.DOMSchemaService;
-import org.opendaylight.yangtools.concepts.Delegator;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.impl.codec.DeserializationException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Deprecated(forRemoval = true)
-public abstract class AbstractForwardedDataBroker implements Delegator<DOMDataBroker>, AutoCloseable {
-
- private static final Logger LOG = LoggerFactory.getLogger(AbstractForwardedDataBroker.class);
- // The Broker to whom we do all forwarding
- private final DOMDataBroker domDataBroker;
-
- private final BindingToNormalizedNodeCodec codec;
-
- protected AbstractForwardedDataBroker(final DOMDataBroker domDataBroker, final BindingToNormalizedNodeCodec codec,
- final DOMSchemaService schemaService) {
- this.domDataBroker = domDataBroker;
- this.codec = codec;
- }
-
- protected AbstractForwardedDataBroker(final DOMDataBroker domDataBroker, final BindingToNormalizedNodeCodec codec) {
- this.domDataBroker = domDataBroker;
- this.codec = codec;
- }
-
- protected BindingToNormalizedNodeCodec getCodec() {
- return codec;
- }
-
- @Override
- public DOMDataBroker getDelegate() {
- return domDataBroker;
- }
-
- protected Map<InstanceIdentifier<?>, DataObject> toBinding(final InstanceIdentifier<?> path,
- final Map<YangInstanceIdentifier, ? extends NormalizedNode<?, ?>> normalized) {
- final Map<InstanceIdentifier<?>, DataObject> newMap = new HashMap<>();
-
- for (final Map.Entry<YangInstanceIdentifier, ? extends NormalizedNode<?, ?>> entry : normalized.entrySet()) {
- try {
- final Optional<Entry<InstanceIdentifier<? extends DataObject>, DataObject>> potential =
- getCodec().toBinding(entry);
- if (potential.isPresent()) {
- final Entry<InstanceIdentifier<? extends DataObject>, DataObject> binding = potential.get();
- newMap.put(binding.getKey(), binding.getValue());
- }
- } catch (final DeserializationException e) {
- LOG.warn("Failed to transform {}, omitting it", entry, e);
- }
- }
- return newMap;
- }
-
- protected Set<InstanceIdentifier<?>> toBinding(final InstanceIdentifier<?> path,
- final Set<YangInstanceIdentifier> normalized) {
- final Set<InstanceIdentifier<?>> hashSet = new HashSet<>();
- for (final YangInstanceIdentifier normalizedPath : normalized) {
- try {
- final Optional<InstanceIdentifier<? extends DataObject>> potential =
- getCodec().toBinding(normalizedPath);
- if (potential.isPresent()) {
- final InstanceIdentifier<? extends DataObject> binding = potential.get();
- hashSet.add(binding);
- } else if (normalizedPath.getLastPathArgument()
- instanceof YangInstanceIdentifier.AugmentationIdentifier) {
- hashSet.add(path);
- }
- } catch (final DeserializationException e) {
- LOG.warn("Failed to transform {}, omitting it", normalizedPath, e);
- }
- }
- return hashSet;
- }
-
- protected Optional<DataObject> toBindingData(final InstanceIdentifier<?> path, final NormalizedNode<?, ?> data) {
- if (path.isWildcarded()) {
- return Optional.empty();
- }
- return (Optional<DataObject>) getCodec().deserializeFunction(path)
- .apply(Optional.<NormalizedNode<?, ?>>of(data));
- }
-
- @Override
- public void close() {
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.impl;
-
-import static java.util.Objects.requireNonNull;
-
-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 com.google.common.util.concurrent.MoreExecutors;
-import org.opendaylight.controller.md.sal.common.api.MappingCheckedFuture;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
-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.dom.api.DOMDataReadTransaction;
-import org.opendaylight.yangtools.concepts.Delegator;
-import org.opendaylight.yangtools.concepts.Identifiable;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-@Deprecated(forRemoval = true)
-abstract class AbstractForwardedTransaction<T extends AsyncTransaction<YangInstanceIdentifier, NormalizedNode<?, ?>>>
- implements Delegator<T>, Identifiable<Object> {
-
- private final T delegate;
- private final BindingToNormalizedNodeCodec codec;
-
- AbstractForwardedTransaction(final T delegateTx, final BindingToNormalizedNodeCodec codec) {
- this.delegate = requireNonNull(delegateTx, "Delegate must not be null");
- this.codec = requireNonNull(codec, "Codec must not be null");
- }
-
- @Override
- public final Object getIdentifier() {
- return delegate.getIdentifier();
- }
-
- @Override
- public final T getDelegate() {
- return delegate;
- }
-
- @SuppressWarnings("unchecked")
- protected final <S extends AsyncTransaction<YangInstanceIdentifier, NormalizedNode<?, ?>>>
- S getDelegateChecked(final Class<S> txType) {
- Preconditions.checkState(txType.isInstance(delegate));
- return (S) delegate;
- }
-
- protected final BindingToNormalizedNodeCodec getCodec() {
- return codec;
- }
-
- protected final <D extends DataObject> CheckedFuture<Optional<D>, ReadFailedException> doRead(
- final DOMDataReadTransaction readTx, final LogicalDatastoreType store,
- final InstanceIdentifier<D> path) {
- Preconditions.checkArgument(!path.isWildcarded(), "Invalid read of wildcarded path %s", path);
-
- return MappingCheckedFuture.create(
- Futures.transform(readTx.read(store, codec.toYangInstanceIdentifierBlocking(path)),
- result -> Optional.fromJavaUtil(codec.deserializeFunction(path).apply(result.toJavaUtil())),
- MoreExecutors.directExecutor()),
- ReadFailedException.MAPPER);
- }
-
- protected final CheckedFuture<Boolean, ReadFailedException> doExists(
- final DOMDataReadTransaction readTx, final LogicalDatastoreType store,
- final InstanceIdentifier<?> path) {
- Preconditions.checkArgument(!path.isWildcarded(), "Invalid read of wildcarded path %s", path);
-
- return MappingCheckedFuture.create(readTx.exists(store, codec.toYangInstanceIdentifierBlocking(path)),
- ReadFailedException.MAPPER);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.impl;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-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.impl.util.compat.DataNormalizationException;
-import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationOperation;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Deprecated(forRemoval = true)
-public class AbstractReadWriteTransaction extends AbstractWriteTransaction<DOMDataReadWriteTransaction> {
-
- private static final Logger LOG = LoggerFactory.getLogger(AbstractReadWriteTransaction.class);
-
- public AbstractReadWriteTransaction(final DOMDataReadWriteTransaction delegate,
- final BindingToNormalizedNodeCodec codec) {
- super(delegate, codec);
- }
-
- @Override
- protected final void ensureParentsByMerge(final LogicalDatastoreType store,
- final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier normalizedPath,
- final InstanceIdentifier<?> path) {
- List<PathArgument> currentArguments = new ArrayList<>();
- DataNormalizationOperation<?> currentOp = getCodec().getDataNormalizer().getRootOperation();
- Iterator<PathArgument> iterator = normalizedPath.getPathArguments().iterator();
- while (iterator.hasNext()) {
- PathArgument currentArg = iterator.next();
- try {
- currentOp = currentOp.getChild(currentArg);
- } catch (DataNormalizationException e) {
- throw new IllegalArgumentException(String.format("Invalid child encountered in path %s", path), e);
- }
- currentArguments.add(currentArg);
- org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier currentPath =
- org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.create(currentArguments);
-
- final Boolean exists;
- try {
- exists = getDelegate().exists(store, currentPath).checkedGet();
- } catch (ReadFailedException e) {
- LOG.error("Failed to read pre-existing data from store {} path {}", store, currentPath, e);
- throw new IllegalStateException("Failed to read pre-existing data", e);
- }
-
- if (!exists && iterator.hasNext()) {
- getDelegate().merge(store, currentPath, currentOp.createDefault(currentArg));
- }
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.impl;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.FluentFuture;
-import java.util.Map.Entry;
-import org.gaul.modernizer_maven_annotations.SuppressModernizer;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
-import org.opendaylight.mdsal.common.api.CommitInfo;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.Identifiable;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-/**
- * Abstract Base Transaction for transactions which are backed by {@link DOMDataWriteTransaction}.
- */
-@Deprecated(forRemoval = true)
-public abstract class AbstractWriteTransaction<T extends DOMDataWriteTransaction> extends
- AbstractForwardedTransaction<T> {
-
- protected AbstractWriteTransaction(final T delegate, final BindingToNormalizedNodeCodec codec) {
- super(delegate, codec);
- }
-
- public final <U extends DataObject> void put(final LogicalDatastoreType store,
- final InstanceIdentifier<U> path, final U data, final boolean createParents) {
- checkArgument(!path.isWildcarded(), "Cannot put data into wildcarded path %s", path);
-
- final Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> normalized = getCodec().toNormalizedNode(path, data);
- if (createParents) {
- ensureParentsByMerge(store, normalized.getKey(), path);
- } else {
- ensureListParentIfNeeded(store,path,normalized);
- }
-
- getDelegate().put(store, normalized.getKey(), normalized.getValue());
- }
-
- public final <U extends DataObject> void merge(final LogicalDatastoreType store,
- final InstanceIdentifier<U> path, final U data,final boolean createParents) {
- checkArgument(!path.isWildcarded(), "Cannot merge data into wildcarded path %s", path);
-
- final Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> normalized = getCodec().toNormalizedNode(path, data);
- if (createParents) {
- ensureParentsByMerge(store, normalized.getKey(), path);
- } else {
- ensureListParentIfNeeded(store,path,normalized);
- }
-
- getDelegate().merge(store, normalized.getKey(), normalized.getValue());
- }
-
- /**
- * Ensures list parent if item is list, otherwise noop.
- *
- * <p>
- * One of properties of binding specification is that it is imposible
- * to represent list as a whole and thus it is impossible to write
- * empty variation of MapNode without creating parent node, with
- * empty list.
- *
- * <p>
- * This actually makes writes such as
- * <pre>
- * put("Nodes", new NodesBuilder().build());
- * put("Nodes/Node[key]", new NodeBuilder().setKey("key").build());
- * </pre>
- * To result in three DOM operations:
- * <pre>
- * put("/nodes",domNodes);
- * merge("/nodes/node",domNodeList);
- * put("/nodes/node/node[key]",domNode);
- * </pre>
- *
- * <p>
- * In order to allow that to be inserted if necessary, if we know
- * item is list item, we will try to merge empty MapNode or OrderedNodeMap
- * to ensure list exists.
- *
- * @param store Data Store type
- * @param path Path to data (Binding Aware)
- * @param normalized Normalized version of data to be written
- */
- private void ensureListParentIfNeeded(final LogicalDatastoreType store, final InstanceIdentifier<?> path,
- final Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> normalized) {
- if (Identifiable.class.isAssignableFrom(path.getTargetType())) {
- YangInstanceIdentifier parentMapPath = normalized.getKey().getParent();
- checkArgument(parentMapPath != null, "Map path %s does not have a parent", path);
-
- NormalizedNode<?, ?> emptyParent = getCodec().getDefaultNodeFor(parentMapPath);
- getDelegate().merge(store, parentMapPath, emptyParent);
- }
- }
-
- /**
- * Deprecated.
- *
- * @deprecated Use {@link YangInstanceIdentifier#getParent()} instead.
- */
- @Deprecated
- @SuppressModernizer
- protected static Optional<YangInstanceIdentifier> getParent(final YangInstanceIdentifier child) {
- return Optional.fromNullable(child.getParent());
- }
-
- /**
- * Subclasses of this class are required to implement creation of parent
- * nodes based on behaviour of their underlying transaction.
- */
- protected abstract void ensureParentsByMerge(LogicalDatastoreType store,
- YangInstanceIdentifier key, InstanceIdentifier<?> path);
-
- protected final void doDelete(final LogicalDatastoreType store,
- final InstanceIdentifier<?> path) {
- checkArgument(!path.isWildcarded(), "Cannot delete wildcarded path %s", path);
-
- final YangInstanceIdentifier normalized = getCodec().toYangInstanceIdentifierBlocking(path);
- getDelegate().delete(store, normalized);
- }
-
- protected final FluentFuture<? extends CommitInfo> doCommit() {
- return getDelegate().commit();
- }
-
- protected final boolean doCancel() {
- return getDelegate().cancel();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2018 Red Hat, Inc. 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.md.sal.binding.impl;
-
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.MountPointService;
-import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
-import org.opendaylight.controller.md.sal.binding.api.NotificationService;
-import org.opendaylight.controller.md.sal.binding.compat.HeliumNotificationProviderServiceWithInterestListeners;
-import org.opendaylight.controller.md.sal.binding.compat.HeliumRpcProviderRegistry;
-import org.opendaylight.controller.md.sal.binding.spi.AdapterFactory;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotificationPublishService;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
-import org.opendaylight.controller.md.sal.dom.spi.DOMNotificationSubscriptionListenerRegistry;
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.mdsal.binding.dom.codec.impl.BindingNormalizedNodeCodecRegistry;
-import org.opendaylight.mdsal.binding.generator.api.ClassLoadingStrategy;
-import org.opendaylight.mdsal.dom.api.DOMSchemaService;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
-
-/**
- * Provides the implementations of the APIs.
- *
- * <p>Intended to be usable in a standalone environment (non-OSGi/Karaf). Also
- * internally used by the Blueprint XML to expose the same as OSGi services.
- * This class does not require (depend on) the Guice dependency injection
- * framework, but can we used with it.
- *
- * @author Michael Vorburger.ch, partially based on refactored code originally by Thomas Pantelis
- */
-@Deprecated(forRemoval = true)
-public class BindingBrokerWiring implements AutoCloseable {
-
- private final BindingToNormalizedNodeCodec bindingToNormalizedNodeCodec;
- private final ListenerRegistration<SchemaContextListener> mappingCodecListenerReg;
- private final RpcProviderRegistry rpcProviderRegistry;
- private final MountPointService mountPointService;
- private final NotificationService notificationService;
- private final NotificationPublishService notificationPublishService;
- private final HeliumNotificationProviderServiceWithInterestListeners notificationAndProviderService;
- private final AdapterFactory adapterFactory;
- private final DataBroker dataBroker;
- private final DataBroker pingPongDataBroker;
-
- public BindingBrokerWiring(ClassLoadingStrategy classLoadingStrategy, DOMSchemaService schemaService,
- DOMRpcService domRpcService, DOMRpcProviderService domRpcProviderService,
- DOMMountPointService domMountPointService, DOMNotificationService domNotificationService,
- DOMNotificationPublishService domNotificationPublishService,
- DOMNotificationSubscriptionListenerRegistry domNotificationListenerRegistry, DOMDataBroker domDataBroker,
- DOMDataBroker domPingPongDataBroker) {
- // Runtime binding/normalized mapping service
- BindingNormalizedNodeCodecRegistry codecRegistry = new BindingNormalizedNodeCodecRegistry();
- bindingToNormalizedNodeCodec = new BindingToNormalizedNodeCodec(classLoadingStrategy, codecRegistry, true);
-
- // Register the BindingToNormalizedNodeCodec with the SchemaService as a SchemaContextListener
- mappingCodecListenerReg = schemaService.registerSchemaContextListener(bindingToNormalizedNodeCodec);
-
- // Binding RPC Registry Service
- BindingDOMRpcServiceAdapter bindingDOMRpcServiceAdapter
- = new BindingDOMRpcServiceAdapter(domRpcService, bindingToNormalizedNodeCodec);
- BindingDOMRpcProviderServiceAdapter bindingDOMRpcProviderServiceAdapter
- = new BindingDOMRpcProviderServiceAdapter(domRpcProviderService, bindingToNormalizedNodeCodec);
- rpcProviderRegistry
- = new HeliumRpcProviderRegistry(bindingDOMRpcServiceAdapter, bindingDOMRpcProviderServiceAdapter);
-
- // Binding MountPoint Service
- mountPointService = new BindingDOMMountPointServiceAdapter(domMountPointService, bindingToNormalizedNodeCodec);
-
- // Binding Notification Service
- BindingDOMNotificationServiceAdapter notificationServiceImpl = new BindingDOMNotificationServiceAdapter(
- bindingToNormalizedNodeCodec.getCodecRegistry(), domNotificationService);
- notificationService = notificationServiceImpl;
- BindingDOMNotificationPublishServiceAdapter notificationPublishServiceImpl =
- new BindingDOMNotificationPublishServiceAdapter(
- bindingToNormalizedNodeCodec, domNotificationPublishService);
- notificationPublishService = notificationPublishServiceImpl;
- notificationAndProviderService = new HeliumNotificationProviderServiceWithInterestListeners(
- notificationPublishServiceImpl, notificationServiceImpl, domNotificationListenerRegistry);
-
- adapterFactory = new BindingToDOMAdapterFactory(bindingToNormalizedNodeCodec);
-
- // Binding DataBroker
- dataBroker = adapterFactory.createDataBroker(domDataBroker);
-
- // Binding PingPong DataBroker
- pingPongDataBroker = adapterFactory.createDataBroker(domPingPongDataBroker);
- }
-
- @Override
- public void close() throws Exception {
- mappingCodecListenerReg.close();
- }
-
- public BindingToNormalizedNodeCodec getBindingToNormalizedNodeCodec() {
- return bindingToNormalizedNodeCodec;
- }
-
- public AdapterFactory getAdapterFactory() {
- return adapterFactory;
- }
-
- public RpcProviderRegistry getRpcProviderRegistry() {
- return rpcProviderRegistry;
- }
-
- public MountPointService getMountPointService() {
- return mountPointService;
- }
-
- public NotificationService getNotificationService() {
- return notificationService;
- }
-
- public NotificationPublishService getNotificationPublishService() {
- return notificationPublishService;
- }
-
- @Deprecated
- public NotificationProviderService getNotificationProviderService() {
- return notificationAndProviderService;
- }
-
- @Deprecated
- public org.opendaylight.controller.sal.binding.api.NotificationService getDeprecatedNotificationService() {
- return notificationAndProviderService;
- }
-
- public DataBroker getDataBroker() {
- return dataBroker;
- }
-
- public DataBroker getPingPongDataBroker() {
- return pingPongDataBroker;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Brocade Communications Systems, Inc. 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.md.sal.binding.impl;
-
-import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.dom.api.ClusteredDOMDataTreeChangeListener;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-
-/**
- * Adapter wrapping Binding {@link ClusteredDataTreeChangeListener} and exposing
- * it as {@link ClusteredDOMDataTreeChangeListener} and translated DOM events
- * to their Binding equivalent.
- *
- * @author Thomas Pantelis
- */
-@Deprecated(forRemoval = true)
-final class BindingClusteredDOMDataTreeChangeListenerAdapter<T extends DataObject>
- extends BindingDOMDataTreeChangeListenerAdapter<T> implements ClusteredDOMDataTreeChangeListener {
- BindingClusteredDOMDataTreeChangeListenerAdapter(BindingToNormalizedNodeCodec codec,
- ClusteredDataTreeChangeListener<T> listener, LogicalDatastoreType store) {
- super(codec, listener, store);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.impl;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ClassToInstanceMap;
-import org.opendaylight.controller.md.sal.binding.api.BindingService;
-import org.opendaylight.controller.md.sal.binding.spi.AdapterBuilder;
-import org.opendaylight.controller.md.sal.dom.api.DOMService;
-
-@Deprecated(forRemoval = true)
-abstract class BindingDOMAdapterBuilder<T extends BindingService> extends AdapterBuilder<T, DOMService> {
-
- interface Factory<T extends BindingService> {
-
- BindingDOMAdapterBuilder<T> newBuilder();
-
- }
-
- private BindingToNormalizedNodeCodec codec;
-
- public void setCodec(final BindingToNormalizedNodeCodec codec) {
- this.codec = codec;
- }
-
- @Override
- protected final T createInstance(final ClassToInstanceMap<DOMService> delegates) {
- Preconditions.checkState(codec != null);
- return createInstance(codec,delegates);
- }
-
- protected abstract T createInstance(BindingToNormalizedNodeCodec codec2, ClassToInstanceMap<DOMService> delegates);
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.impl;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableMap;
-import java.util.Map;
-import org.opendaylight.controller.md.sal.binding.api.ActionProviderService;
-import org.opendaylight.controller.md.sal.binding.api.ActionService;
-import org.opendaylight.controller.md.sal.binding.api.BindingService;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
-import org.opendaylight.controller.md.sal.binding.api.NotificationService;
-import org.opendaylight.controller.md.sal.binding.impl.BindingDOMAdapterBuilder.Factory;
-import org.opendaylight.controller.md.sal.binding.spi.AdapterBuilder;
-import org.opendaylight.controller.md.sal.binding.spi.AdapterLoader;
-import org.opendaylight.controller.md.sal.dom.api.DOMService;
-import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
-
-@Deprecated(forRemoval = true)
-public abstract class BindingDOMAdapterLoader extends AdapterLoader<BindingService, DOMService> {
- private static final Map<Class<?>, BindingDOMAdapterBuilder.Factory<?>> FACTORIES =
- ImmutableMap.<Class<?>, BindingDOMAdapterBuilder.Factory<?>>builder()
- .put(NotificationService.class, BindingDOMNotificationServiceAdapter.BUILDER_FACTORY)
- .put(NotificationPublishService.class, BindingDOMNotificationPublishServiceAdapter.BUILDER_FACTORY)
- .put(DataBroker.class, BindingDOMDataBrokerAdapter.BUILDER_FACTORY)
- .put(RpcConsumerRegistry.class, BindingDOMRpcServiceAdapter.BUILDER_FACTORY)
- .put(ActionProviderService.class, ControllerActionProviderServiceAdapter.BUILDER_FACTORY)
- .put(ActionService.class, ControllerActionServiceAdapter.BUILDER_FACTORY)
- .build();
-
- private final BindingToNormalizedNodeCodec codec;
-
- public BindingDOMAdapterLoader(final BindingToNormalizedNodeCodec codec) {
- this.codec = codec;
- }
-
- @Override
- protected final AdapterBuilder<? extends BindingService, DOMService> createBuilder(
- final Class<? extends BindingService> key) {
- final Factory<?> factory = FACTORIES.get(key);
- Preconditions.checkArgument(factory != null, "Unsupported service type %s", key);
- final BindingDOMAdapterBuilder<?> builder = factory.newBuilder();
- builder.setCodec(codec);
- return builder;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.impl;
-
-import com.google.common.collect.ClassToInstanceMap;
-import com.google.common.collect.ImmutableSet;
-import java.util.Set;
-import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeService;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.binding.impl.BindingDOMAdapterBuilder.Factory;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService;
-import org.opendaylight.controller.md.sal.dom.api.DOMService;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-
-/**
- * The DataBrokerImpl simply defers to the DOMDataBroker for all its operations.
- * All transactions and listener registrations are wrapped by the DataBrokerImpl
- * to allow binding aware components to use the DataBroker transparently.
- *
- * <p>
- * Besides this the DataBrokerImpl and it's collaborators also cache data that
- * is already transformed from the binding independent to binding aware format
- */
-@Deprecated(forRemoval = true)
-public class BindingDOMDataBrokerAdapter extends AbstractForwardedDataBroker
- implements DataBroker, DataTreeChangeService {
- static final Factory<DataBroker> BUILDER_FACTORY = Builder::new;
- private final DataTreeChangeService treeChangeService;
-
- public BindingDOMDataBrokerAdapter(final DOMDataBroker domDataBroker, final BindingToNormalizedNodeCodec codec) {
- super(domDataBroker, codec);
- final DOMDataTreeChangeService domTreeChange = (DOMDataTreeChangeService) domDataBroker
- .getSupportedExtensions().get(DOMDataTreeChangeService.class);
- if (domTreeChange != null) {
- treeChangeService = BindingDOMDataTreeChangeServiceAdapter.create(codec, domTreeChange);
- } else {
- treeChangeService = null;
- }
- }
-
- @Override
-
- public ReadOnlyTransaction newReadOnlyTransaction() {
- return new BindingDOMReadTransactionAdapter(getDelegate().newReadOnlyTransaction(),getCodec());
- }
-
- @Override
- public ReadWriteTransaction newReadWriteTransaction() {
- return new BindingDOMReadWriteTransactionAdapter(getDelegate().newReadWriteTransaction(),getCodec());
- }
-
- @Override
- public WriteTransaction newWriteOnlyTransaction() {
- return new BindingDOMWriteTransactionAdapter<>(getDelegate().newWriteOnlyTransaction(),getCodec());
- }
-
- @Override
- public BindingTransactionChain createTransactionChain(final TransactionChainListener listener) {
- return new BindingDOMTransactionChainAdapter(getDelegate(), getCodec(), listener);
- }
-
- @Override
- public String toString() {
- return "BindingDOMDataBrokerAdapter for " + getDelegate();
- }
-
- private static class Builder extends BindingDOMAdapterBuilder<DataBroker> {
-
- @Override
- public Set<? extends Class<? extends DOMService>> getRequiredDelegates() {
- return ImmutableSet.of(DOMDataBroker.class);
- }
-
- @Override
- protected DataBroker createInstance(final BindingToNormalizedNodeCodec codec,
- final ClassToInstanceMap<DOMService> delegates) {
- final DOMDataBroker domDataBroker = delegates.getInstance(DOMDataBroker.class);
- return new BindingDOMDataBrokerAdapter(domDataBroker, codec);
- }
-
- }
-
- @Override
- public <T extends DataObject, L extends DataTreeChangeListener<T>> ListenerRegistration<L>
- registerDataTreeChangeListener(final DataTreeIdentifier<T> treeId, final L listener) {
- if (treeChangeService == null) {
- throw new UnsupportedOperationException("Underlying data broker does not expose DOMDataTreeChangeService.");
- }
- return treeChangeService.registerDataTreeChangeListener(treeId, listener);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.impl;
-
-import static java.util.Objects.requireNonNull;
-
-import java.util.Collection;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
-
-/**
- * Adapter wrapping Binding {@link DataTreeChangeListener} and exposing
- * it as {@link DOMDataTreeChangeListener} and translated DOM events
- * to their Binding equivalent.
- *
- */
-@Deprecated(forRemoval = true)
-class BindingDOMDataTreeChangeListenerAdapter<T extends DataObject> implements DOMDataTreeChangeListener {
- private final BindingToNormalizedNodeCodec codec;
- private final DataTreeChangeListener<T> listener;
- private final LogicalDatastoreType store;
-
- BindingDOMDataTreeChangeListenerAdapter(final BindingToNormalizedNodeCodec codec,
- final DataTreeChangeListener<T> listener, final LogicalDatastoreType store) {
- this.codec = requireNonNull(codec);
- this.listener = requireNonNull(listener);
- this.store = requireNonNull(store);
- }
-
- @Override
- public void onDataTreeChanged(final Collection<DataTreeCandidate> domChanges) {
- final Collection<DataTreeModification<T>> bindingChanges =
- LazyDataTreeModification.from(codec, domChanges, store);
- listener.onDataTreeChanged(bindingChanges);
- }
-
- @Override
- public String toString() {
- return listener.toString();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.impl;
-
-import static java.util.Objects.requireNonNull;
-
-import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeService;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeIdentifier;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-
-/**
- * Adapter exposing Binding {@link DataTreeChangeService} and wrapping
- * {@link DOMDataTreeChangeService} and is responsible for translation
- * and instantiation of {@link BindingDOMDataTreeChangeListenerAdapter}
- * adapters.
- *
- * <p>
- * Each registered {@link DataTreeChangeListener} is wrapped using
- * adapter and registered directly to DOM service.
- */
-@Deprecated(forRemoval = true)
-final class BindingDOMDataTreeChangeServiceAdapter implements DataTreeChangeService {
-
- private final BindingToNormalizedNodeCodec codec;
- private final DOMDataTreeChangeService dataTreeChangeService;
-
- private BindingDOMDataTreeChangeServiceAdapter(final BindingToNormalizedNodeCodec codec,
- final DOMDataTreeChangeService dataTreeChangeService) {
- this.codec = requireNonNull(codec);
- this.dataTreeChangeService = requireNonNull(dataTreeChangeService);
- }
-
- static DataTreeChangeService create(final BindingToNormalizedNodeCodec codec,
- final DOMDataTreeChangeService dataTreeChangeService) {
- return new BindingDOMDataTreeChangeServiceAdapter(codec, dataTreeChangeService);
- }
-
- @Override
- public <T extends DataObject, L extends DataTreeChangeListener<T>> ListenerRegistration<L>
- registerDataTreeChangeListener(final DataTreeIdentifier<T> treeId, final L listener) {
- final DOMDataTreeIdentifier domIdentifier = toDomTreeIdentifier(treeId);
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- final BindingDOMDataTreeChangeListenerAdapter<T> domListener =
- listener instanceof ClusteredDataTreeChangeListener
- ? new BindingClusteredDOMDataTreeChangeListenerAdapter<>(
- codec, (ClusteredDataTreeChangeListener) listener, treeId.getDatastoreType())
- : new BindingDOMDataTreeChangeListenerAdapter<>(codec, listener, treeId.getDatastoreType());
-
- final ListenerRegistration<BindingDOMDataTreeChangeListenerAdapter<T>> domReg =
- dataTreeChangeService.registerDataTreeChangeListener(domIdentifier, domListener);
- return new BindingDataTreeChangeListenerRegistration<>(listener,domReg);
- }
-
- private DOMDataTreeIdentifier toDomTreeIdentifier(final DataTreeIdentifier<?> treeId) {
- final YangInstanceIdentifier domPath = codec.toYangInstanceIdentifierBlocking(treeId.getRootIdentifier());
- return new DOMDataTreeIdentifier(treeId.getDatastoreType(), domPath);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.impl;
-
-import java.util.Optional;
-import org.opendaylight.controller.md.sal.binding.api.MountPointService.MountPointListener;
-import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
-import org.opendaylight.mdsal.dom.api.DOMMountPointListener;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.impl.codec.DeserializationException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Deprecated(forRemoval = true)
-final class BindingDOMMountPointListenerAdapter<T extends MountPointListener>
- implements ListenerRegistration<T>, DOMMountPointListener {
- private static final Logger LOG = LoggerFactory.getLogger(BindingDOMMountPointListenerAdapter.class);
-
- private final T listener;
- private final ListenerRegistration<DOMMountPointListener> registration;
- private final BindingToNormalizedNodeCodec codec;
-
- BindingDOMMountPointListenerAdapter(final T listener, final BindingToNormalizedNodeCodec codec,
- final DOMMountPointService mountService) {
- this.listener = listener;
- this.codec = codec;
- this.registration = mountService.registerProvisionListener(this);
- }
-
- @Override
- public T getInstance() {
- return listener;
- }
-
- @Override
- public void close() {
- registration.close();
- }
-
- @Override
- public void onMountPointCreated(final YangInstanceIdentifier path) {
- try {
- final InstanceIdentifier<? extends DataObject> bindingPath = toBinding(path);
- listener.onMountPointCreated(bindingPath);
- } catch (final DeserializationException e) {
- LOG.error("Unable to translate mountPoint path {}. Omitting event.", path, e);
- }
-
- }
-
- private InstanceIdentifier<? extends DataObject> toBinding(final YangInstanceIdentifier path)
- throws DeserializationException {
- final Optional<InstanceIdentifier<? extends DataObject>> instanceIdentifierOptional = codec.toBinding(path);
- if (instanceIdentifierOptional.isPresent()) {
- return instanceIdentifierOptional.get();
- } else {
- throw new DeserializationException("Deserialization unsuccessful, " + instanceIdentifierOptional);
- }
- }
-
- @Override
- public void onMountPointRemoved(final YangInstanceIdentifier path) {
- try {
- final InstanceIdentifier<? extends DataObject> bindingPath = toBinding(path);
- listener.onMountPointRemoved(bindingPath);
- } catch (final DeserializationException e) {
- LOG.error("Unable to translate mountPoint path {}. Omitting event.", path, e);
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.impl;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Optional;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
-import org.gaul.modernizer_maven_annotations.SuppressModernizer;
-import org.opendaylight.controller.md.sal.binding.api.MountPoint;
-import org.opendaylight.controller.md.sal.binding.api.MountPointService;
-import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
-import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Deprecated(forRemoval = true)
-public class BindingDOMMountPointServiceAdapter implements MountPointService {
- private static final Logger LOG = LoggerFactory.getLogger(BindingDOMMountPointServiceAdapter.class);
-
- private final BindingToNormalizedNodeCodec codec;
- private final DOMMountPointService mountService;
- @VisibleForTesting
- final LoadingCache<DOMMountPoint, BindingMountPointAdapter> bindingMountpoints = CacheBuilder.newBuilder()
- .weakKeys().weakValues().build(new CacheLoader<DOMMountPoint, BindingMountPointAdapter>() {
- @Override
- public BindingMountPointAdapter load(final DOMMountPoint key) {
- return new BindingMountPointAdapter(codec, key);
- }
- });
-
- public BindingDOMMountPointServiceAdapter(final DOMMountPointService mountService,
- final BindingToNormalizedNodeCodec codec) {
- this.codec = codec;
- this.mountService = mountService;
- }
-
- @Override
- @SuppressModernizer
- public Optional<MountPoint> getMountPoint(final InstanceIdentifier<?> mountPoint) {
-
- YangInstanceIdentifier domPath = codec.toYangInstanceIdentifierBlocking(mountPoint);
- Optional<DOMMountPoint> domMount = mountService.getMountPoint(domPath);
- if (domMount.isPresent()) {
- return Optional.<MountPoint>fromNullable(bindingMountpoints.getUnchecked(domMount.get()));
- }
- return Optional.absent();
- }
-
- @Override
- public <T extends MountPointListener> ListenerRegistration<T> registerListener(final InstanceIdentifier<?> path,
- final T listener) {
- return new BindingDOMMountPointListenerAdapter<>(listener, codec, mountService);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.impl;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.reflect.TypeToken;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener;
-import org.opendaylight.mdsal.binding.dom.adapter.invoke.NotificationListenerInvoker;
-import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
-import org.opendaylight.yangtools.yang.binding.Notification;
-import org.opendaylight.yangtools.yang.binding.NotificationListener;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-
-@Deprecated(forRemoval = true)
-class BindingDOMNotificationListenerAdapter implements DOMNotificationListener {
-
- private final BindingNormalizedNodeSerializer codec;
- private final NotificationListener delegate;
- private final Map<SchemaPath,NotificationListenerInvoker> invokers;
-
- BindingDOMNotificationListenerAdapter(final BindingNormalizedNodeSerializer codec,
- final NotificationListener delegate) {
- this.codec = codec;
- this.delegate = delegate;
- this.invokers = createInvokerMapFor(delegate.getClass());
- }
-
- @Override
- public void onNotification(final DOMNotification notification) {
- final Notification baNotification = deserialize(notification);
- final QName notificationQName = notification.getType().getLastComponent();
- getInvoker(notification.getType()).invokeNotification(delegate, notificationQName, baNotification);
- }
-
- private Notification deserialize(final DOMNotification notification) {
- if (notification instanceof LazySerializedDOMNotification) {
- return ((LazySerializedDOMNotification) notification).getBindingData();
- }
- return codec.fromNormalizedNodeNotification(notification.getType(), notification.getBody());
- }
-
- private NotificationListenerInvoker getInvoker(final SchemaPath type) {
- return invokers.get(type);
- }
-
- protected Set<SchemaPath> getSupportedNotifications() {
- return invokers.keySet();
- }
-
- public static Map<SchemaPath, NotificationListenerInvoker> createInvokerMapFor(
- final Class<? extends NotificationListener> implClz) {
- final Map<SchemaPath, NotificationListenerInvoker> builder = new HashMap<>();
- for (final TypeToken<?> ifaceToken : TypeToken.of(implClz).getTypes().interfaces()) {
- Class<?> iface = ifaceToken.getRawType();
- if (NotificationListener.class.isAssignableFrom(iface) && BindingReflections.isBindingClass(iface)) {
- @SuppressWarnings("unchecked")
- final Class<? extends NotificationListener> listenerType =
- (Class<? extends NotificationListener>) iface;
- final NotificationListenerInvoker invoker = NotificationListenerInvoker.from(listenerType);
- for (final SchemaPath path : getNotificationTypes(listenerType)) {
- builder.put(path, invoker);
- }
- }
- }
- return ImmutableMap.copyOf(builder);
- }
-
- private static Set<SchemaPath> getNotificationTypes(final Class<? extends NotificationListener> type) {
- // TODO: Investigate possibility and performance impact if we cache this or expose
- // it from NotificationListenerInvoker
- final Set<SchemaPath> ret = new HashSet<>();
- for (final Method method : type.getMethods()) {
- if (BindingReflections.isNotificationCallback(method)) {
- final Class<?> notification = method.getParameterTypes()[0];
- final QName name = BindingReflections.findQName(notification);
- ret.add(SchemaPath.create(true, name));
- }
- }
- return ret;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.impl;
-
-import com.google.common.collect.ClassToInstanceMap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.util.concurrent.ListenableFuture;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
-import org.opendaylight.controller.md.sal.binding.impl.BindingDOMAdapterBuilder.Factory;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotificationPublishService;
-import org.opendaylight.controller.md.sal.dom.api.DOMService;
-import org.opendaylight.yangtools.yang.binding.Notification;
-
-@Deprecated(forRemoval = true)
-public class BindingDOMNotificationPublishServiceAdapter implements NotificationPublishService, AutoCloseable {
-
- static final Factory<NotificationPublishService> BUILDER_FACTORY = Builder::new;
-
- private final BindingToNormalizedNodeCodec codecRegistry;
- private final DOMNotificationPublishService domPublishService;
-
- public BindingDOMNotificationPublishServiceAdapter(final BindingToNormalizedNodeCodec codec,
- final DOMNotificationPublishService domPublishService) {
- this.codecRegistry = codec;
- this.domPublishService = domPublishService;
- }
-
- public BindingToNormalizedNodeCodec getCodecRegistry() {
- return codecRegistry;
- }
-
- public DOMNotificationPublishService getDomPublishService() {
- return domPublishService;
- }
-
- @Override
- public void putNotification(final Notification notification) throws InterruptedException {
- domPublishService.putNotification(toDomNotification(notification));
- }
-
- @Override
- public ListenableFuture<?> offerNotification(final Notification notification) {
- ListenableFuture<?> offerResult = domPublishService.offerNotification(toDomNotification(notification));
- return DOMNotificationPublishService.REJECTED.equals(offerResult)
- ? NotificationPublishService.REJECTED
- : offerResult;
- }
-
- @Override
- public ListenableFuture<?> offerNotification(final Notification notification, final int timeout,
- final TimeUnit unit) throws InterruptedException {
- ListenableFuture<?> offerResult = domPublishService.offerNotification(toDomNotification(notification),
- timeout, unit);
- return DOMNotificationPublishService.REJECTED.equals(offerResult)
- ? NotificationPublishService.REJECTED
- : offerResult;
- }
-
- private DOMNotification toDomNotification(final Notification notification) {
- return LazySerializedDOMNotification.create(codecRegistry, notification);
- }
-
- @Override
- public void close() {
-
- }
-
- protected static class Builder extends BindingDOMAdapterBuilder<NotificationPublishService> {
-
- @Override
- public Set<Class<? extends DOMService>> getRequiredDelegates() {
- return ImmutableSet.<Class<? extends DOMService>>of(DOMNotificationPublishService.class);
- }
-
- @Override
- protected NotificationPublishService createInstance(final BindingToNormalizedNodeCodec codec,
- final ClassToInstanceMap<DOMService> delegates) {
- final DOMNotificationPublishService domPublish = delegates.getInstance(DOMNotificationPublishService.class);
- return new BindingDOMNotificationPublishServiceAdapter(codec, domPublish);
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.impl;
-
-import com.google.common.collect.ClassToInstanceMap;
-import com.google.common.collect.ImmutableSet;
-import java.util.Set;
-import org.opendaylight.controller.md.sal.binding.api.NotificationService;
-import org.opendaylight.controller.md.sal.binding.impl.BindingDOMAdapterBuilder.Factory;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService;
-import org.opendaylight.controller.md.sal.dom.api.DOMService;
-import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
-import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.NotificationListener;
-
-@Deprecated(forRemoval = true)
-public class BindingDOMNotificationServiceAdapter implements NotificationService, AutoCloseable {
-
- public static final Factory<NotificationService> BUILDER_FACTORY = Builder::new;
- private final BindingNormalizedNodeSerializer codec;
- private final DOMNotificationService domNotifService;
-
- public BindingDOMNotificationServiceAdapter(final BindingNormalizedNodeSerializer codec,
- final DOMNotificationService domNotifService) {
- this.codec = codec;
- this.domNotifService = domNotifService;
- }
-
- @Override
- public <T extends NotificationListener> ListenerRegistration<T> registerNotificationListener(final T listener) {
- final BindingDOMNotificationListenerAdapter domListener =
- new BindingDOMNotificationListenerAdapter(codec, listener);
- final ListenerRegistration<BindingDOMNotificationListenerAdapter> domRegistration =
- domNotifService.registerNotificationListener(domListener, domListener.getSupportedNotifications());
- return new ListenerRegistrationImpl<>(listener, domRegistration);
- }
-
- @Override
- public void close() {
-
- }
-
- private static class ListenerRegistrationImpl<T extends NotificationListener>
- extends AbstractListenerRegistration<T> {
- private final ListenerRegistration<?> listenerRegistration;
-
- ListenerRegistrationImpl(final T listener, final ListenerRegistration<?> listenerRegistration) {
- super(listener);
- this.listenerRegistration = listenerRegistration;
- }
-
- @Override
- protected void removeRegistration() {
- listenerRegistration.close();
- }
- }
-
- private static class Builder extends BindingDOMAdapterBuilder<NotificationService> {
-
- @Override
- protected NotificationService createInstance(final BindingToNormalizedNodeCodec codec,
- final ClassToInstanceMap<DOMService> delegates) {
- final DOMNotificationService domNotification = delegates.getInstance(DOMNotificationService.class);
- return new BindingDOMNotificationServiceAdapter(codec.getCodecRegistry(), domNotification);
- }
-
- @Override
- public Set<? extends Class<? extends DOMService>> getRequiredDelegates() {
- return ImmutableSet.of(DOMNotificationService.class);
- }
- }
-
- public DOMNotificationService getDomService() {
- return domNotifService;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.impl;
-
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-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.dom.api.DOMDataReadOnlyTransaction;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-@Deprecated(forRemoval = true)
-class BindingDOMReadTransactionAdapter extends AbstractForwardedTransaction<DOMDataReadOnlyTransaction> implements
- ReadOnlyTransaction {
-
- protected BindingDOMReadTransactionAdapter(final DOMDataReadOnlyTransaction delegate,
- final BindingToNormalizedNodeCodec codec) {
- super(delegate, codec);
- }
-
- @Override
- public <T extends DataObject> CheckedFuture<Optional<T>, ReadFailedException> read(
- final LogicalDatastoreType store, final InstanceIdentifier<T> path) {
- return doRead(getDelegate(),store, path);
- }
-
- @Override
- public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store,
- final InstanceIdentifier<?> path) {
- return doExists(getDelegate(), store, path);
- }
-
- @Override
- public void close() {
- getDelegate().close();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.impl;
-
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
-import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-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.dom.api.DOMDataReadWriteTransaction;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-@Deprecated(forRemoval = true)
-class BindingDOMReadWriteTransactionAdapter extends
- BindingDOMWriteTransactionAdapter<DOMDataReadWriteTransaction> implements ReadWriteTransaction {
-
- protected BindingDOMReadWriteTransactionAdapter(final DOMDataReadWriteTransaction delegate,
- final BindingToNormalizedNodeCodec codec) {
- super(delegate, codec);
- }
-
- @Override
- public <T extends DataObject> CheckedFuture<Optional<T>,ReadFailedException> read(
- final LogicalDatastoreType store, final InstanceIdentifier<T> path) {
- return doRead(getDelegate(), store, path);
- }
-
- @Override
- public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store,
- final InstanceIdentifier<?> path) {
- return doExists(getDelegate(), store, path);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.impl;
-
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationRegistration;
-import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-
-@Deprecated(forRemoval = true)
-class BindingDOMRpcAdapterRegistration<T extends RpcService> extends AbstractObjectRegistration<T> {
-
- private final DOMRpcImplementationRegistration<?> reg;
-
- BindingDOMRpcAdapterRegistration(T instance, DOMRpcImplementationRegistration<?> reg) {
- super(instance);
- this.reg = reg;
- }
-
- @Override
- protected void removeRegistration() {
- reg.close();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.impl;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.cache.Cache;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.ListenableFuture;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.concurrent.ExecutionException;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
-import org.opendaylight.mdsal.binding.dom.adapter.BindingDataAware;
-import org.opendaylight.mdsal.binding.dom.adapter.invoke.RpcServiceInvoker;
-import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-
-@Deprecated(forRemoval = true)
-public class BindingDOMRpcImplementationAdapter implements DOMRpcImplementation {
-
- private static final Cache<Class<?>, RpcServiceInvoker> SERVICE_INVOKERS =
- CacheBuilder.newBuilder().weakKeys().build();
-
- private final BindingNormalizedNodeSerializer codec;
- private final RpcServiceInvoker invoker;
- private final RpcService delegate;
- private final QName inputQname;
-
- <T extends RpcService> BindingDOMRpcImplementationAdapter(final BindingNormalizedNodeSerializer codec,
- final Class<T> type, final Map<SchemaPath, Method> localNameToMethod, final T delegate) {
- try {
- this.invoker = SERVICE_INVOKERS.get(type, () -> {
- final Map<QName, Method> map = new HashMap<>();
- for (Entry<SchemaPath, Method> e : localNameToMethod.entrySet()) {
- map.put(e.getKey().getLastComponent(), e.getValue());
- }
-
- return RpcServiceInvoker.from(map);
- });
- } catch (ExecutionException e) {
- throw new IllegalArgumentException("Failed to create invokers for type " + type, e);
- }
-
- this.codec = requireNonNull(codec);
- this.delegate = requireNonNull(delegate);
- inputQname = QName.create(BindingReflections.getQNameModule(type), "input").intern();
- }
-
- @Override
- public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final DOMRpcIdentifier rpc,
- final NormalizedNode<?, ?> input) {
- final SchemaPath schemaPath = rpc.getType();
- final DataObject bindingInput = input != null ? deserialize(rpc.getType(), input) : null;
- final ListenableFuture<RpcResult<?>> bindingResult = invoke(schemaPath, bindingInput);
- return transformResult(bindingResult);
- }
-
- private DataObject deserialize(final SchemaPath rpcPath, final NormalizedNode<?, ?> input) {
- if (input instanceof BindingDataAware) {
- return ((BindingDataAware) input).bindingData();
- }
- final SchemaPath inputSchemaPath = rpcPath.createChild(inputQname);
- return codec.fromNormalizedNodeRpcData(inputSchemaPath, (ContainerNode) input);
- }
-
- private ListenableFuture<RpcResult<?>> invoke(final SchemaPath schemaPath, final DataObject input) {
- return invoker.invokeRpc(delegate, schemaPath.getLastComponent(), input);
- }
-
- private CheckedFuture<DOMRpcResult, DOMRpcException> transformResult(
- final ListenableFuture<RpcResult<?>> bindingResult) {
- return LazyDOMRpcResultFuture.create(codec, bindingResult);
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.impl;
-
-import com.google.common.collect.ImmutableSet;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationRegistration;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService;
-import org.opendaylight.yangtools.concepts.ObjectRegistration;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-
-@Deprecated(forRemoval = true)
-public class BindingDOMRpcProviderServiceAdapter {
-
- private static final Set<YangInstanceIdentifier> GLOBAL = ImmutableSet.of(YangInstanceIdentifier.empty());
- private final BindingToNormalizedNodeCodec codec;
- private final DOMRpcProviderService domRpcRegistry;
-
- public BindingDOMRpcProviderServiceAdapter(final DOMRpcProviderService domRpcRegistry,
- final BindingToNormalizedNodeCodec codec) {
- this.codec = codec;
- this.domRpcRegistry = domRpcRegistry;
- }
-
- public <S extends RpcService, T extends S> ObjectRegistration<T> registerRpcImplementation(final Class<S> type,
- final T implementation) {
- return register(type, implementation, GLOBAL);
- }
-
- public <S extends RpcService, T extends S> ObjectRegistration<T> registerRpcImplementation(final Class<S> type,
- final T implementation, final Set<InstanceIdentifier<?>> paths) {
- return register(type, implementation, toYangInstanceIdentifiers(paths));
- }
-
- private <S extends RpcService, T extends S> ObjectRegistration<T> register(final Class<S> type,
- final T implementation, final Collection<YangInstanceIdentifier> rpcContextPaths) {
- final Map<SchemaPath, Method> rpcs = codec.getRpcMethodToSchemaPath(type).inverse();
-
- final BindingDOMRpcImplementationAdapter adapter = new BindingDOMRpcImplementationAdapter(
- codec.getCodecRegistry(), type, rpcs, implementation);
- final Set<DOMRpcIdentifier> domRpcs = createDomRpcIdentifiers(rpcs.keySet(), rpcContextPaths);
- final DOMRpcImplementationRegistration<?> domReg = domRpcRegistry.registerRpcImplementation(adapter, domRpcs);
- return new BindingRpcAdapterRegistration<>(implementation, domReg);
- }
-
- private static Set<DOMRpcIdentifier> createDomRpcIdentifiers(final Set<SchemaPath> rpcs,
- final Collection<YangInstanceIdentifier> paths) {
- final Set<DOMRpcIdentifier> ret = new HashSet<>();
- for (final YangInstanceIdentifier path : paths) {
- for (final SchemaPath rpc : rpcs) {
- ret.add(DOMRpcIdentifier.create(rpc, path));
- }
- }
- return ret;
- }
-
- private Collection<YangInstanceIdentifier> toYangInstanceIdentifiers(final Set<InstanceIdentifier<?>> identifiers) {
- final Collection<YangInstanceIdentifier> ret = new ArrayList<>(identifiers.size());
- for (final InstanceIdentifier<?> binding : identifiers) {
- ret.add(codec.toYangInstanceIdentifierCached(binding));
- }
- return ret;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.impl;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
-import com.google.common.collect.ClassToInstanceMap;
-import com.google.common.collect.ImmutableSet;
-import java.util.Set;
-import org.opendaylight.controller.md.sal.binding.impl.BindingDOMAdapterBuilder.Factory;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
-import org.opendaylight.controller.md.sal.dom.api.DOMService;
-import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-
-@Deprecated(forRemoval = true)
-public class BindingDOMRpcServiceAdapter implements RpcConsumerRegistry {
-
- protected static final Factory<RpcConsumerRegistry> BUILDER_FACTORY = Builder::new;
-
- private final LoadingCache<Class<? extends RpcService>, RpcServiceAdapter> proxies = CacheBuilder.newBuilder()
- .weakKeys()
- .build(new CacheLoader<Class<? extends RpcService>, RpcServiceAdapter>() {
-
- @Override
- public RpcServiceAdapter load(final Class<? extends RpcService> key) {
- checkArgument(BindingReflections.isBindingClass(key));
- checkArgument(key.isInterface(), "Supplied RPC service type must be interface.");
- return new RpcServiceAdapter(key, codec, domService);
- }
-
- });
-
- private final DOMRpcService domService;
- private final BindingToNormalizedNodeCodec codec;
-
- public BindingDOMRpcServiceAdapter(final DOMRpcService domService, final BindingToNormalizedNodeCodec codec) {
- this.domService = domService;
- this.codec = codec;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public <T extends RpcService> T getRpcService(final Class<T> rpcService) {
- checkArgument(rpcService != null, "Rpc Service needs to be specied.");
- return (T) proxies.getUnchecked(rpcService).getProxy();
- }
-
- private static final class Builder extends BindingDOMAdapterBuilder<RpcConsumerRegistry> {
-
- @Override
- protected RpcConsumerRegistry createInstance(final BindingToNormalizedNodeCodec codec,
- final ClassToInstanceMap<DOMService> delegates) {
- final DOMRpcService domRpc = delegates.getInstance(DOMRpcService.class);
- return new BindingDOMRpcServiceAdapter(domRpc , codec);
- }
-
- @Override
- public Set<? extends Class<? extends DOMService>> getRequiredDelegates() {
- return ImmutableSet.of(DOMRpcService.class);
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.impl;
-
-import static com.google.common.base.Preconditions.checkState;
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.util.concurrent.FluentFuture;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.MoreExecutors;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-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.DOMDataBroker;
-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.common.api.CommitInfo;
-import org.opendaylight.yangtools.concepts.Delegator;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Deprecated(forRemoval = true)
-final class BindingDOMTransactionChainAdapter implements BindingTransactionChain, Delegator<DOMTransactionChain> {
-
- private static final Logger LOG = LoggerFactory.getLogger(BindingDOMTransactionChainAdapter.class);
-
- private final DOMTransactionChain delegate;
- private final BindingToNormalizedNodeCodec codec;
- private final DelegateChainListener domListener;
- private final TransactionChainListener bindingListener;
-
- BindingDOMTransactionChainAdapter(final DOMDataBroker chainFactory,
- final BindingToNormalizedNodeCodec codec, final TransactionChainListener listener) {
- this.domListener = new DelegateChainListener();
- this.bindingListener = listener;
- this.delegate = requireNonNull(chainFactory, "DOM Transaction chain factory must not be null")
- .createTransactionChain(domListener);
- this.codec = codec;
- }
-
- @Override
- public DOMTransactionChain getDelegate() {
- return delegate;
- }
-
- @Override
- public ReadOnlyTransaction newReadOnlyTransaction() {
- final DOMDataReadOnlyTransaction delegateTx = delegate.newReadOnlyTransaction();
- return new BindingDOMReadTransactionAdapter(delegateTx, codec);
- }
-
- @Override
- public ReadWriteTransaction newReadWriteTransaction() {
- final DOMDataReadWriteTransaction delegateTx = delegate.newReadWriteTransaction();
- return new BindingDOMReadWriteTransactionAdapter(delegateTx, codec) {
-
- @Override
- public FluentFuture<? extends CommitInfo> commit() {
- return listenForFailure(this, super.commit());
- }
-
- };
- }
-
- @Override
- public WriteTransaction newWriteOnlyTransaction() {
- final DOMDataWriteTransaction delegateTx = delegate.newWriteOnlyTransaction();
- return new BindingDOMWriteTransactionAdapter<DOMDataWriteTransaction>(delegateTx, codec) {
-
- @Override
- public FluentFuture<? extends CommitInfo> commit() {
- return listenForFailure(this, super.commit());
- }
-
- };
- }
-
- @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
- justification = "https://github.com/spotbugs/spotbugs/issues/811")
- private FluentFuture<? extends CommitInfo> listenForFailure(
- final WriteTransaction tx, final FluentFuture<? extends CommitInfo> future) {
- future.addCallback(new FutureCallback<CommitInfo>() {
- @Override
- public void onFailure(final Throwable ex) {
- failTransactionChain(tx,ex);
- }
-
- @Override
- public void onSuccess(final CommitInfo result) {
- // Intentionally NOOP
- }
- }, MoreExecutors.directExecutor());
-
- return future;
- }
-
- @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
- justification = "https://github.com/spotbugs/spotbugs/issues/811")
- private void failTransactionChain(final WriteTransaction tx, final Throwable ex) {
- /*
- * We asume correct state change for underlaying transaction
- *
- * chain, so we are not changing any of our internal state
- * to mark that we failed.
- */
- this.bindingListener.onTransactionChainFailed(this, tx, ex);
- }
-
- @Override
- public void close() {
- delegate.close();
- }
-
- private final class DelegateChainListener implements TransactionChainListener {
- @Override
- public void onTransactionChainFailed(final TransactionChain<?, ?> chain,
- final AsyncTransaction<?, ?> transaction, final Throwable cause) {
- checkChain(chain);
- /*
- * Intentionally NOOP, callback for failure, since we
- * are also listening on each transaction future for failure,
- * in order to have reference to Binding Transaction (which was seen by client
- * of this transaction chain), instead of DOM transaction
- * which is known only to this chain, binding transaction implementation
- * and underlying transaction chain.
- */
- LOG.debug("Transaction chain {} failed. Failed DOM Transaction {}",this,transaction,cause);
- }
-
- @Override
- public void onTransactionChainSuccessful(final TransactionChain<?, ?> chain) {
- checkChain(chain);
- bindingListener.onTransactionChainSuccessful(BindingDOMTransactionChainAdapter.this);
- }
-
- private void checkChain(final TransactionChain<?, ?> chain) {
- checkState(delegate.equals(chain), "Illegal state - listener for %s was invoked for incorrect chain %s.",
- delegate, chain);
- }
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.impl;
-
-import com.google.common.util.concurrent.FluentFuture;
-import java.util.ArrayList;
-import java.util.List;
-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.impl.util.compat.DataNormalizationException;
-import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationOperation;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
-import org.opendaylight.mdsal.common.api.CommitInfo;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
-
-@Deprecated(forRemoval = true)
-class BindingDOMWriteTransactionAdapter<T extends DOMDataWriteTransaction> extends
- AbstractWriteTransaction<T> implements WriteTransaction {
-
- protected BindingDOMWriteTransactionAdapter(final T delegateTx, final BindingToNormalizedNodeCodec codec) {
- super(delegateTx, codec);
- }
-
- @Override
- public <U extends DataObject> void put(final LogicalDatastoreType store, final InstanceIdentifier<U> path,
- final U data) {
- put(store, path, data,false);
- }
-
- @Override
- public <D extends DataObject> void merge(final LogicalDatastoreType store, final InstanceIdentifier<D> path,
- final D data) {
- merge(store, path, data,false);
- }
-
-
- @Override
- protected void ensureParentsByMerge(final LogicalDatastoreType store,
- final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier normalizedPath,
- final InstanceIdentifier<?> path) {
- List<PathArgument> currentArguments = new ArrayList<>();
- DataNormalizationOperation<?> currentOp = getCodec().getDataNormalizer().getRootOperation();
- for (PathArgument currentArg : normalizedPath.getPathArguments()) {
- try {
- currentOp = currentOp.getChild(currentArg);
- } catch (DataNormalizationException e) {
- throw new IllegalArgumentException(String.format("Invalid child encountered in path %s", path), e);
- }
- currentArguments.add(currentArg);
- YangInstanceIdentifier currentPath = YangInstanceIdentifier.create(
- currentArguments);
-
- getDelegate().merge(store, currentPath, currentOp.createDefault(currentArg));
- }
- }
-
- @Override
- public void delete(final LogicalDatastoreType store, final InstanceIdentifier<?> path) {
- doDelete(store, path);
- }
-
- @Override
- public FluentFuture<? extends CommitInfo> commit() {
- return doCommit();
- }
-
- @Override
- public boolean cancel() {
- return doCancel();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.impl;
-
-import static java.util.Objects.requireNonNull;
-
-import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
-import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-
-@Deprecated(forRemoval = true)
-class BindingDataTreeChangeListenerRegistration<L extends DataTreeChangeListener<?>>
- extends AbstractListenerRegistration<L> {
-
- private final ListenerRegistration<?> domReg;
-
- BindingDataTreeChangeListenerRegistration(final L listener, final ListenerRegistration<?> domReg) {
- super(listener);
- this.domReg = requireNonNull(domReg);
- }
-
- @Override
- protected void removeRegistration() {
- domReg.close();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.impl;
-
-import com.google.common.base.Optional;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.LoadingCache;
-import org.gaul.modernizer_maven_annotations.SuppressModernizer;
-import org.opendaylight.controller.md.sal.binding.api.BindingService;
-import org.opendaylight.controller.md.sal.binding.api.MountPoint;
-import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
-import org.opendaylight.controller.md.sal.dom.api.DOMService;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-@Deprecated(forRemoval = true)
-public class BindingMountPointAdapter implements MountPoint {
-
- private final InstanceIdentifier<?> identifier;
- private LoadingCache<Class<? extends BindingService>, Optional<BindingService>> services;
-
- public BindingMountPointAdapter(final BindingToNormalizedNodeCodec codec, final DOMMountPoint domMountPoint) {
- identifier = codec.getCodecRegistry().fromYangInstanceIdentifier(domMountPoint.getIdentifier());
- services = CacheBuilder.newBuilder().build(new BindingDOMAdapterLoader(codec) {
-
- @Override
- protected DOMService getDelegate(final Class<? extends DOMService> reqDeleg) {
- return domMountPoint.getService(reqDeleg).orNull();
- }
- });
- }
-
- @Override
- public InstanceIdentifier<?> getIdentifier() {
- return identifier;
- }
-
- @Override
- @SuppressModernizer
- public <T extends BindingService> Optional<T> getService(final Class<T> service) {
- Optional<BindingService> potential = services.getUnchecked(service);
- if (potential.isPresent()) {
- return Optional.of(service.cast(potential.get()));
- }
- return Optional.absent();
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.impl;
-
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationRegistration;
-import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-
-@Deprecated(forRemoval = true)
-class BindingRpcAdapterRegistration<T extends RpcService> extends AbstractObjectRegistration<T> {
-
- private final DOMRpcImplementationRegistration<?> reg;
-
- BindingRpcAdapterRegistration(T instance, DOMRpcImplementationRegistration<?> reg) {
- super(instance);
- this.reg = reg;
- }
-
- @Override
- protected void removeRegistration() {
- reg.close();
- }
-}
+++ /dev/null
-/*
- * 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.md.sal.binding.impl;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.annotations.Beta;
-import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.spi.AdapterFactory;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-
-@Beta
-@Deprecated(forRemoval = true)
-@NonNullByDefault
-public final class BindingToDOMAdapterFactory implements AdapterFactory {
- private final BindingToNormalizedNodeCodec codec;
-
- public BindingToDOMAdapterFactory(final BindingToNormalizedNodeCodec codec) {
- this.codec = requireNonNull(codec);
- }
-
- @Override
- public DataBroker createDataBroker(final DOMDataBroker domBroker) {
- return new BindingDOMDataBrokerAdapter(requireNonNull(domBroker), codec);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.impl;
-
-import com.google.common.collect.ImmutableBiMap;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import java.lang.reflect.Method;
-import java.util.Iterator;
-import java.util.Map;
-import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationException;
-import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationOperation;
-import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizer;
-import org.opendaylight.mdsal.binding.dom.codec.api.BindingDataObjectCodecTreeNode;
-import org.opendaylight.mdsal.binding.dom.codec.impl.BindingNormalizedNodeCodecRegistry;
-import org.opendaylight.mdsal.binding.generator.api.ClassLoadingStrategy;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
-@Deprecated(forRemoval = true)
-@SuppressFBWarnings(value = "NM_SAME_SIMPLE_NAME_AS_SUPERCLASS", justification = "Migration path")
-public class BindingToNormalizedNodeCodec
- extends org.opendaylight.mdsal.binding.dom.adapter.BindingToNormalizedNodeCodec {
-
- private DataNormalizer legacyToNormalized = null;
-
- public BindingToNormalizedNodeCodec(final ClassLoadingStrategy classLoadingStrategy,
- final BindingNormalizedNodeCodecRegistry codecRegistry) {
- super(classLoadingStrategy, codecRegistry);
- }
-
- public BindingToNormalizedNodeCodec(final ClassLoadingStrategy classLoadingStrategy,
- final BindingNormalizedNodeCodecRegistry codecRegistry, final boolean waitForSchema) {
- super(classLoadingStrategy, codecRegistry, waitForSchema);
- }
-
- DataNormalizer getDataNormalizer() {
- return this.legacyToNormalized;
- }
-
- @Override
- public YangInstanceIdentifier toYangInstanceIdentifierBlocking(
- final InstanceIdentifier<? extends DataObject> binding) {
- return super.toYangInstanceIdentifierBlocking(binding);
- }
-
- @Override
- public YangInstanceIdentifier toYangInstanceIdentifierCached(final InstanceIdentifier<?> binding) {
- return super.toYangInstanceIdentifierCached(binding);
- }
-
- @Override
- public void onGlobalContextUpdated(final SchemaContext schemaContext) {
- this.legacyToNormalized = new DataNormalizer(schemaContext);
- super.onGlobalContextUpdated(schemaContext);
- }
-
- /**
- * Returns an default object according to YANG schema for supplied path.
- *
- * @param path DOM Path
- * @return Node with defaults set on.
- */
- @Override
- public NormalizedNode<?, ?> getDefaultNodeFor(final YangInstanceIdentifier path) {
- final Iterator<PathArgument> iterator = path.getPathArguments().iterator();
- DataNormalizationOperation<?> currentOp = this.legacyToNormalized.getRootOperation();
- while (iterator.hasNext()) {
- final PathArgument currentArg = iterator.next();
- try {
- currentOp = currentOp.getChild(currentArg);
- } catch (final DataNormalizationException e) {
- throw new IllegalArgumentException(String.format("Invalid child encountered in path %s", path), e);
- }
- }
- return currentOp.createDefault(path.getLastPathArgument());
- }
-
- @Override
- public ImmutableBiMap<Method, RpcDefinition> getRpcMethodToSchema(final Class<? extends RpcService> key) {
- return super.getRpcMethodToSchema(key);
- }
-
- @Override
- public Map.Entry<InstanceIdentifier<?>, BindingDataObjectCodecTreeNode<?>> getSubtreeCodec(
- final YangInstanceIdentifier domIdentifier) {
- return super.getSubtreeCodec(domIdentifier);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.impl;
-
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import java.lang.reflect.Method;
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.annotations.RoutingContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Deprecated(forRemoval = true)
-abstract class ContextReferenceExtractor {
- private static final Logger LOG = LoggerFactory.getLogger(ContextReferenceExtractor.class);
- private static final ContextReferenceExtractor NULL_EXTRACTOR = new ContextReferenceExtractor() {
-
- @Override
- InstanceIdentifier<?> extract(final DataObject obj) {
- return null;
- }
- };
-
- private static final LoadingCache<Class<?>, ContextReferenceExtractor> EXTRACTORS = CacheBuilder.newBuilder()
- .weakKeys().build(new CacheLoader<Class<?>, ContextReferenceExtractor>() {
-
- @Override
- public ContextReferenceExtractor load(final Class<?> key) {
- return create(key);
- }
- });
-
-
- private static final String GET_VALUE_NAME = "getValue";
-
- static ContextReferenceExtractor from(final Class<?> obj) {
- return EXTRACTORS.getUnchecked(obj);
- }
-
- /**
- * Extract context-reference (Instance Identifier) from
- * Binding DataObject.
- *
- * @param obj DataObject from which context reference should be extracted.
- *
- * @return Instance Identifier representing context reference or null, if data object does not contain
- * context reference.
- */
- abstract @Nullable InstanceIdentifier<?> extract(DataObject obj);
-
- @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
- justification = "https://github.com/spotbugs/spotbugs/issues/811")
- private static @NonNull ContextReferenceExtractor create(final Class<?> key) {
- final Method contextGetter = getContextGetter(key);
- if (contextGetter == null) {
- return NULL_EXTRACTOR;
- }
- final Class<?> returnType = contextGetter.getReturnType();
- try {
- if (InstanceIdentifier.class.isAssignableFrom(returnType)) {
- return DirectGetterRouteContextExtractor.create(contextGetter);
- }
- final Method getValueMethod = findGetValueMethod(returnType, InstanceIdentifier.class);
- if (getValueMethod != null) {
- return GetValueRouteContextExtractor.create(contextGetter, getValueMethod);
- } else {
- LOG.warn("Class {} can not be used to determine context, falling back to NULL_EXTRACTOR.", returnType);
- }
- } catch (final IllegalAccessException e) {
- LOG.warn("Class {} does not conform to Binding Specification v1. Falling back to NULL_EXTRACTOR",
- returnType, e);
- }
- return NULL_EXTRACTOR;
- }
-
- private static @Nullable Method findGetValueMethod(final Class<?> type, final Class<?> returnType) {
- try {
- final Method method = type.getMethod(GET_VALUE_NAME);
- if (returnType.equals(method.getReturnType())) {
- return method;
- }
- } catch (final NoSuchMethodException e) {
- LOG.warn("Value class {} does not comform to Binding Specification v1.", type, e);
- }
- return null;
- }
-
- private static Method getContextGetter(final Class<?> key) {
- for (final Method method : key.getMethods()) {
- if (method.getAnnotation(RoutingContext.class) != null) {
- return method;
- }
- }
- return null;
- }
-}
+++ /dev/null
-/*
- * 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.md.sal.binding.impl;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.collect.ClassToInstanceMap;
-import com.google.common.collect.ImmutableSet;
-import java.util.Set;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.controller.md.sal.binding.api.ActionProviderService;
-import org.opendaylight.controller.md.sal.binding.impl.BindingDOMAdapterBuilder.Factory;
-import org.opendaylight.controller.md.sal.dom.api.DOMActionProviderService;
-import org.opendaylight.controller.md.sal.dom.api.DOMService;
-import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
-import org.opendaylight.mdsal.binding.dom.adapter.ActionProviderServiceAdapter;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.yangtools.concepts.ObjectRegistration;
-import org.opendaylight.yangtools.yang.binding.Action;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-@Deprecated(forRemoval = true)
-final class ControllerActionProviderServiceAdapter implements ActionProviderService {
- private static final class Builder extends BindingDOMAdapterBuilder<ActionProviderService> {
- @Override
- public Set<? extends Class<? extends DOMService>> getRequiredDelegates() {
- return ImmutableSet.of(DOMActionProviderService.class);
- }
-
- @Override
- protected ActionProviderService createInstance(BindingToNormalizedNodeCodec codec,
- ClassToInstanceMap<DOMService> delegates) {
- final DOMActionProviderService domAction = delegates.getInstance(DOMActionProviderService.class);
- return new ControllerActionProviderServiceAdapter(requireNonNull(codec), domAction);
- }
- }
-
- static final Factory<ActionProviderService> BUILDER_FACTORY = Builder::new;
-
- private final ActionProviderServiceAdapter delegate;
-
- ControllerActionProviderServiceAdapter(BindingToNormalizedNodeCodec codec, DOMActionProviderService domService) {
- this.delegate = ActionProviderServiceAdapter.create(codec, domService);
- }
-
- @Override
- public <O extends @NonNull DataObject, P extends @NonNull InstanceIdentifier<O>, T extends @NonNull Action<P, ?, ?>,
- S extends T> ObjectRegistration<S> registerImplementation(Class<T> actionInterface, S implementation,
- LogicalDatastoreType datastore, Set<DataTreeIdentifier<O>> validNodes) {
- return delegate.registerImplementation(actionInterface, implementation, datastore, validNodes);
- }
-}
+++ /dev/null
-/*
- * 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.md.sal.binding.impl;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.collect.ClassToInstanceMap;
-import com.google.common.collect.ImmutableSet;
-import java.util.Set;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.controller.md.sal.binding.api.ActionService;
-import org.opendaylight.controller.md.sal.binding.impl.BindingDOMAdapterBuilder.Factory;
-import org.opendaylight.controller.md.sal.dom.api.DOMActionService;
-import org.opendaylight.controller.md.sal.dom.api.DOMService;
-import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
-import org.opendaylight.mdsal.binding.dom.adapter.ActionServiceAdapter;
-import org.opendaylight.yangtools.yang.binding.Action;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-
-@Deprecated(forRemoval = true)
-final class ControllerActionServiceAdapter implements ActionService {
- private static final class Builder extends BindingDOMAdapterBuilder<ActionService> {
- @Override
- public Set<? extends Class<? extends DOMService>> getRequiredDelegates() {
- return ImmutableSet.of(DOMActionService.class);
- }
-
- @Override
- protected ActionService createInstance(final BindingToNormalizedNodeCodec codec,
- final ClassToInstanceMap<DOMService> delegates) {
- final DOMActionService domAction = delegates.getInstance(DOMActionService.class);
- return new ControllerActionServiceAdapter(requireNonNull(codec), domAction);
- }
- }
-
- static final Factory<ActionService> BUILDER_FACTORY = Builder::new;
- private final ActionServiceAdapter delegate;
-
- ControllerActionServiceAdapter(final BindingToNormalizedNodeCodec codec, final DOMActionService domService) {
- this.delegate = ActionServiceAdapter.create(codec, domService);
- }
-
- @Override
- public <O extends @NonNull DataObject, T extends @NonNull Action<?, ?, ?>> T getActionHandle(
- final Class<T> actionInterface, final Set<DataTreeIdentifier<O>> validNodes) {
- return delegate.getActionHandle(actionInterface, validNodes);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.impl;
-
-import com.google.common.base.Throwables;
-import java.lang.invoke.MethodHandle;
-import java.lang.invoke.MethodHandles;
-import java.lang.invoke.MethodHandles.Lookup;
-import java.lang.invoke.MethodType;
-import java.lang.reflect.Method;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-@Deprecated(forRemoval = true)
-final class DirectGetterRouteContextExtractor extends ContextReferenceExtractor {
-
- private static final Lookup PUBLIC_LOOKUP = MethodHandles.publicLookup();
- private final MethodHandle handle;
-
- private DirectGetterRouteContextExtractor(final MethodHandle rawHandle) {
- handle = rawHandle.asType(MethodType.methodType(InstanceIdentifier.class, DataObject.class));
- }
-
- static ContextReferenceExtractor create(final Method getterMethod) throws IllegalAccessException {
- final MethodHandle getterHandle = PUBLIC_LOOKUP.unreflect(getterMethod);
- return new DirectGetterRouteContextExtractor(getterHandle);
- }
-
- @Override
- @SuppressWarnings("checkstyle:IllegalCatch")
- InstanceIdentifier<?> extract(final DataObject obj) {
- try {
- return (InstanceIdentifier<?>) handle.invokeExact(obj);
- } catch (Throwable e) {
- throw Throwables.propagate(e);
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.impl;
-
-import com.google.common.base.Throwables;
-import java.lang.invoke.MethodHandle;
-import java.lang.invoke.MethodHandles;
-import java.lang.invoke.MethodHandles.Lookup;
-import java.lang.invoke.MethodType;
-import java.lang.reflect.Method;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-@Deprecated(forRemoval = true)
-final class GetValueRouteContextExtractor extends ContextReferenceExtractor {
-
- private static final Lookup PUBLIC_LOOKUP = MethodHandles.publicLookup();
- private final MethodHandle contextHandle;
- private final MethodHandle valueHandle;
-
- private GetValueRouteContextExtractor(final MethodHandle rawContextHandle, final MethodHandle rawValueHandle) {
- contextHandle = rawContextHandle.asType(MethodType.methodType(Object.class, DataObject.class));
- valueHandle = rawValueHandle.asType(MethodType.methodType(InstanceIdentifier.class, Object.class));
- }
-
- public static ContextReferenceExtractor create(final Method contextGetter, final Method getValueMethod)
- throws IllegalAccessException {
- final MethodHandle rawContextHandle = PUBLIC_LOOKUP.unreflect(contextGetter);
- final MethodHandle rawValueHandle = PUBLIC_LOOKUP.unreflect(getValueMethod);
- return new GetValueRouteContextExtractor(rawContextHandle, rawValueHandle);
- }
-
- @Override
- @SuppressWarnings("checkstyle:IllegalCatch")
- InstanceIdentifier<?> extract(final DataObject obj) {
- try {
- final Object ctx = contextHandle.invokeExact(obj);
- if (ctx != null) {
- return (InstanceIdentifier<?>) valueHandle.invokeExact(ctx);
- }
- return null;
- } catch (Throwable e) {
- throw Throwables.propagate(e);
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.impl;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.base.Throwables;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.ListenableFuture;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Executor;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
-import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult;
-import org.opendaylight.mdsal.binding.dom.adapter.BindingRpcFutureAware;
-import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
-import org.opendaylight.yangtools.yang.binding.DataContainer;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-@Deprecated(forRemoval = true)
-final class LazyDOMRpcResultFuture implements CheckedFuture<DOMRpcResult, DOMRpcException>, BindingRpcFutureAware {
-
- private final ListenableFuture<RpcResult<?>> bindingFuture;
- private final BindingNormalizedNodeSerializer codec;
- private volatile DOMRpcResult result;
-
- private LazyDOMRpcResultFuture(final ListenableFuture<RpcResult<?>> delegate,
- final BindingNormalizedNodeSerializer codec) {
- this.bindingFuture = requireNonNull(delegate, "delegate");
- this.codec = requireNonNull(codec, "codec");
- }
-
- static CheckedFuture<DOMRpcResult, DOMRpcException> create(final BindingNormalizedNodeSerializer codec,
- final ListenableFuture<RpcResult<?>> bindingResult) {
- return new LazyDOMRpcResultFuture(bindingResult, codec);
- }
-
- @Override
- public ListenableFuture<RpcResult<?>> getBindingFuture() {
- return bindingFuture;
- }
-
- @Override
- public boolean cancel(final boolean mayInterruptIfRunning) {
- return bindingFuture.cancel(mayInterruptIfRunning);
- }
-
- @Override
- public void addListener(final Runnable listener, final Executor executor) {
- bindingFuture.addListener(listener, executor);
- }
-
- @Override
- public DOMRpcResult get() throws InterruptedException, ExecutionException {
- if (result != null) {
- return result;
- }
- return transformIfNecessary(bindingFuture.get());
- }
-
- @Override
- public DOMRpcResult get(final long timeout, final TimeUnit unit) throws InterruptedException, ExecutionException,
- TimeoutException {
- if (result != null) {
- return result;
- }
- return transformIfNecessary(bindingFuture.get(timeout, unit));
- }
-
- @Override
- public DOMRpcResult checkedGet() {
- try {
- return get();
- } catch (InterruptedException | ExecutionException e) {
- // FIXME: Add exception mapping
- throw Throwables.propagate(e);
- }
- }
-
- @Override
- public DOMRpcResult checkedGet(final long timeout, final TimeUnit unit) throws TimeoutException {
- try {
- return get(timeout, unit);
- } catch (InterruptedException | ExecutionException e) {
- // FIXME: Add exception mapping
- throw Throwables.propagate(e);
- }
- }
-
- @Override
- public boolean isCancelled() {
- return bindingFuture.isCancelled();
- }
-
- @Override
- public boolean isDone() {
- return bindingFuture.isDone();
- }
-
- private synchronized DOMRpcResult transformIfNecessary(final RpcResult<?> input) {
- if (result == null) {
- result = transform(input);
- }
- return result;
- }
-
- private DOMRpcResult transform(final RpcResult<?> input) {
- if (input.isSuccessful()) {
- final Object inputData = input.getResult();
- if (inputData instanceof DataContainer) {
- return new DefaultDOMRpcResult(codec.toNormalizedNodeRpcData((DataContainer) inputData));
- } else {
- return new DefaultDOMRpcResult((NormalizedNode<?, ?>) null);
- }
- }
- return new DefaultDOMRpcResult(input.getErrors());
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.impl;
-
-import static com.google.common.base.Verify.verify;
-import static java.util.Objects.requireNonNull;
-import static org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType.UNMODIFIED;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Optional;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
-import org.opendaylight.mdsal.binding.dom.adapter.BindingStructuralType;
-import org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTreeNode;
-import org.opendaylight.mdsal.binding.dom.codec.api.BindingDataObjectCodecTreeNode;
-import org.opendaylight.yangtools.yang.binding.Augmentation;
-import org.opendaylight.yangtools.yang.binding.ChildOf;
-import org.opendaylight.yangtools.yang.binding.ChoiceIn;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.Identifiable;
-import org.opendaylight.yangtools.yang.binding.Identifier;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.IdentifiableItem;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.Item;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Lazily translated {@link DataObjectModification} based on {@link DataTreeCandidateNode}.
- *
- * {@link LazyDataObjectModification} represents Data tree change event,
- * but whole tree is not translated or resolved eagerly, but only child nodes
- * which are directly accessed by user of data object modification.
- *
- * @param <T> Type of Binding Data Object
- */
-@Deprecated(forRemoval = true)
-final class LazyDataObjectModification<T extends DataObject> implements DataObjectModification<T> {
-
- private static final Logger LOG = LoggerFactory.getLogger(LazyDataObjectModification.class);
-
- private final BindingDataObjectCodecTreeNode<T> codec;
- private final DataTreeCandidateNode domData;
- private final PathArgument identifier;
-
- private volatile Collection<LazyDataObjectModification<? extends DataObject>> childNodesCache;
- private volatile ModificationType modificationType;
-
- private LazyDataObjectModification(final BindingDataObjectCodecTreeNode<T> codec,
- final DataTreeCandidateNode domData) {
- this.codec = requireNonNull(codec);
- this.domData = requireNonNull(domData);
- this.identifier = codec.deserializePathArgument(domData.getIdentifier());
- }
-
- static <T extends DataObject> LazyDataObjectModification<T> create(final BindingDataObjectCodecTreeNode<T> codec,
- final DataTreeCandidateNode domData) {
- return new LazyDataObjectModification<>(codec, domData);
- }
-
- private static Collection<LazyDataObjectModification<? extends DataObject>> from(
- final BindingDataObjectCodecTreeNode<?> parentCodec,
- final Collection<DataTreeCandidateNode> domChildNodes) {
- final List<LazyDataObjectModification<? extends DataObject>> result = new ArrayList<>(domChildNodes.size());
- populateList(result, parentCodec, domChildNodes);
- return result;
- }
-
- private static void populateList(final List<LazyDataObjectModification<? extends DataObject>> result,
- final BindingDataObjectCodecTreeNode<?> parentCodec,
- final Collection<DataTreeCandidateNode> domChildNodes) {
- for (final DataTreeCandidateNode domChildNode : domChildNodes) {
- if (domChildNode.getModificationType() != UNMODIFIED) {
- final BindingStructuralType type = BindingStructuralType.from(domChildNode);
- if (type != BindingStructuralType.NOT_ADDRESSABLE) {
- /*
- * Even if type is UNKNOWN, from perspective of BindingStructuralType
- * we try to load codec for it. We will use that type to further specify
- * debug log.
- */
- try {
- final BindingCodecTreeNode childCodec = parentCodec.yangPathArgumentChild(
- domChildNode.getIdentifier());
- verify(childCodec instanceof BindingDataObjectCodecTreeNode, "Unhandled codec %s for type %s",
- childCodec, type);
- populateList(result, type, (BindingDataObjectCodecTreeNode<?>) childCodec, domChildNode);
- } catch (final IllegalArgumentException e) {
- if (type == BindingStructuralType.UNKNOWN) {
- LOG.debug("Unable to deserialize unknown DOM node {}", domChildNode, e);
- } else {
- LOG.debug("Binding representation for DOM node {} was not found", domChildNode, e);
- }
- }
- }
- }
- }
- }
-
- private static void populateList(final List<LazyDataObjectModification<? extends DataObject>> result,
- final BindingStructuralType type, final BindingDataObjectCodecTreeNode<?> childCodec,
- final DataTreeCandidateNode domChildNode) {
- switch (type) {
- case INVISIBLE_LIST:
- // We use parent codec intentionally.
- populateListWithSingleCodec(result, childCodec, domChildNode.getChildNodes());
- break;
- case INVISIBLE_CONTAINER:
- populateList(result, childCodec, domChildNode.getChildNodes());
- break;
- case UNKNOWN:
- case VISIBLE_CONTAINER:
- result.add(create(childCodec, domChildNode));
- break;
- default:
- break;
- }
- }
-
- private static void populateListWithSingleCodec(final List<LazyDataObjectModification<? extends DataObject>> result,
- final BindingDataObjectCodecTreeNode<?> codec, final Collection<DataTreeCandidateNode> childNodes) {
- for (final DataTreeCandidateNode child : childNodes) {
- if (child.getModificationType() != UNMODIFIED) {
- result.add(create(codec, child));
- }
- }
- }
-
- @Override
- public T getDataBefore() {
- return deserialize(domData.getDataBefore());
- }
-
- @Override
- public T getDataAfter() {
- return deserialize(domData.getDataAfter());
- }
-
- @Override
- public Class<T> getDataType() {
- return codec.getBindingClass();
- }
-
- @Override
- public PathArgument getIdentifier() {
- return identifier;
- }
-
- @Override
- public ModificationType getModificationType() {
- ModificationType localType = modificationType;
- if (localType != null) {
- return localType;
- }
-
- switch (domData.getModificationType()) {
- case APPEARED:
- case WRITE:
- localType = ModificationType.WRITE;
- break;
- case DISAPPEARED:
- case DELETE:
- localType = ModificationType.DELETE;
- break;
- case SUBTREE_MODIFIED:
- localType = resolveSubtreeModificationType();
- break;
- default:
- // TODO: Should we lie about modification type instead of exception?
- throw new IllegalStateException("Unsupported DOM Modification type " + domData.getModificationType());
- }
-
- modificationType = localType;
- return localType;
- }
-
- private ModificationType resolveSubtreeModificationType() {
- switch (codec.getChildAddressabilitySummary()) {
- case ADDRESSABLE:
- // All children are addressable, it is safe to report SUBTREE_MODIFIED
- return ModificationType.SUBTREE_MODIFIED;
- case UNADDRESSABLE:
- // All children are non-addressable, report WRITE
- return ModificationType.WRITE;
- case MIXED:
- // This case is not completely trivial, as we may have NOT_ADDRESSABLE nodes underneath us. If that
- // is the case, we need to turn this modification into a WRITE operation, so that the user is able
- // to observe those nodes being introduced. This is not efficient, but unfortunately unavoidable,
- // as we cannot accurately represent such changes.
- for (DataTreeCandidateNode child : domData.getChildNodes()) {
- if (BindingStructuralType.recursiveFrom(child) == BindingStructuralType.NOT_ADDRESSABLE) {
- // We have a non-addressable child, turn this modification into a write
- return ModificationType.WRITE;
- }
- }
-
- // No unaddressable children found, proceed in addressed mode
- return ModificationType.SUBTREE_MODIFIED;
- default:
- throw new IllegalStateException("Unsupported child addressability summary "
- + codec.getChildAddressabilitySummary());
- }
- }
-
- @Override
- public Collection<LazyDataObjectModification<? extends DataObject>> getModifiedChildren() {
- Collection<LazyDataObjectModification<? extends DataObject>> local = childNodesCache;
- if (local == null) {
- childNodesCache = local = from(codec, domData.getChildNodes());
- }
- return local;
- }
-
- @Override
- public <H extends ChoiceIn<? super T> & DataObject, C extends ChildOf<? super H>>
- Collection<DataObjectModification<C>> getModifiedChildren(final Class<H> caseType,
- final Class<C> childType) {
- return streamModifiedChildren(childType)
- .filter(child -> caseType.equals(child.identifier.getCaseType().orElse(null)))
- .collect(Collectors.toList());
- }
-
- @SuppressWarnings("unchecked")
- private <C extends DataObject> Stream<LazyDataObjectModification<C>> streamModifiedChildren(
- final Class<C> childType) {
- return getModifiedChildren().stream()
- .filter(child -> childType.isAssignableFrom(child.getDataType()))
- .map(child -> (LazyDataObjectModification<C>) child);
- }
-
- @Override
- public DataObjectModification<? extends DataObject> getModifiedChild(final PathArgument arg) {
- final List<YangInstanceIdentifier.PathArgument> domArgumentList = new ArrayList<>();
- final BindingDataObjectCodecTreeNode<?> childCodec = codec.bindingPathArgumentChild(arg, domArgumentList);
- final Iterator<YangInstanceIdentifier.PathArgument> toEnter = domArgumentList.iterator();
- DataTreeCandidateNode current = domData;
- while (toEnter.hasNext() && current != null) {
- current = current.getModifiedChild(toEnter.next()).orElse(null);
- }
- return current != null && current.getModificationType() != UNMODIFIED ? create(childCodec, current) : null;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <C extends Identifiable<K> & ChildOf<? super T>, K extends Identifier<C>> DataObjectModification<C>
- getModifiedChildListItem(final Class<C> listItem, final K listKey) {
- return (DataObjectModification<C>) getModifiedChild(IdentifiableItem.of(listItem, listKey));
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <H extends ChoiceIn<? super T> & DataObject, C extends Identifiable<K> & ChildOf<? super H>,
- K extends Identifier<C>> DataObjectModification<C> getModifiedChildListItem(final Class<H> caseType,
- final Class<C> listItem, final K listKey) {
- return (DataObjectModification<C>) getModifiedChild(IdentifiableItem.of(caseType, listItem, listKey));
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <C extends ChildOf<? super T>> DataObjectModification<C> getModifiedChildContainer(final Class<C> child) {
- return (DataObjectModification<C>) getModifiedChild(Item.of(child));
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <H extends ChoiceIn<? super T> & DataObject, C extends ChildOf<? super H>> DataObjectModification<C>
- getModifiedChildContainer(final Class<H> caseType, final Class<C> child) {
- return (DataObjectModification<C>) getModifiedChild(Item.of(caseType, child));
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <C extends Augmentation<T> & DataObject> DataObjectModification<C> getModifiedAugmentation(
- final Class<C> augmentation) {
- return (DataObjectModification<C>) getModifiedChild(Item.of(augmentation));
- }
-
- private T deserialize(final Optional<NormalizedNode<?, ?>> dataAfter) {
- return dataAfter.map(codec::deserialize).orElse(null);
- }
-
- @Override
- public String toString() {
- return getClass().getSimpleName() + "{identifier = " + identifier + ", domData = " + domData + "}";
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.impl;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map.Entry;
-import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.mdsal.binding.dom.codec.api.BindingDataObjectCodecTreeNode;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
-
-/**
- * Lazily translated {@link DataTreeModification} based on {@link DataTreeCandidate}.
- *
- * {@link DataTreeModification} represents Data tree change event,
- * but whole tree is not translated or resolved eagerly, but only child nodes
- * which are directly accessed by user of data object modification.
- *
- */
-@Deprecated(forRemoval = true)
-class LazyDataTreeModification<T extends DataObject> implements DataTreeModification<T> {
-
- private final DataTreeIdentifier<T> path;
- private final DataObjectModification<T> rootNode;
-
- LazyDataTreeModification(final LogicalDatastoreType datastoreType, final InstanceIdentifier<T> path,
- final BindingDataObjectCodecTreeNode<T> codec, final DataTreeCandidate domChange) {
- this.path = new DataTreeIdentifier<>(datastoreType, path);
- this.rootNode = LazyDataObjectModification.create(codec, domChange.getRootNode());
- }
-
- @Override
- public DataObjectModification<T> getRootNode() {
- return rootNode;
- }
-
- @Override
- public DataTreeIdentifier<T> getRootPath() {
- return path;
- }
-
- @SuppressWarnings({"unchecked", "rawtypes"})
- static <T extends DataObject> DataTreeModification<T> create(final BindingToNormalizedNodeCodec codec,
- final DataTreeCandidate domChange, final LogicalDatastoreType datastoreType) {
- final Entry<InstanceIdentifier<?>, BindingDataObjectCodecTreeNode<?>> codecCtx =
- codec.getSubtreeCodec(domChange.getRootPath());
- return new LazyDataTreeModification(datastoreType, codecCtx.getKey(), codecCtx.getValue(), domChange);
- }
-
- static <T extends DataObject> Collection<DataTreeModification<T>> from(final BindingToNormalizedNodeCodec codec,
- final Collection<DataTreeCandidate> domChanges, final LogicalDatastoreType datastoreType) {
- final List<DataTreeModification<T>> result = new ArrayList<>(domChanges.size());
- for (final DataTreeCandidate domChange : domChanges) {
- result.add(LazyDataTreeModification.<T>create(codec, domChange, datastoreType));
- }
- return result;
- }
-
- @Override
- public String toString() {
- return getClass().getSimpleName() + "{path = " + path + ", rootNode = " + rootNode + "}";
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.impl;
-
-import java.util.Collection;
-import java.util.Optional;
-import org.opendaylight.mdsal.binding.dom.adapter.BindingDataAware;
-import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
-import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
-import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-
-// FIXME: Should be this moved to binding-data-codec?
-@Deprecated(forRemoval = true)
-class LazySerializedContainerNode implements ContainerNode, BindingDataAware {
-
- private final NodeIdentifier identifier;
- private final DataObject bindingData;
-
- private BindingNormalizedNodeSerializer registry;
- private ContainerNode domData;
-
- private LazySerializedContainerNode(final QName identifier, final DataObject binding,
- final BindingNormalizedNodeSerializer registry) {
- this.identifier = new NodeIdentifier(identifier);
- this.bindingData = binding;
- this.registry = registry;
- this.domData = null;
- }
-
- static NormalizedNode<?, ?> create(final SchemaPath rpcName, final DataObject data,
- final BindingNormalizedNodeSerializer codec) {
- return new LazySerializedContainerNode(rpcName.getLastComponent(), data, codec);
- }
-
- static NormalizedNode<?, ?> withContextRef(final SchemaPath rpcName, final DataObject data,
- final LeafNode<?> contextRef, final BindingNormalizedNodeSerializer codec) {
- return new WithContextRef(rpcName.getLastComponent(), data, contextRef, codec);
- }
-
- private ContainerNode delegate() {
- if (domData == null) {
- domData = registry.toNormalizedNodeRpcData(bindingData);
- registry = null;
- }
- return domData;
- }
-
- @Override
- public final QName getNodeType() {
- return identifier.getNodeType();
- }
-
- @Override
- public final Collection<DataContainerChild<? extends PathArgument, ?>> getValue() {
- return delegate().getValue();
- }
-
- @Override
- public final NodeIdentifier getIdentifier() {
- return identifier;
- }
-
- @Override
- public Optional<DataContainerChild<? extends PathArgument, ?>> getChild(final PathArgument child) {
- return delegate().getChild(child);
- }
-
- @Override
- public final DataObject bindingData() {
- return bindingData;
- }
-
- /**
- * Lazy Serialized Node with pre-cached serialized leaf holding routing information.
- *
- */
- private static final class WithContextRef extends LazySerializedContainerNode {
-
- private final LeafNode<?> contextRef;
-
- protected WithContextRef(final QName identifier, final DataObject binding, final LeafNode<?> contextRef,
- final BindingNormalizedNodeSerializer registry) {
- super(identifier, binding, registry);
- this.contextRef = contextRef;
- }
-
- @Override
- public Optional<DataContainerChild<? extends PathArgument, ?>> getChild(final PathArgument child) {
- /*
- * Use precached value of routing field and do not run full serialization if we are
- * accessing it.
- */
- if (contextRef.getIdentifier().equals(child)) {
- return Optional.<DataContainerChild<? extends PathArgument, ?>>of(contextRef);
- }
- return super.getChild(child);
- }
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.impl;
-
-import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
-import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
-import org.opendaylight.yangtools.yang.binding.Notification;
-import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-
-/**
- * Lazy serialized implementation of DOM Notification.
- *
- * <p>
- * This implementation performs serialization of data, only if receiver
- * of notification actually accessed data from notification.
- *
- */
-@Deprecated(forRemoval = true)
-public final class LazySerializedDOMNotification implements DOMNotification {
-
- private final BindingNormalizedNodeSerializer codec;
- private final Notification data;
- private final SchemaPath type;
-
- private ContainerNode domBody;
-
- private LazySerializedDOMNotification(final BindingNormalizedNodeSerializer codec, final Notification data,
- final SchemaPath type) {
- this.codec = codec;
- this.data = data;
- this.type = type;
- }
-
- static DOMNotification create(final BindingNormalizedNodeSerializer codec, final Notification data) {
- final SchemaPath type = SchemaPath.create(true, BindingReflections.findQName(data.implementedInterface()));
- return new LazySerializedDOMNotification(codec, data, type);
- }
-
- @Override
- public SchemaPath getType() {
- return type;
- }
-
- @Override
- public ContainerNode getBody() {
- if (domBody == null) {
- domBody = codec.toNormalizedNodeNotification(data);
- }
- return domBody;
- }
-
- public Notification getBindingData() {
- return data;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.impl;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.MoreExecutors;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.Collection;
-import java.util.Map.Entry;
-import java.util.concurrent.Future;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
-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.broker.spi.rpc.RpcRoutingStrategy;
-import org.opendaylight.controller.sal.core.compat.LegacyDOMRpcResultFutureAdapter;
-import org.opendaylight.mdsal.binding.dom.adapter.BindingRpcFutureAware;
-import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
-import org.opendaylight.yangtools.yang.binding.DataContainer;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.RpcError;
-import org.opendaylight.yangtools.yang.common.RpcError.ErrorSeverity;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-
-@Deprecated(forRemoval = true)
-class RpcServiceAdapter implements InvocationHandler {
-
- private final ImmutableMap<Method, RpcInvocationStrategy> rpcNames;
- private final Class<? extends RpcService> type;
- private final BindingToNormalizedNodeCodec codec;
- private final DOMRpcService delegate;
- private final RpcService proxy;
-
- RpcServiceAdapter(final Class<? extends RpcService> type, final BindingToNormalizedNodeCodec codec,
- final DOMRpcService domService) {
- this.type = requireNonNull(type);
- this.codec = requireNonNull(codec);
- this.delegate = requireNonNull(domService);
- final ImmutableMap.Builder<Method, RpcInvocationStrategy> rpcBuilder = ImmutableMap.builder();
- for (final Entry<Method, RpcDefinition> rpc : codec.getRpcMethodToSchema(type).entrySet()) {
- rpcBuilder.put(rpc.getKey(), createStrategy(rpc.getKey(), rpc.getValue()));
- }
- rpcNames = rpcBuilder.build();
- proxy = (RpcService) Proxy.newProxyInstance(type.getClassLoader(), new Class[] {type}, this);
- }
-
- ListenableFuture<RpcResult<?>> invoke0(final SchemaPath schemaPath, final NormalizedNode<?, ?> input) {
- final CheckedFuture<DOMRpcResult, DOMRpcException> result = delegate.invokeRpc(schemaPath, input);
- if (result instanceof BindingRpcFutureAware) {
- return ((BindingRpcFutureAware) result).getBindingFuture();
- } else if (result instanceof LegacyDOMRpcResultFutureAdapter) {
- Future<org.opendaylight.mdsal.dom.api.DOMRpcResult> delegateFuture =
- ((LegacyDOMRpcResultFutureAdapter)result).delegate();
- if (delegateFuture instanceof BindingRpcFutureAware) {
- return ((BindingRpcFutureAware) delegateFuture).getBindingFuture();
- }
- }
-
- return transformFuture(schemaPath, result, codec.getCodecFactory());
- }
-
- private RpcInvocationStrategy createStrategy(final Method method, final RpcDefinition schema) {
- final RpcRoutingStrategy strategy = RpcRoutingStrategy.from(schema);
- if (strategy.isContextBasedRouted()) {
- return new RoutedStrategy(schema.getPath(), method, strategy.getLeaf());
- }
- return new NonRoutedStrategy(schema.getPath());
- }
-
- RpcService getProxy() {
- return proxy;
- }
-
- @Override
- public Object invoke(final Object proxyObj, final Method method, final Object[] args) {
-
- final RpcInvocationStrategy rpc = rpcNames.get(method);
- if (rpc != null) {
- if (method.getParameterCount() == 0) {
- return rpc.invokeEmpty();
- }
- if (args.length != 1) {
- throw new IllegalArgumentException("Input must be provided.");
- }
- return rpc.invoke((DataObject) args[0]);
- }
-
- if (isObjectMethod(method)) {
- return callObjectMethod(proxyObj, method, args);
- }
- throw new UnsupportedOperationException("Method " + method.toString() + "is unsupported.");
- }
-
- private static boolean isObjectMethod(final Method method) {
- switch (method.getName()) {
- case "toString":
- return method.getReturnType().equals(String.class) && method.getParameterCount() == 0;
- case "hashCode":
- return method.getReturnType().equals(int.class) && method.getParameterCount() == 0;
- case "equals":
- return method.getReturnType().equals(boolean.class) && method.getParameterCount() == 1 && method
- .getParameterTypes()[0] == Object.class;
- default:
- return false;
- }
- }
-
- private Object callObjectMethod(final Object self, final Method method, final Object[] args) {
- switch (method.getName()) {
- case "toString":
- return type.getName() + "$Adapter{delegate=" + delegate.toString() + "}";
- case "hashCode":
- return System.identityHashCode(self);
- case "equals":
- return self == args[0];
- default:
- return null;
- }
- }
-
- private static ListenableFuture<RpcResult<?>> transformFuture(final SchemaPath rpc,
- final ListenableFuture<DOMRpcResult> domFuture, final BindingNormalizedNodeSerializer codec) {
- return Futures.transform(domFuture, input -> {
- final NormalizedNode<?, ?> domData = input.getResult();
- final DataObject bindingResult;
- if (domData != null) {
- final SchemaPath rpcOutput = rpc.createChild(QName.create(rpc.getLastComponent(), "output"));
- bindingResult = codec.fromNormalizedNodeRpcData(rpcOutput, (ContainerNode) domData);
- } else {
- bindingResult = null;
- }
-
- // DOMRpcResult does not have a notion of success, hence we have to reverse-engineer it by looking
- // at reported errors and checking whether they are just warnings.
- final Collection<? extends RpcError> errors = input.getErrors();
- return RpcResult.class.cast(RpcResultBuilder.status(errors.stream()
- .noneMatch(error -> error.getSeverity() == ErrorSeverity.ERROR))
- .withResult(bindingResult).withRpcErrors(errors).build());
- }, MoreExecutors.directExecutor());
- }
-
- private abstract class RpcInvocationStrategy {
-
- private final SchemaPath rpcName;
-
- protected RpcInvocationStrategy(final SchemaPath path) {
- rpcName = path;
- }
-
- final ListenableFuture<RpcResult<?>> invoke(final DataObject input) {
- return invoke0(rpcName, serialize(input));
- }
-
- abstract NormalizedNode<?, ?> serialize(DataObject input);
-
- final ListenableFuture<RpcResult<?>> invokeEmpty() {
- return invoke0(rpcName, null);
- }
-
- final SchemaPath getRpcName() {
- return rpcName;
- }
- }
-
- private final class NonRoutedStrategy extends RpcInvocationStrategy {
-
- protected NonRoutedStrategy(final SchemaPath path) {
- super(path);
- }
-
- @Override
- NormalizedNode<?, ?> serialize(final DataObject input) {
- return LazySerializedContainerNode.create(getRpcName(), input, codec.getCodecRegistry());
- }
- }
-
- private final class RoutedStrategy extends RpcInvocationStrategy {
-
- private final ContextReferenceExtractor refExtractor;
- private final NodeIdentifier contextName;
-
- protected RoutedStrategy(final SchemaPath path, final Method rpcMethod, final QName leafName) {
- super(path);
- final Class<? extends DataContainer> inputType = BindingReflections.resolveRpcInputClass(rpcMethod).get();
- refExtractor = ContextReferenceExtractor.from(inputType);
- this.contextName = new NodeIdentifier(leafName);
- }
-
- @Override
- NormalizedNode<?, ?> serialize(final DataObject input) {
- final InstanceIdentifier<?> bindingII = refExtractor.extract(input);
- if (bindingII != null) {
- final YangInstanceIdentifier yangII = codec.toYangInstanceIdentifierCached(bindingII);
- final LeafNode<?> contextRef = ImmutableNodes.leafNode(contextName, yangII);
- return LazySerializedContainerNode.withContextRef(getRpcName(), input, contextRef,
- codec.getCodecRegistry());
- }
- return LazySerializedContainerNode.create(getRpcName(), input, codec.getCodecRegistry());
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.spi;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ClassToInstanceMap;
-import com.google.common.collect.ImmutableClassToInstanceMap;
-import com.google.common.collect.MutableClassToInstanceMap;
-import java.util.Set;
-import org.opendaylight.yangtools.concepts.Builder;
-
-@Deprecated(forRemoval = true)
-public abstract class AdapterBuilder<T,D> implements Builder<T> {
-
- private final ClassToInstanceMap<D> delegates = MutableClassToInstanceMap.create();
-
- public abstract Set<? extends Class<? extends D>> getRequiredDelegates();
-
- protected abstract T createInstance(ClassToInstanceMap<D> classToInstanceMap);
-
- private void checkAllRequiredServices() {
- for (final Class<? extends D> type : getRequiredDelegates()) {
- Preconditions.checkState(delegates.get(type) != null, "Requires service %s is not defined.",type);
- }
- }
-
- public final <V extends D> void addDelegate(final Class<V> type,final D impl) {
- delegates.put(type,impl);
- }
-
- @Override
- public final T build() {
- checkAllRequiredServices();
- return createInstance(ImmutableClassToInstanceMap.<D,D>copyOf(delegates));
- }
-}
+++ /dev/null
-/*
- * 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.md.sal.binding.spi;
-
-import com.google.common.annotations.Beta;
-import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-
-@Beta
-@Deprecated(forRemoval = true)
-@NonNullByDefault
-public interface AdapterFactory {
- /**
- * Return a {@link DataBroker} implementation backed by the specified {@link DOMDataBroker}.
- *
- * @param domBroker Backing DOMDataBroker
- * @return A DataBroker instance.
- * @throws NullPointerException if {@code domBroker} is null.
- */
- DataBroker createDataBroker(DOMDataBroker domBroker);
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.spi;
-
-import com.google.common.base.Optional;
-import com.google.common.cache.CacheLoader;
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.Nullable;
-import org.gaul.modernizer_maven_annotations.SuppressModernizer;
-
-@Deprecated(forRemoval = true)
-public abstract class AdapterLoader<T, D> extends CacheLoader<Class<? extends T>, Optional<T>> {
-
- @Override
- @SuppressModernizer
- public Optional<T> load(final Class<? extends T> key) {
-
- final AdapterBuilder<? extends T, D> builder = createBuilder(key);
- for (final Class<? extends D> reqDeleg : builder.getRequiredDelegates()) {
- final D deleg = getDelegate(reqDeleg);
- if (deleg != null) {
- builder.addDelegate(reqDeleg, deleg);
- } else {
- return Optional.absent();
- }
- }
- return Optional.<T>of(builder.build());
- }
-
- protected abstract @Nullable D getDelegate(Class<? extends D> reqDeleg);
-
- protected abstract @NonNull AdapterBuilder<? extends T, D> createBuilder(Class<? extends T> key);
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.binding.impl;
-
-import static com.google.common.base.Preconditions.checkState;
-
-import com.google.common.collect.ImmutableClassToInstanceMap;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.MountPointService;
-import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
-import org.opendaylight.controller.md.sal.binding.util.AbstractBindingSalProviderInstance;
-import org.opendaylight.controller.md.sal.binding.util.BindingContextUtils;
-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.NotificationProviderService;
-import org.opendaylight.controller.sal.binding.api.NotificationService;
-import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
-import org.opendaylight.yangtools.concepts.Identifiable;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.concepts.Mutable;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-import org.osgi.framework.BundleContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Deprecated(forRemoval = true)
-public class RootBindingAwareBroker implements Mutable, Identifiable<String>, BindingAwareBroker, AutoCloseable,
- RpcProviderRegistry {
-
- private static final Logger LOG = LoggerFactory.getLogger(RootBindingAwareBroker.class);
-
- RootSalInstance controllerRoot;
-
- private final String identifier;
-
- private RpcProviderRegistry rpcBroker;
-
- private NotificationProviderService notificationBroker;
-
- private NotificationPublishService notificationPublishService;
-
- private DataBroker dataBroker;
-
- private ImmutableClassToInstanceMap<BindingAwareService> supportedConsumerServices;
-
- private ImmutableClassToInstanceMap<BindingAwareService> supportedProviderServices;
-
- private MountPointService mountService;
-
- public RootBindingAwareBroker(final String instanceName) {
- this.identifier = instanceName;
- }
-
- @Override
- public String getIdentifier() {
- return identifier;
- }
-
- public RootSalInstance getRoot() {
- return controllerRoot;
- }
-
- public NotificationProviderService getNotificationBroker() {
- return this.notificationBroker;
- }
-
- public NotificationPublishService getNotificationPublishService() {
- return this.notificationPublishService;
- }
-
- public RpcProviderRegistry getRpcProviderRegistry() {
- return this.rpcBroker;
- }
-
- public RpcProviderRegistry getRpcBroker() {
- return rpcBroker;
- }
-
- public MountPointService getMountService() {
- return mountService;
- }
-
- public void setDataBroker(final DataBroker asyncDataBroker) {
- dataBroker = asyncDataBroker;
- }
-
- public void setMountService(final MountPointService mount) {
- this.mountService = mount;
- }
-
- public void setRpcBroker(final RpcProviderRegistry rpcBroker) {
- this.rpcBroker = rpcBroker;
- }
-
- public void setNotificationBroker(final NotificationProviderService notificationBroker) {
- this.notificationBroker = notificationBroker;
- }
-
- public void setNotificationPublishService(final NotificationPublishService notificationPublishService) {
- this.notificationPublishService = notificationPublishService;
- }
-
- public void start() {
- checkState(controllerRoot == null, "Binding Aware Broker was already started.");
- LOG.info("Starting Binding Aware Broker: {}", identifier);
-
- controllerRoot = new RootSalInstance(getRpcProviderRegistry(), getNotificationBroker());
-
- final ImmutableClassToInstanceMap.Builder<BindingAwareService> consBuilder = ImmutableClassToInstanceMap
- .builder();
-
- consBuilder.put(NotificationService.class, getRoot());
- consBuilder.put(RpcConsumerRegistry.class, getRoot());
- if (dataBroker != null) {
- consBuilder.put(DataBroker.class, dataBroker);
- }
- consBuilder.put(MountPointService.class, mountService);
-
- supportedConsumerServices = consBuilder.build();
- final ImmutableClassToInstanceMap.Builder<BindingAwareService> provBuilder = ImmutableClassToInstanceMap
- .builder();
- provBuilder.putAll(supportedConsumerServices).put(NotificationProviderService.class, getRoot())
- .put(RpcProviderRegistry.class, getRoot());
- if (notificationPublishService != null) {
- provBuilder.put(NotificationPublishService.class, notificationPublishService);
- }
-
- supportedProviderServices = provBuilder.build();
- }
-
- @Override
- public ConsumerContext registerConsumer(final BindingAwareConsumer consumer, final BundleContext ctx) {
- return registerConsumer(consumer);
- }
-
- @Override
- public ConsumerContext registerConsumer(final BindingAwareConsumer consumer) {
- checkState(supportedConsumerServices != null, "Broker is not initialized.");
- return BindingContextUtils.createConsumerContextAndInitialize(consumer, supportedConsumerServices);
- }
-
- @Override
- public ProviderContext registerProvider(final BindingAwareProvider provider, final BundleContext ctx) {
- return registerProvider(provider);
- }
-
- @Override
- public ProviderContext registerProvider(final BindingAwareProvider provider) {
- checkState(supportedProviderServices != null, "Broker is not initialized.");
- return BindingContextUtils.createProviderContextAndInitialize(provider, supportedProviderServices);
- }
-
- @Override
- public void close() {
- // FIXME: Close all sessions
- }
-
- @Override
- public <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(final Class<T> type,
- final T implementation) throws IllegalStateException {
- return getRoot().addRoutedRpcImplementation(type, implementation);
- }
-
- @Override
- public <T extends RpcService> RpcRegistration<T> addRpcImplementation(final Class<T> type, final T implementation)
- throws IllegalStateException {
- return getRoot().addRpcImplementation(type, implementation);
- }
-
- @Override
- public <T extends RpcService> T getRpcService(final Class<T> module) {
- return getRoot().getRpcService(module);
- }
-
- @Override
- public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L>
- registerRouteChangeListener(final L listener) {
- return getRoot().registerRouteChangeListener(listener);
- }
-
- public static class RootSalInstance extends
- AbstractBindingSalProviderInstance<NotificationProviderService, RpcProviderRegistry> {
-
- public RootSalInstance(final RpcProviderRegistry rpcRegistry,
- final NotificationProviderService notificationBroker) {
- super(rpcRegistry, notificationBroker);
- }
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0">
-
- <reference id="classLoadingStrategy" interface="org.opendaylight.mdsal.binding.generator.api.ClassLoadingStrategy" />
- <reference id="schemaService" interface="org.opendaylight.mdsal.dom.api.DOMSchemaService" />
- <reference id="domRpcService" interface="org.opendaylight.controller.md.sal.dom.api.DOMRpcService"/>
- <reference id="domRpcRegistry" interface="org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService"/>
- <reference id="domMountPointService" interface="org.opendaylight.controller.md.sal.dom.api.DOMMountPointService"/>
- <reference id="domNotificationService" interface="org.opendaylight.controller.md.sal.dom.api.DOMNotificationService"/>
- <reference id="domNotificationPublishService" interface="org.opendaylight.controller.md.sal.dom.api.DOMNotificationPublishService"/>
- <reference id="domNotificationListenerRegistry" interface="org.opendaylight.controller.md.sal.dom.spi.DOMNotificationSubscriptionListenerRegistry"/>
- <reference id="domDefaultDataBroker" interface="org.opendaylight.controller.md.sal.dom.api.DOMDataBroker"
- odl:type="default"/>
- <reference id="domPingPongDataBroker" interface="org.opendaylight.controller.md.sal.dom.api.DOMDataBroker"
- odl:type="pingpong"/>
-
- <bean id="wiring" class="org.opendaylight.controller.md.sal.binding.impl.BindingBrokerWiring">
- <argument ref="classLoadingStrategy"/>
- <argument ref="schemaService"/>
- <argument ref="domRpcService"/>
- <argument ref="domRpcRegistry"/>
- <argument ref="domMountPointService"/>
- <argument ref="domNotificationService"/>
- <argument ref="domNotificationPublishService"/>
- <argument ref="domNotificationListenerRegistry"/>
- <argument ref="domDefaultDataBroker"/>
- <argument ref="domPingPongDataBroker"/>
- </bean>
-
- <!-- Runtime binding/normalized mapping service -->
-
- <bean id="mappingCodec" factory-ref="wiring" factory-method="getBindingToNormalizedNodeCodec" />
-
- <service ref="mappingCodec" odl:type="default">
- <interfaces>
- <value>org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer</value>
- <value>org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTreeFactory</value>
- </interfaces>
- </service>
-
- <!-- Adapter service -->
- <bean id="adapterFactory" factory-ref="wiring" factory-method="getAdapterFactory" />
-
- <service id="factory" ref="adapterFactory">
- <interfaces>
- <value>org.opendaylight.controller.md.sal.binding.spi.AdapterFactory</value>
- </interfaces>
- </service>
-
- <!-- Binding RPC Registry Service -->
-
- <bean id="bindingRpcRegistry" factory-ref="wiring" factory-method="getRpcProviderRegistry" />
-
- <service ref="bindingRpcRegistry" interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry"
- odl:type="default"/>
-
- <!-- Binding MountPoint Service -->
-
- <bean id="bindingMountPointService" factory-ref="wiring" factory-method="getMountPointService" />
-
- <service ref="bindingMountPointService" interface="org.opendaylight.controller.md.sal.binding.api.MountPointService"
- odl:type="default"/>
-
- <!-- Binding Notification Service -->
-
- <bean id="bindingNotificationServiceAdapter" factory-ref="wiring" factory-method="getNotificationService" />
- <service ref="bindingNotificationServiceAdapter" interface="org.opendaylight.controller.md.sal.binding.api.NotificationService"
- odl:type="default"/>
-
- <bean id="bindingNotificationPublishAdapter" factory-ref="wiring" factory-method="getNotificationPublishService" />
- <service ref="bindingNotificationPublishAdapter" interface="org.opendaylight.controller.md.sal.binding.api.NotificationPublishService"
- odl:type="default"/>
-
- <bean id="notificationProviderService" factory-ref="wiring" factory-method="getNotificationProviderService" />
- <service ref="notificationProviderService" interface="org.opendaylight.controller.sal.binding.api.NotificationProviderService" odl:type="default" />
-
- <bean id="deprecatedNotificationService" factory-ref="wiring" factory-method="getNotificationProviderService" />
- <service ref="deprecatedNotificationService" interface="org.opendaylight.controller.sal.binding.api.NotificationService" odl:type="default" />
-
- <!-- Binding DataBroker -->
-
- <bean id="bindingDataBroker" factory-ref="wiring" factory-method="getDataBroker" />
-
- <service ref="bindingDataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
- odl:type="default"/>
-
- <!-- Binding PingPong DataBroker -->
-
- <bean id="bindingPingPongDataBroker" factory-ref="wiring" factory-method="getPingPongDataBroker" />
-
- <service ref="bindingPingPongDataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
- odl:type="pingpong"/>
-
- <!-- Legacy BindingAwareBroker -->
-
- <bean id="bindingNotificationProviderService" class="org.opendaylight.controller.md.sal.binding.compat.HeliumNotificationProviderServiceWithInterestListeners">
- <argument ref="bindingNotificationPublishAdapter"/>
- <argument ref="bindingNotificationServiceAdapter"/>
- <argument ref="domNotificationListenerRegistry"/>
- </bean>
-
- <bean id="bindingAwareBroker" class="org.opendaylight.controller.sal.binding.impl.RootBindingAwareBroker"
- init-method="start" destroy-method="close">
- <argument value="deprecated-BindingAwareBroker"/>
- <property name="dataBroker" ref="bindingDataBroker"/>
- <property name="mountService" ref="bindingMountPointService"/>
- <property name="rpcBroker" ref="bindingRpcRegistry"/>
- <property name="notificationBroker" ref="bindingNotificationProviderService"/>
- <property name="notificationPublishService" ref="bindingNotificationPublishAdapter"/>
- </bean>
-
- <service ref="bindingAwareBroker" interface="org.opendaylight.controller.sal.binding.api.BindingAwareBroker"/>
-</blueprint>
+++ /dev/null
-/*
- * Copyright (c) 2015 Brocade Communications Systems, Inc. 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.md.sal.binding.impl;
-
-import static org.mockito.AdditionalMatchers.not;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.isA;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.reset;
-import static org.mockito.Mockito.verify;
-
-import java.util.Collection;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.ArgumentMatchers;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeService;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-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.mdsal.binding.dom.codec.impl.BindingNormalizedNodeCodecRegistry;
-import org.opendaylight.mdsal.binding.generator.impl.GeneratedClassLoadingStrategy;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-
-/**
- * Unit tests for BindingDOMDataTreeChangeServiceAdapter.
- *
- * @author Thomas Pantelis
- */
-@Deprecated
-public class BindingDOMDataTreeChangeServiceAdapterTest {
- private static final InstanceIdentifier<Top> TOP_PATH = InstanceIdentifier.create(Top.class);
-
- @Mock
- private DOMDataTreeChangeService mockDOMService;
-
- @Mock
- private GeneratedClassLoadingStrategy classLoadingStrategy;
-
- @Mock
- private BindingNormalizedNodeCodecRegistry codecRegistry;
-
- @Mock
- private YangInstanceIdentifier mockYangID;
-
- @SuppressWarnings("rawtypes")
- @Mock
- private ListenerRegistration mockDOMReg;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- doReturn(this.mockYangID).when(this.codecRegistry).toYangInstanceIdentifier(TOP_PATH);
- }
-
- @Test
- public void testRegisterDataTreeChangeListener() {
- final BindingToNormalizedNodeCodec codec =
- new BindingToNormalizedNodeCodec(this.classLoadingStrategy, this.codecRegistry);
-
- final DataTreeChangeService service = BindingDOMDataTreeChangeServiceAdapter.create(codec, this.mockDOMService);
-
- doReturn(this.mockDOMReg).when(this.mockDOMService).registerDataTreeChangeListener(
- domDataTreeIdentifier(this.mockYangID),
- any(DOMDataTreeChangeListener.class));
- final DataTreeIdentifier<Top> treeId = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, TOP_PATH);
- final TestClusteredDataTreeChangeListener mockClusteredListener = new TestClusteredDataTreeChangeListener();
- service.registerDataTreeChangeListener(treeId , mockClusteredListener);
-
- verify(this.mockDOMService).registerDataTreeChangeListener(domDataTreeIdentifier(this.mockYangID),
- isA(ClusteredDOMDataTreeChangeListener.class));
-
- reset(this.mockDOMService);
- doReturn(this.mockDOMReg).when(this.mockDOMService).registerDataTreeChangeListener(
- domDataTreeIdentifier(this.mockYangID), any(DOMDataTreeChangeListener.class));
- final TestDataTreeChangeListener mockNonClusteredListener = new TestDataTreeChangeListener();
- service.registerDataTreeChangeListener(treeId , mockNonClusteredListener);
-
- verify(this.mockDOMService).registerDataTreeChangeListener(domDataTreeIdentifier(this.mockYangID),
- not(isA(ClusteredDOMDataTreeChangeListener.class)));
- }
-
- static DOMDataTreeIdentifier domDataTreeIdentifier(final YangInstanceIdentifier yangID) {
- return ArgumentMatchers.argThat(treeId -> treeId.getDatastoreType() == LogicalDatastoreType.CONFIGURATION
- && yangID.equals(treeId.getRootIdentifier()));
- }
-
- @Deprecated
- private static class TestClusteredDataTreeChangeListener implements ClusteredDataTreeChangeListener<Top> {
- @Override
- public void onDataTreeChanged(final Collection<DataTreeModification<Top>> changes) {
- }
- }
-
- @Deprecated
- private static class TestDataTreeChangeListener implements DataTreeChangeListener<Top> {
- @Override
- public void onDataTreeChanged(final Collection<DataTreeModification<Top>> changes) {
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2019 FRINX 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.md.sal.binding.impl;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-
-import com.google.common.base.Optional;
-import com.google.common.cache.LoadingCache;
-import org.gaul.modernizer_maven_annotations.SuppressModernizer;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
-import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
-import org.opendaylight.mdsal.binding.dom.codec.impl.BindingNormalizedNodeCodecRegistry;
-import org.opendaylight.mdsal.binding.generator.api.ClassLoadingStrategy;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-
-@Deprecated
-public class BindingDOMMountPointServiceAdapterTest {
-
- @Mock
- private DOMMountPointService mountService;
- // Use a real instance of codec, since its getCodecRegistry() method is final and cannot be mocked
- private BindingToNormalizedNodeCodec codec;
- @Mock
- private BindingNormalizedNodeCodecRegistry codecRegistry;
- @Mock
- private ClassLoadingStrategy classLoadingStrategy;
-
- @Before
- @SuppressModernizer
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- codec = spy(new BindingToNormalizedNodeCodec(classLoadingStrategy, codecRegistry));
- doReturn(Optional.of(mock(DOMMountPoint.class)))
- .when(mountService).getMountPoint(any(YangInstanceIdentifier.class));
- doReturn(YangInstanceIdentifier.create(new YangInstanceIdentifier.NodeIdentifier(QName.create("(a)b"))))
- .when(codec).toYangInstanceIdentifierBlocking(any(InstanceIdentifier.class));
- doReturn(InstanceIdentifier.create(DataObject.class))
- .when(codecRegistry).fromYangInstanceIdentifier(any(YangInstanceIdentifier.class));
- }
-
- @Test(timeout = 30 * 1000)
- public void testCaching() throws Exception {
- BindingDOMMountPointServiceAdapter baService = new BindingDOMMountPointServiceAdapter(mountService, codec);
- LoadingCache<DOMMountPoint, BindingMountPointAdapter> cache = baService.bindingMountpoints;
-
- baService.getMountPoint(InstanceIdentifier.create(DataObject.class));
-
- while (true) {
- cache.cleanUp();
- System.gc();
- Thread.sleep(100);
- if (cache.asMap().keySet().size() == 0) {
- // Cache has been cleared, the single cache entry was garbage collected
- return;
- }
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2014, 2015 Cisco Systems, Inc. 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.md.sal.binding.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import com.google.common.collect.ImmutableBiMap;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.ImmutableSetMultimap;
-import com.google.common.collect.SetMultimap;
-import com.google.common.util.concurrent.Uninterruptibles;
-import java.lang.reflect.Method;
-import java.net.URI;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicReference;
-import org.junit.Test;
-import org.opendaylight.controller.md.sal.binding.test.AbstractSchemaAwareTest;
-import org.opendaylight.mdsal.binding.dom.codec.impl.BindingNormalizedNodeCodecRegistry;
-import org.opendaylight.mdsal.binding.generator.impl.GeneratedClassLoadingStrategy;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeLeafOnlyAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.rpcservice.rev140701.OpendaylightTestRpcServiceService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
-import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.opendaylight.yangtools.yang.model.util.AbstractSchemaContext;
-
-@Deprecated
-public class BindingNormalizedCodecTest extends AbstractSchemaAwareTest {
-
- private static final TopLevelListKey TOP_FOO_KEY = new TopLevelListKey("foo");
- private static final InstanceIdentifier<TopLevelList> BA_TOP_LEVEL_LIST = InstanceIdentifier
- .builder(Top.class).child(TopLevelList.class, TOP_FOO_KEY).build();
- private static final InstanceIdentifier<TreeLeafOnlyAugment> BA_TREE_LEAF_ONLY =
- BA_TOP_LEVEL_LIST.augmentation(TreeLeafOnlyAugment.class);
- private static final InstanceIdentifier<TreeComplexUsesAugment> BA_TREE_COMPLEX_USES =
- BA_TOP_LEVEL_LIST.augmentation(TreeComplexUsesAugment.class);
- private static final QName SIMPLE_VALUE_QNAME = QName.create(TreeComplexUsesAugment.QNAME, "simple-value");
- private static final QName NAME_QNAME = QName.create(Top.QNAME, "name");
- private static final YangInstanceIdentifier BI_TOP_LEVEL_LIST = YangInstanceIdentifier.builder()
- .node(Top.QNAME).node(TopLevelList.QNAME).nodeWithKey(
- TopLevelList.QNAME, NAME_QNAME, TOP_FOO_KEY.getName()).build();
-
-
- private BindingToNormalizedNodeCodec codec;
- private SchemaContext context;
-
- @Override
- protected void setupWithSchema(final SchemaContext schemaContext) {
- this.context = schemaContext;
- final BindingNormalizedNodeCodecRegistry registry = new BindingNormalizedNodeCodecRegistry();
- this.codec = new BindingToNormalizedNodeCodec(GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(),
- registry, true);
- }
-
- @Test
- public void testComplexAugmentationSerialization() {
- this.codec.onGlobalContextUpdated(this.context);
- final PathArgument lastArg = this.codec.toYangInstanceIdentifier(BA_TREE_COMPLEX_USES).getLastPathArgument();
- assertTrue(lastArg instanceof AugmentationIdentifier);
- }
-
-
- @Test
- public void testLeafOnlyAugmentationSerialization() {
- this.codec.onGlobalContextUpdated(this.context);
- final PathArgument leafOnlyLastArg = this.codec.toYangInstanceIdentifier(BA_TREE_LEAF_ONLY)
- .getLastPathArgument();
- assertTrue(leafOnlyLastArg instanceof AugmentationIdentifier);
- assertTrue(((AugmentationIdentifier) leafOnlyLastArg).getPossibleChildNames().contains(SIMPLE_VALUE_QNAME));
- }
-
- @Test
- @SuppressWarnings("checkstyle:IllegalCatch")
- public void testToYangInstanceIdentifierBlocking() {
- this.codec.onGlobalContextUpdated(new EmptySchemaContext());
-
- final CountDownLatch done = new CountDownLatch(1);
- final AtomicReference<YangInstanceIdentifier> yangId = new AtomicReference<>();
- final AtomicReference<RuntimeException> error = new AtomicReference<>();
-
- new Thread(() -> {
- try {
- yangId.set(BindingNormalizedCodecTest.this.codec.toYangInstanceIdentifierBlocking(BA_TOP_LEVEL_LIST));
- } catch (RuntimeException e) {
- error.set(e);
- } finally {
- done.countDown();
- }
- }).start();
-
- Uninterruptibles.sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
- this.codec.onGlobalContextUpdated(this.context);
-
- assertEquals("toYangInstanceIdentifierBlocking completed", true,
- Uninterruptibles.awaitUninterruptibly(done, 3, TimeUnit.SECONDS));
- if (error.get() != null) {
- throw error.get();
- }
-
- assertEquals("toYangInstanceIdentifierBlocking", BI_TOP_LEVEL_LIST, yangId.get());
- }
-
- @Test
- public void testGetRpcMethodToSchemaPathWithNoInitialSchemaContext() {
- testGetRpcMethodToSchemaPath();
- }
-
- @Test
- public void testGetRpcMethodToSchemaPathBlocking() {
- this.codec.onGlobalContextUpdated(new EmptySchemaContext());
- testGetRpcMethodToSchemaPath();
- }
-
- @SuppressWarnings("checkstyle:IllegalCatch")
- private void testGetRpcMethodToSchemaPath() {
- final CountDownLatch done = new CountDownLatch(1);
- final AtomicReference<ImmutableBiMap<Method, SchemaPath>> retMap = new AtomicReference<>();
- final AtomicReference<RuntimeException> error = new AtomicReference<>();
- new Thread(() -> {
- try {
- retMap.set(BindingNormalizedCodecTest.this.codec.getRpcMethodToSchemaPath(
- OpendaylightTestRpcServiceService.class));
- } catch (RuntimeException e) {
- error.set(e);
- } finally {
- done.countDown();
- }
- }).start();
-
- Uninterruptibles.sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
- this.codec.onGlobalContextUpdated(this.context);
-
- assertEquals("getRpcMethodToSchemaPath completed", true,
- Uninterruptibles.awaitUninterruptibly(done, 3, TimeUnit.SECONDS));
- if (error.get() != null) {
- throw error.get();
- }
-
- for (final Method method: retMap.get().keySet()) {
- if (method.getName().equals("rockTheHouse")) {
- return;
- }
- }
-
- fail("rockTheHouse RPC method not found");
- }
-
- static class EmptySchemaContext extends AbstractSchemaContext {
- @Override
- public Set<Module> getModules() {
- return ImmutableSet.of();
- }
-
- @Override
- protected Map<QNameModule, Module> getModuleMap() {
- return ImmutableMap.of();
- }
-
- @Override
- protected SetMultimap<URI, Module> getNamespaceToModules() {
- return ImmutableSetMultimap.of();
- }
-
- @Override
- protected SetMultimap<String, Module> getNameToModules() {
- return ImmutableSetMultimap.of();
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.impl;
-
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-
-import org.junit.Test;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.rpcservice.rev140701.RockTheHouseInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.rpcservice.rev140701.RockTheHouseInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.EncapsulatedRoute;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.EncapsulatedRouteInGrouping;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.RoutedSimpleRouteInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.RoutedSimpleRouteInputBuilder;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-@Deprecated
-public final class ContextExtractorTest {
-
- public interface Transitive extends EncapsulatedRouteInGrouping {
-
- }
-
- private static final InstanceIdentifier<?> TEST_ROUTE = InstanceIdentifier.create(Top.class);
- private static final Transitive TEST_GROUPING = new Transitive() {
-
- @Override
- public Class<? extends Transitive> implementedInterface() {
- return Transitive.class;
- }
-
- @Override
- public EncapsulatedRoute getRoute() {
- return new EncapsulatedRoute(TEST_ROUTE);
- }
- };
-
- @Test
- public void testNonRoutedExtraction() {
- final ContextReferenceExtractor extractor = ContextReferenceExtractor.from(RockTheHouseInput.class);
- final RockTheHouseInput input = new RockTheHouseInputBuilder().build();
- final InstanceIdentifier<?> extractedValue = extractor.extract(input);
- assertNull(extractedValue);
- }
-
- @Test
- public void testRoutedSimpleExtraction() {
- final ContextReferenceExtractor extractor = ContextReferenceExtractor.from(RoutedSimpleRouteInput.class);
- final RoutedSimpleRouteInput input = new RoutedSimpleRouteInputBuilder().setRoute(TEST_ROUTE).build();
- final InstanceIdentifier<?> extractedValue = extractor.extract(input);
- assertSame(TEST_ROUTE,extractedValue);
- }
-
- @Test
- public void testRoutedEncapsulatedExtraction() {
- final ContextReferenceExtractor extractor = ContextReferenceExtractor.from(EncapsulatedRouteInGrouping.class);
- final InstanceIdentifier<?> extractedValue = extractor.extract(TEST_GROUPING);
- assertSame(TEST_ROUTE,extractedValue);
-
- }
-
- @Test
- public void testRoutedEncapsulatedTransitiveExtraction() {
- final ContextReferenceExtractor extractor = ContextReferenceExtractor.from(Transitive.class);
- final InstanceIdentifier<?> extractedValue = extractor.extract(TEST_GROUPING);
- assertSame(TEST_ROUTE,extractedValue);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.impl.test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import com.google.common.collect.ImmutableList;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
-import org.opendaylight.controller.md.sal.binding.api.NotificationService;
-import org.opendaylight.controller.md.sal.binding.compat.HeliumNotificationProviderServiceAdapter;
-import org.opendaylight.controller.md.sal.binding.test.AbstractNotificationBrokerTest;
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.OpendaylightMdsalListTestListener;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TwoLevelListChanged;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TwoLevelListChangedBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.NotificationListener;
-
-@Deprecated
-public class BackwardsCompatibleNotificationBrokerTest extends AbstractNotificationBrokerTest {
-
- private NotificationProviderService notificationProviderService;
-
- @Before
- public void initTest() {
- final NotificationService notificationService = getNotificationService();
- final NotificationPublishService notificationPublishService = getNotificationPublishService();
- notificationProviderService = new HeliumNotificationProviderServiceAdapter(notificationPublishService,
- notificationService);
- }
-
- private static TwoLevelListChanged createTestData() {
- final TwoLevelListChangedBuilder tb = new TwoLevelListChangedBuilder();
- tb.setTopLevelList(ImmutableList.of(new TopLevelListBuilder().withKey(new TopLevelListKey("test")).build()));
- return tb.build();
- }
-
- @Test
- public void testNotifSubscriptionForwarded() throws InterruptedException {
- final CountDownLatch latch = new CountDownLatch(1);
- final TwoLevelListChanged testData = createTestData();
-
- final NotifTestListenerChild testNotifListener = new NotifTestListenerChild(latch);
- final ListenerRegistration<NotificationListener> listenerRegistration =
- notificationProviderService.registerNotificationListener(testNotifListener);
- notificationProviderService.publish(testData);
-
- latch.await(500L, TimeUnit.MILLISECONDS);
- assertTrue(testNotifListener.getReceivedNotifications().size() == 1);
- assertEquals(testData, testNotifListener.getReceivedNotifications().get(0));
- listenerRegistration.close();
- }
-
- private static class NotifTestListenerChild extends NotifTestListener {
-
- NotifTestListenerChild(final CountDownLatch latch) {
- super(latch);
- }
- }
-
- private static class NotifTestListener implements OpendaylightMdsalListTestListener {
- private final List<TwoLevelListChanged> receivedNotifications = new ArrayList<>();
- private final CountDownLatch latch;
-
- NotifTestListener(final CountDownLatch latch) {
- this.latch = latch;
- }
-
- @Override
- public void onTwoLevelListChanged(final TwoLevelListChanged notification) {
- receivedNotifications.add(notification);
- latch.countDown();
- }
-
- public List<TwoLevelListChanged> getReceivedNotifications() {
- return receivedNotifications;
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.impl.test;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.verify;
-
-import com.google.common.collect.ImmutableMap;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
-import org.opendaylight.controller.md.sal.binding.impl.BindingDOMDataBrokerAdapter;
-import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.dom.api.ClusteredDOMDataTreeChangeListener;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-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.mdsal.binding.dom.codec.impl.BindingNormalizedNodeCodecRegistry;
-import org.opendaylight.mdsal.binding.generator.impl.GeneratedClassLoadingStrategy;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-
-@Deprecated
-public class BindingDOMDataBrokerAdapterTest {
-
- @Mock
- DOMDataBroker dataBroker;
-
- @Mock
- GeneratedClassLoadingStrategy classLoadingStrategy;
-
- @Mock
- BindingNormalizedNodeCodecRegistry codecRegistry;
-
- @Mock
- DOMDataTreeChangeService dataTreeChangeService;
-
- @Mock
- ListenerRegistration<DOMDataTreeChangeListener> listenerRegistration;
-
- @Mock
- ClusteredDataTreeChangeListener<Top> clusteredDataTreeChangeListener;
-
- private static final InstanceIdentifier<Top> TOP_PATH = InstanceIdentifier.create(Top.class);
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- }
-
- @Test
- public void testClusteredDataTreeChangeListenerRegisteration() {
-
- doReturn(YangInstanceIdentifier.of(Top.QNAME)).when(codecRegistry).toYangInstanceIdentifier(TOP_PATH);
-
- doReturn(listenerRegistration).when(dataTreeChangeService).registerDataTreeChangeListener(any(), any());
-
- doReturn(ImmutableMap.of(DOMDataTreeChangeService.class, dataTreeChangeService))
- .when(dataBroker).getSupportedExtensions();
-
- final BindingToNormalizedNodeCodec codec =
- new BindingToNormalizedNodeCodec(this.classLoadingStrategy, this.codecRegistry);
-
- try (BindingDOMDataBrokerAdapter bindingDOMDataBrokerAdapter = new BindingDOMDataBrokerAdapter(this.dataBroker,
- codec)) {
-
- ListenerRegistration<ClusteredDataTreeChangeListener<Top>> bindingListenerReg =
- bindingDOMDataBrokerAdapter.registerDataTreeChangeListener(
- new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, TOP_PATH),
- clusteredDataTreeChangeListener);
-
- verify(dataTreeChangeService).registerDataTreeChangeListener(
- eq(new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.of(Top.QNAME))),
- any(ClusteredDOMDataTreeChangeListener.class));
-
- bindingListenerReg.close();
-
- verify(listenerRegistration).close();
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.impl.test;
-
-import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.TOP_FOO_KEY;
-import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.path;
-import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.topLevelList;
-
-import com.google.common.collect.ImmutableSet;
-import java.util.Set;
-import org.junit.Test;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.binding.test.AbstractDataTreeChangeListenerTest;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugmentBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ContainerWithUsesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TopBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
-
-/**
- * Regression test suite for Bug 1125 - Can't detect switch disconnection
- * https://bugs.opendaylight.org/show_bug.cgi?id=1125.
- */
-@Deprecated
-public class Bug1125RegressionTest extends AbstractDataTreeChangeListenerTest {
-
- private static final InstanceIdentifier<Top> TOP_PATH = InstanceIdentifier
- .create(Top.class);
- private static final InstanceIdentifier<TopLevelList> TOP_FOO_PATH = TOP_PATH
- .child(TopLevelList.class, TOP_FOO_KEY);
-
- private static final InstanceIdentifier<TreeComplexUsesAugment> FOO_AUGMENT_PATH = TOP_FOO_PATH
- .augmentation(TreeComplexUsesAugment.class);
-
- private static final InstanceIdentifier<TreeComplexUsesAugment> WILDCARDED_AUGMENT_PATH = TOP_PATH
- .child(TopLevelList.class).augmentation(
- TreeComplexUsesAugment.class);
-
- @Override
- protected Set<YangModuleInfo> getModuleInfos() throws Exception {
- return ImmutableSet.of(BindingReflections.getModuleInfo(Top.class),
- BindingReflections.getModuleInfo(TreeComplexUsesAugment.class));
- }
-
- private TreeComplexUsesAugment writeInitialState() {
- WriteTransaction initialTx = getDataBroker().newWriteOnlyTransaction();
- initialTx.put(LogicalDatastoreType.OPERATIONAL, TOP_PATH,
- new TopBuilder().build());
- TreeComplexUsesAugment fooAugment = new TreeComplexUsesAugmentBuilder()
- .setContainerWithUses(
- new ContainerWithUsesBuilder().setLeafFromGrouping(
- "foo").build()).build();
- initialTx.put(LogicalDatastoreType.OPERATIONAL, path(TOP_FOO_KEY),
- topLevelList(TOP_FOO_KEY, fooAugment));
- assertCommit(initialTx.submit());
- return fooAugment;
- }
-
- private void delete(final InstanceIdentifier<?> path) {
- WriteTransaction tx = getDataBroker().newWriteOnlyTransaction();
- tx.delete(LogicalDatastoreType.OPERATIONAL, path);
- assertCommit(tx.submit());
- }
-
- private void deleteAndListenAugment(final InstanceIdentifier<?> path) {
- TreeComplexUsesAugment augment = writeInitialState();
- TestListener<TreeComplexUsesAugment> listener = createListener(LogicalDatastoreType.OPERATIONAL,
- WILDCARDED_AUGMENT_PATH, added(FOO_AUGMENT_PATH, augment), deleted(FOO_AUGMENT_PATH, augment));
- delete(path);
- listener.verify();
- }
-
- @Test
- public void deleteAndListenAugment() {
- deleteAndListenAugment(TOP_PATH);
-
- deleteAndListenAugment(TOP_FOO_PATH);
-
- deleteAndListenAugment(FOO_AUGMENT_PATH);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.impl.test;
-
-import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION;
-import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.TOP_FOO_KEY;
-import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.USES_ONE_KEY;
-import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.USES_TWO_KEY;
-import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.complexUsesAugment;
-import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.path;
-import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.top;
-import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.topLevelList;
-
-import com.google.common.collect.ImmutableSet;
-import java.util.Set;
-import org.junit.Test;
-import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.md.sal.binding.test.AbstractDataTreeChangeListenerTest;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ListViaUses;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
-
-/**
- * This testsuite tries to replicate bug 1333 and tests regresion of it
- * using test-model with similar construction as one reported.
- *
- * <p>
- * See https://bugs.opendaylight.org/show_bug.cgi?id=1333 for Bug Description
- */
-@Deprecated
-public class Bug1333DataChangeListenerTest extends AbstractDataTreeChangeListenerTest {
-
- private static final InstanceIdentifier<Top> TOP_PATH = InstanceIdentifier.create(Top.class);
-
- private static final InstanceIdentifier<TreeComplexUsesAugment> AUGMENT_WILDCARD =
- TOP_PATH.child(TopLevelList.class).augmentation(TreeComplexUsesAugment.class);
-
- @Override
- protected Set<YangModuleInfo> getModuleInfos() throws Exception {
- return ImmutableSet.of(BindingReflections.getModuleInfo(Top.class),
- BindingReflections.getModuleInfo(TreeComplexUsesAugment.class));
- }
-
- private static Top topWithListItem() {
- return top(topLevelList(TOP_FOO_KEY, complexUsesAugment(USES_ONE_KEY, USES_TWO_KEY)));
- }
-
- public Top writeTopWithListItem(final LogicalDatastoreType store) {
- ReadWriteTransaction tx = getDataBroker().newReadWriteTransaction();
- Top topItem = topWithListItem();
- tx.put(store, TOP_PATH, topItem);
- assertCommit(tx.submit());
- return topItem;
- }
-
- public void deleteItem(final LogicalDatastoreType store, final InstanceIdentifier<?> path) {
- ReadWriteTransaction tx = getDataBroker().newReadWriteTransaction();
- tx.delete(store, path);
- assertCommit(tx.submit());
- }
-
- @Test
- public void writeTopWithListItemAugmentedListenTopSubtree() {
- TestListener<Top> listener = createListener(CONFIGURATION, TOP_PATH, added(TOP_PATH, topWithListItem()));
-
- writeTopWithListItem(CONFIGURATION);
-
- listener.verify();
- }
-
- @Test
- public void writeTopWithListItemAugmentedListenAugmentSubtreeWildcarded() {
- TestListener<TreeComplexUsesAugment> listener = createListener(CONFIGURATION, AUGMENT_WILDCARD,
- added(path(TOP_FOO_KEY, TreeComplexUsesAugment.class), complexUsesAugment(USES_ONE_KEY, USES_TWO_KEY)));
-
- writeTopWithListItem(CONFIGURATION);
-
- listener.verify();
- }
-
- @Test
- public void deleteAugmentChildListenTopSubtree() {
- Top top = writeTopWithListItem(CONFIGURATION);
-
- TestListener<Top> listener = createListener(CONFIGURATION, TOP_PATH, added(TOP_PATH, top),
- subtreeModified(TOP_PATH, top, top(topLevelList(TOP_FOO_KEY, complexUsesAugment(USES_TWO_KEY)))));
-
- InstanceIdentifier<ListViaUses> deletePath = path(TOP_FOO_KEY, USES_ONE_KEY);
- deleteItem(CONFIGURATION, deletePath);
-
- listener.verify();
- }
-
- @Test
- public void deleteAugmentChildListenAugmentSubtreeWildcarded() {
- writeTopWithListItem(CONFIGURATION);
-
- TestListener<TreeComplexUsesAugment> listener = createListener(CONFIGURATION, AUGMENT_WILDCARD,
- added(path(TOP_FOO_KEY, TreeComplexUsesAugment.class), complexUsesAugment(USES_ONE_KEY, USES_TWO_KEY)),
- subtreeModified(path(TOP_FOO_KEY, TreeComplexUsesAugment.class),
- complexUsesAugment(USES_ONE_KEY, USES_TWO_KEY), complexUsesAugment(USES_TWO_KEY)));
-
- InstanceIdentifier<?> deletePath = path(TOP_FOO_KEY, USES_ONE_KEY);
- deleteItem(CONFIGURATION, deletePath);
-
- listener.verify();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014, 2015 Cisco Systems, Inc. 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.md.sal.binding.impl.test;
-
-import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION;
-import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.TOP_FOO_KEY;
-import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.complexUsesAugment;
-import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.leafOnlyUsesAugment;
-import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.path;
-import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.top;
-import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.topLevelList;
-
-import com.google.common.collect.ImmutableSet;
-import java.util.Set;
-import org.junit.Test;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.binding.test.AbstractDataTreeChangeListenerTest;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeLeafOnlyUsesAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ListViaUsesKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
-
-@Deprecated
-public class Bug1418AugmentationTest extends AbstractDataTreeChangeListenerTest {
- private static final InstanceIdentifier<Top> TOP = InstanceIdentifier.create(Top.class);
- private static final InstanceIdentifier<TopLevelList> TOP_FOO = TOP.child(TopLevelList.class, TOP_FOO_KEY);
- private static final InstanceIdentifier<TreeLeafOnlyUsesAugment> SIMPLE_AUGMENT =
- TOP.child(TopLevelList.class, TOP_FOO_KEY).augmentation(TreeLeafOnlyUsesAugment.class);
- private static final InstanceIdentifier<TreeComplexUsesAugment> COMPLEX_AUGMENT =
- TOP.child(TopLevelList.class, TOP_FOO_KEY).augmentation(TreeComplexUsesAugment.class);
- private static final ListViaUsesKey LIST_VIA_USES_KEY =
- new ListViaUsesKey("list key");
- private static final ListViaUsesKey LIST_VIA_USES_KEY_MOD =
- new ListViaUsesKey("list key modified");
-
- @Override
- protected Set<YangModuleInfo> getModuleInfos() throws Exception {
- return ImmutableSet.of(BindingReflections.getModuleInfo(Top.class),
- BindingReflections.getModuleInfo(TreeComplexUsesAugment.class),
- BindingReflections.getModuleInfo(TreeLeafOnlyUsesAugment.class));
- }
-
- @Test
- public void leafOnlyAugmentationCreatedTest() {
- TreeLeafOnlyUsesAugment leafOnlyUsesAugment = leafOnlyUsesAugment("test leaf");
- final TestListener<TreeLeafOnlyUsesAugment> listener = createListener(CONFIGURATION, SIMPLE_AUGMENT,
- added(path(TOP_FOO_KEY, TreeLeafOnlyUsesAugment.class), leafOnlyUsesAugment));
-
- WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
- writeTx.put(CONFIGURATION, TOP, top());
- writeTx.put(CONFIGURATION, TOP_FOO, topLevelList(new TopLevelListKey(TOP_FOO_KEY)));
- writeTx.put(CONFIGURATION, SIMPLE_AUGMENT, leafOnlyUsesAugment);
- assertCommit(writeTx.submit());
-
- listener.verify();
- }
-
- @Test
- public void leafOnlyAugmentationUpdatedTest() {
- WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
- writeTx.put(CONFIGURATION, TOP, top());
- writeTx.put(CONFIGURATION, TOP_FOO, topLevelList(new TopLevelListKey(TOP_FOO_KEY)));
- TreeLeafOnlyUsesAugment leafOnlyUsesAugmentBefore = leafOnlyUsesAugment("test leaf");
- writeTx.put(CONFIGURATION, SIMPLE_AUGMENT, leafOnlyUsesAugmentBefore);
- assertCommit(writeTx.submit());
-
- TreeLeafOnlyUsesAugment leafOnlyUsesAugmentAfter = leafOnlyUsesAugment("test leaf changed");
- final TestListener<TreeLeafOnlyUsesAugment> listener = createListener(CONFIGURATION, SIMPLE_AUGMENT,
- added(path(TOP_FOO_KEY, TreeLeafOnlyUsesAugment.class), leafOnlyUsesAugmentBefore),
- replaced(path(TOP_FOO_KEY, TreeLeafOnlyUsesAugment.class), leafOnlyUsesAugmentBefore,
- leafOnlyUsesAugmentAfter));
-
- writeTx = getDataBroker().newWriteOnlyTransaction();
- writeTx.put(CONFIGURATION, SIMPLE_AUGMENT, leafOnlyUsesAugmentAfter);
- assertCommit(writeTx.submit());
-
- listener.verify();
- }
-
- @Test
- public void leafOnlyAugmentationDeletedTest() {
- WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
- writeTx.put(CONFIGURATION, TOP, top());
- writeTx.put(CONFIGURATION, TOP_FOO, topLevelList(new TopLevelListKey(TOP_FOO_KEY)));
- TreeLeafOnlyUsesAugment leafOnlyUsesAugment = leafOnlyUsesAugment("test leaf");
- writeTx.put(CONFIGURATION, SIMPLE_AUGMENT, leafOnlyUsesAugment);
- assertCommit(writeTx.submit());
-
- final TestListener<TreeLeafOnlyUsesAugment> listener = createListener(CONFIGURATION, SIMPLE_AUGMENT,
- added(path(TOP_FOO_KEY, TreeLeafOnlyUsesAugment.class), leafOnlyUsesAugment),
- deleted(path(TOP_FOO_KEY, TreeLeafOnlyUsesAugment.class), leafOnlyUsesAugment));
-
- writeTx = getDataBroker().newWriteOnlyTransaction();
- writeTx.delete(CONFIGURATION, SIMPLE_AUGMENT);
- assertCommit(writeTx.submit());
-
- listener.verify();
- }
-
- @Test
- public void complexAugmentationCreatedTest() {
- TreeComplexUsesAugment complexUsesAugment = complexUsesAugment(LIST_VIA_USES_KEY);
- final TestListener<TreeComplexUsesAugment> listener = createListener(CONFIGURATION, COMPLEX_AUGMENT,
- added(path(TOP_FOO_KEY, TreeComplexUsesAugment.class), complexUsesAugment));
-
- WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
- writeTx.put(CONFIGURATION, TOP, top());
- writeTx.put(CONFIGURATION, TOP_FOO, topLevelList(new TopLevelListKey(TOP_FOO_KEY)));
- writeTx.put(CONFIGURATION, COMPLEX_AUGMENT, complexUsesAugment);
- assertCommit(writeTx.submit());
-
- listener.verify();
- }
-
- @Test
- public void complexAugmentationUpdatedTest() {
- WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
- writeTx.put(CONFIGURATION, TOP, top());
- writeTx.put(CONFIGURATION, TOP_FOO, topLevelList(new TopLevelListKey(TOP_FOO_KEY)));
- TreeComplexUsesAugment complexUsesAugmentBefore = complexUsesAugment(LIST_VIA_USES_KEY);
- writeTx.put(CONFIGURATION, COMPLEX_AUGMENT, complexUsesAugmentBefore);
- assertCommit(writeTx.submit());
-
- TreeComplexUsesAugment complexUsesAugmentAfter = complexUsesAugment(LIST_VIA_USES_KEY_MOD);
-
- final TestListener<TreeComplexUsesAugment> listener = createListener(CONFIGURATION, COMPLEX_AUGMENT,
- added(path(TOP_FOO_KEY, TreeComplexUsesAugment.class), complexUsesAugmentBefore),
- replaced(path(TOP_FOO_KEY, TreeComplexUsesAugment.class), complexUsesAugmentBefore,
- complexUsesAugmentAfter));
-
- writeTx = getDataBroker().newWriteOnlyTransaction();
- writeTx.put(CONFIGURATION, COMPLEX_AUGMENT, complexUsesAugmentAfter);
- assertCommit(writeTx.submit());
-
- listener.verify();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. 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.md.sal.binding.impl.test;
-
-import com.google.common.collect.ImmutableSet;
-import java.util.Arrays;
-import java.util.Set;
-import org.junit.Test;
-import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.md.sal.binding.test.AbstractDataTreeChangeListenerTest;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
-import org.opendaylight.yang.gen.v1.opendaylight.test.bug._2562.namespace.rev160101.Root;
-import org.opendaylight.yang.gen.v1.opendaylight.test.bug._2562.namespace.rev160101.RootBuilder;
-import org.opendaylight.yang.gen.v1.opendaylight.test.bug._2562.namespace.rev160101.root.Fooroot;
-import org.opendaylight.yang.gen.v1.opendaylight.test.bug._2562.namespace.rev160101.root.FoorootBuilder;
-import org.opendaylight.yang.gen.v1.opendaylight.test.bug._2562.namespace.rev160101.root.fooroot.Barroot;
-import org.opendaylight.yang.gen.v1.opendaylight.test.bug._2562.namespace.rev160101.root.fooroot.BarrootBuilder;
-import org.opendaylight.yang.gen.v1.opendaylight.test.bug._2562.namespace.rev160101.root.fooroot.BarrootKey;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
-
-@Deprecated
-public class Bug2562DeserializedUnkeyedListTest extends AbstractDataTreeChangeListenerTest {
- private static final InstanceIdentifier<Root> ROOT_PATH = InstanceIdentifier.create(Root.class);
-
- @Override
- protected Set<YangModuleInfo> getModuleInfos() throws Exception {
- return ImmutableSet.of(BindingReflections.getModuleInfo(Root.class));
- }
-
- @Test
- public void writeListToList2562Root() {
- final Barroot barRoot = new BarrootBuilder().setType(2).setValue(2).withKey(new BarrootKey(2)).build();
- final Fooroot fooRoot = new FoorootBuilder().setBarroot(Arrays.asList(barRoot)).build();
- final Root root = new RootBuilder().setFooroot(Arrays.asList(fooRoot)).build();
-
- final TestListener<Root> listenerRoot = createListener(LogicalDatastoreType.CONFIGURATION, ROOT_PATH,
- added(ROOT_PATH, root));
-
- final ReadWriteTransaction readWriteTransaction = getDataBroker().newReadWriteTransaction();
- readWriteTransaction.put(LogicalDatastoreType.CONFIGURATION, ROOT_PATH, root);
- assertCommit(readWriteTransaction.submit());
-
- listenerRoot.verify();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. 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.md.sal.binding.impl.test;
-
-import com.google.common.collect.ImmutableSet;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Set;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-import org.junit.Test;
-import org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType;
-import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.md.sal.binding.test.AbstractDataTreeChangeListenerTest;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.opendaylight.test.bug._3090.rev160101.Root;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.opendaylight.test.bug._3090.rev160101.RootBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.opendaylight.test.bug._3090.rev160101.root.ListInRoot;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.opendaylight.test.bug._3090.rev160101.root.ListInRootBuilder;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
-
-@Deprecated
-public class Bug3090MultiKeyList extends AbstractDataTreeChangeListenerTest {
- private static final InstanceIdentifier<Root> ROOT_PATH = InstanceIdentifier.create(Root.class);
-
- @Override
- protected Set<YangModuleInfo> getModuleInfos() throws Exception {
- return ImmutableSet.of(BindingReflections.getModuleInfo(Root.class));
- }
-
- @Test
- public void listWithMultiKeyTest() {
- final List<ListInRoot> listInRoots = new ArrayList<>();
- for (int i = 0; i < 10; i++) {
- listInRoots.add(new ListInRootBuilder()
- .setLeafA("leaf a" + i)
- .setLeafC("leaf c" + i)
- .setLeafB("leaf b" + i)
- .build()
- );
- }
-
- final Root root = new RootBuilder().setListInRoot(listInRoots).build();
-
- final TestListener<Root> listener = createListener(LogicalDatastoreType.CONFIGURATION, ROOT_PATH,
- match(ModificationType.WRITE, ROOT_PATH, Objects::isNull,
- (Function<Root, Boolean>) dataAfter -> checkData(root, dataAfter)));
-
- final ReadWriteTransaction readWriteTransaction = getDataBroker().newReadWriteTransaction();
- readWriteTransaction.put(LogicalDatastoreType.CONFIGURATION, ROOT_PATH, root);
- assertCommit(readWriteTransaction.submit());
-
- listener.verify();
- }
-
- private static boolean checkData(final Root expected, final Root actual) {
- if (actual == null) {
- return false;
- }
-
- Set<ListInRoot> expListInRoot = new HashSet<>(expected.getListInRoot());
- Set<ListInRoot> actualListInRoot = actual.getListInRoot().stream()
- .map(list -> new ListInRootBuilder(list).build()).collect(Collectors.toSet());
- return expListInRoot.equals(actualListInRoot);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.impl.test;
-
-import java.util.ArrayList;
-import org.junit.Test;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TopBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-@Deprecated
-public class Bug4494Test extends AbstractDataBrokerTest {
- @Test
- public void testDelete() throws Exception {
- DataBroker dataBroker = getDataBroker();
- WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
- ArrayList<TopLevelList> list = new ArrayList<>();
- list.add(new TopLevelListBuilder().setName("name").build());
- TopBuilder builder = new TopBuilder().setTopLevelList(list);
- writeTransaction.put(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Top.class), builder.build());
- assertCommit(writeTransaction.submit());
-
- InstanceIdentifier<TopLevelList> id = InstanceIdentifier.builder(Top.class)
- .child(TopLevelList.class, new TopLevelListKey("name")).build();
-
- ReadWriteTransaction writeTransaction1 = dataBroker.newReadWriteTransaction();
-
- writeTransaction1.delete(LogicalDatastoreType.OPERATIONAL, id);
- assertCommit(writeTransaction1.submit());
- ReadWriteTransaction writeTransaction2 = dataBroker.newReadWriteTransaction();
-
- writeTransaction2.delete(LogicalDatastoreType.OPERATIONAL, id);
- assertCommit(writeTransaction2.submit());
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc., Inocybe Technologies 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.md.sal.binding.impl.test;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.timeout;
-import static org.mockito.Mockito.verify;
-
-import java.util.Arrays;
-import java.util.Collection;
-import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.listener.rev150825.ListenerTest;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.listener.rev150825.ListenerTestBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.listener.rev150825.listener.test.ListItem;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.listener.rev150825.listener.test.ListItemBuilder;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.Uint32;
-
-/**
- * Regression test suite for https://bugs.opendaylight.org/show_bug.cgi?id=4513 - Change event is empty when
- * Homogeneous composite key is used homogeneous composite key is used.
- */
-@Deprecated
-public class Bug4513Test extends AbstractDataBrokerTest {
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Test
- public void testDataTreeChangeListener() {
- DataBroker dataBroker = getDataBroker();
-
- DataTreeChangeListener<ListItem> listener = mock(DataTreeChangeListener.class);
- InstanceIdentifier<ListItem> wildCard = InstanceIdentifier.builder(ListenerTest.class)
- .child(ListItem.class).build();
- ListenerRegistration<DataTreeChangeListener<ListItem>> reg = dataBroker.registerDataTreeChangeListener(
- new DataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, wildCard), listener);
-
- final ListItem item = writeListItem();
-
- ArgumentCaptor<Collection> captor = ArgumentCaptor.forClass(Collection.class);
-
- verify(listener, timeout(100)).onDataTreeChanged(captor.capture());
-
- Collection<DataTreeModification<ListItem>> mods = captor.getValue();
- assertEquals("ListItem", item, mods.iterator().next().getRootNode().getDataAfter());
- }
-
- private ListItem writeListItem() {
- WriteTransaction writeTransaction = getDataBroker().newWriteOnlyTransaction();
- final ListItem item = new ListItemBuilder().setSip("name").setOp(Uint32.valueOf(43)).build();
- ListenerTestBuilder builder = new ListenerTestBuilder().setListItem(Arrays.asList(item));
- writeTransaction.put(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.builder(
- ListenerTest.class).build(), builder.build());
- assertCommit(writeTransaction.submit());
- return item;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014, 2015 Cisco Systems, Inc. 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.md.sal.binding.impl.test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.timeout;
-import static org.mockito.Mockito.verify;
-import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.TOP_BAR_KEY;
-import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.TOP_FOO_KEY;
-import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.USES_ONE_KEY;
-import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.complexUsesAugment;
-import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.path;
-import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.top;
-import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.topLevelList;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-import com.google.common.util.concurrent.SettableFuture;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Matchers;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
-import org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.binding.impl.BindingDOMDataBrokerAdapter;
-import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TopBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TwoLevelList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
-import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
-
-@Deprecated
-public class DataTreeChangeListenerTest extends AbstractConcurrentDataBrokerTest {
-
- private static final InstanceIdentifier<Top> TOP_PATH = InstanceIdentifier.create(Top.class);
- private static final PathArgument TOP_ARGUMENT = TOP_PATH.getPathArguments().iterator().next();
- private static final InstanceIdentifier<TopLevelList> FOO_PATH = path(TOP_FOO_KEY);
- private static final PathArgument FOO_ARGUMENT = Iterables.getLast(FOO_PATH.getPathArguments());
- private static final TopLevelList FOO_DATA = topLevelList(TOP_FOO_KEY, complexUsesAugment(USES_ONE_KEY));
- private static final InstanceIdentifier<TopLevelList> BAR_PATH = path(TOP_BAR_KEY);
- private static final PathArgument BAR_ARGUMENT = Iterables.getLast(BAR_PATH.getPathArguments());
- private static final TopLevelList BAR_DATA = topLevelList(TOP_BAR_KEY);
- private static final DataTreeIdentifier<Top> TOP_IDENTIFIER =
- new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, TOP_PATH);
-
- private static final Top TOP_INITIAL_DATA = top(FOO_DATA);
-
- private BindingDOMDataBrokerAdapter dataBrokerImpl;
-
- private static final class EventCapturingListener<T extends DataObject> implements DataTreeChangeListener<T> {
-
- private SettableFuture<Collection<DataTreeModification<T>>> changes = SettableFuture.create();
-
- @Override
- public void onDataTreeChanged(final Collection<DataTreeModification<T>> modification) {
- this.changes.set(modification);
-
- }
-
- Collection<DataTreeModification<T>> nextEvent() throws Exception {
- final Collection<DataTreeModification<T>> result = changes.get(200,TimeUnit.MILLISECONDS);
- changes = SettableFuture.create();
- return result;
- }
- }
-
- @Override
- protected Set<YangModuleInfo> getModuleInfos() throws Exception {
- return ImmutableSet.of(
- BindingReflections.getModuleInfo(TwoLevelList.class),
- BindingReflections.getModuleInfo(TreeComplexUsesAugment.class)
- );
- }
-
- @Before
- public void setupWithDataBroker() {
- dataBrokerImpl = (BindingDOMDataBrokerAdapter) getDataBroker();
- }
-
- @Test
- public void testTopLevelListener() throws Exception {
- final EventCapturingListener<Top> listener = new EventCapturingListener<>();
- dataBrokerImpl.registerDataTreeChangeListener(TOP_IDENTIFIER, listener);
-
- createAndVerifyTop(listener);
-
- putTx(BAR_PATH, BAR_DATA).submit().checkedGet();
- final DataObjectModification<Top> afterBarPutEvent = Iterables.getOnlyElement(listener.nextEvent())
- .getRootNode();
- verifyModification(afterBarPutEvent, TOP_ARGUMENT, ModificationType.SUBTREE_MODIFIED);
- final DataObjectModification<TopLevelList> barPutMod = afterBarPutEvent
- .getModifiedChildListItem(TopLevelList.class, TOP_BAR_KEY);
- assertNotNull(barPutMod);
- verifyModification(barPutMod, BAR_ARGUMENT, ModificationType.WRITE);
-
- deleteTx(BAR_PATH).submit().checkedGet();
- final DataObjectModification<Top> afterBarDeleteEvent = Iterables.getOnlyElement(listener.nextEvent())
- .getRootNode();
- verifyModification(afterBarDeleteEvent, TOP_ARGUMENT, ModificationType.SUBTREE_MODIFIED);
- final DataObjectModification<TopLevelList> barDeleteMod = afterBarDeleteEvent
- .getModifiedChildListItem(TopLevelList.class, TOP_BAR_KEY);
- verifyModification(barDeleteMod, BAR_ARGUMENT, ModificationType.DELETE);
- }
-
- @Test
- public void testWildcardedListListener() throws Exception {
- final EventCapturingListener<TopLevelList> listener = new EventCapturingListener<>();
- final DataTreeIdentifier<TopLevelList> wildcard = new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL,
- TOP_PATH.child(TopLevelList.class));
- dataBrokerImpl.registerDataTreeChangeListener(wildcard, listener);
-
- putTx(TOP_PATH, TOP_INITIAL_DATA).submit().checkedGet();
-
- final DataTreeModification<TopLevelList> fooWriteEvent = Iterables.getOnlyElement(listener.nextEvent());
- assertEquals(FOO_PATH, fooWriteEvent.getRootPath().getRootIdentifier());
- verifyModification(fooWriteEvent.getRootNode(), FOO_ARGUMENT, ModificationType.WRITE);
-
- putTx(BAR_PATH, BAR_DATA).submit().checkedGet();
- final DataTreeModification<TopLevelList> barWriteEvent = Iterables.getOnlyElement(listener.nextEvent());
- assertEquals(BAR_PATH, barWriteEvent.getRootPath().getRootIdentifier());
- verifyModification(barWriteEvent.getRootNode(), BAR_ARGUMENT, ModificationType.WRITE);
-
- deleteTx(BAR_PATH).submit().checkedGet();
- final DataTreeModification<TopLevelList> barDeleteEvent = Iterables.getOnlyElement(listener.nextEvent());
- assertEquals(BAR_PATH, barDeleteEvent.getRootPath().getRootIdentifier());
- verifyModification(barDeleteEvent.getRootNode(), BAR_ARGUMENT, ModificationType.DELETE);
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void testWildcardNotificationOfPreexistingData() {
- InstanceIdentifier<Top> id = InstanceIdentifier.builder(Top.class).build();
- ArrayList<TopLevelList> list = new ArrayList<>();
- list.add(new TopLevelListBuilder().setName("name").build());
- TopBuilder builder = new TopBuilder().setTopLevelList(list);
-
- DataBroker dataBroker = getDataBroker();
-
- WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
- writeTransaction.put(LogicalDatastoreType.OPERATIONAL, id, builder.build());
- assertCommit(writeTransaction.submit());
-
- DataTreeChangeListener<TopLevelList> listener = mock(DataTreeChangeListener.class);
- InstanceIdentifier<TopLevelList> wildcard = InstanceIdentifier.builder(Top.class).child(TopLevelList.class)
- .build();
- dataBroker.registerDataTreeChangeListener(new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, wildcard),
- listener);
-
- verify(listener, timeout(1000)).onDataTreeChanged(Matchers.anyObject());
- }
-
- private void createAndVerifyTop(final EventCapturingListener<Top> listener) throws Exception {
- putTx(TOP_PATH,TOP_INITIAL_DATA).submit().checkedGet();
- final Collection<DataTreeModification<Top>> events = listener.nextEvent();
-
- assertFalse("Non empty collection should be received.",events.isEmpty());
- final DataTreeModification<Top> initialWrite = Iterables.getOnlyElement(events);
- final DataObjectModification<? extends DataObject> initialNode = initialWrite.getRootNode();
- verifyModification(initialNode,TOP_PATH.getPathArguments().iterator().next(),ModificationType.WRITE);
- assertEquals(TOP_INITIAL_DATA, initialNode.getDataAfter());
- }
-
- private static void verifyModification(final DataObjectModification<? extends DataObject> barWrite,
- final PathArgument pathArg, final ModificationType eventType) {
- assertEquals(pathArg.getType(), barWrite.getDataType());
- assertEquals(eventType,barWrite.getModificationType());
- assertEquals(pathArg, barWrite.getIdentifier());
- }
-
- private <T extends DataObject> WriteTransaction putTx(final InstanceIdentifier<T> path,final T data) {
- final WriteTransaction tx = dataBrokerImpl.newWriteOnlyTransaction();
- tx.put(LogicalDatastoreType.OPERATIONAL, path, data);
- return tx;
- }
-
- private WriteTransaction deleteTx(final InstanceIdentifier<?> path) {
- final WriteTransaction tx = dataBrokerImpl.newWriteOnlyTransaction();
- tx.delete(LogicalDatastoreType.OPERATIONAL, path);
- return tx;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.impl.test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertTrue;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import org.junit.Assert;
-import org.junit.Test;
-import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
-import org.opendaylight.controller.md.sal.binding.test.AbstractNotificationBrokerTest;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.OpendaylightMdsalListTestListener;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TwoLevelListChanged;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TwoLevelListChangedBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Deprecated
-public class ForwardedNotificationAdapterTest extends AbstractNotificationBrokerTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(ForwardedNotificationAdapterTest.class);
-
- @Override
- protected Set<YangModuleInfo> getModuleInfos() throws Exception {
- return ImmutableSet.of(BindingReflections.getModuleInfo(TwoLevelListChanged.class));
-
- }
-
- private static TwoLevelListChanged createTestData() {
- final TwoLevelListChangedBuilder tb = new TwoLevelListChangedBuilder();
- tb.setTopLevelList(ImmutableList.of(new TopLevelListBuilder().withKey(new TopLevelListKey("test")).build()));
- return tb.build();
- }
-
- @Test
- public void testNotifSubscription() throws InterruptedException {
- final CountDownLatch latch = new CountDownLatch(1);
- final TwoLevelListChanged testData = createTestData();
-
- final TestNotifListener testNotifListener = new TestNotifListener(latch);
- final ListenerRegistration<TestNotifListener> listenerRegistration = getNotificationService()
- .registerNotificationListener(testNotifListener);
- getNotificationPublishService().putNotification(testData);
-
- latch.await();
- assertTrue(testNotifListener.getReceivedNotifications().size() == 1);
- assertEquals(testData, testNotifListener.getReceivedNotifications().get(0));
-
- listenerRegistration.close();
- }
-
- @Test
- public void testNotifSubscription2() throws InterruptedException {
- final CountDownLatch latch = new CountDownLatch(1);
- final TwoLevelListChanged testData = createTestData();
-
- final TestNotifListener testNotifListener = new TestNotifListener(latch);
- final ListenerRegistration<TestNotifListener> listenerRegistration = getNotificationService()
- .registerNotificationListener(testNotifListener);
- try {
- getNotificationPublishService().offerNotification(testData).get(1, TimeUnit.SECONDS);
- } catch (ExecutionException | TimeoutException e) {
- LOG.error("Notification delivery failed", e);
- Assert.fail("notification should be delivered");
- }
-
- latch.await();
- assertTrue(testNotifListener.getReceivedNotifications().size() == 1);
- assertEquals(testData, testNotifListener.getReceivedNotifications().get(0));
-
- listenerRegistration.close();
- }
-
- @Test
- public void testNotifSubscription3() throws InterruptedException {
- final CountDownLatch latch = new CountDownLatch(1);
- final TwoLevelListChanged testData = createTestData();
-
- final TestNotifListener testNotifListener = new TestNotifListener(latch);
- final ListenerRegistration<TestNotifListener> listenerRegistration = getNotificationService()
- .registerNotificationListener(testNotifListener);
- assertNotSame(NotificationPublishService.REJECTED,
- getNotificationPublishService().offerNotification(testData, 5, TimeUnit.SECONDS));
-
- latch.await();
- assertTrue(testNotifListener.getReceivedNotifications().size() == 1);
- assertEquals(testData, testNotifListener.getReceivedNotifications().get(0));
-
- listenerRegistration.close();
- }
-
- private static class TestNotifListener implements OpendaylightMdsalListTestListener {
- private final List<TwoLevelListChanged> receivedNotifications = new ArrayList<>();
- private final CountDownLatch latch;
-
- TestNotifListener(final CountDownLatch latch) {
- this.latch = latch;
- }
-
- @Override
- public void onTwoLevelListChanged(final TwoLevelListChanged notification) {
- receivedNotifications.add(notification);
- latch.countDown();
- }
-
- public List<TwoLevelListChanged> getReceivedNotifications() {
- return receivedNotifications;
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.impl.test;
-import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION;
-import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.TOP_BAR_KEY;
-import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.TOP_FOO_KEY;
-import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.top;
-import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.topLevelList;
-
-import com.google.common.collect.ImmutableSet;
-import java.util.HashSet;
-import java.util.Objects;
-import java.util.Set;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
-import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.binding.test.AbstractDataTreeChangeListenerTest;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
-
-/**
- * This testsuite tests explanation for data change scope and data modifications
- * which were described in
- * https://lists.opendaylight.org/pipermail/controller-dev/2014-July/005541.html.
- */
-@Deprecated
-public class ListInsertionDataChangeListenerTest extends AbstractDataTreeChangeListenerTest {
-
- private static final InstanceIdentifier<Top> TOP = InstanceIdentifier.create(Top.class);
- private static final InstanceIdentifier<TopLevelList> WILDCARDED = TOP.child(TopLevelList.class);
- private static final InstanceIdentifier<TopLevelList> TOP_FOO = TOP.child(TopLevelList.class, TOP_FOO_KEY);
- private static final InstanceIdentifier<TopLevelList> TOP_BAR = TOP.child(TopLevelList.class, TOP_BAR_KEY);
-
- @Override
- protected Set<YangModuleInfo> getModuleInfos() throws Exception {
- return ImmutableSet.of(BindingReflections.getModuleInfo(Top.class));
- }
-
- @Before
- public void setupWithDataBroker() {
- WriteTransaction initialTx = getDataBroker().newWriteOnlyTransaction();
- initialTx.put(CONFIGURATION, TOP, top(topLevelList(TOP_FOO_KEY)));
- assertCommit(initialTx.submit());
- }
-
- @Test
- public void replaceTopNodeSubtreeListeners() {
- final TopLevelList topBar = topLevelList(TOP_BAR_KEY);
- final Top top = top(topBar);
- final TopLevelList topFoo = topLevelList(TOP_FOO_KEY);
-
- // Listener for TOP element
- final TestListener<Top> topListener = createListener(CONFIGURATION, TOP,
- added(TOP, top(topLevelList(TOP_FOO_KEY))), replaced(TOP, top(topFoo), top));
-
- // Listener for all list items. This one should see Foo item deleted and Bar item added.
- final TestListener<TopLevelList> allListener = createListener(CONFIGURATION, WILDCARDED,
- added(TOP_FOO, topFoo), added(TOP_BAR, topBar), deleted(TOP_FOO, topFoo));
-
- // Listener for all Foo item. This one should see only Foo item deleted.
- final TestListener<TopLevelList> fooListener = createListener(CONFIGURATION, TOP_FOO,
- added(TOP_FOO, topFoo), deleted(TOP_FOO, topFoo));
-
- // Listener for bar list items.
- final TestListener<TopLevelList> barListener = createListener(CONFIGURATION, TOP_BAR,
- added(TOP_BAR, topBar));
-
- ReadWriteTransaction writeTx = getDataBroker().newReadWriteTransaction();
- writeTx.put(CONFIGURATION, TOP, top);
- assertCommit(writeTx.submit());
-
- topListener.verify();
- allListener.verify();
- fooListener.verify();
- barListener.verify();
- }
-
- @Test
- public void mergeTopNodeSubtreeListeners() {
- final TopLevelList topBar = topLevelList(TOP_BAR_KEY);
- final TopLevelList topFoo = topLevelList(TOP_FOO_KEY);
-
- final TestListener<Top> topListener = createListener(CONFIGURATION, TOP,
- added(TOP, top(topLevelList(TOP_FOO_KEY))), topSubtreeModified(topFoo, topBar));
- final TestListener<TopLevelList> allListener = createListener(CONFIGURATION, WILDCARDED,
- added(TOP_FOO, topFoo), added(TOP_BAR, topBar));
- final TestListener<TopLevelList> fooListener = createListener(CONFIGURATION, TOP_FOO,
- added(TOP_FOO, topFoo));
- final TestListener<TopLevelList> barListener = createListener(CONFIGURATION, TOP_BAR,
- added(TOP_BAR, topBar));
-
- ReadWriteTransaction writeTx = getDataBroker().newReadWriteTransaction();
- writeTx.merge(CONFIGURATION, TOP, top(topLevelList(TOP_BAR_KEY)));
- assertCommit(writeTx.submit());
-
- topListener.verify();
- allListener.verify();
- fooListener.verify();
- barListener.verify();
- }
-
- @Test
- public void putTopBarNodeSubtreeListeners() {
- final TopLevelList topBar = topLevelList(TOP_BAR_KEY);
- final TopLevelList topFoo = topLevelList(TOP_FOO_KEY);
-
- final TestListener<Top> topListener = createListener(CONFIGURATION, TOP,
- added(TOP, top(topLevelList(TOP_FOO_KEY))), topSubtreeModified(topFoo, topBar));
- final TestListener<TopLevelList> allListener = createListener(CONFIGURATION, WILDCARDED,
- added(TOP_FOO, topFoo), added(TOP_BAR, topBar));
- final TestListener<TopLevelList> fooListener = createListener(CONFIGURATION, TOP_FOO,
- added(TOP_FOO, topFoo));
- final TestListener<TopLevelList> barListener = createListener(CONFIGURATION, TOP_BAR,
- added(TOP_BAR, topBar));
-
- ReadWriteTransaction writeTx = getDataBroker().newReadWriteTransaction();
- writeTx.put(CONFIGURATION, TOP_BAR, topLevelList(TOP_BAR_KEY));
- assertCommit(writeTx.submit());
-
- topListener.verify();
- allListener.verify();
- fooListener.verify();
- barListener.verify();
- }
-
- @Test
- public void mergeTopBarNodeSubtreeListeners() {
- final TopLevelList topBar = topLevelList(TOP_BAR_KEY);
- final TopLevelList topFoo = topLevelList(TOP_FOO_KEY);
-
- final TestListener<Top> topListener = createListener(CONFIGURATION, TOP,
- added(TOP, top(topLevelList(TOP_FOO_KEY))), topSubtreeModified(topFoo, topBar));
- final TestListener<TopLevelList> allListener = createListener(CONFIGURATION, WILDCARDED,
- added(TOP_FOO, topFoo), added(TOP_BAR, topBar));
- final TestListener<TopLevelList> fooListener = createListener(CONFIGURATION, TOP_FOO,
- added(TOP_FOO, topFoo));
- final TestListener<TopLevelList> barListener = createListener(CONFIGURATION, TOP_BAR,
- added(TOP_BAR, topBar));
-
- ReadWriteTransaction writeTx = getDataBroker().newReadWriteTransaction();
- writeTx.merge(CONFIGURATION, TOP_BAR, topLevelList(TOP_BAR_KEY));
- assertCommit(writeTx.submit());
-
- topListener.verify();
- allListener.verify();
- fooListener.verify();
- barListener.verify();
- }
-
- private static Function<DataTreeModification<Top>, Boolean> topSubtreeModified(final TopLevelList topFoo,
- final TopLevelList topBar) {
- return match(ModificationType.SUBTREE_MODIFIED, TOP,
- (Function<Top, Boolean>) dataBefore -> Objects.equals(top(topFoo), dataBefore),
- dataAfter -> {
- Set<TopLevelList> expList = new HashSet<>(top(topBar, topFoo).getTopLevelList());
- Set<TopLevelList> actualList = dataAfter.getTopLevelList().stream()
- .map(list -> new TopLevelListBuilder(list).build()).collect(Collectors.toSet());
- return expList.equals(actualList);
- });
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.impl.test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import com.google.common.base.Optional;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import org.junit.Test;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TopBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-@Deprecated
-public class WriteTransactionTest extends AbstractConcurrentDataBrokerTest {
-
- private static final InstanceIdentifier<Top> TOP_PATH = InstanceIdentifier.create(Top.class);
- private static final TopLevelListKey TOP_LIST_KEY = new TopLevelListKey("foo");
- private static final InstanceIdentifier<TopLevelList> NODE_PATH = TOP_PATH.child(TopLevelList.class, TOP_LIST_KEY);
- private static final TopLevelList NODE = new TopLevelListBuilder().withKey(TOP_LIST_KEY).build();
-
- @Test
- @Deprecated
- public void testSubmit() throws InterruptedException, ExecutionException, TimeoutException {
- WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
- writeTx.put(LogicalDatastoreType.OPERATIONAL, TOP_PATH, new TopBuilder().build());
- writeTx.put(LogicalDatastoreType.OPERATIONAL, NODE_PATH, NODE);
- writeTx.submit().get(5, TimeUnit.SECONDS);
-
- ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
- Optional<TopLevelList> listNode = readTx.read(LogicalDatastoreType.OPERATIONAL, NODE_PATH).get();
- assertTrue("List node must exists after commit", listNode.isPresent());
- assertEquals("List node", NODE, listNode.get());
- }
-
- @Test
- public void testCommit() throws InterruptedException, ExecutionException, TimeoutException {
- WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
- writeTx.put(LogicalDatastoreType.OPERATIONAL, TOP_PATH, new TopBuilder().build());
- writeTx.put(LogicalDatastoreType.OPERATIONAL, NODE_PATH, NODE);
- writeTx.commit().get(5, TimeUnit.SECONDS);
-
- ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
- Optional<TopLevelList> listNode = readTx.read(LogicalDatastoreType.OPERATIONAL, NODE_PATH).get();
- assertTrue("List node must exists after commit", listNode.isPresent());
- assertEquals("List node", NODE, listNode.get());
- }
-
- @Test
- public void testPutCreateParentsSuccess() throws InterruptedException, ExecutionException, TimeoutException {
- WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
- writeTx.put(LogicalDatastoreType.OPERATIONAL, NODE_PATH, NODE,true);
- writeTx.commit().get(5, TimeUnit.SECONDS);
-
- ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
- Optional<Top> topNode = readTx.read(LogicalDatastoreType.OPERATIONAL, TOP_PATH).get();
- assertTrue("Top node must exists after commit",topNode.isPresent());
- Optional<TopLevelList> listNode = readTx.read(LogicalDatastoreType.OPERATIONAL, NODE_PATH).get();
- assertTrue("List node must exists after commit",listNode.isPresent());
- }
-
- @Test
- public void testMergeCreateParentsSuccess() throws InterruptedException, ExecutionException, TimeoutException {
- WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
- writeTx.merge(LogicalDatastoreType.OPERATIONAL, NODE_PATH, NODE,true);
- writeTx.commit().get(5, TimeUnit.SECONDS);
-
- ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
- Optional<Top> topNode = readTx.read(LogicalDatastoreType.OPERATIONAL, TOP_PATH).get();
- assertTrue("Top node must exists after commit",topNode.isPresent());
- Optional<TopLevelList> listNode = readTx.read(LogicalDatastoreType.OPERATIONAL, NODE_PATH).get();
- assertTrue("List node must exists after commit",listNode.isPresent());
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Red Hat, Inc. 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.md.sal.binding.test;
-
-import com.google.common.util.concurrent.ListenableFuture;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
-@Deprecated
-public abstract class AbstractBaseDataBrokerTest extends AbstractSchemaAwareTest {
-
- private static final int ASSERT_COMMIT_DEFAULT_TIMEOUT = 5000;
-
- private AbstractDataBrokerTestCustomizer testCustomizer;
- private DataBroker dataBroker;
- private DOMDataBroker domBroker;
-
- protected abstract AbstractDataBrokerTestCustomizer createDataBrokerTestCustomizer();
-
- public AbstractDataBrokerTestCustomizer getDataBrokerTestCustomizer() {
- if (testCustomizer == null) {
- throw new IllegalStateException("testCustomizer not yet set by call to createDataBrokerTestCustomizer()");
- }
- return testCustomizer;
- }
-
- @Override
- protected void setupWithSchema(final SchemaContext context) {
- testCustomizer = createDataBrokerTestCustomizer();
- dataBroker = testCustomizer.createDataBroker();
- domBroker = testCustomizer.getDOMDataBroker();
- testCustomizer.updateSchema(context);
- }
-
- public DataBroker getDataBroker() {
- return dataBroker;
- }
-
- public DOMDataBroker getDomBroker() {
- return domBroker;
- }
-
- protected static final void assertCommit(final ListenableFuture<Void> commit) {
- assertCommit(commit, ASSERT_COMMIT_DEFAULT_TIMEOUT);
- }
-
- protected static final void assertCommit(final ListenableFuture<Void> commit, long timeoutInMS) {
- try {
- commit.get(timeoutInMS, TimeUnit.MILLISECONDS);
- } catch (InterruptedException | ExecutionException | TimeoutException e) {
- throw new IllegalStateException(e);
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Red Hat, Inc. 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.md.sal.binding.test;
-
-/**
- * AbstractConcurrentDataBrokerTest.
- *
- * <p>Uses single thread executor for the Serialized DOM DataBroker (instead of the
- * direct executor used by the {@literal @}Deprecated AbstractDataBrokerTest) in order
- * to allow tests to use the DataBroker concurrently from several threads.
- *
- * <p>See also <a href="https://bugs.opendaylight.org/show_bug.cgi?id=7538">bug 7538</a> for more details.
- *
- * @author Michael Vorburger
- */
-@Deprecated
-public abstract class AbstractConcurrentDataBrokerTest extends AbstractBaseDataBrokerTest {
- private final boolean useMTDataTreeChangeListenerExecutor;
-
- protected AbstractConcurrentDataBrokerTest() {
- this(false);
- }
-
- protected AbstractConcurrentDataBrokerTest(final boolean useMTDataTreeChangeListenerExecutor) {
- this.useMTDataTreeChangeListenerExecutor = useMTDataTreeChangeListenerExecutor;
- }
-
- @Override
- protected AbstractDataBrokerTestCustomizer createDataBrokerTestCustomizer() {
- return new ConcurrentDataBrokerTestCustomizer(useMTDataTreeChangeListenerExecutor);
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.test;
-
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
-/**
- * AbstractDataBrokerTest.
- *
- * @deprecated Please now use the AbstractConcurrentDataBrokerTest instead of
- * this. Normally in a well written test this should be a drop-in
- * replacement. Instead of {@literal @}Override
- * setupWithDataBroker(DataBroker dataBroker), please just use
- * JUnit's {@literal @}Before before() { ... getDataBroker() }. Some
- * tests which relied on the Test DataBroker being synchronous,
- * contrary to its specification as well as the production
- * implementation, may require changes to e.g. use get() on
- * submit()'ed transaction to make the test wait before asserts. See
- * also
- * <a href="https://bugs.opendaylight.org/show_bug.cgi?id=7538">bug
- * 7538</a> for more details.
- */
-@Deprecated
-public class AbstractDataBrokerTest extends AbstractBaseDataBrokerTest {
-
- @Override
- protected AbstractDataBrokerTestCustomizer createDataBrokerTestCustomizer() {
- return new DataBrokerTestCustomizer();
- }
-
- @Override
- protected void setupWithSchema(SchemaContext context) {
- super.setupWithSchema(context);
- setupWithDataBroker(getDataBroker());
- }
-
- protected void setupWithDataBroker(final DataBroker dataBroker) {
- // Intentionally left No-op, subclasses may customize it
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Red Hat, Inc. 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.md.sal.binding.test;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
-import org.opendaylight.controller.md.sal.binding.api.NotificationService;
-import org.opendaylight.controller.md.sal.binding.impl.BindingDOMDataBrokerAdapter;
-import org.opendaylight.controller.md.sal.binding.impl.BindingDOMNotificationPublishServiceAdapter;
-import org.opendaylight.controller.md.sal.binding.impl.BindingDOMNotificationServiceAdapter;
-import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-import org.opendaylight.controller.md.sal.dom.broker.impl.DOMNotificationRouter;
-import org.opendaylight.controller.md.sal.dom.broker.impl.SerializedDOMDataBroker;
-import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
-import org.opendaylight.controller.sal.binding.test.util.MockSchemaService;
-import org.opendaylight.controller.sal.core.spi.data.DOMStore;
-import org.opendaylight.mdsal.binding.dom.codec.impl.BindingNormalizedNodeCodecRegistry;
-import org.opendaylight.mdsal.binding.generator.impl.GeneratedClassLoadingStrategy;
-import org.opendaylight.mdsal.dom.api.DOMSchemaService;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
-@Deprecated
-public abstract class AbstractDataBrokerTestCustomizer {
-
- private DOMDataBroker domDataBroker;
- private final DOMNotificationRouter domNotificationRouter;
- private final MockSchemaService schemaService;
- private ImmutableMap<LogicalDatastoreType, DOMStore> datastores;
- private final BindingToNormalizedNodeCodec bindingToNormalized;
-
- public ImmutableMap<LogicalDatastoreType, DOMStore> createDatastores() {
- return ImmutableMap.<LogicalDatastoreType, DOMStore>builder()
- .put(LogicalDatastoreType.OPERATIONAL, createOperationalDatastore())
- .put(LogicalDatastoreType.CONFIGURATION,createConfigurationDatastore())
- .build();
- }
-
- public AbstractDataBrokerTestCustomizer() {
- this.schemaService = new MockSchemaService();
- final BindingNormalizedNodeCodecRegistry codecRegistry = new BindingNormalizedNodeCodecRegistry();
- final GeneratedClassLoadingStrategy loading = GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy();
- this.bindingToNormalized = new BindingToNormalizedNodeCodec(loading, codecRegistry);
- this.schemaService.registerSchemaContextListener(this.bindingToNormalized);
- this.domNotificationRouter = DOMNotificationRouter.create(16);
- }
-
- public DOMStore createConfigurationDatastore() {
- final InMemoryDOMDataStore store = new InMemoryDOMDataStore("CFG", getDataTreeChangeListenerExecutor());
- this.schemaService.registerSchemaContextListener(store);
- return store;
- }
-
- public DOMStore createOperationalDatastore() {
- final InMemoryDOMDataStore store = new InMemoryDOMDataStore("OPER", getDataTreeChangeListenerExecutor());
- this.schemaService.registerSchemaContextListener(store);
- return store;
- }
-
- public DOMDataBroker createDOMDataBroker() {
- return new SerializedDOMDataBroker(getDatastores(), getCommitCoordinatorExecutor());
- }
-
- public NotificationService createNotificationService() {
- return new BindingDOMNotificationServiceAdapter(this.bindingToNormalized.getCodecRegistry(),
- this.domNotificationRouter);
- }
-
- public NotificationPublishService createNotificationPublishService() {
- return new BindingDOMNotificationPublishServiceAdapter(this.bindingToNormalized, this.domNotificationRouter);
- }
-
- public abstract ListeningExecutorService getCommitCoordinatorExecutor();
-
- public ListeningExecutorService getDataTreeChangeListenerExecutor() {
- return MoreExecutors.newDirectExecutorService();
- }
-
- public DataBroker createDataBroker() {
- return new BindingDOMDataBrokerAdapter(getDOMDataBroker(), this.bindingToNormalized);
- }
-
- public BindingToNormalizedNodeCodec getBindingToNormalized() {
- return this.bindingToNormalized;
- }
-
- public DOMSchemaService getSchemaService() {
- return this.schemaService;
- }
-
- public DOMDataBroker getDOMDataBroker() {
- if (this.domDataBroker == null) {
- this.domDataBroker = createDOMDataBroker();
- }
- return this.domDataBroker;
- }
-
- private synchronized ImmutableMap<LogicalDatastoreType, DOMStore> getDatastores() {
- if (this.datastores == null) {
- this.datastores = createDatastores();
- }
- return this.datastores;
- }
-
- public void updateSchema(final SchemaContext ctx) {
- this.schemaService.changeSchema(ctx);
- }
-
- public DOMNotificationRouter getDomNotificationRouter() {
- return this.domNotificationRouter;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2018 Inocybe Technologies 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.md.sal.binding.test;
-
-import static org.junit.Assert.fail;
-
-import com.google.common.util.concurrent.SettableFuture;
-import com.google.common.util.concurrent.Uninterruptibles;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Objects;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.function.Function;
-import org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * Abstract base that provides a DTCL for verification.
- *
- * @author Thomas Pantelis
- */
-@Deprecated
-public class AbstractDataTreeChangeListenerTest extends AbstractConcurrentDataBrokerTest {
- protected static final class TestListener<T extends DataObject> implements DataTreeChangeListener<T> {
-
- private final List<DataTreeModification<T>> accumulatedChanges = new ArrayList<>();
- private final SettableFuture<Collection<DataTreeModification<T>>> future = SettableFuture.create();
- private final Function<DataTreeModification<T>, Boolean>[] matchers;
- private final int expChangeCount;
-
- private TestListener(Function<DataTreeModification<T>, Boolean>[] matchers) {
- this.expChangeCount = matchers.length;
- this.matchers = matchers;
- }
-
- @Override
- public void onDataTreeChanged(Collection<DataTreeModification<T>> changes) {
- synchronized (accumulatedChanges) {
- accumulatedChanges.addAll(changes);
- if (expChangeCount == accumulatedChanges.size()) {
- future.set(new ArrayList<>(accumulatedChanges));
- }
- }
- }
-
- public Collection<DataTreeModification<T>> changes() {
- try {
- final Collection<DataTreeModification<T>> changes = future.get(5, TimeUnit.SECONDS);
- Uninterruptibles.sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
- return changes;
- } catch (InterruptedException | TimeoutException | ExecutionException e) {
- throw new AssertionError(String.format(
- "Data tree change notifications not received. Expected: %s. Actual: %s - %s",
- expChangeCount, accumulatedChanges.size(), accumulatedChanges), e);
- }
- }
-
- public void verify() {
- Collection<DataTreeModification<T>> changes = new ArrayList<>(changes());
- Iterator<DataTreeModification<T>> iter = changes.iterator();
- while (iter.hasNext()) {
- DataTreeModification<T> dataTreeModification = iter.next();
- for (Function<DataTreeModification<T>, Boolean> matcher: matchers) {
- if (matcher.apply(dataTreeModification)) {
- iter.remove();
- break;
- }
- }
- }
-
- if (!changes.isEmpty()) {
- DataTreeModification<T> mod = changes.iterator().next();
- fail(String.format("Received unexpected notification: type: %s, path: %s, before: %s, after: %s",
- mod.getRootNode().getModificationType(), mod.getRootPath().getRootIdentifier(),
- mod.getRootNode().getDataBefore(), mod.getRootNode().getDataAfter()));
- }
- }
-
- public boolean hasChanges() {
- synchronized (accumulatedChanges) {
- return !accumulatedChanges.isEmpty();
- }
- }
- }
-
- protected AbstractDataTreeChangeListenerTest() {
- super(true);
- }
-
- @SafeVarargs
- protected final <T extends DataObject> TestListener<T> createListener(final LogicalDatastoreType store,
- final InstanceIdentifier<T> path, Function<DataTreeModification<T>, Boolean>... matchers) {
- TestListener<T> listener = new TestListener<>(matchers);
- getDataBroker().registerDataTreeChangeListener(new DataTreeIdentifier<>(store, path), listener);
- return listener;
- }
-
- public static <T extends DataObject> Function<DataTreeModification<T>, Boolean> match(
- ModificationType type, InstanceIdentifier<T> path, Function<T, Boolean> checkDataBefore,
- Function<T, Boolean> checkDataAfter) {
- return modification -> type == modification.getRootNode().getModificationType()
- && path.equals(modification.getRootPath().getRootIdentifier())
- && checkDataBefore.apply(modification.getRootNode().getDataBefore())
- && checkDataAfter.apply(modification.getRootNode().getDataAfter());
- }
-
- public static <T extends DataObject> Function<DataTreeModification<T>, Boolean> match(
- ModificationType type, InstanceIdentifier<T> path, T expDataBefore, T expDataAfter) {
- return match(type, path, dataBefore -> Objects.equals(expDataBefore, dataBefore),
- (Function<T, Boolean>) dataAfter -> Objects.equals(expDataAfter, dataAfter));
- }
-
- public static <T extends DataObject> Function<DataTreeModification<T>, Boolean> added(
- InstanceIdentifier<T> path, T data) {
- return match(ModificationType.WRITE, path, null, data);
- }
-
- public static <T extends DataObject> Function<DataTreeModification<T>, Boolean> replaced(
- InstanceIdentifier<T> path, T dataBefore, T dataAfter) {
- return match(ModificationType.WRITE, path, dataBefore, dataAfter);
- }
-
- public static <T extends DataObject> Function<DataTreeModification<T>, Boolean> deleted(
- InstanceIdentifier<T> path, T dataBefore) {
- return match(ModificationType.DELETE, path, dataBefore, null);
- }
-
- public static <T extends DataObject> Function<DataTreeModification<T>, Boolean> subtreeModified(
- InstanceIdentifier<T> path, T dataBefore, T dataAfter) {
- return match(ModificationType.SUBTREE_MODIFIED, path, dataBefore, dataAfter);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.binding.test;
-
-import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
-import org.opendaylight.controller.md.sal.binding.api.NotificationService;
-import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec;
-import org.opendaylight.controller.md.sal.dom.broker.impl.DOMNotificationRouter;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
-@Deprecated
-public class AbstractNotificationBrokerTest extends AbstractSchemaAwareTest {
-
- private BindingToNormalizedNodeCodec bindingToNormalizedNodeCodec;
- private DOMNotificationRouter domNotificationRouter;
- private NotificationService notificationService;
- private NotificationPublishService notificationPublishService;
-
- @Override
- protected void setupWithSchema(final SchemaContext context) {
- final DataBrokerTestCustomizer testCustomizer = createDataBrokerTestCustomizer();
- domNotificationRouter = testCustomizer.getDomNotificationRouter();
- notificationService = testCustomizer.createNotificationService();
- notificationPublishService = testCustomizer.createNotificationPublishService();
- bindingToNormalizedNodeCodec = testCustomizer.getBindingToNormalized();
- testCustomizer.updateSchema(context);
- }
-
- protected DataBrokerTestCustomizer createDataBrokerTestCustomizer() {
- return new DataBrokerTestCustomizer();
- }
-
- public NotificationService getNotificationService() {
- return notificationService;
- }
-
- public NotificationPublishService getNotificationPublishService() {
- return notificationPublishService;
- }
-
- public DOMNotificationRouter getDomNotificationRouter() {
- return domNotificationRouter;
- }
-
- public BindingToNormalizedNodeCodec getBindingToNormalizedNodeCodec() {
- return bindingToNormalizedNodeCodec;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.test;
-
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
-import com.google.common.collect.ImmutableSet;
-import java.util.Set;
-import org.junit.Before;
-import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
-import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
-@Deprecated
-public abstract class AbstractSchemaAwareTest {
- private static final LoadingCache<ClassLoader, Set<YangModuleInfo>> MODULE_INFO_CACHE = CacheBuilder.newBuilder()
- .weakKeys().weakValues().build(new CacheLoader<ClassLoader, Set<YangModuleInfo>>() {
- @Override
- public Set<YangModuleInfo> load(final ClassLoader key) {
- return BindingReflections.loadModuleInfos(key);
- }
- });
- private static final LoadingCache<Set<YangModuleInfo>, SchemaContext> SCHEMA_CONTEXT_CACHE =
- CacheBuilder.newBuilder().weakValues().build(new CacheLoader<Set<YangModuleInfo>, SchemaContext>() {
- @Override
- public SchemaContext load(final Set<YangModuleInfo> key) {
- final ModuleInfoBackedContext moduleContext = ModuleInfoBackedContext.create();
- moduleContext.addModuleInfos(key);
- return moduleContext.tryToCreateSchemaContext().get();
- }
- });
-
- protected Set<YangModuleInfo> getModuleInfos() throws Exception {
- return MODULE_INFO_CACHE.getUnchecked(Thread.currentThread().getContextClassLoader());
- }
-
- protected SchemaContext getSchemaContext() throws Exception {
- // ImmutableSet guarantees non-null
- return SCHEMA_CONTEXT_CACHE.getUnchecked(ImmutableSet.copyOf(getModuleInfos()));
- }
-
- @Before
- public final void setup() throws Exception {
- setupWithSchema(getSchemaContext());
- }
-
- /**
- * Setups test with Schema context.
- * This method is called before {@link #setupWithSchemaService(SchemaService)}
- */
- protected abstract void setupWithSchema(SchemaContext context);
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014, 2015 Cisco Systems, Inc. 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.md.sal.binding.test;
-
-import java.util.Collection;
-import java.util.Map;
-import org.junit.Assert;
-
-@Deprecated
-public final class AssertCollections {
- private AssertCollections() {
- }
-
- public static void assertEmpty(final Collection<?> set) {
- Assert.assertTrue(set.isEmpty());
- }
-
- public static void assertEmpty(final Map<?,?> set) {
- Assert.assertTrue(set.isEmpty());
- }
-
- public static void assertContains(final Collection<?> set, final Object... values) {
- for (Object key : values) {
- Assert.assertTrue(set.contains(key));
- }
-
- }
-
- public static void assertContains(final Map<?,?> map, final Object... values) {
- for (Object key : values) {
- Assert.assertTrue(map.containsKey(key));
- }
- }
-
- public static void assertNotContains(final Collection<?> set, final Object... values) {
- for (Object key : values) {
- Assert.assertFalse(set.contains(key));
- }
- }
-
- public static void assertNotContains(final Map<?,?> map, final Object... values) {
- for (Object key : values) {
- Assert.assertFalse(map.containsKey(key));
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Red Hat, Inc. 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.md.sal.binding.test;
-
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
-import java.util.concurrent.Executors;
-
-/**
- * ConcurrentDataBrokerTestCustomizer.
- *
- * <p>See {@link AbstractConcurrentDataBrokerTest} and
- * <a href="https://bugs.opendaylight.org/show_bug.cgi?id=7538">bug 7538</a> for more details & background.
- *
- * @author Michael Vorburger
- */
-@Deprecated
-public class ConcurrentDataBrokerTestCustomizer extends AbstractDataBrokerTestCustomizer {
-
- private final ListeningExecutorService dataTreeChangeListenerExecutorSingleton;
-
- public ConcurrentDataBrokerTestCustomizer(boolean useMTDataTreeChangeListenerExecutor) {
- if (useMTDataTreeChangeListenerExecutor) {
- dataTreeChangeListenerExecutorSingleton = MoreExecutors.listeningDecorator(Executors.newCachedThreadPool());
- } else {
- dataTreeChangeListenerExecutorSingleton = MoreExecutors.newDirectExecutorService();
- }
- }
-
- @Override
- public ListeningExecutorService getCommitCoordinatorExecutor() {
- return MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor());
- }
-
- @Override
- public ListeningExecutorService getDataTreeChangeListenerExecutor() {
- return dataTreeChangeListenerExecutorSingleton;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Red Hat, Inc. 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.md.sal.binding.test;
-
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
-/**
- * AbstractDataBrokerTest which creates the SchemaContext
- * only once, and keeps it in a static, instead of re-recreating
- * it for each Test, and is thus faster.
- *
- * @author Michael Vorburger
- * @deprecated This class is no longer useful, as {@link AbstractSchemaAwareTest#getSchemaContext()} provides effective
- * caching.
- */
-@Deprecated
-public class ConstantSchemaAbstractDataBrokerTest extends AbstractConcurrentDataBrokerTest {
-
- public ConstantSchemaAbstractDataBrokerTest() {
- }
-
- public ConstantSchemaAbstractDataBrokerTest(final boolean useMTDataTreeChangeListenerExecutor) {
- super(useMTDataTreeChangeListenerExecutor);
- }
-
- @Override
- protected SchemaContext getSchemaContext() throws Exception {
- return SchemaContextSingleton.getSchemaContext(super::getSchemaContext);
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.test;
-
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
-
-/**
- * DataBrokerTestCustomizer.
- *
- * @deprecated Please use the ConcurrentDataBrokerTestCustomizer instead of
- * this; see AbstractDataBrokerTest for more details.
- */
-@Deprecated
-public class DataBrokerTestCustomizer extends AbstractDataBrokerTestCustomizer {
-
- @Override
- public ListeningExecutorService getCommitCoordinatorExecutor() {
- return MoreExecutors.newDirectExecutorService();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Red Hat, Inc. 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.md.sal.binding.test;
-
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-import org.opendaylight.controller.md.sal.dom.broker.impl.DOMNotificationRouter;
-import org.opendaylight.mdsal.dom.api.DOMSchemaService;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
-
-@Deprecated
-public class DataBrokerTestModule {
-
- public static DataBroker dataBroker() {
- return new DataBrokerTestModule(false).getDataBroker();
- }
-
- private final boolean useMTDataTreeChangeListenerExecutor;
- private ConstantSchemaAbstractDataBrokerTest dataBrokerTest;
-
- public DataBrokerTestModule(boolean useMTDataTreeChangeListenerExecutor) {
- this.useMTDataTreeChangeListenerExecutor = useMTDataTreeChangeListenerExecutor;
- }
-
- // Suppress IllegalCatch because of AbstractDataBrokerTest (change later)
- @SuppressWarnings({ "checkstyle:IllegalCatch", "checkstyle:IllegalThrows" })
- public DataBroker getDataBroker() throws RuntimeException {
- try {
- // This is a little bit "upside down" - in the future,
- // we should probably put what is in AbstractDataBrokerTest
- // into this DataBrokerTestModule, and make AbstractDataBrokerTest
- // use it, instead of the way around it currently is (the opposite);
- // this is just for historical reasons... and works for now.
- dataBrokerTest = new ConstantSchemaAbstractDataBrokerTest(useMTDataTreeChangeListenerExecutor);
- dataBrokerTest.setup();
- return dataBrokerTest.getDataBroker();
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- public DOMDataBroker getDOMDataBroker() {
- return dataBrokerTest.getDomBroker();
- }
-
- public BindingToNormalizedNodeCodec getBindingToNormalizedNodeCodec() {
- return dataBrokerTest.getDataBrokerTestCustomizer().getBindingToNormalized();
- }
-
- public DOMNotificationRouter getDOMNotificationRouter() {
- return dataBrokerTest.getDataBrokerTestCustomizer().getDomNotificationRouter();
- }
-
- public DOMSchemaService getSchemaService() {
- return dataBrokerTest.getDataBrokerTestCustomizer().getSchemaService();
- }
-
- public SchemaContextProvider getSchemaContextProvider() {
- return (SchemaContextProvider) dataBrokerTest.getDataBrokerTestCustomizer().getSchemaService();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Red Hat, Inc. 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.md.sal.binding.test;
-
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
-/**
- * {@link SchemaContext} singleton holder (static).
- *
- * <p>This is useful in scenarios such as unit tests, but not OSGi environments,
- * where there is a flat classpath and thus really only one single
- * SchemaContext.
- *
- * @author Michael Vorburger
- * @deprecated This class should not be used, as it pollutes the classpath.
- */
-@Deprecated
-public final class SchemaContextSingleton {
-
- private static SchemaContext staticSchemaContext;
-
- public static synchronized SchemaContext getSchemaContext(final Supplier<SchemaContext> supplier) throws Exception {
- if (staticSchemaContext == null) {
- staticSchemaContext = supplier.get();
- }
- return staticSchemaContext;
- }
-
- private SchemaContextSingleton() {
-
- }
-
- @FunctionalInterface
- public interface Supplier<T> {
- T get() throws Exception;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Red Hat, Inc. 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.md.sal.binding.test.tests;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.TOP_FOO_KEY;
-import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.path;
-import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.topLevelList;
-
-import org.junit.Before;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.runners.MethodSorters;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest;
-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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugmentBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ContainerWithUsesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TopBuilder;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * Integration tests the AbstractDataBrokerTest.
- *
- * @author Michael Vorburger
- */
-@Deprecated
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class AbstractDataBrokerTestTest extends AbstractConcurrentDataBrokerTest {
-
- private static final InstanceIdentifier<Top> TOP_PATH = InstanceIdentifier.create(Top.class);
-
- @Before
- public void before() {
- assertThat(getDataBroker()).isNotNull();
- }
-
- @Test
- public void aEnsureDataBrokerIsNotNull() {
- assertThat(getDataBroker()).isNotNull();
- }
-
- @Test
- public void bPutSomethingIntoDataStore() throws Exception {
- writeInitialState();
- assertThat(isTopInDataStore()).isTrue();
- }
-
- @Test
- public void cEnsureDataStoreIsEmptyAgainInNewTest() throws ReadFailedException {
- assertThat(isTopInDataStore()).isFalse();
- }
-
- // copy/pasted from Bug1125RegressionTest.writeInitialState()
- private void writeInitialState() throws TransactionCommitFailedException {
- WriteTransaction initialTx = getDataBroker().newWriteOnlyTransaction();
- initialTx.put(LogicalDatastoreType.OPERATIONAL, TOP_PATH, new TopBuilder().build());
- TreeComplexUsesAugment fooAugment = new TreeComplexUsesAugmentBuilder()
- .setContainerWithUses(new ContainerWithUsesBuilder().setLeafFromGrouping("foo").build()).build();
- initialTx.put(LogicalDatastoreType.OPERATIONAL, path(TOP_FOO_KEY), topLevelList(TOP_FOO_KEY, fooAugment));
- initialTx.submit().checkedGet();
- }
-
- private boolean isTopInDataStore() throws ReadFailedException {
- try (ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction()) {
- return readTx.read(LogicalDatastoreType.OPERATIONAL, TOP_PATH).checkedGet().isPresent();
- }
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Red Hat, Inc. 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.md.sal.binding.test.tests;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import org.junit.Ignore;
-import org.junit.Test;
-import org.opendaylight.controller.md.sal.binding.test.DataBrokerTestModule;
-
-/**
- * Integration tests the DataBrokerTestModule.
- *
- * @author Michael Vorburger
- */
-@Deprecated
-public class DataBrokerTestModuleTest {
-
- @Test
- public void ensureDataBrokerTestModuleWorksWithoutException() {
- assertThat(DataBrokerTestModule.dataBroker()).isNotNull();
- }
-
- @Test
- @Ignore // This test is flaky on build server VMs (although fine locally)
- public void slowYangLoadingShouldOnlyHappenOnceAndNotDelayEachDataBroker() {
- // TODO Write a lil' Timer utility class to make this kind of timing test code more readable
- long startAtMs = System.currentTimeMillis();
- DataBrokerTestModule.dataBroker();
- long firstDataBrokerAtMs = System.currentTimeMillis();
- long firstDataBrokerDurationMs = firstDataBrokerAtMs - startAtMs;
- DataBrokerTestModule.dataBroker();
- long secondDataBrokerDurationMs = System.currentTimeMillis() - firstDataBrokerAtMs;
- assertThat(Math.abs(secondDataBrokerDurationMs - firstDataBrokerDurationMs))
- .isLessThan(firstDataBrokerDurationMs / 4);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.binding.test;
-
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
-import org.junit.Before;
-import org.opendaylight.controller.sal.binding.test.util.BindingBrokerTestFactory;
-import org.opendaylight.controller.sal.binding.test.util.BindingTestContext;
-
-@Deprecated
-public abstract class AbstractDataServiceTest {
-
- protected BindingTestContext testContext;
-
- @Before
- public void setUp() {
- ListeningExecutorService executor = MoreExecutors.newDirectExecutorService();
- BindingBrokerTestFactory factory = new BindingBrokerTestFactory();
- factory.setExecutor(executor);
- factory.setStartWithParsedSchema(getStartWithSchema());
- testContext = factory.getTestContext();
- testContext.start();
- }
-
- protected boolean getStartWithSchema() {
- return true;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.binding.test;
-
-import static org.junit.Assert.assertNotNull;
-
-import org.opendaylight.yangtools.yang.binding.Augmentable;
-import org.opendaylight.yangtools.yang.binding.Augmentation;
-
-@Deprecated
-public class AugmentationVerifier<T extends Augmentable<T>> {
-
- private final T object;
-
- public AugmentationVerifier(final T objectToVerify) {
- this.object = objectToVerify;
- }
-
- public AugmentationVerifier<T> assertHasAugmentation(final Class<? extends Augmentation<T>> augmentation) {
- assertHasAugmentation(object, augmentation);
- return this;
- }
-
- public static <T extends Augmentable<T>> void assertHasAugmentation(final T object,
- final Class<? extends Augmentation<T>> augmentation) {
- assertNotNull(object);
- assertNotNull("Augmentation " + augmentation.getSimpleName() + " is not present.",
- object.augmentation(augmentation));
- }
-
- public static <T extends Augmentable<T>> AugmentationVerifier<T> from(final T obj) {
- return new AugmentationVerifier<>(obj);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.binding.test;
-
-@Deprecated
-public class BindingTestUtilities {
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.binding.test.mock;
-
-import org.opendaylight.yangtools.yang.binding.NotificationListener;
-
-@Deprecated
-public interface BarListener extends NotificationListener {
-
- void onBarUpdate(BarUpdate notification);
-
- void onFlowDelete(FlowDelete notification);
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.binding.test.mock;
-
-import org.opendaylight.yangtools.yang.binding.Notification;
-
-@Deprecated
-public interface BarUpdate extends Grouping,Notification {
-
-
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.binding.test.mock;
-
-@Deprecated
-public interface CompositeListener extends FooListener, BarListener {
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.binding.test.mock;
-
-import org.opendaylight.yangtools.yang.binding.Notification;
-
-@Deprecated
-public interface FlowDelete extends Notification{
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.binding.test.mock;
-
-import org.opendaylight.yangtools.yang.binding.NotificationListener;
-
-@Deprecated
-public interface FooListener extends NotificationListener {
-
- void onFooUpdate(FooUpdate notification);
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.binding.test.mock;
-
-import java.util.concurrent.Future;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-
-@Deprecated
-public interface FooService extends RpcService {
-
- Future<RpcResult<Void>> foo();
-
- Future<RpcResult<Void>> simple(SimpleInput obj);
-
- Future<RpcResult<Void>> inheritedContext(InheritedContextInput obj);
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.binding.test.mock;
-
-import org.opendaylight.yangtools.yang.binding.Notification;
-
-@Deprecated
-public interface FooUpdate extends Notification {
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.binding.test.mock;
-
-import org.opendaylight.yangtools.yang.binding.BaseIdentity;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.annotations.RoutingContext;
-
-@Deprecated
-public interface Grouping {
-
- @RoutingContext(BaseIdentity.class)
- InstanceIdentifier<?> getInheritedIdentifier();
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.binding.test.mock;
-
-@Deprecated
-public interface InheritedContextInput extends Grouping {
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.binding.test.mock;
-
-import org.opendaylight.yangtools.yang.binding.ChildOf;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.DataRoot;
-import org.opendaylight.yangtools.yang.binding.Identifiable;
-
-@Deprecated
-public interface ReferencableObject extends DataObject, Identifiable<ReferencableObjectKey>, ChildOf<DataRoot> {
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.binding.test.mock;
-
-import org.opendaylight.yangtools.yang.binding.Identifier;
-
-@Deprecated
-public class ReferencableObjectKey implements Identifier<ReferencableObject> {
- private static final long serialVersionUID = 1L;
- final Integer value;
-
- public ReferencableObjectKey(Integer value) {
- this.value = value;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + (value == null ? 0 : value.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- ReferencableObjectKey other = (ReferencableObjectKey) obj;
- if (value == null) {
- if (other.value != null) {
- return false;
- }
- } else if (!value.equals(other.value)) {
- return false;
- }
- return true;
- }
-
- @Override
- public String toString() {
- return "ReferencableObjectKey [value=" + value + "]";
- }
-
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.binding.test.mock;
-
-import org.opendaylight.yangtools.yang.binding.Augmentable;
-import org.opendaylight.yangtools.yang.binding.BaseIdentity;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.annotations.RoutingContext;
-
-@Deprecated
-public interface SimpleInput extends DataObject,Augmentable<SimpleInput> {
-
- @RoutingContext(BaseIdentity.class)
- InstanceIdentifier<?> getIdentifier();
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.binding.test.util;
-
-import com.google.common.annotations.Beta;
-import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
-import java.util.concurrent.ExecutorService;
-
-@Beta
-@Deprecated
-public class BindingBrokerTestFactory {
- private boolean startWithParsedSchema = true;
- private ExecutorService executor;
-
-
- public boolean isStartWithParsedSchema() {
- return startWithParsedSchema;
- }
-
- public void setStartWithParsedSchema(final boolean startWithParsedSchema) {
- this.startWithParsedSchema = startWithParsedSchema;
- }
-
- public ExecutorService getExecutor() {
- return executor;
- }
-
- public void setExecutor(final ExecutorService executor) {
- this.executor = executor;
- }
-
- public BindingTestContext getTestContext() {
- Preconditions.checkState(executor != null, "Executor is not set.");
- ListeningExecutorService listenableExecutor = MoreExecutors.listeningDecorator(executor);
- return new BindingTestContext(listenableExecutor, startWithParsedSchema);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.binding.test.util;
-
-import static com.google.common.base.Preconditions.checkState;
-
-import com.google.common.annotations.Beta;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
-import java.util.Set;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.MountPointService;
-import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
-import org.opendaylight.controller.md.sal.binding.api.NotificationService;
-import org.opendaylight.controller.md.sal.binding.compat.HeliumNotificationProviderServiceAdapter;
-import org.opendaylight.controller.md.sal.binding.compat.HeliumRpcProviderRegistry;
-import org.opendaylight.controller.md.sal.binding.impl.BindingDOMDataBrokerAdapter;
-import org.opendaylight.controller.md.sal.binding.impl.BindingDOMMountPointServiceAdapter;
-import org.opendaylight.controller.md.sal.binding.impl.BindingDOMNotificationPublishServiceAdapter;
-import org.opendaylight.controller.md.sal.binding.impl.BindingDOMNotificationServiceAdapter;
-import org.opendaylight.controller.md.sal.binding.impl.BindingDOMRpcProviderServiceAdapter;
-import org.opendaylight.controller.md.sal.binding.impl.BindingDOMRpcServiceAdapter;
-import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotificationPublishService;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
-import org.opendaylight.controller.md.sal.dom.broker.impl.DOMNotificationRouter;
-import org.opendaylight.controller.md.sal.dom.broker.impl.DOMRpcRouter;
-import org.opendaylight.controller.md.sal.dom.broker.impl.SerializedDOMDataBroker;
-import org.opendaylight.controller.md.sal.dom.broker.impl.mount.DOMMountPointServiceImpl;
-import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
-import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.controller.sal.binding.impl.RootBindingAwareBroker;
-import org.opendaylight.controller.sal.core.spi.data.DOMStore;
-import org.opendaylight.mdsal.binding.dom.codec.impl.BindingNormalizedNodeCodecRegistry;
-import org.opendaylight.mdsal.binding.generator.impl.GeneratedClassLoadingStrategy;
-import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
-import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
-@Beta
-@Deprecated
-public class BindingTestContext implements AutoCloseable {
- private BindingToNormalizedNodeCodec codec;
-
- private RootBindingAwareBroker baBrokerImpl;
-
- private HeliumNotificationProviderServiceAdapter baNotifyImpl;
-
-
- private final ListeningExecutorService executor;
-
- private final boolean startWithSchema;
-
- private DOMMountPointService biMountImpl;
-
- private ImmutableMap<LogicalDatastoreType, DOMStore> newDatastores;
-
- private DOMDataBroker newDOMDataBroker;
-
- private final MockSchemaService mockSchemaService = new MockSchemaService();
-
- private DataBroker dataBroker;
-
- private RpcConsumerRegistry baConsumerRpc;
-
- private BindingDOMRpcProviderServiceAdapter baProviderRpc;
- private DOMRpcRouter domRouter;
- private org.opendaylight.mdsal.dom.broker.DOMRpcRouter delegateDomRouter;
-
- private NotificationPublishService publishService;
-
- private NotificationService listenService;
-
- private DOMNotificationPublishService domPublishService;
-
- private DOMNotificationService domListenService;
-
- private Set<YangModuleInfo> schemaModuleInfos;
-
- public DOMDataBroker getDomAsyncDataBroker() {
- return this.newDOMDataBroker;
- }
-
- public BindingToNormalizedNodeCodec getCodec() {
- return this.codec;
- }
-
-
- protected BindingTestContext(final ListeningExecutorService executor, final boolean startWithSchema) {
- this.executor = executor;
- this.startWithSchema = startWithSchema;
- }
-
- public void startDomDataBroker() {
- }
-
- public void startNewDataBroker() {
- checkState(this.executor != null, "Executor needs to be set");
- checkState(this.newDOMDataBroker != null, "DOM Data Broker must be set");
- this.dataBroker = new BindingDOMDataBrokerAdapter(this.newDOMDataBroker, this.codec);
- }
-
- public void startNewDomDataBroker() {
- checkState(this.executor != null, "Executor needs to be set");
- final InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("OPER",
- MoreExecutors.newDirectExecutorService());
- final InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG",
- MoreExecutors.newDirectExecutorService());
- this.newDatastores = ImmutableMap.<LogicalDatastoreType, DOMStore>builder()
- .put(LogicalDatastoreType.OPERATIONAL, operStore)
- .put(LogicalDatastoreType.CONFIGURATION, configStore)
- .build();
-
- this.newDOMDataBroker = new SerializedDOMDataBroker(this.newDatastores, this.executor);
-
- this.mockSchemaService.registerSchemaContextListener(configStore);
- this.mockSchemaService.registerSchemaContextListener(operStore);
- }
-
- public void startBindingDataBroker() {
-
- }
-
- public void startBindingBroker() {
- checkState(this.executor != null, "Executor needs to be set");
- checkState(this.baNotifyImpl != null, "Notification Service must be started");
-
- this.baConsumerRpc = new BindingDOMRpcServiceAdapter(getDomRpcInvoker(), this.codec);
- this.baProviderRpc = new BindingDOMRpcProviderServiceAdapter(getDomRpcRegistry(), this.codec);
-
- this.baBrokerImpl = new RootBindingAwareBroker("test");
-
- final MountPointService mountService = new BindingDOMMountPointServiceAdapter(this.biMountImpl, this.codec);
- this.baBrokerImpl.setMountService(mountService);
- this.baBrokerImpl.setRpcBroker(new HeliumRpcProviderRegistry(this.baConsumerRpc, this.baProviderRpc));
- this.baBrokerImpl.setNotificationBroker(this.baNotifyImpl);
- this.baBrokerImpl.start();
- }
-
- public void startForwarding() {
-
- }
-
- public void startBindingToDomMappingService() {
- final BindingNormalizedNodeCodecRegistry codecRegistry = new BindingNormalizedNodeCodecRegistry();
- final GeneratedClassLoadingStrategy loading = GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy();
- this.codec = new BindingToNormalizedNodeCodec(loading, codecRegistry);
- this.mockSchemaService.registerSchemaContextListener(this.codec);
- }
-
- private void updateYangSchema(final Set<YangModuleInfo> moduleInfos) {
- this.mockSchemaService.changeSchema(getContext(moduleInfos));
- }
-
- private static SchemaContext getContext(final Set<YangModuleInfo> moduleInfos) {
- final ModuleInfoBackedContext ctx = ModuleInfoBackedContext.create();
- ctx.addModuleInfos(moduleInfos);
- return ctx.tryToCreateSchemaContext().get();
- }
-
- public void start() {
- startNewDomDataBroker();
-
- startDomBroker();
- startDomMountPoint();
- startBindingToDomMappingService();
- startNewDataBroker();
- startBindingNotificationBroker();
- startBindingBroker();
-
- startForwarding();
-
- if (schemaModuleInfos != null) {
- updateYangSchema(schemaModuleInfos);
- } else if (this.startWithSchema) {
- loadYangSchemaFromClasspath();
- }
- }
-
- private void startDomMountPoint() {
- this.biMountImpl = new DOMMountPointServiceImpl();
- }
-
- private void startDomBroker() {
- checkState(this.executor != null);
-
- delegateDomRouter = org.opendaylight.mdsal.dom.broker.DOMRpcRouter.newInstance(mockSchemaService);
- this.domRouter = new DOMRpcRouter(delegateDomRouter.getRpcService(), delegateDomRouter.getRpcProviderService());
- }
-
- public void startBindingNotificationBroker() {
- checkState(this.executor != null);
- final DOMNotificationRouter router = DOMNotificationRouter.create(16);
- this.domPublishService = router;
- this.domListenService = router;
- this.publishService = new BindingDOMNotificationPublishServiceAdapter(this.codec, this.domPublishService);
- this.listenService = new BindingDOMNotificationServiceAdapter(this.codec, this.domListenService);
- this.baNotifyImpl = new HeliumNotificationProviderServiceAdapter(this.publishService,this.listenService);
-
- }
-
- public void loadYangSchemaFromClasspath() {
- updateYangSchema(BindingReflections.loadModuleInfos());
- }
-
- public RpcProviderRegistry getBindingRpcRegistry() {
- return this.baBrokerImpl.getRoot();
- }
-
- public DOMRpcProviderService getDomRpcRegistry() {
- return this.domRouter;
- }
-
- public DOMRpcService getDomRpcInvoker() {
- return this.domRouter;
- }
-
- public org.opendaylight.mdsal.dom.broker.DOMRpcRouter getDelegateDomRouter() {
- return delegateDomRouter;
- }
-
- @Override
- public void close() {
-
- }
-
- public MountPointService getBindingMountPointService() {
- return this.baBrokerImpl.getMountService();
- }
-
- public DOMMountPointService getDomMountProviderService() {
- return this.biMountImpl;
- }
-
- public DataBroker getDataBroker() {
- return this.dataBroker;
- }
-
- public void setSchemaModuleInfos(Set<YangModuleInfo> moduleInfos) {
- this.schemaModuleInfos = moduleInfos;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.binding.test.util;
-
-import com.google.common.collect.ClassToInstanceMap;
-import com.google.common.collect.ImmutableClassToInstanceMap;
-import org.opendaylight.mdsal.dom.api.DOMSchemaService;
-import org.opendaylight.mdsal.dom.api.DOMSchemaServiceExtension;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.util.ListenerRegistry;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
-
-@Deprecated
-public final class MockSchemaService implements DOMSchemaService, SchemaContextProvider {
-
- private SchemaContext schemaContext;
-
- ListenerRegistry<SchemaContextListener> listeners = ListenerRegistry.create();
-
- @Override
- public synchronized SchemaContext getGlobalContext() {
- return schemaContext;
- }
-
- @Override
- public synchronized SchemaContext getSessionContext() {
- return schemaContext;
- }
-
- @Override
- public ListenerRegistration<SchemaContextListener> registerSchemaContextListener(
- final SchemaContextListener listener) {
- return listeners.register(listener);
- }
-
- @Override
- public synchronized SchemaContext getSchemaContext() {
- return schemaContext;
- }
-
- @Override
- public ClassToInstanceMap<DOMSchemaServiceExtension> getExtensions() {
- return ImmutableClassToInstanceMap.of();
- }
-
- public synchronized void changeSchema(final SchemaContext newContext) {
- schemaContext = newContext;
- for (ListenerRegistration<? extends SchemaContextListener> listener : listeners.getRegistrations()) {
- listener.getInstance().onGlobalContextUpdated(schemaContext);
- }
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>odlparent</artifactId>
- <version>6.0.4</version>
- <relativePath/>
- </parent>
-
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-dom-it</artifactId>
- <version>1.12.0-SNAPSHOT</version>
- <packaging>jar</packaging>
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yangtools-artifacts</artifactId>
- <version>4.0.6</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-artifacts</artifactId>
- <version>5.0.9</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-artifacts</artifactId>
- <version>1.12.0-SNAPSHOT</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>yang-binding</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-broker-impl</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-broker-impl</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-container-native</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-test-util</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-test-model</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>opendaylight-l2-types</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.jacoco</groupId>
- <artifactId>jacoco-maven-plugin</artifactId>
- <configuration>
- <includes>
- <include>org.opendaylight.controller.*</include>
- </includes>
- </configuration>
- <executions>
- <execution>
- <id>pre-test</id>
- <goals>
- <goal>prepare-agent</goal>
- </goals>
- </execution>
- <execution>
- <id>post-test</id>
- <goals>
- <goal>report</goal>
- </goals>
- <phase>test</phase>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <scm>
- <connection>scm:git:http://git.opendaylight.org/gerrit/controller.git</connection>
- <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
- <tag>HEAD</tag>
- <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
- </scm>
-
-</project>
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.data;
-
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import org.junit.Test;
-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.sal.binding.test.AbstractDataServiceTest;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-// FIXME: THis test should be moved to sal-binding-broker and rewritten to use new DataBroker API
-public class ConcurrentImplicitCreateTest extends AbstractDataServiceTest {
-
- private static final TopLevelListKey FOO_KEY = new TopLevelListKey("foo");
- private static final TopLevelListKey BAR_KEY = new TopLevelListKey("bar");
- private static final InstanceIdentifier<Top> TOP_PATH = InstanceIdentifier.builder(Top.class).build();
- private static final InstanceIdentifier<TopLevelList> FOO_PATH = TOP_PATH.child(TopLevelList.class, FOO_KEY);
- private static final InstanceIdentifier<TopLevelList> BAR_PATH = TOP_PATH.child(TopLevelList.class, BAR_KEY);
-
- @Test
- public void testConcurrentCreate() throws InterruptedException, ExecutionException, TimeoutException {
-
- DataBroker dataBroker = testContext.getDataBroker();
- WriteTransaction fooTx = dataBroker.newWriteOnlyTransaction();
- WriteTransaction barTx = dataBroker.newWriteOnlyTransaction();
-
- fooTx.put(LogicalDatastoreType.OPERATIONAL, FOO_PATH, new TopLevelListBuilder().withKey(FOO_KEY).build());
- barTx.put(LogicalDatastoreType.OPERATIONAL, BAR_PATH, new TopLevelListBuilder().withKey(BAR_KEY).build());
-
- fooTx.submit().get(5, TimeUnit.SECONDS);
- barTx.submit().get(5, TimeUnit.SECONDS);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.data;
-
-import static org.junit.Assert.assertFalse;
-import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.OPERATIONAL;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.common.util.concurrent.Uninterruptibles;
-import java.util.Collections;
-import java.util.Set;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import org.junit.Test;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.binding.test.AbstractDataTreeChangeListenerTest;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugmentBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ContainerWithUses;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ContainerWithUsesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ListViaUses;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ListViaUsesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ListViaUsesKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
-
-// FIXME: This test should be moved to compat test-suite
-public class WildcardedDataChangeListenerTest extends AbstractDataTreeChangeListenerTest {
-
- private static final TopLevelListKey TOP_LEVEL_LIST_0_KEY = new TopLevelListKey("test:0");
- private static final TopLevelListKey TOP_LEVEL_LIST_1_KEY = new TopLevelListKey("test:1");
-
- protected static final InstanceIdentifier<ListViaUses> DEEP_WILDCARDED_PATH = InstanceIdentifier
- .builder(Top.class)
- .child(TopLevelList.class)
- .augmentation(TreeComplexUsesAugment.class)
- .child(ListViaUses.class)
- .build();
-
- private static final InstanceIdentifier<TreeComplexUsesAugment> NODE_0_TCU_PATH = InstanceIdentifier
- .builder(Top.class)
- .child(TopLevelList.class, TOP_LEVEL_LIST_0_KEY)
- .augmentation(TreeComplexUsesAugment.class)
- .build();
-
- private static final InstanceIdentifier<TreeComplexUsesAugment> NODE_1_TCU_PATH = InstanceIdentifier
- .builder(Top.class)
- .child(TopLevelList.class, TOP_LEVEL_LIST_1_KEY)
- .augmentation(TreeComplexUsesAugment.class)
- .build();
-
-
- private static final ListViaUsesKey LIST_VIA_USES_KEY = new ListViaUsesKey("test");
-
- private static final InstanceIdentifier<ListViaUses> NODE_0_LVU_PATH = NODE_0_TCU_PATH.child(ListViaUses.class,
- LIST_VIA_USES_KEY);
-
- private static final InstanceIdentifier<ListViaUses> NODE_1_LVU_PATH = NODE_1_TCU_PATH.child(ListViaUses.class,
- LIST_VIA_USES_KEY);
-
- private static final InstanceIdentifier<ContainerWithUses> NODE_0_CWU_PATH =
- NODE_0_TCU_PATH.child(ContainerWithUses.class);
-
- private static final ContainerWithUses CWU = new ContainerWithUsesBuilder()
- .setLeafFromGrouping("some container value").build();
-
- private static final ListViaUses LVU = new ListViaUsesBuilder()
- .withKey(LIST_VIA_USES_KEY).setName("john").build();
-
- @Override
- protected Set<YangModuleInfo> getModuleInfos() throws Exception {
- return ImmutableSet.of(BindingReflections.getModuleInfo(Top.class),
- BindingReflections.getModuleInfo(TreeComplexUsesAugment.class));
- }
-
- @Test
- public void testSeparateWrites() throws InterruptedException, TimeoutException, ExecutionException {
-
- DataBroker dataBroker = getDataBroker();
-
- final TestListener<ListViaUses> listener = createListener(OPERATIONAL, DEEP_WILDCARDED_PATH,
- dataTreeModification -> NODE_0_LVU_PATH.equals(dataTreeModification.getRootPath().getRootIdentifier()),
- dataTreeModification -> NODE_1_LVU_PATH.equals(dataTreeModification.getRootPath().getRootIdentifier()));
-
- final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
- transaction.put(OPERATIONAL, NODE_0_CWU_PATH, CWU, true);
- transaction.put(OPERATIONAL, NODE_0_LVU_PATH, LVU, true);
- transaction.put(OPERATIONAL, NODE_1_LVU_PATH, LVU, true);
- transaction.submit().get(5, TimeUnit.SECONDS);
-
- listener.verify();
- }
-
- @Test
- public void testWriteByReplace() throws InterruptedException, TimeoutException, ExecutionException {
-
- DataBroker dataBroker = getDataBroker();
-
- final TestListener<ListViaUses> listener = createListener(OPERATIONAL, DEEP_WILDCARDED_PATH,
- dataTreeModification -> NODE_0_LVU_PATH.equals(dataTreeModification.getRootPath().getRootIdentifier()),
- dataTreeModification -> NODE_1_LVU_PATH.equals(dataTreeModification.getRootPath().getRootIdentifier()));
-
- final WriteTransaction cwuTx = dataBroker.newWriteOnlyTransaction();
- cwuTx.put(OPERATIONAL, NODE_0_CWU_PATH, CWU, true);
- cwuTx.submit().get(5, TimeUnit.SECONDS);
-
- Uninterruptibles.sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
- assertFalse(listener.hasChanges());
-
- final WriteTransaction lvuTx = dataBroker.newWriteOnlyTransaction();
-
- TreeComplexUsesAugment tcua = new TreeComplexUsesAugmentBuilder()
- .setListViaUses(Collections.singletonList(LVU)).build();
-
- lvuTx.put(OPERATIONAL, NODE_0_TCU_PATH, tcua, true);
- lvuTx.put(OPERATIONAL, NODE_1_LVU_PATH, LVU, true);
- lvuTx.submit().get(5, TimeUnit.SECONDS);
-
- listener.verify();
- }
-
- @Test
- public void testChangeOnReplaceWithSameValue() throws InterruptedException, TimeoutException, ExecutionException {
-
- DataBroker dataBroker = getDataBroker();
-
- // Write initial state NODE_0_FLOW
- final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
- transaction.put(OPERATIONAL, NODE_0_LVU_PATH, LVU, true);
- transaction.submit().get(5, TimeUnit.SECONDS);
-
- final TestListener<ListViaUses> listener = createListener(OPERATIONAL, DEEP_WILDCARDED_PATH,
- dataTreeModification -> NODE_1_LVU_PATH.equals(dataTreeModification.getRootPath().getRootIdentifier()),
- dataTreeModification -> NODE_0_LVU_PATH.equals(dataTreeModification.getRootPath().getRootIdentifier()),
- dataTreeModification -> NODE_1_LVU_PATH.equals(dataTreeModification.getRootPath().getRootIdentifier()));
-
- final WriteTransaction secondTx = dataBroker.newWriteOnlyTransaction();
- secondTx.put(OPERATIONAL, NODE_0_LVU_PATH, LVU, true);
- secondTx.put(OPERATIONAL, NODE_1_LVU_PATH, LVU, true);
- secondTx.submit().get(5, TimeUnit.SECONDS);
-
- listener.verify();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014, 2015 Cisco Systems, Inc. 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.binding.test.bugfix;
-
-import com.google.common.collect.ImmutableSet;
-import java.util.Set;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import org.junit.Test;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.binding.test.AbstractDataTreeChangeListenerTest;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.List11SimpleAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.List11SimpleAugmentBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.TllComplexAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.List1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.List1Key;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.list1.List11;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.list1.List11Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.list1.List11Key;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
-
-public class DeleteNestedAugmentationListenParentTest extends AbstractDataTreeChangeListenerTest {
-
- private static final TopLevelListKey FOO_KEY = new TopLevelListKey("foo");
-
- private static final List1Key LIST1_KEY = new List1Key("one");
-
- private static final List11Key LIST11_KEY = new List11Key(100);
-
- private static final InstanceIdentifier<TllComplexAugment> TLL_COMPLEX_AUGMENT_PATH = InstanceIdentifier
- .builder(Top.class)
- .child(TopLevelList.class,FOO_KEY)
- .augmentation(TllComplexAugment.class)
- .build();
-
- private static final InstanceIdentifier<List11> LIST11_PATH = TLL_COMPLEX_AUGMENT_PATH.builder()
- .child(List1.class,LIST1_KEY)
- .child(List11.class,LIST11_KEY)
- .build();
-
- @Override
- protected Set<YangModuleInfo> getModuleInfos() throws Exception {
- return ImmutableSet.of(BindingReflections.getModuleInfo(Top.class),
- BindingReflections.getModuleInfo(List11SimpleAugment.class));
- }
-
- @Test
- public void deleteChildListenParent() throws InterruptedException, ExecutionException, TimeoutException {
- DataBroker dataBroker = getDataBroker();
- final WriteTransaction initTx = dataBroker.newWriteOnlyTransaction();
-
- List11 list11Before = createList11();
- initTx.put(LogicalDatastoreType.OPERATIONAL, LIST11_PATH, list11Before, true);
- initTx.submit().get(5, TimeUnit.SECONDS);
-
- List11 list11After = new List11Builder().withKey(LIST11_KEY).setAttrStr("good").build();
-
- final TestListener<List11> listener = createListener(LogicalDatastoreType.OPERATIONAL, LIST11_PATH,
- added(LIST11_PATH, list11Before), subtreeModified(LIST11_PATH, list11Before, list11After));
-
- final WriteTransaction deleteTx = dataBroker.newWriteOnlyTransaction();
- deleteTx.delete(LogicalDatastoreType.OPERATIONAL, LIST11_PATH.augmentation(List11SimpleAugment.class));
- deleteTx.submit().get(5, TimeUnit.SECONDS);
-
- listener.verify();
- }
-
- private static List11 createList11() {
- List11Builder builder = new List11Builder()
- .withKey(LIST11_KEY)
- .addAugmentation(List11SimpleAugment.class,new List11SimpleAugmentBuilder()
- .setAttrStr2("bad").build())
- .setAttrStr("good");
- return builder.build();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.binding.test.bugfix;
-
-import static org.junit.Assert.assertEquals;
-import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.OPERATIONAL;
-
-import com.google.common.collect.ImmutableSet;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-import org.junit.Test;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.binding.test.AbstractDataTreeChangeListenerTest;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugmentBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.complex.from.grouping.ContainerWithUsesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
-
-public class WriteParentListenAugmentTest extends AbstractDataTreeChangeListenerTest {
-
- private static final String TLL_NAME = "foo";
-
- private static final TopLevelListKey TLL_KEY = new TopLevelListKey(TLL_NAME);
- private static final InstanceIdentifier<TopLevelList> TLL_INSTANCE_ID_BA = InstanceIdentifier.builder(Top.class)
- .child(TopLevelList.class, TLL_KEY).build();
-
- private static final InstanceIdentifier<TreeComplexUsesAugment> AUGMENT_WILDCARDED_PATH = InstanceIdentifier
- .builder(Top.class).child(TopLevelList.class).augmentation(TreeComplexUsesAugment.class).build();
-
- private static final InstanceIdentifier<TreeComplexUsesAugment> AUGMENT_TLL_PATH = InstanceIdentifier
- .builder(Top.class).child(TopLevelList.class, TLL_KEY).augmentation(TreeComplexUsesAugment.class).build();
-
- @Override
- protected Set<YangModuleInfo> getModuleInfos() throws Exception {
- return ImmutableSet.of(BindingReflections.getModuleInfo(Top.class),
- BindingReflections.getModuleInfo(TreeComplexUsesAugment.class));
- }
-
- @Test
- public void writeNodeListenAugment() throws Exception {
-
- DataBroker dataBroker = getDataBroker();
-
- final TreeComplexUsesAugment treeComplexUsesAugment = treeComplexUsesAugment("one");
-
- final TestListener<TreeComplexUsesAugment> listener = createListener(OPERATIONAL, AUGMENT_WILDCARDED_PATH,
- added(AUGMENT_TLL_PATH, treeComplexUsesAugment));
-
- final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
-
- TopLevelList tll = new TopLevelListBuilder().withKey(TLL_KEY)
- .addAugmentation(TreeComplexUsesAugment.class, treeComplexUsesAugment).build();
- transaction.put(OPERATIONAL, TLL_INSTANCE_ID_BA, tll, true);
- transaction.submit().get(5, TimeUnit.SECONDS);
-
- listener.verify();
-
- final WriteTransaction transaction2 = dataBroker.newWriteOnlyTransaction();
- transaction2.put(OPERATIONAL, AUGMENT_TLL_PATH, treeComplexUsesAugment("two"));
- transaction2.submit().get(5, TimeUnit.SECONDS);
-
- TreeComplexUsesAugment readedAug = dataBroker.newReadOnlyTransaction().read(
- OPERATIONAL, AUGMENT_TLL_PATH).get(5, TimeUnit.SECONDS).get();
- assertEquals("two", readedAug.getContainerWithUses().getLeafFromGrouping());
- }
-
- private static TreeComplexUsesAugment treeComplexUsesAugment(final String value) {
- return new TreeComplexUsesAugmentBuilder()
- .setContainerWithUses(new ContainerWithUsesBuilder().setLeafFromGrouping(value).build())
- .build();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.binding.test.bugfix;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableList;
-import java.util.concurrent.TimeUnit;
-import org.junit.Test;
-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.sal.binding.test.AbstractDataServiceTest;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.TllComplexAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.List1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.List1Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.List1Key;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.list1.List11;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.list1.List11Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.list1.List11Key;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-public class WriteParentReadChildTest extends AbstractDataServiceTest {
-
- private static final int LIST11_ID = 1234;
- private static final String LIST1_NAME = "bar";
- private static final String TLL_NAME = "foo";
-
- private static final TopLevelListKey TLL_KEY = new TopLevelListKey(TLL_NAME);
- private static final List11Key LIST11_KEY = new List11Key(LIST11_ID);
- private static final List1Key LIST1_KEY = new List1Key(LIST1_NAME);
-
- private static final InstanceIdentifier<TopLevelList> TLL_INSTANCE_ID_BA = InstanceIdentifier.builder(Top.class)
- .child(TopLevelList.class, TLL_KEY).build();
-
- private static final InstanceIdentifier<List1> LIST1_INSTANCE_ID_BA =
- TLL_INSTANCE_ID_BA.builder()
- .augmentation(TllComplexAugment.class).child(List1.class, LIST1_KEY).build();
-
- private static final InstanceIdentifier<? extends DataObject> LIST11_INSTANCE_ID_BA =
- LIST1_INSTANCE_ID_BA.child(List11.class, LIST11_KEY);
-
- /**
- * The scenario tests writing parent node, which also contains child items
- * and then reading child directly, by specifying path to the child.
- * Expected behaviour is child is returned.
- */
- @Test
- public void writeParentReadChild() throws Exception {
-
- DataBroker dataBroker = testContext.getDataBroker();
- final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
-
- List11 list11 = new List11Builder().withKey(LIST11_KEY).setAttrStr("primary").build();
- List1 list1 = new List1Builder().withKey(LIST1_KEY).setList11(ImmutableList.of(list11)).build();
-
- transaction.put(LogicalDatastoreType.OPERATIONAL, LIST1_INSTANCE_ID_BA, list1, true);
- transaction.submit().get(5, TimeUnit.SECONDS);
-
- Optional<List1> readList1 = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL,
- LIST1_INSTANCE_ID_BA).get(1000, TimeUnit.MILLISECONDS);
- assertTrue(readList1.isPresent());
-
- Optional<? extends DataObject> readList11 = dataBroker.newReadOnlyTransaction().read(
- LogicalDatastoreType.OPERATIONAL, LIST11_INSTANCE_ID_BA).get(5, TimeUnit.SECONDS);
- assertNotNull("Readed flow should not be null.",readList11);
- assertTrue(readList11.isPresent());
- assertEquals(list11, readList11.get());
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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
- */
-/**
- * This testsuite test Hydrogen-level API and regression for most of it.
- */
-// FIXME: this testsuite needs to be refactored to use new DataBroker API, moved to sal-binding-broker-impl
-// and uses models only from sal-test-model.
-package org.opendaylight.controller.sal.binding.test.bugfix;
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.binding.test.connect.dom;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import com.google.common.base.Optional;
-import java.util.concurrent.TimeUnit;
-import org.junit.Test;
-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.sal.binding.test.AbstractDataServiceTest;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-public class BrokerIntegrationTest extends AbstractDataServiceTest {
-
- private static final TopLevelListKey TLL_FOO_KEY = new TopLevelListKey("foo");
- private static final TopLevelListKey TLL_BAR_KEY = new TopLevelListKey("bar");
- private static final TopLevelListKey TLL_BAZ_KEY = new TopLevelListKey("baz");
- private static final InstanceIdentifier<Top> TOP_PATH = InstanceIdentifier.builder(Top.class).build();
- private static final InstanceIdentifier<TopLevelList> FOO_PATH = TOP_PATH.child(TopLevelList.class, TLL_FOO_KEY);
- private static final InstanceIdentifier<TopLevelList> BAR_PATH = TOP_PATH.child(TopLevelList.class, TLL_BAR_KEY);
- private static final InstanceIdentifier<TopLevelList> BAZ_PATH = TOP_PATH.child(TopLevelList.class, TLL_BAZ_KEY);
-
- @Test
- public void simpleModifyOperation() throws Exception {
-
- DataBroker dataBroker = testContext.getDataBroker();
- Optional<TopLevelList> tllFoo = dataBroker.newReadOnlyTransaction().read(
- LogicalDatastoreType.CONFIGURATION, FOO_PATH).get(5, TimeUnit.SECONDS);
- assertFalse(tllFoo.isPresent());
-
- TopLevelList tllFooData = createTll(TLL_FOO_KEY);
-
- final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
- transaction.put(LogicalDatastoreType.CONFIGURATION, FOO_PATH, tllFooData);
- transaction.submit().get(5, TimeUnit.SECONDS);
-
- Optional<TopLevelList> readedData = dataBroker.newReadOnlyTransaction().read(
- LogicalDatastoreType.CONFIGURATION, FOO_PATH).get(5, TimeUnit.SECONDS);
- assertTrue(readedData.isPresent());
- assertEquals(tllFooData.key(), readedData.get().key());
-
- TopLevelList nodeBarData = createTll(TLL_BAR_KEY);
- TopLevelList nodeBazData = createTll(TLL_BAZ_KEY);
-
- final WriteTransaction insertMoreTr = dataBroker.newWriteOnlyTransaction();
- insertMoreTr.put(LogicalDatastoreType.CONFIGURATION, BAR_PATH, nodeBarData);
- insertMoreTr.put(LogicalDatastoreType.CONFIGURATION, BAZ_PATH, nodeBazData);
- insertMoreTr.submit().get(5, TimeUnit.SECONDS);
-
- Optional<Top> top = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, TOP_PATH)
- .get(5, TimeUnit.SECONDS);
- assertTrue(top.isPresent());
- assertEquals(3, top.get().getTopLevelList().size());
-
- // We create transaction no 2
- final WriteTransaction removalTransaction = dataBroker.newWriteOnlyTransaction();
-
- // We remove node 1
- removalTransaction.delete(LogicalDatastoreType.CONFIGURATION, BAR_PATH);
-
- // We commit transaction
- removalTransaction.submit().get(5, TimeUnit.SECONDS);
-
- Optional<TopLevelList> readedData2 = dataBroker.newReadOnlyTransaction().read(
- LogicalDatastoreType.CONFIGURATION, BAR_PATH).get(5, TimeUnit.SECONDS);
- assertFalse(readedData2.isPresent());
- }
-
- private static TopLevelList createTll(final TopLevelListKey key) {
- return new TopLevelListBuilder().withKey(key).build();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.binding.test.connect.dom;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.FluentFuture;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.MoreExecutors;
-import java.util.Collections;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import org.gaul.modernizer_maven_annotations.SuppressModernizer;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.MountPoint;
-import org.opendaylight.controller.md.sal.binding.api.MountPointService;
-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.TransactionChainListener;
-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.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.DOMMountPointService;
-import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
-import org.opendaylight.controller.sal.binding.test.util.BindingBrokerTestFactory;
-import org.opendaylight.controller.sal.binding.test.util.BindingTestContext;
-import org.opendaylight.mdsal.common.api.CommitInfo;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.List11SimpleAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.TllComplexAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.List1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.List1Key;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.list1.List11;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.list1.List11Key;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.top.top.level.list.list1.list1._1.Cont;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-
-public class CrossBrokerMountPointTest {
-
- private static final QName TLL_NAME_QNAME = QName.create(TopLevelList.QNAME, "name");
- private static final String TLL_NAME = "foo:1";
-
- private static final TopLevelListKey TLL_KEY = new TopLevelListKey(TLL_NAME);
-
- private static final Map<QName, Object> TLL_KEY_BI = Collections.<QName, Object>singletonMap(TLL_NAME_QNAME,
- TLL_NAME);
-
- private static final InstanceIdentifier<TopLevelList> TLL_INSTANCE_ID_BA = InstanceIdentifier.builder(Top.class) //
- .child(TopLevelList.class, TLL_KEY).build();
-
- private static final List1Key LIST1_KEY = new List1Key("foo");
- private static final List11Key LIST11_KEY = new List11Key(1);
-
- private static final InstanceIdentifier<Cont> AUG_CONT_ID_BA = TLL_INSTANCE_ID_BA
- .builder().augmentation(TllComplexAugment.class) //
- .child(List1.class, LIST1_KEY) //
- .child(List11.class, LIST11_KEY) //
- .augmentation(List11SimpleAugment.class) //
- .child(Cont.class) //
- .build();
-
- private static final QName AUG_CONT = QName.create(List11.QNAME,
- Cont.QNAME.getLocalName());
-
- private static final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier TLL_INSTANCE_ID_BI = //
- YangInstanceIdentifier.builder() //
- .node(Top.QNAME) //
- .node(TopLevelList.QNAME) //
- .nodeWithKey(TopLevelList.QNAME, TLL_KEY_BI) //
- .build();
-
- private static final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier GROUP_STATISTICS_ID_BI =
- YangInstanceIdentifier
- .builder(TLL_INSTANCE_ID_BI)
- .nodeWithKey(QName.create(TllComplexAugment.QNAME, "list1"),
- QName.create(TllComplexAugment.QNAME, "attr-str"), LIST1_KEY.getAttrStr())
- .nodeWithKey(QName.create(TllComplexAugment.QNAME, "list1-1"),
- QName.create(TllComplexAugment.QNAME, "attr-int"), LIST11_KEY.getAttrInt())
- .node(AUG_CONT).build();
-
- private BindingTestContext testContext;
- private MountPointService bindingMountPointService;
- private DOMMountPointService domMountPointService;
-
- @Before
- public void setup() {
- final BindingBrokerTestFactory testFactory = new BindingBrokerTestFactory();
- testFactory.setExecutor(MoreExecutors.newDirectExecutorService());
- testFactory.setStartWithParsedSchema(true);
- testContext = testFactory.getTestContext();
-
- testContext.start();
- bindingMountPointService = testContext.getBindingMountPointService();
- domMountPointService = testContext.getDomMountProviderService();
-
- // biRpcInvoker = testContext.getDomRpcInvoker();
- assertNotNull(bindingMountPointService);
- assertNotNull(domMountPointService);
-
- // flowService = MessageCapturingFlowService.create(baRpcRegistry);
- }
-
- @Test
- public void testMountPoint() throws ReadFailedException, TimeoutException {
- final Integer attrIntValue = 500;
- domMountPointService.createMountPoint(TLL_INSTANCE_ID_BI)
- .addService(DOMDataBroker.class, new DOMDataBroker() {
-
- @Override
- public DOMDataWriteTransaction newWriteOnlyTransaction() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public DOMDataReadWriteTransaction newReadWriteTransaction() {
- return new DOMDataReadWriteTransaction() {
-
- @Override
- @SuppressModernizer
- public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(
- final LogicalDatastoreType store, final YangInstanceIdentifier path) {
- if (store == LogicalDatastoreType.OPERATIONAL && path.getLastPathArgument()
- .equals(GROUP_STATISTICS_ID_BI.getLastPathArgument())) {
-
- final ContainerNode data = Builders.containerBuilder()
- .withNodeIdentifier(new NodeIdentifier(AUG_CONT))
- .withChild(ImmutableNodes.leafNode(QName.create(AUG_CONT, "attr-int"),
- attrIntValue))
- .build();
-
- return Futures.immediateCheckedFuture(Optional.<NormalizedNode<?,?>>of(data));
- }
- return Futures.immediateFailedCheckedFuture(new ReadFailedException(TLL_NAME,
- new Exception()));
- }
-
- @Override
- public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store,
- final YangInstanceIdentifier path) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Object getIdentifier() {
- return this;
- }
-
- @Override
- public boolean cancel() {
- return false;
- }
-
- @Override
- public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path,
- final NormalizedNode<?, ?> data) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path,
- final NormalizedNode<?, ?> data) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public FluentFuture<? extends CommitInfo> commit() {
- throw new UnsupportedOperationException();
- }
- };
- }
-
- @Override
- public DOMDataReadOnlyTransaction newReadOnlyTransaction() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public DOMTransactionChain createTransactionChain(final TransactionChainListener listener) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Map<Class<? extends DOMDataBrokerExtension>, DOMDataBrokerExtension> getSupportedExtensions() {
- return Collections.emptyMap();
- }
- }).register();
-
- final Optional<MountPoint> bindingMountPoint = bindingMountPointService.getMountPoint(TLL_INSTANCE_ID_BA);
- assertTrue(bindingMountPoint.isPresent());
-
- final Optional<DataBroker> dataBroker = bindingMountPoint.get().getService(DataBroker.class);
- assertTrue(dataBroker.isPresent());
-
- final Optional<Cont> data = dataBroker.get().newReadWriteTransaction().read(LogicalDatastoreType.OPERATIONAL,
- AUG_CONT_ID_BA).checkedGet(5, TimeUnit.SECONDS);
- assertTrue(data.isPresent());
- assertEquals(attrIntValue ,data.get().getAttrInt());
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.binding.test.connect.dom;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Multimap;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.MoreExecutors;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier;
-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.DefaultDOMRpcResult;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.controller.sal.binding.test.util.BindingBrokerTestFactory;
-import org.opendaylight.controller.sal.binding.test.util.BindingTestContext;
-import org.opendaylight.mdsal.binding.dom.adapter.BindingDOMRpcProviderServiceAdapter;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.KnockKnockInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.KnockKnockInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.KnockKnockOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.KnockKnockOutputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.OpendaylightOfMigrationTestModelService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.TestContext;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-
-public class CrossBrokerRpcTest {
-
- protected RpcProviderRegistry providerRegistry;
- protected DOMRpcProviderService provisionRegistry;
- private BindingTestContext testContext;
- private DOMRpcService biRpcInvoker;
- private MessageCapturingFlowService knockService;
-
- public static final TopLevelListKey NODE_A = new TopLevelListKey("a");
- public static final TopLevelListKey NODE_B = new TopLevelListKey("b");
- public static final TopLevelListKey NODE_C = new TopLevelListKey("c");
-
- private static final QName NODE_ID_QNAME = QName.create(TopLevelList.QNAME, "name");
- private static final QName KNOCK_KNOCK_QNAME = QName.create(KnockKnockOutput.QNAME, "knock-knock");
- private static final SchemaPath KNOCK_KNOCK_PATH = SchemaPath.create(true, KNOCK_KNOCK_QNAME);
-
- public static final InstanceIdentifier<Top> NODES_PATH = InstanceIdentifier.builder(Top.class).build();
- public static final InstanceIdentifier<TopLevelList> BA_NODE_A_ID = NODES_PATH.child(TopLevelList.class, NODE_A);
- public static final InstanceIdentifier<TopLevelList> BA_NODE_B_ID = NODES_PATH.child(TopLevelList.class, NODE_B);
- public static final InstanceIdentifier<TopLevelList> BA_NODE_C_ID = NODES_PATH.child(TopLevelList.class, NODE_C);
-
- public static final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier BI_NODE_C_ID =
- createBINodeIdentifier(NODE_C);
-
-
- @Before
- public void setup() throws Exception {
- BindingBrokerTestFactory testFactory = new BindingBrokerTestFactory();
- testFactory.setExecutor(MoreExecutors.newDirectExecutorService());
- testContext = testFactory.getTestContext();
-
- testContext.setSchemaModuleInfos(ImmutableSet.of(
- BindingReflections.getModuleInfo(OpendaylightOfMigrationTestModelService.class)));
- testContext.start();
- providerRegistry = testContext.getBindingRpcRegistry();
- provisionRegistry = testContext.getDomRpcRegistry();
- biRpcInvoker = testContext.getDomRpcInvoker();
- assertNotNull(providerRegistry);
- assertNotNull(provisionRegistry);
-
- knockService = MessageCapturingFlowService.create(providerRegistry);
-
- }
-
- @After
- public void teardown() {
- testContext.close();
- }
-
- @Test
- public void testBindingRpcShortcutRegisteredViaLegacyAPI()
- throws InterruptedException, ExecutionException, TimeoutException {
- final ListenableFuture<RpcResult<KnockKnockOutput>> knockResult = knockResult(true, "open");
- knockService.registerPath(TestContext.class, BA_NODE_A_ID).setKnockKnockResult(knockResult);
-
- OpendaylightOfMigrationTestModelService baKnockInvoker =
- providerRegistry.getRpcService(OpendaylightOfMigrationTestModelService.class);
-
- final KnockKnockInput knockInput = knockKnock(BA_NODE_A_ID).setQuestion("Who's there?").build();
- ListenableFuture<RpcResult<KnockKnockOutput>> future = baKnockInvoker.knockKnock(knockInput);
-
- final RpcResult<KnockKnockOutput> rpcResult = future.get(5, TimeUnit.SECONDS);
-
- assertEquals(knockResult.get().getResult().getClass(), rpcResult.getResult().getClass());
- assertSame(knockResult.get().getResult(), rpcResult.getResult());
- assertSame(knockInput, knockService.getReceivedKnocks().get(BA_NODE_A_ID).iterator().next());
- }
-
- @Test
- public void testBindingRpcShortcutRegisteredViaMdsalAPI()
- throws InterruptedException, ExecutionException, TimeoutException {
- final ListenableFuture<RpcResult<KnockKnockOutput>> knockResult = knockResult(true, "open");
-
- BindingDOMRpcProviderServiceAdapter mdsalServiceRegistry = new BindingDOMRpcProviderServiceAdapter(
- testContext.getDelegateDomRouter().getRpcProviderService(), testContext.getCodec());
-
- final Multimap<InstanceIdentifier<?>, KnockKnockInput> receivedKnocks = HashMultimap.create();
- mdsalServiceRegistry.registerRpcImplementation(OpendaylightOfMigrationTestModelService.class,
- (OpendaylightOfMigrationTestModelService) input -> {
- receivedKnocks.put(input.getKnockerId(), input);
- return knockResult;
- }, ImmutableSet.of(BA_NODE_A_ID));
-
- OpendaylightOfMigrationTestModelService baKnockInvoker =
- providerRegistry.getRpcService(OpendaylightOfMigrationTestModelService.class);
-
- final KnockKnockInput knockInput = knockKnock(BA_NODE_A_ID).setQuestion("Who's there?").build();
- Future<RpcResult<KnockKnockOutput>> future = baKnockInvoker.knockKnock(knockInput);
-
- final RpcResult<KnockKnockOutput> rpcResult = future.get(5, TimeUnit.SECONDS);
-
- assertEquals(knockResult.get().getResult().getClass(), rpcResult.getResult().getClass());
- assertSame(knockResult.get().getResult(), rpcResult.getResult());
- assertSame(knockInput, receivedKnocks.get(BA_NODE_A_ID).iterator().next());
- }
-
- @Test
- public void bindingRoutedRpcProvider_DomInvokerTest() throws Exception {
-
- knockService//
- .registerPath(TestContext.class, BA_NODE_A_ID) //
- .registerPath(TestContext.class, BA_NODE_B_ID) //
- .setKnockKnockResult(knockResult(true, "open"));
-
- OpendaylightOfMigrationTestModelService baKnockInvoker =
- providerRegistry.getRpcService(OpendaylightOfMigrationTestModelService.class);
- assertNotSame(knockService, baKnockInvoker);
-
- KnockKnockInput knockKnockA = knockKnock(BA_NODE_A_ID) //
- .setQuestion("who's there?").build();
-
- ContainerNode knockKnockDom = toDomRpc(KNOCK_KNOCK_QNAME, knockKnockA);
- assertNotNull(knockKnockDom);
- DOMRpcResult domResult = biRpcInvoker.invokeRpc(KNOCK_KNOCK_PATH, knockKnockDom).get();
- assertNotNull(domResult);
- assertNotNull("DOM result is successful.", domResult.getResult());
- assertTrue("Bidning Add Flow RPC was captured.", knockService.getReceivedKnocks().containsKey(BA_NODE_A_ID));
- assertEquals(knockKnockA, knockService.getReceivedKnocks().get(BA_NODE_A_ID).iterator().next());
- }
-
- @Test
- public void bindingRpcInvoker_DomRoutedProviderTest() throws Exception {
- KnockKnockOutputBuilder builder = new KnockKnockOutputBuilder();
- builder.setAnswer("open");
- final KnockKnockOutput output = builder.build();
-
- provisionRegistry.registerRpcImplementation((rpc, input) -> {
- ContainerNode result = testContext.getCodec().getCodecFactory().toNormalizedNodeRpcData(output);
- return Futures.immediateCheckedFuture(new DefaultDOMRpcResult(result));
- }, DOMRpcIdentifier.create(KNOCK_KNOCK_PATH, BI_NODE_C_ID));
-
- OpendaylightOfMigrationTestModelService baKnockInvoker =
- providerRegistry.getRpcService(OpendaylightOfMigrationTestModelService.class);
- Future<RpcResult<KnockKnockOutput>> baResult = baKnockInvoker.knockKnock(knockKnock(BA_NODE_C_ID)
- .setQuestion("Who's there?").build());
- assertNotNull(baResult);
- assertEquals(output, baResult.get().getResult());
- }
-
- private ContainerNode toDomRpcInput(final DataObject addFlowA) {
- return testContext.getCodec().getCodecFactory().toNormalizedNodeRpcData(addFlowA);
- }
-
- private static org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier createBINodeIdentifier(
- final TopLevelListKey listKey) {
- return org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.builder().node(Top.QNAME)
- .node(TopLevelList.QNAME)
- .nodeWithKey(TopLevelList.QNAME, NODE_ID_QNAME, listKey.getName()).build();
- }
-
- private static ListenableFuture<RpcResult<KnockKnockOutput>> knockResult(final boolean success,
- final String answer) {
- KnockKnockOutput output = new KnockKnockOutputBuilder().setAnswer(answer).build();
- RpcResult<KnockKnockOutput> result = RpcResultBuilder.<KnockKnockOutput>status(success).withResult(output)
- .build();
- return Futures.immediateFuture(result);
- }
-
- private static KnockKnockInputBuilder knockKnock(final InstanceIdentifier<TopLevelList> listId) {
- KnockKnockInputBuilder builder = new KnockKnockInputBuilder();
- builder.setKnockerId(listId);
- return builder;
- }
-
- private ContainerNode toDomRpc(final QName rpcName, final KnockKnockInput knockInput) {
- return toDomRpcInput(knockInput);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.binding.test.connect.dom;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.MoreExecutors;
-import java.util.concurrent.ExecutionException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.controller.md.sal.binding.api.MountPoint;
-import org.opendaylight.controller.md.sal.binding.api.MountPointService;
-import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
-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.DOMRpcResult;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
-import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult;
-import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
-import org.opendaylight.controller.sal.binding.test.util.BindingBrokerTestFactory;
-import org.opendaylight.controller.sal.binding.test.util.BindingTestContext;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.rpcservice.rev140701.OpendaylightTestRpcServiceService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.rpcservice.rev140701.RockTheHouseInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.rpcservice.rev140701.RockTheHouseOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
-import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-
-/**
- * Test case for reported bug 560.
- *
- * @author Lukas Sedlak
- * @see <a
- * href="https://bugs.opendaylight.org/show_bug.cgi?id=560">https://bugs.opendaylight.org/show_bug.cgi?id=560</a>
- */
-public class DOMRpcServiceTestBugfix560 {
-
- private static final String RPC_SERVICE_NAMESPACE =
- "urn:opendaylight:params:xml:ns:yang:controller:md:sal:test:bi:ba:rpcservice";
- private static final String REVISION_DATE = "2014-07-01";
- private static final QName RPC_NAME = QName.create(RPC_SERVICE_NAMESPACE, REVISION_DATE, "rock-the-house");
-
- private static final String TLL_NAME = "id";
- private static final QName TLL_NAME_QNAME = QName.create(TopLevelList.QNAME, "name");
-
- private static final InstanceIdentifier<TopLevelList> BA_MOUNT_ID = createBATllIdentifier(TLL_NAME);
- private static final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier BI_MOUNT_ID =
- createBITllIdentifier(TLL_NAME);
-
- private BindingTestContext testContext;
- private DOMMountPointService domMountPointService;
- private MountPointService bindingMountPointService;
- private SchemaContext schemaContext;
-
- @Before
- public void setUp() throws Exception {
- final BindingBrokerTestFactory testFactory = new BindingBrokerTestFactory();
- testFactory.setExecutor(MoreExecutors.newDirectExecutorService());
- testFactory.setStartWithParsedSchema(true);
- testContext = testFactory.getTestContext();
-
- testContext.start();
- domMountPointService = testContext.getDomMountProviderService();
- bindingMountPointService = testContext.getBindingMountPointService();
- assertNotNull(domMountPointService);
-
- final YangModuleInfo moduleInfo = BindingReflections.getModuleInfo(OpendaylightTestRpcServiceService.class);
- assertNotNull(moduleInfo);
-
- schemaContext = YangParserTestUtils.parseYangSources(StatementParserMode.DEFAULT_MODE, null,
- YangTextSchemaSource.delegateForByteSource(RevisionSourceIdentifier.create(
- moduleInfo.getName().getLocalName(), moduleInfo.getName().getRevision()),
- moduleInfo.getYangTextByteSource()));
- }
-
- private static org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier createBITllIdentifier(
- final String mount) {
- return org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier
- .builder().node(Top.QNAME)
- .node(TopLevelList.QNAME)
- .nodeWithKey(TopLevelList.QNAME, TLL_NAME_QNAME, mount)
- .build();
- }
-
- private static InstanceIdentifier<TopLevelList> createBATllIdentifier(
- final String mount) {
- return InstanceIdentifier.builder(Top.class)
- .child(TopLevelList.class, new TopLevelListKey(mount)).build();
- }
-
- @Test
- public void test() throws ExecutionException, InterruptedException {
- // FIXME: This is made to only make sure instance identifier codec for path is instantiated.
- domMountPointService.createMountPoint(BI_MOUNT_ID).addService(DOMRpcService.class, new DOMRpcService() {
- @Override
- public <T extends DOMRpcAvailabilityListener> ListenerRegistration<T> registerRpcListener(final T arg0) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final SchemaPath arg0,
- final NormalizedNode<?, ?> arg1) {
- return Futures.immediateCheckedFuture(new DefaultDOMRpcResult((NormalizedNode<?, ?>) null));
- }
- }).register();
-
- final Optional<MountPoint> mountInstance = bindingMountPointService.getMountPoint(BA_MOUNT_ID);
- assertTrue(mountInstance.isPresent());
-
- final Optional<RpcConsumerRegistry> rpcRegistry = mountInstance.get().getService(RpcConsumerRegistry.class);
- assertTrue(rpcRegistry.isPresent());
- final OpendaylightTestRpcServiceService rpcService = rpcRegistry.get()
- .getRpcService(OpendaylightTestRpcServiceService.class);
- assertNotNull(rpcService);
-
- try {
- final ListenableFuture<RpcResult<RockTheHouseOutput>> result = rpcService
- .rockTheHouse(new RockTheHouseInputBuilder().build());
- assertTrue(result.get().isSuccessful());
- } catch (final IllegalStateException ex) {
- fail("OpendaylightTestRpcServiceService class doesn't contain rockTheHouse method!");
- }
- }
-
- @After
- public void teardown() {
- testContext.close();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.binding.test.connect.dom;
-
-import static org.junit.Assert.assertNotNull;
-
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.Multimap;
-import com.google.common.util.concurrent.ListenableFuture;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.KnockKnockInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.KnockKnockOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.OpendaylightOfMigrationTestModelService;
-import org.opendaylight.yangtools.yang.binding.BaseIdentity;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-
-public class MessageCapturingFlowService implements OpendaylightOfMigrationTestModelService, AutoCloseable {
-
- private ListenableFuture<RpcResult<KnockKnockOutput>> knockKnockResult;
-
- private final Multimap<InstanceIdentifier<?>, KnockKnockInput> receivedKnocks = HashMultimap.create();
- private RoutedRpcRegistration<OpendaylightOfMigrationTestModelService> registration;
-
- public ListenableFuture<RpcResult<KnockKnockOutput>> getKnockKnockResult() {
- return knockKnockResult;
- }
-
- public MessageCapturingFlowService setKnockKnockResult(
- final ListenableFuture<RpcResult<KnockKnockOutput>> kkOutput) {
- this.knockKnockResult = kkOutput;
- return this;
- }
-
- public Multimap<InstanceIdentifier<?>, KnockKnockInput> getReceivedKnocks() {
- return receivedKnocks;
- }
-
- public MessageCapturingFlowService registerTo(final RpcProviderRegistry registry) {
- registration = registry.addRoutedRpcImplementation(OpendaylightOfMigrationTestModelService.class, this);
- assertNotNull(registration);
- return this;
- }
-
- @Override
- public void close() {
- registration.close();
- }
-
- public MessageCapturingFlowService registerPath(final Class<? extends BaseIdentity> context,
- final InstanceIdentifier<?> path) {
- registration.registerPath(context, path);
- return this;
- }
-
- public MessageCapturingFlowService unregisterPath(final Class<? extends BaseIdentity> context,
- final InstanceIdentifier<?> path) {
- registration.unregisterPath(context, path);
- return this;
- }
-
- public static MessageCapturingFlowService create() {
- return new MessageCapturingFlowService();
- }
-
- public static MessageCapturingFlowService create(final RpcProviderRegistry registry) {
- MessageCapturingFlowService ret = new MessageCapturingFlowService();
- ret.registerTo(registry);
- return ret;
- }
-
- @Override
- public ListenableFuture<RpcResult<KnockKnockOutput>> knockKnock(final KnockKnockInput input) {
- receivedKnocks.put(input.getKnockerId(), input);
- return knockKnockResult;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.test.sal.binding.it;
-
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
-
-public abstract class AbstractTestProvider implements BindingAwareProvider {
-
-
-}
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import com.google.common.base.Optional;
+import java.util.Optional;
import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
import org.junit.Test;
-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.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.WriteTransaction;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.Lists;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.UnorderedContainer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedList;
UnorderedList nodeData1 = createNode("0");
transaction.put(LogicalDatastoreType.OPERATIONAL, node1, nodeData1);
- transaction.submit().get(5, TimeUnit.SECONDS);
+ transaction.commit().get(5, TimeUnit.SECONDS);
Optional<UnorderedList> readedData = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL,
node1).get(5, TimeUnit.SECONDS);
transaction2.delete(LogicalDatastoreType.OPERATIONAL, node1);
- transaction2.submit().get(5, TimeUnit.SECONDS);
+ transaction2.commit().get(5, TimeUnit.SECONDS);
Optional<UnorderedList> readedData2 = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL,
node1).get(5, TimeUnit.SECONDS);
import java.util.List;
import javax.inject.Inject;
import org.junit.Test;
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.mdsal.binding.api.NotificationPublishService;
+import org.opendaylight.mdsal.binding.api.NotificationService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.notification.rev150205.OpendaylightTestNotificationListener;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.notification.rev150205.OutOfPixieDustNotification;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.notification.rev150205.OutOfPixieDustNotificationBuilder;
@Inject
@Filter(timeout = 120 * 1000)
- NotificationProviderService notificationService;
+ NotificationService notificationService;
+
+ @Inject
+ @Filter(timeout = 120 * 1000)
+ NotificationPublishService notificationPublishService;
/**
* Test of delivering of notification.
LOG.info("The notification of type FlowAdded with cookie ID 0 is created. The "
+ "delay 100ms to make sure that the notification was delivered to "
+ "listener.");
- notificationService.publish(noDustNotification("rainy day", 42));
+ notificationPublishService.putNotification(noDustNotification("rainy day", 42));
Thread.sleep(100);
/**
notificationService.registerNotificationListener(listener2);
LOG.info("3 notifications are published");
- notificationService.publish(noDustNotification("rainy day", 5));
- notificationService.publish(noDustNotification("rainy day", 10));
- notificationService.publish(noDustNotification("tax collector", 2));
+ notificationPublishService.putNotification(noDustNotification("rainy day", 5));
+ notificationPublishService.putNotification(noDustNotification("rainy day", 10));
+ notificationPublishService.putNotification(noDustNotification("tax collector", 2));
/**
* The delay 100ms to make sure that the notifications were delivered to
listener2Reg.close();
LOG.info("The notification 5 is published");
- notificationService.publish(noDustNotification("entomologist hunt", 10));
+ notificationPublishService.putNotification(noDustNotification("entomologist hunt", 10));
/**
* The delay 100ms to make sure that the notification was delivered to
}
/**
- * Implements
- * {@link OpendaylightTestNotificationListener} and contains attributes which keep lists of objects of
- * the type {@link OutOfFairyDustNotification}.
+ * Implements {@link OpendaylightTestNotificationListener} and contains attributes which keep lists of objects of
+ * the type {@link OutOfPixieDustNotification}.
*/
public static class NotificationTestListener implements OpendaylightTestNotificationListener {
List<OutOfPixieDustNotification> notificationBag = new ArrayList<>();
import static org.mockito.Mockito.verify;
import com.google.common.util.concurrent.Futures;
+import java.util.Set;
import javax.inject.Inject;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.OpendaylightTestRoutedRpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.RoutedSimpleRouteInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.RoutedSimpleRouteInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.RoutedSimpleRouteOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.TestContext;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.Lists;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.UnorderedContainer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedListKey;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.ops4j.pax.exam.util.Filter;
@Inject
@Filter(timeout = 120 * 1000)
- RpcProviderRegistry rpcProviderRegistry;
+ RpcProviderService rpcProviderService;
+
+ @Inject
+ @Filter(timeout = 120 * 1000)
+ RpcConsumerRegistry rpcConsumerRegistry;
/**
* Prepare mocks.
@Test
public void testServiceRegistration() {
- LOG.info("Register provider 1 with first implementation of routeSimpleService - service1");
+ LOG.info("Register provider 1 with first implementation of routeSimpleService - service1 of node 1");
+ final InstanceIdentifier<UnorderedList> nodeOnePath = createNodeRef("foo:node:1");
+ final InstanceIdentifier<UnorderedList> nodeTwo = createNodeRef("foo:node:2");
- RoutedRpcRegistration<OpendaylightTestRoutedRpcService> firstReg = rpcProviderRegistry
- .addRoutedRpcImplementation(OpendaylightTestRoutedRpcService.class, odlRoutedService1);
+ ObjectRegistration<OpendaylightTestRoutedRpcService> firstReg = rpcProviderService.registerRpcImplementation(
+ OpendaylightTestRoutedRpcService.class, odlRoutedService1, Set.of(nodeOnePath));
assertNotNull("Registration should not be null", firstReg);
assertSame(odlRoutedService1, firstReg.getInstance());
- LOG.info("Register provider 2 with second implementation of routeSimpleService - service2");
+ LOG.info("Register provider 2 with second implementation of routeSimpleService - service2 of node 2");
- RoutedRpcRegistration<OpendaylightTestRoutedRpcService> secondReg = rpcProviderRegistry
- .addRoutedRpcImplementation(OpendaylightTestRoutedRpcService.class, odlRoutedService2);
+ ObjectRegistration<OpendaylightTestRoutedRpcService> secondReg = rpcProviderService.registerRpcImplementation(
+ OpendaylightTestRoutedRpcService.class, odlRoutedService2, Set.of(nodeTwo));
assertNotNull("Registration should not be null", firstReg);
assertSame(odlRoutedService2, secondReg.getInstance());
assertNotSame(secondReg, firstReg);
OpendaylightTestRoutedRpcService consumerService =
- rpcProviderRegistry.getRpcService(OpendaylightTestRoutedRpcService.class);
+ rpcConsumerRegistry.getRpcService(OpendaylightTestRoutedRpcService.class);
assertNotNull("MD-SAL instance of test Service should be returned", consumerService);
assertNotSame("Provider instance and consumer instance should not be same.", odlRoutedService1,
consumerService);
- final InstanceIdentifier<UnorderedList> nodeOnePath = createNodeRef("foo:node:1");
-
- LOG.info("Provider 1 registers path of node 1");
- firstReg.registerPath(TestContext.class, nodeOnePath);
-
/**
* Consumer creates addFlow message for node one and sends it to the MD-SAL.
*/
*/
verify(odlRoutedService2, times(0)).routedSimpleRoute(simpleRouteFirstFoo);
- LOG.info("Provider 2 registers path of node 2");
- final InstanceIdentifier<UnorderedList> nodeTwo = createNodeRef("foo:node:2");
- secondReg.registerPath(TestContext.class, nodeTwo);
-
/**
* Consumer sends message to nodeTwo for three times. Should be processed by second instance.
*/
verify(odlRoutedService1, times(0)).routedSimpleRoute(simpleRouteSecondFoo);
LOG.info("Unregistration of the path for the node one in the first provider");
- firstReg.unregisterPath(TestContext.class, nodeOnePath);
+ firstReg.close();
LOG.info("Provider 2 registers path of node 1");
- secondReg.registerPath(TestContext.class, nodeOnePath);
+ secondReg.close();
+ secondReg = rpcProviderService.registerRpcImplementation(
+ OpendaylightTestRoutedRpcService.class, odlRoutedService2, Set.of(nodeOnePath));
/**
* A consumer sends third message to node 1.
* @return simpleRouteInput instance
*/
static RoutedSimpleRouteInput createSimpleRouteInput(final InstanceIdentifier<UnorderedList> node) {
- final RoutedSimpleRouteInputBuilder ret = new RoutedSimpleRouteInputBuilder();
- ret.setRoute(node);
- return ret.build();
+ return new RoutedSimpleRouteInputBuilder().setRoute(node).build();
}
}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-parent</artifactId>
- <version>1.12.0-SNAPSHOT</version>
- <relativePath>../parent</relativePath>
- </parent>
-
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-util</artifactId>
- <version>1.12.0-SNAPSHOT</version>
- <packaging>bundle</packaging>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-api</artifactId>
- </dependency>
- </dependencies>
-
- <scm>
- <connection>scm:git:http://git.opendaylight.org/gerrit/controller.git</connection>
- <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
- <tag>HEAD</tag>
- <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
- </scm>
-
-</project>
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.util;
-
-import com.google.common.base.Preconditions;
-import org.opendaylight.controller.sal.binding.api.NotificationListener;
-import org.opendaylight.controller.sal.binding.api.NotificationService;
-import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.Notification;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-
-@Deprecated(forRemoval = true)
-public abstract class AbstractBindingSalConsumerInstance<N extends NotificationService, R extends RpcConsumerRegistry>
- implements RpcConsumerRegistry, NotificationService {
-
- private final R rpcRegistry;
- private final N notificationBroker;
-
- protected final R getRpcRegistry() {
- return rpcRegistry;
- }
-
- protected final N getNotificationBroker() {
- return notificationBroker;
- }
-
- protected final R getRpcRegistryChecked() {
- Preconditions.checkState(rpcRegistry != null,"Rpc Registry is not available.");
- return rpcRegistry;
- }
-
- protected final N getNotificationBrokerChecked() {
- Preconditions.checkState(notificationBroker != null,"Notification Broker is not available.");
- return notificationBroker;
- }
-
- protected AbstractBindingSalConsumerInstance(R rpcRegistry, N notificationBroker) {
- this.rpcRegistry = rpcRegistry;
- this.notificationBroker = notificationBroker;
- }
-
- @Override
- public <T extends RpcService> T getRpcService(Class<T> module) {
- return getRpcRegistryChecked().getRpcService(module);
- }
-
- @Override
- public <T extends Notification> ListenerRegistration<NotificationListener<T>> registerNotificationListener(
- Class<T> notificationType, NotificationListener<T> listener) {
- return getNotificationBrokerChecked().registerNotificationListener(notificationType, listener);
- }
-
- @Override
- public ListenerRegistration<org.opendaylight.yangtools.yang.binding.NotificationListener>
- registerNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener) {
- return getNotificationBrokerChecked().registerNotificationListener(listener);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.util;
-
-import java.util.concurrent.ExecutorService;
-import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-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.Notification;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-
-@Deprecated(forRemoval = true)
-public abstract class AbstractBindingSalProviderInstance<N extends NotificationProviderService,
- R extends RpcProviderRegistry>
- extends AbstractBindingSalConsumerInstance<N, R>
- implements RpcProviderRegistry, NotificationProviderService {
-
- public AbstractBindingSalProviderInstance(final R rpcRegistry, final N notificationBroker) {
- super(rpcRegistry, notificationBroker);
- }
-
- @Override
- public <T extends RpcService> RpcRegistration<T> addRpcImplementation(final Class<T> type, final T implementation)
- throws IllegalStateException {
- return getRpcRegistryChecked().addRpcImplementation(type, implementation);
- }
-
- @Override
- public <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(final Class<T> type,
- final T implementation) throws IllegalStateException {
- return getRpcRegistryChecked().addRoutedRpcImplementation(type, implementation);
- }
-
- @Override
- public void publish(final Notification notification) {
- getNotificationBrokerChecked().publish(notification);
- }
-
- @Override
- public void publish(final Notification notification, final ExecutorService service) {
- getNotificationBrokerChecked().publish(notification, service);
- }
-
- @Override
- public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L>
- registerRouteChangeListener(final L listener) {
- return getRpcRegistryChecked().registerRouteChangeListener(listener);
- }
-
- @Override
- public ListenerRegistration<NotificationInterestListener> registerInterestListener(
- final NotificationInterestListener interestListener) {
- return getNotificationBrokerChecked().registerInterestListener(interestListener);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.util;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.collect.ClassToInstanceMap;
-import com.google.common.collect.MutableClassToInstanceMap;
-import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
-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.RpcConsumerRegistry;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-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;
-
-@Deprecated(forRemoval = true)
-public final class BindingContextUtils {
- private BindingContextUtils() {
- }
-
- public static ConsumerContext createConsumerContext(final BindingAwareConsumer consumer,
- final ClassToInstanceMap<BindingAwareService> serviceProvider) {
- requireNonNull(consumer, "Consumer should not be null");
- return new SingleConsumerContextImpl(requireNonNull(serviceProvider, "Service map should not be null"));
- }
-
- public static ProviderContext createProviderContext(final BindingAwareProvider provider,
- final ClassToInstanceMap<BindingAwareService> serviceProvider) {
- requireNonNull(provider, "Provider should not be null");
- return new SingleProviderContextImpl(requireNonNull(serviceProvider, "Service map should not be null"));
- }
-
- public static ConsumerContext createConsumerContextAndInitialize(final BindingAwareConsumer consumer,
- final ClassToInstanceMap<BindingAwareService> serviceProvider) {
- ConsumerContext context = createConsumerContext(consumer, serviceProvider);
- consumer.onSessionInitialized(context);
- return context;
- }
-
- public static ProviderContext createProviderContextAndInitialize(final BindingAwareProvider provider,
- final ClassToInstanceMap<BindingAwareService> serviceProvider) {
- ProviderContext context = createProviderContext(provider, serviceProvider);
- provider.onSessionInitiated(context);
- return context;
- }
-
- public static <T extends BindingAwareService> T createContextProxyOrReturnService(final Class<T> service,
- final T instance) {
- // FIXME: Create Proxy
- return instance;
- }
-
- private static class SingleConsumerContextImpl implements ConsumerContext, AutoCloseable {
-
- private ClassToInstanceMap<BindingAwareService> alreadyRetrievedServices;
- private ClassToInstanceMap<BindingAwareService> serviceProvider;
-
- SingleConsumerContextImpl(final ClassToInstanceMap<BindingAwareService> serviceProvider) {
- this.alreadyRetrievedServices = MutableClassToInstanceMap.create();
- this.serviceProvider = serviceProvider;
- }
-
- @Override
- public final <T extends RpcService> T getRpcService(final Class<T> module) {
- return getSALService(RpcConsumerRegistry.class).getRpcService(module);
- }
-
- @Override
- public final <T extends BindingAwareService> T getSALService(final Class<T> service) {
- T potential = alreadyRetrievedServices.getInstance(requireNonNull(service,
- "Service class should not be null."));
- if (potential != null) {
- return potential;
- }
- return tryToRetrieveSalService(service);
- }
-
- private synchronized <T extends BindingAwareService> T tryToRetrieveSalService(final Class<T> service) {
- final T potential = alreadyRetrievedServices.getInstance(service);
- if (potential != null) {
- return potential;
- }
- final T requested = serviceProvider.getInstance(service);
- if (requested == null) {
- throw new IllegalArgumentException("Requested service " + service.getName() + " is not available.");
- }
- final T retrieved = BindingContextUtils.createContextProxyOrReturnService(service,requested);
- alreadyRetrievedServices.put(service, retrieved);
- return retrieved;
- }
-
- @Override
- public final void close() {
- alreadyRetrievedServices = null;
- serviceProvider = null;
- }
- }
-
- private static class SingleProviderContextImpl extends SingleConsumerContextImpl implements ProviderContext {
- SingleProviderContextImpl(final ClassToInstanceMap<BindingAwareService> serviceProvider) {
- super(serviceProvider);
- }
-
- @Override
- public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L>
- registerRouteChangeListener(final L listener) {
- return getSALService(RpcProviderRegistry.class).registerRouteChangeListener(listener);
- }
-
- @Override
- public <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(final Class<T> type,
- final T implementation) {
- return getSALService(RpcProviderRegistry.class).addRoutedRpcImplementation(type, implementation);
- }
-
- @Override
- public <T extends RpcService> RpcRegistration<T> addRpcImplementation(final Class<T> type,
- final T implementation) {
- return getSALService(RpcProviderRegistry.class).addRpcImplementation(type, implementation);
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.util;
-
-import org.opendaylight.controller.md.sal.common.api.data.DataReader;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * Deprecated.
- *
- * @deprecated Use {@link org.opendaylight.controller.md.sal.binding.api.ReadTransaction#read(
- * org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType, InstanceIdentifier)} instead.
- */
-@Deprecated(forRemoval = true)
-public final class TypeSafeDataReader {
-
- private final DataReader<InstanceIdentifier<? extends DataObject>, DataObject> delegate;
-
- public DataReader<InstanceIdentifier<?>, DataObject> getDelegate() {
- return delegate;
- }
-
- public TypeSafeDataReader(
- final DataReader<InstanceIdentifier<? extends DataObject>, DataObject> delegate) {
- this.delegate = delegate;
- }
-
- @SuppressWarnings("unchecked")
- public <D extends DataObject> D readConfigurationData(
- final InstanceIdentifier<D> path) {
- return (D) delegate.readConfigurationData(path);
- }
-
- @SuppressWarnings("unchecked")
- public <D extends DataObject> D readOperationalData(
- final InstanceIdentifier<D> path) {
- return (D) delegate.readOperationalData(path);
- }
-
- public static TypeSafeDataReader forReader(
- final DataReader<InstanceIdentifier<? extends DataObject>, DataObject> delegate) {
- return new TypeSafeDataReader(delegate);
- }
-}
<!-- OpenDaylight -->
<dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-api</artifactId>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-binding-api</artifactId>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-parent</artifactId>
- <version>1.12.0-SNAPSHOT</version>
- <relativePath>../parent</relativePath>
- </parent>
-
- <groupId>org.opendaylight.controller</groupId>
- <version>1.12.0-SNAPSHOT</version>
- <artifactId>sal-common-api</artifactId>
- <packaging>bundle</packaging>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>concepts</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>util</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-common</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-data-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-common-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <scm>
- <connection>scm:git:http://git.opendaylight.org/gerrit/controller.git</connection>
- <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
- <tag>HEAD</tag>
- <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
- </scm>
-</project>
+++ /dev/null
-/*
- * Copyright (c) 2014 Brocade Communications Systems, Inc. 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.md.sal.common.api;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.util.concurrent.AbstractCheckedFuture;
-import com.google.common.util.concurrent.ListenableFuture;
-import java.util.concurrent.CancellationException;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.function.Function;
-
-/**
- * An implementation of CheckedFuture that provides similar behavior for the <code>get</code> methods
- * that the <code>checkedGet</code> methods provide.
- *
- * <p>For {@link CancellationException} and {@link InterruptedException}, the specified exception mapper
- * is invoked to translate them to the checked exception type.
- *
- * <p>For {@link ExecutionException}, the mapper is invoked to translate the cause to the checked exception
- * and a new ExecutionException is thrown with the translated cause.
- *
- * @author Thomas Pantelis
- *
- * @param <V> The result type returned by this Future's get method
- * @param <X> The checked exception type
- */
-@Deprecated(forRemoval = true)
-public final class MappingCheckedFuture<V, X extends Exception> extends AbstractCheckedFuture<V, X> {
- private final Function<Exception, X> mapper;
-
- private MappingCheckedFuture(final ListenableFuture<V> delegate, final Function<Exception, X> mapper) {
- super(delegate);
- this.mapper = requireNonNull(mapper);
- }
-
- /**
- * Creates a new <code>MappingCheckedFuture</code> that wraps the given {@link ListenableFuture}
- * delegate.
- *
- * @param delegate the {@link ListenableFuture} to wrap
- * @param mapper the mapping {@link Function} used to translate exceptions from the delegate
- * @return a new <code>MappingCheckedFuture</code>
- */
- public static <V, X extends Exception> MappingCheckedFuture<V, X> create(
- final ListenableFuture<V> delegate, final Function<Exception, X> mapper) {
- return new MappingCheckedFuture<>(delegate, mapper);
- }
-
- @Override
- @SuppressWarnings("checkstyle:parameterName")
- protected X mapException(final Exception e) {
- return mapper.apply(e);
- }
-
- private ExecutionException wrapInExecutionException(final String message, final Exception ex) {
- return new ExecutionException(message, mapException(ex));
- }
-
- @Override
- public V get() throws InterruptedException, ExecutionException {
- try {
- return super.get();
- } catch (final InterruptedException e) {
- Thread.currentThread().interrupt();
- throw wrapInExecutionException("Operation was interrupted", e);
- } catch (final CancellationException e) {
- throw wrapInExecutionException("Operation was cancelled", e);
- } catch (final ExecutionException e) {
- throw wrapInExecutionException(e.getMessage(), e);
- }
- }
-
- @Override
- public V get(final long timeout, final TimeUnit unit)
- throws InterruptedException, ExecutionException, TimeoutException {
- try {
- return super.get(timeout, unit);
- } catch (final InterruptedException e) {
- Thread.currentThread().interrupt();
- throw wrapInExecutionException("Operation was interrupted", e);
- } catch (final CancellationException e) {
- throw wrapInExecutionException("Operation was cancelled", e);
- } catch (final ExecutionException e) {
- throw wrapInExecutionException(e.getMessage(), e);
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.common.api;
-
-import java.util.EventListener;
-import org.opendaylight.yangtools.concepts.Registration;
-
-@Deprecated(forRemoval = true)
-public interface RegistrationListener<T extends Registration> extends EventListener {
-
- void onRegister(T registration);
-
- void onUnregister(T registration);
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.common.api.data;
-
-import com.google.common.util.concurrent.ListenableFuture;
-import org.opendaylight.yangtools.concepts.Path;
-
-/**
- * Three phase Commit Cohort for subtree, which is uniquely associated with user submitted transaction.
- *
- * @param <P>
- * Type of path (subtree identifier), which represents location in
- * tree
- * @param <D>
- * Type of data (payload), which represents data payload
- */
-@Deprecated(forRemoval = true)
-public interface AsyncConfigurationCommitCohort<P extends Path<P>, D> {
-
- /**
- * Initiates a pre-commit of associated request
- *
- * <p>
- * Implementation MUST NOT do any blocking calls during this callback, all
- * pre-commit preparation SHOULD happen asynchronously and MUST result in
- * completing returned future object.
- *
- * @param rebasedTransaction
- * Read-only view of transaction as if happened on top of actual
- * data store
- * @return Future which is completed once pre-commit phase for this request
- * is finished.
- */
- ListenableFuture<Void> preCommit(AsyncReadTransaction<P, D> rebasedTransaction);
-
- /**
- * Initiates a commit phase of associated request
- *
- * <p>
- * Implementation MUST NOT do any blocking calls during this callback, all
- * commit finalization SHOULD happen asynchronously and MUST result in
- * completing returned future object.
- *
- * @return Future which is completed once commit phase for associated
- * request is finished.
- */
- ListenableFuture<Void> commit();
-
- /**
- * Initiates abort phase of associated request
- *
- * <p>
- * Implementation MUST NOT do any blocking calls during this callback, all
- * commit finalization SHOULD happen asynchronously and MUST result in
- * completing returned future object.
- *
- * @return Future which is completed once commit phase for associated
- * request is finished.
- */
- ListenableFuture<Void> abort();
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.common.api.data;
-
-import org.opendaylight.yangtools.concepts.ObjectRegistration;
-import org.opendaylight.yangtools.concepts.Path;
-
-/**
- * Three Phase Commit Coordinator with support of user-supplied commit cohorts
- * which participates in three-phase commit protocols.
- *
- * @param <P>
- * Type of path (subtree identifier), which represents location in
- * tree
- * @param <D>
- * Type of data (payload), which represents data payload
- */
-@Deprecated(forRemoval = true)
-public interface AsyncConfigurationCommitCoordinator<P extends Path<P>, D> {
- /**
- * Register configuration commit handler for particular subtree. Configuration commit handler is invoked for all
- * write transactions which modifies <code>subtree</code>
- *
- * @param subtree Subtree which configuration commit handler is interested it
- * @param commitHandler Instance of user-provided commit handler
- * @return Registration object representing this registration. Invoking {@link ObjectRegistration#close()}
- * will unregister configuration commit handler.
- */
- <C extends AsyncConfigurationCommitCohort<P, D>> ObjectRegistration<C> registerConfigurationCommitHandler(
- P subtree, C commitHandler);
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.common.api.data;
-
-import com.google.common.util.concurrent.CheckedFuture;
-import org.opendaylight.yangtools.concepts.Path;
-
-/**
- * User-supplied participant in three-phase commit of transaction for configuration data tree.
- *
- * <p>
- * Client-supplied implementation of commit handler for subtree, which
- * is responsible for processing CAN-COMMIT phase of three-phase commit protocol
- * and return CommitCohort, which provides access to additional transitions
- * such as PRE-COMMIT, COMMIT and ABORT.
- *
- * @param <P>
- * Type of path (subtree identifier), which represents location in
- * tree
- * @param <D>
- * Type of data (payload), which represents data payload
- */
-@Deprecated(forRemoval = true)
-public interface AsyncConfigurationCommitHandler<P extends Path<P>, D> {
-
- /**
- * Requests a can commit phase
- *
- * <p>
- * Implementations SHOULD NOT do any blocking operation during
- * processing this callback.
- *
- * <b>Implementation Notes</b>
- * <ul>
- * <li>Implementation are REQUIRED to use <code>request</code> object for any data related access</li>
- * <li>Implementations SHOULD NOT use any other state stored outside configuration subtree for validation</li>
- * <li>Validation should happen asynchronously, outside callback call by updating returned {@link CheckedFuture}
- * object.</li>
- * <li>If validation (CAN_COMMIT) phase:
- * <ul>
- * <li><b>is successful</b> - invocation of {@link CheckedFuture#checkedGet()} on returned future MUST
- * return {@link AsyncConfigurationCommitCohort} associated with request.</li>
- * <li><b>is unsuccessful</b> - invocation of {@link CheckedFuture#checkedGet()} must throw instance
- * of {@link DataValidationFailedException}
- * with human readable explanaition of error condition.
- * </li>
- * </ul>
- * </li>
- * </ul>
- * @param request
- * Commit Request submitted by client, which contains
- * information about modifications and read-only view as
- * if transaction happened.
- * @return CheckedFuture which contains client-supplied implementation of {@link AsyncConfigurationCommitCohort}
- * associated with submitted request, if can commit phase is
- * successful, if can commit was unsuccessful, future must fail with
- * {@link TransactionCommitFailedException} exception.
- */
- CheckedFuture<AsyncConfigurationCommitCohort<P, D>, DataValidationFailedException> canCommit(
- ConfigurationCommitRequest<P, D> request);
-
- /**
- * Commit Request as was submitted by client code
- *
- * <p>
- * Commit Request contains list view of created / updated / removed
- * path and read-only view of proposed client transaction,
- * which may be used to retrieve modified or referenced data.
- *
- *
- * @param <P>
- * Type of path (subtree identifier), which represents location
- * in tree
- * @param <D>
- * Type of data (payload), which represents data payload
- */
- interface ConfigurationCommitRequest<P extends Path<P>, D> {
-
- /**
- * Read-only transaction which provides access only to configuration
- * data tree as if submitted transaction successfully happened and
- * no other concurrent modifications happened between allocation
- * of client transactions and write of client transactions.
- *
- * <p>
- * Implementations of Commit Handlers are REQUIRED to use this
- * read-only view to access any data from configuration data tree,
- * in order to capture them as preconditions for this transaction.
- *
- * @return Read-only transaction which provides access only to configuration
- * data tree as if submitted transaction successfully happened
- */
- AsyncReadTransaction<P, D> getReadOnlyView();
-
- /**
- * Returns iteration of paths, to data which was introduced by this transaction.
- *
- * @return Iteration of paths, which was introduced by this transaction.
- */
- Iterable<P> getCreatedPaths();
-
- /**
- * Returns iteration of paths, to data which was updated by this transaction.
- *
- * @return Iteration of paths, which was updated by this transaction.
- */
- Iterable<P> getUpdatedPaths();
-
- /**
- * Returns iteration of paths, to data which was removed by this transaction.
- *
- * @return Iteration of paths, which was removed by this transaction.
- */
- Iterable<P> getRemovedPaths();
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.common.api.data;
-
-import org.opendaylight.yangtools.concepts.Path;
-
-/**
- * Base interface that provides access to a conceptual data tree store and also provides the ability to
- * subscribe for changes to data under a given branch of the tree.
- *
- * <p>
- * All operations on the data tree are performed via one of the transactions:
- * <ul>
- * <li>Read-Only - allocated using {@link #newReadOnlyTransaction()}
- * <li>Write-Only - allocated using {@link #newWriteOnlyTransaction()}
- * <li>Read-Write - allocated using {@link #newReadWriteTransaction()}
- * </ul>
- *
- * <p>
- * These transactions provide a stable isolated view of data tree, which is
- * guaranteed to be not affected by other concurrent transactions, until
- * transaction is committed.
- *
- * <p>
- * For a detailed explanation of how transaction are isolated and how transaction-local
- * changes are committed to global data tree, see
- * {@link AsyncReadTransaction}, {@link AsyncWriteTransaction},
- * {@link AsyncReadWriteTransaction} and {@link AsyncWriteTransaction#submit()}.
- *
- *
- * <p>
- * It is strongly recommended to use the type of transaction, which
- * provides only the minimal capabilities you need. This allows for
- * optimizations at the data broker / data store level. For example,
- * implementations may optimize the transaction for reading if they know ahead
- * of time that you only need to read data - such as not keeping additional meta-data,
- * which may be required for write transactions.
- *
- * <p>
- * <b>Implementation Note:</b> This interface is not intended to be implemented
- * by users of MD-SAL, but only to be consumed by them.
- *
- * @param <P>
- * Type of path (subtree identifier), which represents location in
- * tree
- * @param <D>
- * Type of data (payload), which represents data payload
- */
-@Deprecated(forRemoval = true)
-public interface AsyncDataBroker<P extends Path<P>, D> extends AsyncDataTransactionFactory<P, D> {
-
- @Override
- AsyncReadOnlyTransaction<P, D> newReadOnlyTransaction();
-
- @Override
- AsyncReadWriteTransaction<P, D> newReadWriteTransaction();
-
- @Override
- AsyncWriteTransaction<P, D> newWriteOnlyTransaction();
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.common.api.data;
-
-import org.opendaylight.yangtools.concepts.Path;
-
-/**
- * A factory which allocates new transactions to operate on the data
- * tree.
- *
- * <p>
- * <b>Note:</b> This interface is not intended to be used directly, but rather
- * via subinterfaces which introduces additional semantics to allocated
- * transactions.
- * <ul>
- * <li> {@link AsyncDataBroker}
- * <li> {@link TransactionChain}
- * </ul>
- *
- * <p>
- * All operations on the data tree are performed via one of the transactions:
- * <ul>
- * <li>Read-Only - allocated using {@link #newReadOnlyTransaction()}
- * <li>Write-Only - allocated using {@link #newWriteOnlyTransaction()}
- * <li>Read-Write - allocated using {@link #newReadWriteTransaction()}
- * </ul>
- *
- * <p>
- * These transactions provides a stable isolated view of the data tree, which is
- * guaranteed to be not affected by other concurrent transactions, until
- * transaction is committed.
- *
- * <p>
- * For a detailed explanation of how transaction are isolated and how transaction-local
- * changes are committed to global data tree, see
- * {@link AsyncReadTransaction}, {@link AsyncWriteTransaction},
- * {@link AsyncReadWriteTransaction} and {@link AsyncWriteTransaction#submit()}.
- *
- * <p>
- * It is strongly recommended to use the type of transaction, which
- * provides only the minimal capabilities you need. This allows for
- * optimizations at the data broker / data store level. For example,
- * implementations may optimize the transaction for reading if they know ahead
- * of time that you only need to read data - such as not keeping additional meta-data,
- * which may be required for write transactions.
- *
- * <p>
- * <b>Implementation Note:</b> This interface is not intended to be implemented
- * by users of MD-SAL, but only to be consumed by them.
- *
- * @see AsyncDataBroker
- * @see TransactionChain
- *
- * @param <P>
- * Type of path (subtree identifier), which represents location in
- * tree
- * @param <D>
- * Type of data (payload), which represents data payload
- */
-@Deprecated(forRemoval = true)
-public interface AsyncDataTransactionFactory<P extends Path<P>, D> {
-
- /**
- * Allocates a new read-only transaction which provides an immutable snapshot of the data tree.
- *
- * <p>
- * The view of data tree is an immutable snapshot of current data tree state when
- * transaction was allocated.
- *
- * @return new read-only transaction
- */
- AsyncReadOnlyTransaction<P, D> newReadOnlyTransaction();
-
- /**
- * Allocates new read-write transaction which provides a mutable view of the data
- * tree.
- *
- * <p>
- * Preconditions for mutation of data tree are captured from the snapshot of
- * data tree state, when the transaction is allocated. If data was
- * changed during transaction in an incompatible way then the commit of this transaction
- * will fail. See {@link AsyncWriteTransaction#submit()} for more
- * details about conflicting and not-conflicting changes and
- * failure scenarios.
- *
- * @return new read-write transaction
- */
- AsyncReadWriteTransaction<P, D> newReadWriteTransaction();
-
- /**
- * Allocates new write-only transaction based on latest state of data
- * tree.
- *
- * <p>
- * Preconditions for mutation of data tree are captured from the snapshot of
- * data tree state, when the transaction is allocated. If data was
- * changed during transaction in an incompatible way then the commit of this transaction
- * will fail. See {@link AsyncWriteTransaction#submit()} for more
- * details about conflicting and not-conflicting changes and
- * failure scenarios.
- *
- * <p>
- * Since this transaction does not provide a view of the data it SHOULD BE
- * used only by callers which are exclusive writers (exporters of data)
- * to the subtree they modify. This prevents optimistic
- * lock failures as described in {@link AsyncWriteTransaction#submit()}.
- *
- * <p>
- * Exclusivity of writers to particular subtree SHOULD BE enforced by
- * external locking mechanism.
- *
- * @return new write-only transaction
- */
- AsyncWriteTransaction<P, D> newWriteOnlyTransaction();
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.common.api.data;
-
-import org.opendaylight.yangtools.concepts.Path;
-
-/**
- * Marker interface for a read-only view of the data tree.
- *
- * @see AsyncReadTransaction
- *
- * @param <P>
- * Type of path (subtree identifier), which represents location in
- * tree
- * @param <D>
- * Type of data (payload), which represents data payload
- */
-@Deprecated(forRemoval = true)
-public interface AsyncReadOnlyTransaction<P extends Path<P>, D> extends AsyncReadTransaction<P, D>, AutoCloseable {
-
- /**
- * Closes this transaction and releases all resources associated with it.
- *
- */
- @Override
- void close();
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.common.api.data;
-
-import org.opendaylight.yangtools.concepts.Path;
-
-/**
- * Marker interface for stateful read view of the data tree.
- *
- * <p>
- * View of the data tree is a stable point-in-time snapshot of the current data tree state when
- * the transaction was created. It's state and underlying data tree
- * is not affected by other concurrently running transactions.
- *
- * <p>
- * <b>Implementation Note:</b> This interface is not intended to be implemented
- * by users of MD-SAL, but only to be consumed by them.
- *
- * <h2>Transaction isolation example</h2>
- * Lets assume initial state of data tree for <code>PATH</code> is <code>A</code>.
- *
- * <pre>
- * txRead = broker.newReadOnlyTransaction(); // read Transaction is snapshot of data
- * txWrite = broker.newReadWriteTransactoin(); // concurrent write transaction
- *
- * txRead.read(OPERATIONAL,PATH).get(); // will return Optional containing A
- * txWrite = broker.put(OPERATIONAL,PATH,B); // writes B to PATH
- *
- * txRead.read(OPERATIONAL,PATH).get(); // still returns Optional containing A
- *
- * txWrite.commit().get(); // data tree is updated, PATH contains B
- * txRead.read(OPERATIONAL,PATH).get(); // still returns Optional containing A
- *
- * txAfterCommit = broker.newReadOnlyTransaction(); // read Transaction is snapshot of new state
- * txAfterCommit.read(OPERATIONAL,PATH).get(); // returns Optional containing B;
- * </pre>
- *
- * <p>
- * <b>Note:</b> example contains blocking calls on future only to illustrate
- * that action happened after other asynchronous action. Use of blocking call
- * {@link com.google.common.util.concurrent.ListenableFuture#get()} is discouraged for most
- * uses and you should use
- * {@link com.google.common.util.concurrent.Futures#addCallback(com.google.common.util.concurrent.ListenableFuture,
- * com.google.common.util.concurrent.FutureCallback, java.util.concurrent.Executor)}
- * or other functions from {@link com.google.common.util.concurrent.Futures} to
- * register more specific listeners.
- *
- * @param <P>
- * Type of path (subtree identifier), which represents location in
- * tree
- * @param <D>
- * Type of data (payload), which represents data payload
- */
-@Deprecated(forRemoval = true)
-public interface AsyncReadTransaction<P extends Path<P>, D> extends AsyncTransaction<P, D> {
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.common.api.data;
-
-import org.opendaylight.yangtools.concepts.Path;
-
-/**
- * Transaction enabling a client to have a combined read/write capabilities.
- *
- * <p>
- * The initial state of the write transaction is stable snapshot of current data tree
- * state captured when transaction was created and it's state and underlying
- * data tree are not affected by other concurrently running transactions.
- *
- * <p>
- * Write transactions are isolated from other concurrent write transactions. All
- * writes are local to the transaction and represents only a proposal of state
- * change for data tree and it is not visible to any other concurrently running
- * transactions.
- *
- * <p>
- * Applications publish the changes proposed in the transaction by calling {@link #submit}
- * on the transaction. This seals the transaction
- * (preventing any further writes using this transaction) and submits it to be
- * processed and applied to global conceptual data tree.
- *
- * <p>
- * The transaction commit may fail due to a concurrent transaction modifying and committing data in
- * an incompatible way. See {@link #submit()} for more concrete commit failure examples.
- *
- * <b>Implementation Note:</b> This interface is not intended to be implemented
- * by users of MD-SAL, but only to be consumed by them.
- *
- * <h2>Examples</h2>
- *
- * <h3>Transaction local state</h3>
- *
- * <p>
- * Let assume initial state of data tree for <code>PATH</code> is <code>A</code>
- * .
- *
- * <pre>
- * txWrite = broker.newReadWriteTransaction(); // concurrent write transaction
- *
- * txWrite.read(OPERATIONAL,PATH).get() // will return Optional containing A
- * txWrite.put(OPERATIONAL,PATH,B); // writes B to PATH
- * txWrite.read(OPERATIONAL,PATH).get() // will return Optional Containing B
- *
- * txWrite.commit().get(); // data tree is updated, PATH contains B
- *
- * tx1afterCommit = broker.newReadOnlyTransaction(); // read Transaction is snapshot of new state
- * tx1afterCommit.read(OPERATIONAL,PATH).get(); // returns Optional containing B
- * </pre>
- *
- * <p>
- * As you could see read-write transaction provides capabilities as
- * {@link AsyncWriteTransaction} but also allows for reading proposed changes as
- * if they already happened.
- *
- * <h3>Transaction isolation (read transaction, read-write transaction)</h3> Let
- * assume initial state of data tree for <code>PATH</code> is <code>A</code>.
- *
- * <pre>
- * txRead = broker.newReadOnlyTransaction(); // read Transaction is snapshot of data
- * txWrite = broker.newReadWriteTransaction(); // concurrent write transaction
- *
- * txRead.read(OPERATIONAL,PATH).get(); // will return Optional containing A
- * txWrite.read(OPERATIONAL,PATH).get() // will return Optional containing A
- *
- * txWrite.put(OPERATIONAL,PATH,B); // writes B to PATH
- * txWrite.read(OPERATIONAL,PATH).get() // will return Optional Containing B
- *
- * txRead.read(OPERATIONAL,PATH).get(); // concurrent read transaction still returns
- * // Optional containing A
- *
- * txWrite.commit().get(); // data tree is updated, PATH contains B
- * txRead.read(OPERATIONAL,PATH).get(); // still returns Optional containing A
- *
- * tx1afterCommit = broker.newReadOnlyTransaction(); // read Transaction is snapshot of new state
- * tx1afterCommit.read(OPERATIONAL,PATH).get(); // returns Optional containing B
- * </pre>
- *
- * <h3>Transaction isolation (2 concurrent read-write transactions)</h3> Let
- * assume initial state of data tree for <code>PATH</code> is <code>A</code>.
- *
- * <pre>
- * tx1 = broker.newReadWriteTransaction(); // read Transaction is snapshot of data
- * tx2 = broker.newReadWriteTransaction(); // concurrent write transaction
- *
- * tx1.read(OPERATIONAL,PATH).get(); // will return Optional containing A
- * tx2.read(OPERATIONAL,PATH).get() // will return Optional containing A
- *
- * tx2.put(OPERATIONAL,PATH,B); // writes B to PATH
- * tx2.read(OPERATIONAL,PATH).get() // will return Optional Containing B
- *
- * tx1.read(OPERATIONAL,PATH).get(); // tx1 read-write transaction still sees Optional
- * // containing A since is isolated from tx2
- * tx1.put(OPERATIONAL,PATH,C); // writes C to PATH
- * tx1.read(OPERATIONAL,PATH).get() // will return Optional Containing C
- *
- * tx2.read(OPERATIONAL,PATH).get() // tx2 read-write transaction still sees Optional
- * // containing B since is isolated from tx1
- *
- * tx2.commit().get(); // data tree is updated, PATH contains B
- * tx1.read(OPERATIONAL,PATH).get(); // still returns Optional containing C since is isolated from tx2
- *
- * tx1afterCommit = broker.newReadOnlyTransaction(); // read Transaction is snapshot of new state
- * tx1afterCommit.read(OPERATIONAL,PATH).get(); // returns Optional containing B
- *
- * tx1.commit() // Will fail with OptimisticLockFailedException
- * // which means concurrent transaction changed the same PATH
- *
- * </pre>
- *
- * <p>
- * <b>Note:</b> examples contains blocking calls on future only to illustrate
- * that action happened after other asynchronous action. Use of blocking call
- * {@link com.google.common.util.concurrent.ListenableFuture#get()} is discouraged for most uses and you should
- * use {@link com.google.common.util.concurrent.Futures#addCallback(com.google.common.util.concurrent.ListenableFuture,
- * com.google.common.util.concurrent.FutureCallback, java.util.concurrent.Executor)}
- * or other functions from {@link com.google.common.util.concurrent.Futures} to
- * register more specific listeners.
- *
- * @see AsyncReadTransaction
- * @see AsyncWriteTransaction
- *
- * @param <P>
- * Type of path (subtree identifier), which represents location in
- * tree
- * @param <D>
- * Type of data (payload), which represents data payload
- */
-@Deprecated(forRemoval = true)
-public interface AsyncReadWriteTransaction<P extends Path<P>, D> extends AsyncReadTransaction<P, D>,
- AsyncWriteTransaction<P, D> {
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.common.api.data;
-
-import org.opendaylight.yangtools.concepts.Identifiable;
-import org.opendaylight.yangtools.concepts.Path;
-
-
-/**
- * A common parent for all transactions which operate on a conceptual data tree.
- *
- * <p>
- * See derived transaction types for more concrete behavior:
- * <ul>
- * <li>{@link AsyncReadTransaction} - Read capabilities, user is able to read data from data tree</li>
- * <li>{@link AsyncWriteTransaction} - Write capabilities, user is able to propose changes to data tree</li>
- * <li>{@link AsyncReadWriteTransaction} - Read and Write capabilities, user is able to read state and to propose
- * changes of state.</li>
- * </ul>
- *
- * <b>Implementation Note:</b> This interface is not intended to be implemented
- * by users of MD-SAL.
- *
- * @param <P> Type of path (subtree identifier), which represents location in tree
- * @param <D> Type of data (payload), which represents data payload
- */
-@Deprecated(forRemoval = true)
-public interface AsyncTransaction<P extends Path<P>,D> extends //
- Identifiable<Object> {
-
- @Override
- Object getIdentifier();
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.common.api.data;
-
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.FluentFuture;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.MoreExecutors;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.controller.md.sal.common.api.MappingCheckedFuture;
-import org.opendaylight.mdsal.common.api.CommitInfo;
-import org.opendaylight.yangtools.concepts.Path;
-import org.opendaylight.yangtools.util.concurrent.ExceptionMapper;
-
-/**
- * Write transaction provides mutation capabilities for a data tree.
- *
- * <p>
- * Initial state of write transaction is a stable snapshot of the current data tree.
- * The state is captured when the transaction is created and its state and underlying
- * data tree are not affected by other concurrently running transactions.
- *
- * <p>
- * Write transactions are isolated from other concurrent write transactions. All
- * writes are local to the transaction and represent only a proposal of state
- * change for the data tree and it is not visible to any other concurrently running
- * transaction.
- *
- * <p>
- * Applications make changes to the local data tree in the transaction by via the
- * <b>put</b>, <b>merge</b>, and <b>delete</b> operations.
- *
- * <h2>Put operation</h2>
- * Stores a piece of data at a specified path. This acts as an add / replace
- * operation, which is to say that whole subtree will be replaced by the
- * specified data.
- *
- * <p>
- * Performing the following put operations:
- *
- * <pre>
- * 1) container { list [ a ] }
- * 2) container { list [ b ] }
- * </pre>
- *
- * <p>
- * will result in the following data being present:
- *
- * <pre>
- * container { list [ b ] }
- * </pre>
- * <h2>Merge operation</h2>
- * Merges a piece of data with the existing data at a specified path. Any pre-existing data
- * which is not explicitly overwritten will be preserved. This means that if you store a container,
- * its child lists will be merged.
- *
- * <p>
- * Performing the following merge operations:
- *
- * <pre>
- * 1) container { list [ a ] }
- * 2) container { list [ b ] }
- * </pre>
- *
- * <p>
- * will result in the following data being present:
- *
- * <pre>
- * container { list [ a, b ] }
- * </pre>
- *
- * <p>
- * This also means that storing the container will preserve any
- * augmentations which have been attached to it.
- *
- * <h2>Delete operation</h2>
- * Removes a piece of data from a specified path.
- *
- * <p>
- * After applying changes to the local data tree, applications publish the changes proposed in the
- * transaction by calling {@link #submit} on the transaction. This seals the transaction
- * (preventing any further writes using this transaction) and submits it to be
- * processed and applied to global conceptual data tree.
- *
- * <p>
- * The transaction commit may fail due to a concurrent transaction modifying and committing data in
- * an incompatible way. See {@link #submit} for more concrete commit failure examples.
- *
- * <p>
- * <b>Implementation Note:</b> This interface is not intended to be implemented
- * by users of MD-SAL, but only to be consumed by them.
- *
- * @param <P>
- * Type of path (subtree identifier), which represents location in
- * tree
- * @param <D>
- * Type of data (payload), which represents data payload
- */
-@Deprecated(forRemoval = true)
-public interface AsyncWriteTransaction<P extends Path<P>, D> extends AsyncTransaction<P, D> {
- /**
- * Cancels the transaction.
- *
- * <p>
- * Transactions can only be cancelled if it's state is new or submitted.
- *
- * <p>
- * Invoking cancel() on a failed or cancelled transaction will have no effect, and transaction
- * is considered cancelled.
- *
- * <p>
- * Invoking cancel() on a finished transaction (future returned by {@link #submit()} already completed will always
- * fail (return false).
- *
- * @return {@code false} if the task could not be cancelled, typically because it has already completed normally
- * {@code true} otherwise
- *
- */
- boolean cancel();
-
- /**
- * Removes a piece of data from specified path. This operation does not fail
- * if the specified path does not exist.
- *
- * @param store
- * Logical data store which should be modified
- * @param path
- * Data object path
- * @throws IllegalStateException
- * if the transaction as already been submitted or cancelled
- */
- void delete(LogicalDatastoreType store, P path);
-
- /**
- * Submits this transaction to be asynchronously applied to update the logical data tree.
- * The returned CheckedFuture conveys the result of applying the data changes.
- *
- * <p>
- * <b>Note:</b> It is strongly recommended to process the CheckedFuture result in an asynchronous
- * manner rather than using the blocking get() method. See example usage below.
- *
- * <p>
- * This call logically seals the transaction, which prevents the client from
- * further changing data tree using this transaction. Any subsequent calls to
- * {@link #delete(LogicalDatastoreType, Path)} will fail with
- * {@link IllegalStateException}.
- *
- * <p>
- * The transaction is marked as submitted and enqueued into the data store back-end for processing.
- *
- * <p>
- * Whether or not the commit is successful is determined by versioning
- * of the data tree and validation of registered commit participants
- * ({@link AsyncConfigurationCommitHandler}) if the transaction changes the data tree.
- *
- * <p>
- * The effects of a successful commit of data depends on data tree change listeners and commit participants
- * ({@link AsyncConfigurationCommitHandler}) that are registered with the data broker.
- *
- * <h3>Example usage:</h3>
- * <pre>
- * private void doWrite( final int tries ) {
- * WriteTransaction writeTx = dataBroker.newWriteOnlyTransaction();
- *
- * MyDataObject data = ...;
- * InstanceIdentifier<MyDataObject> path = ...;
- * writeTx.put( LogicalDatastoreType.OPERATIONAL, path, data );
- *
- * Futures.addCallback( writeTx.submit(), new FutureCallback<Void>() {
- * public void onSuccess( Void result ) {
- * // succeeded
- * }
- *
- * public void onFailure( Throwable t ) {
- * if( t instanceof OptimisticLockFailedException ) {
- * if( ( tries - 1 ) > 0 ) {
- * // do retry
- * doWrite( tries - 1 );
- * } else {
- * // out of retries
- * }
- * } else {
- * // failed due to another type of TransactionCommitFailedException.
- * }
- * } );
- * }
- * ...
- * doWrite( 2 );
- * </pre>
- * <h2>Failure scenarios</h2>
- *
- * <p>
- * Transaction may fail because of multiple reasons, such as
- * <ul>
- * <li>Another transaction finished earlier and modified the same node in a
- * non-compatible way (see below). In this case the returned future will fail with an
- * {@link OptimisticLockFailedException}. It is the responsibility of the
- * caller to create a new transaction and submit the same modification again in
- * order to update data tree. <i><b>Warning</b>: In most cases, retrying after an
- * OptimisticLockFailedException will result in a high probability of success.
- * However, there are scenarios, albeit unusual, where any number of retries will
- * not succeed. Therefore it is strongly recommended to limit the number of retries (2 or 3)
- * to avoid an endless loop.</i>
- * </li>
- * <li>Data change introduced by this transaction did not pass validation by
- * commit handlers or data was incorrectly structured. Returned future will
- * fail with a {@link DataValidationFailedException}. User should not retry to
- * create new transaction with same data, since it probably will fail again.
- * </li>
- * </ul>
- *
- * <h3>Change compatibility</h3>
- *
- * <p>
- * There are several sets of changes which could be considered incompatible
- * between two transactions which are derived from same initial state.
- * Rules for conflict detection applies recursively for each subtree
- * level.
- *
- * <h4>Change compatibility of leafs, leaf-list items</h4>
- *
- * <p>
- * Following table shows state changes and failures between two concurrent transactions,
- * which are based on same initial state, Tx 1 completes successfully
- * before Tx 2 is submitted.
- *
- * <table>
- * <caption>Data store state changes</caption>
- * <tr><th>Initial state</th><th>Tx 1</th><th>Tx 2</th><th>Result</th></tr>
- * <tr><td>Empty</td><td>put(A,1)</td><td>put(A,2)</td><td>Tx 2 will fail, state is A=1</td></tr>
- * <tr><td>Empty</td><td>put(A,1)</td><td>merge(A,2)</td><td>A=2</td></tr>
- *
- * <tr><td>Empty</td><td>merge(A,1)</td><td>put(A,2)</td><td>Tx 2 will fail, state is A=1</td></tr>
- * <tr><td>Empty</td><td>merge(A,1)</td><td>merge(A,2)</td><td>A=2</td></tr>
- *
- *
- * <tr><td>A=0</td><td>put(A,1)</td><td>put(A,2)</td><td>Tx 2 will fail, A=1</td></tr>
- * <tr><td>A=0</td><td>put(A,1)</td><td>merge(A,2)</td><td>A=2</td></tr>
- * <tr><td>A=0</td><td>merge(A,1)</td><td>put(A,2)</td><td>Tx 2 will fail, A=1</td></tr>
- * <tr><td>A=0</td><td>merge(A,1)</td><td>merge(A,2)</td><td>A=2</td></tr>
- *
- * <tr><td>A=0</td><td>delete(A)</td><td>put(A,2)</td><td>Tx 2 will fail, A does not exists</td></tr>
- * <tr><td>A=0</td><td>delete(A)</td><td>merge(A,2)</td><td>A=2</td></tr>
- * </table>
- *
- * <h4>Change compatibility of subtrees</h4>
- *
- * <p>
- * Following table shows state changes and failures between two concurrent transactions,
- * which are based on same initial state, Tx 1 completes successfully
- * before Tx 2 is submitted.
- *
- * <table>
- * <caption>Data store state changes</caption>
- * <tr><th>Initial state</th><th>Tx 1</th><th>Tx 2</th><th>Result</th></tr>
- *
- * <tr><td>Empty</td><td>put(TOP,[])</td><td>put(TOP,[])</td><td>Tx 2 will fail, state is TOP=[]</td></tr>
- * <tr><td>Empty</td><td>put(TOP,[])</td><td>merge(TOP,[])</td><td>TOP=[]</td></tr>
- *
- * <tr><td>Empty</td><td>put(TOP,[FOO=1])</td><td>put(TOP,[BAR=1])</td><td>Tx 2 will fail, state is TOP=[FOO=1]
- * </td></tr>
- * <tr><td>Empty</td><td>put(TOP,[FOO=1])</td><td>merge(TOP,[BAR=1])</td><td>TOP=[FOO=1,BAR=1]</td></tr>
- *
- * <tr><td>Empty</td><td>merge(TOP,[FOO=1])</td><td>put(TOP,[BAR=1])</td><td>Tx 2 will fail, state is TOP=[FOO=1]
- * </td></tr>
- * <tr><td>Empty</td><td>merge(TOP,[FOO=1])</td><td>merge(TOP,[BAR=1])</td><td>TOP=[FOO=1,BAR=1]</td></tr>
- *
- * <tr><td>TOP=[]</td><td>put(TOP,[FOO=1])</td><td>put(TOP,[BAR=1])</td><td>Tx 2 will fail, state is TOP=[FOO=1]
- * </td></tr>
- * <tr><td>TOP=[]</td><td>put(TOP,[FOO=1])</td><td>merge(TOP,[BAR=1])</td><td>state is TOP=[FOO=1,BAR=1]</td></tr>
- * <tr><td>TOP=[]</td><td>merge(TOP,[FOO=1])</td><td>put(TOP,[BAR=1])</td><td>Tx 2 will fail, state is TOP=[FOO=1]
- * </td></tr>
- * <tr><td>TOP=[]</td><td>merge(TOP,[FOO=1])</td><td>merge(TOP,[BAR=1])</td><td>state is TOP=[FOO=1,BAR=1]</td></tr>
- * <tr><td>TOP=[]</td><td>delete(TOP)</td><td>put(TOP,[BAR=1])</td><td>Tx 2 will fail, state is empty store
- * </td></tr>
- * <tr><td>TOP=[]</td><td>delete(TOP)</td><td>merge(TOP,[BAR=1])</td><td>state is TOP=[BAR=1]</td></tr>
- *
- * <tr><td>TOP=[]</td><td>put(TOP/FOO,1)</td><td>put(TOP/BAR,1])</td><td>state is TOP=[FOO=1,BAR=1]</td></tr>
- * <tr><td>TOP=[]</td><td>put(TOP/FOO,1)</td><td>merge(TOP/BAR,1)</td><td>state is TOP=[FOO=1,BAR=1]</td></tr>
- * <tr><td>TOP=[]</td><td>merge(TOP/FOO,1)</td><td>put(TOP/BAR,1)</td><td>state is TOP=[FOO=1,BAR=1]</td></tr>
- * <tr><td>TOP=[]</td><td>merge(TOP/FOO,1)</td><td>merge(TOP/BAR,1)</td><td>state is TOP=[FOO=1,BAR=1]</td></tr>
- * <tr><td>TOP=[]</td><td>delete(TOP)</td><td>put(TOP/BAR,1)</td><td>Tx 2 will fail, state is empty store</td></tr>
- * <tr><td>TOP=[]</td><td>delete(TOP)</td><td>merge(TOP/BAR,1]</td><td>Tx 2 will fail, state is empty store
- * </td></tr>
- *
- * <tr><td>TOP=[FOO=1]</td><td>put(TOP/FOO,2)</td><td>put(TOP/BAR,1)</td><td>state is TOP=[FOO=2,BAR=1]</td></tr>
- * <tr><td>TOP=[FOO=1]</td><td>put(TOP/FOO,2)</td><td>merge(TOP/BAR,1)</td><td>state is TOP=[FOO=2,BAR=1]</td></tr>
- * <tr><td>TOP=[FOO=1]</td><td>merge(TOP/FOO,2)</td><td>put(TOP/BAR,1)</td><td>state is TOP=[FOO=2,BAR=1]</td></tr>
- * <tr><td>TOP=[FOO=1]</td><td>merge(TOP/FOO,2)</td><td>merge(TOP/BAR,1)</td><td>state is TOP=[FOO=2,BAR=1]
- * </td></tr>
- * <tr><td>TOP=[FOO=1]</td><td>delete(TOP/FOO)</td><td>put(TOP/BAR,1)</td><td>state is TOP=[BAR=1]</td></tr>
- * <tr><td>TOP=[FOO=1]</td><td>delete(TOP/FOO)</td><td>merge(TOP/BAR,1]</td><td>state is TOP=[BAR=1]</td></tr>
- * </table>
- *
- *
- * <h3>Examples of failure scenarios</h3>
- *
- * <h4>Conflict of two transactions</h4>
- *
- * <p>
- * This example illustrates two concurrent transactions, which derived from
- * same initial state of data tree and proposes conflicting modifications.
- *
- * <pre>
- * txA = broker.newWriteTransaction(); // allocates new transaction, data tree is empty
- * txB = broker.newWriteTransaction(); // allocates new transaction, data tree is empty
- *
- * txA.put(CONFIGURATION, PATH, A); // writes to PATH value A
- * txB.put(CONFIGURATION, PATH, B) // writes to PATH value B
- *
- * ListenableFuture futureA = txA.submit(); // transaction A is sealed and submitted
- * ListenebleFuture futureB = txB.submit(); // transaction B is sealed and submitted
- * </pre>
- *
- * <p>
- * Commit of transaction A will be processed asynchronously and data tree
- * will be updated to contain value <code>A</code> for <code>PATH</code>.
- * Returned {@link ListenableFuture} will successfully complete once
- * state is applied to data tree.
- *
- * <p>
- * Commit of Transaction B will fail, because previous transaction also
- * modified path in a concurrent way. The state introduced by transaction B
- * will not be applied. Returned {@link ListenableFuture} object will fail
- * with {@link OptimisticLockFailedException} exception, which indicates to
- * client that concurrent transaction prevented the submitted transaction from being
- * applied.
- * <br>
- * @return a CheckFuture containing the result of the commit. The Future blocks until the
- * commit operation is complete. A successful commit returns nothing. On failure,
- * the Future will fail with a {@link TransactionCommitFailedException} or an exception
- * derived from TransactionCommitFailedException.
- *
- * @throws IllegalStateException
- * if the transaction is not new
- * @deprecated Use {@link #commit()} instead.
- */
- @Deprecated
- default CheckedFuture<Void, TransactionCommitFailedException> submit() {
- return MappingCheckedFuture.create(commit().transform(ignored -> null, MoreExecutors.directExecutor()),
- SUBMIT_EXCEPTION_MAPPER);
- }
-
- /**
- * Submits this transaction to be asynchronously applied to update the logical data tree. The returned
- * {@link FluentFuture} conveys the result of applying the data changes.
- *
- * <p>
- * This call logically seals the transaction, which prevents the client from further changing the data tree using
- * this transaction. Any subsequent calls to <code>put(LogicalDatastoreType, Path, Object)</code>,
- * <code>merge(LogicalDatastoreType, Path, Object)</code>, <code>delete(LogicalDatastoreType, Path)</code> will fail
- * with {@link IllegalStateException}. The transaction is marked as submitted and enqueued into the data store
- * back-end for processing.
- *
- * <p>
- * Whether or not the commit is successful is determined by versioning of the data tree and validation of registered
- * commit participants if the transaction changes the data tree.
- *
- * <p>
- * The effects of a successful commit of data depends on listeners and commit participants that are registered with
- * the data broker.
- *
- * <p>
- * A successful commit produces implementation-specific {@link CommitInfo} structure, which is used to communicate
- * post-condition information to the caller. Such information can contain commit-id, timing information or any
- * other information the implementation wishes to share.
- *
- * @return a FluentFuture containing the result of the commit information. The Future blocks until the commit
- * operation is complete. A successful commit returns nothing. On failure, the Future will fail with a
- * {@link TransactionCommitFailedException} or an exception derived from TransactionCommitFailedException.
- * @throws IllegalStateException if the transaction is already committed or was canceled.
- */
- @NonNull FluentFuture<? extends @NonNull CommitInfo> commit();
-
- /**
- * This only exists for reuse by the deprecated {@link #submit} method and is not intended for general use.
- */
- @Deprecated
- ExceptionMapper<TransactionCommitFailedException> SUBMIT_EXCEPTION_MAPPER =
- new ExceptionMapper<TransactionCommitFailedException>("submit", TransactionCommitFailedException.class) {
- @Override
- protected TransactionCommitFailedException newWithCause(final String message, final Throwable cause) {
- return new TransactionCommitFailedException(message, cause);
- }
- };
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.md.sal.common.api.data;
-
-import org.opendaylight.yangtools.concepts.Path;
-
-/**
- * Reader for reading YANG subtrees based on their path.
- *
- * <p>
- * Reader is requested to return object at specified path and all it's subnodes
- * known to the reader or null if node is not found in this reader.
- *
- * @param <P> Path Type
- * @param <D> Data Type
- * @deprecated Replaced by org.opendaylight.controller.sal.core.spi.data.DOMStore contract.
- */
-@Deprecated(forRemoval = true)
-public interface DataReader<P extends Path<P>, D> {
-
- /**
- * Reads data from Operational data store located at provided path.
- *
- * @param path Path to data
- * @return the data
- */
- D readOperationalData(P path);
-
- D readConfigurationData(P path);
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.common.api.data;
-
-/**
- * This exception occurs if the datastore is temporarily unavailable.
- * A retry of the transaction may succeed after a period of time
- *
- * @deprecated Use {@link org.opendaylight.mdsal.common.api.DataStoreUnavailableException} instead.
- */
-@Deprecated(forRemoval = true)
-public class DataStoreUnavailableException extends Exception {
- private static final long serialVersionUID = 1L;
-
- public DataStoreUnavailableException(String message, Throwable cause) {
- super(message, cause);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.common.api.data;
-
-import static java.util.Objects.requireNonNull;
-
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import org.opendaylight.yangtools.concepts.Path;
-import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-
-/**
- * Failure of asynchronous transaction commit caused by invalid data.
- *
- * <p>
- * This exception is raised and returned when transaction commit
- * failed, because other data submitted via transactions.
- *
- * <p>
- * Clients usually are not able recover from this error condition by
- * retrieving same transaction, since data introduced by this transaction
- * are invalid.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.common.api.DataValidationFailedException} instead.
- */
-@Deprecated(forRemoval = true)
-public class DataValidationFailedException extends TransactionCommitFailedException {
-
- private static final long serialVersionUID = 1L;
-
- @SuppressFBWarnings("SE_BAD_FIELD")
- private final Path<?> path;
-
- private final Class<? extends Path<?>> pathType;
-
- public <P extends Path<P>> DataValidationFailedException(final Class<P> pathType,final P path,
- final String message, final Throwable cause) {
- super(message, cause, RpcResultBuilder.newError(ErrorType.APPLICATION, "invalid-value", message, null,
- path != null ? path.toString() : null, cause));
- this.pathType = requireNonNull(pathType, "path type must not be null");
- this.path = requireNonNull(path,"path must not be null.");
- }
-
- public <P extends Path<P>> DataValidationFailedException(final Class<P> pathType,final P path,
- final String message) {
- this(pathType, path, message, null);
- }
-
- public final Path<?> getPath() {
- return path;
- }
-
- public final Class<? extends Path<?>> getPathType() {
- return pathType;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.common.api.data;
-
-import org.eclipse.jdt.annotation.NonNullByDefault;
-
-@Deprecated(forRemoval = true)
-@NonNullByDefault
-public enum LogicalDatastoreType {
- /**
- * Logical atastore representing operational state of the system
- * and it's components
- *
- * <p>
- * This datastore is used to describe operational state of
- * the system and it's operation related data.
- *
- */
- OPERATIONAL {
- @Override
- public org.opendaylight.mdsal.common.api.LogicalDatastoreType toMdsal() {
- return org.opendaylight.mdsal.common.api.LogicalDatastoreType.OPERATIONAL;
- }
- },
- /**
- * Logical Datastore representing configuration state of the system
- * and it's components.
- *
- * <p>
- * This datastore is used to describe intended state of
- * the system and intended operation mode.
- *
- */
- CONFIGURATION {
- @Override
- public org.opendaylight.mdsal.common.api.LogicalDatastoreType toMdsal() {
- return org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION;
- }
- };
-
- /**
- * Convert this logical datastore type to its MD-SAL counterpart.
- *
- * @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);
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014, 2015 Cisco Systems, Inc. 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.md.sal.common.api.data;
-
-import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-
-/**
-* Failure of asynchronous transaction commit caused by failure
-* of optimistic locking.
-*
-* <p>
-* This exception is raised and returned when transaction commit
-* failed, because other transaction finished successfully
-* and modified same data as failed transaction.
-*
-* <p>
-* Clients may recover from this error condition by
-* retrieving current state and submitting new updated
-* transaction.
-*
- * @deprecated Use {@link org.opendaylight.mdsal.common.api.OptimisticLockFailedException} instead.
-*/
-@Deprecated(forRemoval = true)
-public class OptimisticLockFailedException extends TransactionCommitFailedException {
-
- private static final long serialVersionUID = 1L;
-
- public OptimisticLockFailedException(final String message, final Throwable cause) {
- super(message, cause, RpcResultBuilder.newError(ErrorType.APPLICATION, "resource-denied",
- message, null, null, cause));
- }
-
- public OptimisticLockFailedException(final String message) {
- this(message, null);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Brocade Communications Systems, Inc. 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.md.sal.common.api.data;
-
-import org.opendaylight.yangtools.util.concurrent.ExceptionMapper;
-import org.opendaylight.yangtools.yang.common.OperationFailedException;
-import org.opendaylight.yangtools.yang.common.RpcError;
-
-/**
- * An exception for a failed read.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.common.api.ReadFailedException} instead.
- */
-@Deprecated(forRemoval = true)
-public class ReadFailedException extends OperationFailedException {
-
- private static final long serialVersionUID = 1L;
-
- public static final ExceptionMapper<ReadFailedException> MAPPER =
- new ExceptionMapper<ReadFailedException>("read", ReadFailedException.class) {
- @Override
- protected ReadFailedException newWithCause(String message, Throwable cause) {
- return new ReadFailedException(message, cause);
- }
- };
-
- public ReadFailedException(String message, RpcError... errors) {
- super(message, errors);
- }
-
- public ReadFailedException(String message, Throwable cause, RpcError... errors) {
- super(message, cause, errors);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.common.api.data;
-
-import org.opendaylight.yangtools.concepts.Path;
-
-/**
- * A chain of transactions. Transactions in a chain need to be committed in
- * sequence and each transaction should see the effects of previous committed transactions
- * as they occurred. A chain makes no guarantees of atomicity across the chained transactions -
- * the transactions are committed as soon as possible in the order that they were submitted.
- *
- * <p>
- * This behaviour is different from the default AsyncDataBroker, where a
- * transaction is always created from the current global state, not taking into
- * account any transactions previously committed by the calling thread. Due to
- * the asynchronous nature of transaction submission this can lead to surprising
- * results. If a thread executes the following sequence sufficiently quickly:
- *
- * <p>
- * AsyncWriteTransaction t1 = broker.newWriteOnlyTransaction();
- * t1.put(id, data);
- * t1.submit();
- *
- * <p>
- * AsyncReadTransaction t2 = broker.newReadOnlyTransaction();
- * Optional<?> maybeData = t2.read(id).get();
- *
- * <p>
- * it may happen, that it sees maybeData.isPresent() == false, simply because
- * t1 has not completed the processes of being applied and t2 is actually
- * allocated from the previous state. This is obviously bad for users who create
- * incremental state in the datastore and actually read what they write in
- * subsequent transactions.
- *
- * <p>
- * Using a TransactionChain instead of a broker solves this particular problem,
- * and leads to expected behavior: t2 will always see the data written in t1
- * present.
- */
-@Deprecated(forRemoval = true)
-public interface TransactionChain<P extends Path<P>, D> extends AutoCloseable, AsyncDataTransactionFactory<P, D> {
-
- /**
- * Create a new read only transaction which will continue the chain.
- *
- * <p>
- * The previous write transaction has to be either SUBMITTED
- * ({@link AsyncWriteTransaction#submit submit} was invoked) or CANCELLED
- * ({@link #close close} was invoked).
- *
- * <p>
- * The returned read-only transaction presents an isolated view of the data if the previous
- * write transaction was successful - in other words, this read-only transaction will see the
- * state changes made by the previous write transaction in the chain. However, state which
- * was introduced by other transactions outside this transaction chain after creation of
- * the previous transaction is not visible.
- *
- * @return New transaction in the chain.
- * @throws IllegalStateException
- * if the previous transaction was not SUBMITTED or CANCELLED.
- * @throws TransactionChainClosedException
- * if the chain has been closed.
- */
- @Override
- AsyncReadOnlyTransaction<P, D> newReadOnlyTransaction();
-
- /**
- * Create a new read-write transaction which will continue the chain.
- *
- * <p>
- * The previous write transaction has to be either SUBMITTED
- * ({@link AsyncWriteTransaction#submit submit} was invoked) or CANCELLED
- * ({@link #close close} was invoked).
- *
- * <p>
- * The returned read-write transaction presents an isolated view of the data if the previous
- * write transaction was successful - in other words, this read-write transaction will see the
- * state changes made by the previous write transaction in the chain. However, state which
- * was introduced by other transactions outside this transaction chain after creation of
- * the previous transaction is not visible.
- *
- * <p>
- * Committing this read-write transaction using {@link AsyncWriteTransaction#submit submit}
- * will submit the state changes in this transaction to be visible to any subsequent
- * transaction in this chain and also to any transaction outside this chain.
- *
- * @return New transaction in the chain.
- * @throws IllegalStateException
- * if the previous transaction was not SUBMITTED or CANCELLED.
- * @throws TransactionChainClosedException
- * if the chain has been closed.
- */
- @Override
- AsyncReadWriteTransaction<P, D> newReadWriteTransaction();
-
- /**
- * Create a new write-only transaction which will continue the chain.
- *
- * <p>
- * The previous write transaction has to be either SUBMITTED
- * ({@link AsyncWriteTransaction#submit submit} was invoked) or CANCELLED
- * ({@link #close close} was invoked).
- *
- * <p>
- * The returned write-only transaction presents an isolated view of the data if the previous
- * write transaction was successful - in other words, this write-only transaction will see the
- * state changes made by the previous write transaction in the chain. However, state which
- * was introduced by other transactions outside this transaction chain after creation of
- * the previous transaction is not visible.
- *
- * <p>
- * Committing this write-only transaction using {@link AsyncWriteTransaction#submit submit}
- * will submit the state changes in this transaction to be visible to any subsequent
- * transaction in this chain and also to any transaction outside this chain.
- *
- * @return New transaction in the chain.
- * @throws IllegalStateException
- * if the previous transaction was not SUBMITTED or CANCELLED.
- * @throws TransactionChainClosedException
- * if the chain has been closed.
- */
- @Override
- AsyncWriteTransaction<P, D> newWriteOnlyTransaction();
-
- @Override
- void close();
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.common.api.data;
-
-/**
- * Exception thrown when an attempt is made to open a new transaction in a closed chain.
- */
-@Deprecated(forRemoval = true)
-public final class TransactionChainClosedException extends IllegalStateException {
- private static final long serialVersionUID = 1L;
-
- public TransactionChainClosedException(final String message) {
- super(message);
- }
-
- public TransactionChainClosedException(final String message, final Throwable cause) {
- super(message, cause);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.md.sal.common.api.data;
-
-import org.opendaylight.yangtools.concepts.Path;
-
-/**
- * Interface for creating transaction chains.
- */
-@Deprecated(forRemoval = true)
-public interface TransactionChainFactory<P extends Path<P>, D> {
-
- /**
- * Create a new transaction chain. The chain will be initialized to read
- * from its backing datastore, with no outstanding transaction. Listener
- * will be registered to handle chain-level events.
- *
- * @param listener Transaction chain event listener
- * @return A new transaction chain.
- */
- TransactionChain<P, D> createTransactionChain(TransactionChainListener listener);
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.common.api.data;
-
-import java.util.EventListener;
-
-/**
- * Listener for transaction chain events.
- */
-@Deprecated(forRemoval = true)
-public interface TransactionChainListener extends EventListener {
- /**
- * Invoked if when a transaction in the chain fails. All other transactions are automatically cancelled by the time
- * this notification is invoked. Implementations should invoke chain.close() to close the chain.
- *
- * @param chain Transaction chain which failed
- * @param transaction Transaction which caused the chain to fail
- * @param cause The cause of transaction failure
- */
- void onTransactionChainFailed(TransactionChain<?, ?> chain, AsyncTransaction<?, ?> transaction, Throwable cause);
-
- /**
- * Invoked when a transaction chain is completed. A transaction chain is considered completed when it has been
- * closed and all its instructions have completed successfully.
- *
- * @param chain Transaction chain which completed
- */
- void onTransactionChainSuccessful(TransactionChain<?, ?> chain);
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2014 Brocade Communications Systems, Inc. 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.md.sal.common.api.data;
-
-import com.google.common.base.Supplier;
-import org.opendaylight.yangtools.yang.common.RpcError;
-import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-
-/**
- * A type of TransactionCommitFailedException that indicates a situation that would result in a
- * threading deadlock. This can occur if a caller that submits a write transaction tries to perform
- * a blocking call via one of the <code>get</code> methods on the returned ListenableFuture. Callers
- * should process the commit result asynchronously (via Futures#addCallback) to ensure deadlock
- * won't occur.
- *
- * @author Thomas Pantelis
- *
- * @deprecated Use {@link org.opendaylight.mdsal.common.api.TransactionCommitDeadlockException} instead.
- */
-@Deprecated(forRemoval = true)
-public class TransactionCommitDeadlockException extends TransactionCommitFailedException {
- private static final long serialVersionUID = 1L;
- private static final String DEADLOCK_MESSAGE =
- "An attempt to block on a ListenableFuture via a get method from a write "
- + "transaction submit was detected that would result in deadlock. The commit "
- + "result must be obtained asynchronously, e.g. via Futures#addCallback, to avoid deadlock.";
- private static final RpcError DEADLOCK_RPCERROR = RpcResultBuilder.newError(ErrorType.APPLICATION,
- "lock-denied", DEADLOCK_MESSAGE);
-
- public static final Supplier<Exception> DEADLOCK_EXCEPTION_SUPPLIER =
- () -> new TransactionCommitDeadlockException(DEADLOCK_MESSAGE, DEADLOCK_RPCERROR);
-
- public TransactionCommitDeadlockException(final String message, final RpcError... errors) {
- super(message, errors);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.common.api.data;
-
-import org.opendaylight.yangtools.yang.common.OperationFailedException;
-import org.opendaylight.yangtools.yang.common.RpcError;
-
-/**
- * Failed commit of asynchronous transaction. This exception is raised and returned when transaction commit failed.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.common.api.TransactionCommitFailedException} instead.
- */
-@Deprecated(forRemoval = true)
-public class TransactionCommitFailedException extends OperationFailedException {
-
- private static final long serialVersionUID = 1L;
-
- public TransactionCommitFailedException(final String message, final RpcError... errors) {
- this(message, null, errors);
- }
-
- public TransactionCommitFailedException(final String message, final Throwable cause,
- final RpcError... errors) {
- super(message, cause, errors);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.md.sal.common.api.notify;
-
-import java.util.concurrent.ExecutorService;
-
-/**
- * Interface for publishing YANG-modeled notifications.
- *
- * <p>
- * Users of this interface can publish any YANG-modeled notification which will
- * be delivered to all subscribed listeners.
- *
- * <p>
- * Preferred way of publishing of notifications is done by invoking {@link #publish(Object)}.
- *
- * <p>You may consider using {@link #publish(Object, ExecutorService)} if and only if
- * your use-case requires customized execution policy or run-to-completion
- * inside process.
- *
- * <p>
- * The metadata required to deliver a notification to the correct listeners is
- * extracted from the published notification.
- *
- * <p>
- * FIXME: Consider clarification of execution/delivery policy, how it will be
- * affected by Actor model and cluster-wide notifications.
- *
- * @param <N> the type of notifications
- */
-@Deprecated(forRemoval = true)
-public interface NotificationPublishService<N> {
-
- /**
- * Publishes a notification and notifies subscribed listeners. All listener
- * notifications are done via a default executor.
- *
- * <p>
- * <b>Note:</b> This call will block when the default executor is saturated
- * and the notification queue for this executor is full.
- *
- * @param notification
- * the notification to publish.
- */
- void publish(N notification);
-
- /**
- * Publishes a notification and notifies subscribed listeners. All listener
- * notifications are done via the provided executor.
- *
- * <p>
- * <b>Note:</b> Use only if necessary. Consider using
- * {@link #publish(Object)} for most use-cases.
- *
- * <p>
- * By using this method you could customize execution policy of listeners present
- * inside process (e.g. using single-threaded executor or even same-thread executor
- * delivery.
- *
- * <p>
- * This executor is used only for inside-process notification deliveries.
- *
- * @param notification
- * the notification to publish.
- * @param executor
- * the executor that will be used to deliver notifications to
- * subscribed listeners.
- */
- void publish(N notification, ExecutorService executor);
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.md.sal.common.api.notify;
-
-import java.util.EventListener;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-
-@Deprecated(forRemoval = true)
-public interface NotificationSubscriptionService<T, N, L extends EventListener> {
-
- ListenerRegistration<L> registerNotificationListener(T type, L listener);
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.md.sal.common.api.routing;
-
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Event representing change in RPC routing table.
- *
- *
- * @param <C> Type, which is used to represent Routing context.
- * @param <P> Type of data tree path, which is used to identify route.
- */
-@Deprecated(forRemoval = true)
-public interface RouteChange<C, P> {
-
- /**
- * Returns a map of removed routes in associated routing contexts.
- *
- * <p>
- * This map represents routes, which were withdrawn from broker local
- * routing table and broker may need to forward RPC to other broker
- * in order to process RPC request.
- *
- * @return Map of contexts and removed routes
- */
- Map<C,Set<P>> getRemovals();
-
- /**
- * Returns a map of announced routes in associated routing contexts.
- *
- * <p>
- * This map represents routes, which were announced by broker
- * and are present in broker's local routing table. This routes
- * are processed by implementations which are registered
- * to originating broker.
- *
- * @return Map of contexts and announced routes
- */
- Map<C, Set<P>> getAnnouncements();
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.common.api.routing;
-
-import java.util.EventListener;
-
-/**
- * Listener which is interested in receiving RouteChangeEvents for its local broker.
- *
- * <p>
- * Listener is registered via {@link RouteChangePublisher#registerRouteChangeListener(RouteChangeListener)}
- *
- * @param <C> Type, which is used to represent Routing context.
- * @param <P> Type of data tree path, which is used to identify route.
- */
-@Deprecated(forRemoval = true)
-public interface RouteChangeListener<C, P> extends EventListener {
-
- /**
- * Callback which is invoked if there is an rpc routing table change.
- *
- * @param change Event representing change in local RPC routing table.
- */
- void onRouteChange(RouteChange<C, P> change);
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.common.api.routing;
-
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-
-/**
- * Publishes changes in local RPC routing table to registered listener.
- *
- * @param <C> Type, which is used to represent Routing context.
- * @param <P> Type of data tree path, which is used to identify route.
- */
-@Deprecated(forRemoval = true)
-public interface RouteChangePublisher<C,P> {
-
- <L extends RouteChangeListener<C,P>> ListenerRegistration<L> registerRouteChangeListener(L listener);
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.md.sal.common.api.routing;
-
-import org.opendaylight.yangtools.concepts.Path;
-import org.opendaylight.yangtools.concepts.Registration;
-
-/**
- * Base interface for a routed RPC RPC implementation registration.
- *
- * @param <C> the context type used for routing
- * @param <P> the path identifier type
- * @param <S> the RPC implementation type
- */
-@Deprecated(forRemoval = true)
-public interface RoutedRegistration<C, P extends Path<P>, S> extends Registration {
-
- /**
- * Registers the RPC implementation associated with this registration for the given path
- * identifier and context.
- *
- * @param context the context used for routing RPCs to this implementation.
- * @param path the path identifier for which to register.
- */
- void registerPath(C context, P path);
-
- /**
- * Unregisters the RPC implementation associated with this registration for the given path
- * identifier and context.
- *
- * @param context the context used for routing RPCs to this implementation.
- * @param path the path identifier for which to unregister.
- */
- void unregisterPath(C context, P path);
-
- @Override
- void close();
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.md.sal.common.api.routing;
-
-import java.util.Map;
-import org.opendaylight.yangtools.concepts.Path;
-
-@Deprecated(forRemoval = true)
-public interface RoutingTable<C, P extends Path<P>, T> {
-
- C getIdentifier();
-
- T getDefaultRoute();
-
- Map<P,T> getRoutes();
-
- T getRoute(P path);
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Brocade Communications Systems, Inc. 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.md.sal.common.api;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.SettableFuture;
-import java.util.concurrent.CancellationException;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicReference;
-import org.junit.Test;
-import org.opendaylight.yangtools.util.concurrent.ExceptionMapper;
-
-/**
- * Unit tests for MappingCheckedFuture.
- *
- * @author Thomas Pantelis
- */
-@Deprecated
-public class MappingCheckedFutureTest {
-
- interface FutureInvoker {
- void invokeGet(CheckedFuture<?,?> future) throws Exception;
-
- Throwable extractWrappedTestEx(Exception from);
- }
-
- static class TestException extends Exception {
- private static final long serialVersionUID = 1L;
-
- TestException(final String message, final Throwable cause) {
- super(message, cause);
- }
- }
-
- static final ExceptionMapper<TestException> MAPPER = new ExceptionMapper<TestException>(
- "Test", TestException.class) {
-
- @Override
- protected TestException newWithCause(final String message, final Throwable cause) {
- return new TestException(message, cause);
- }
- };
-
- static final FutureInvoker GET = new FutureInvoker() {
- @Override
- public void invokeGet(final CheckedFuture<?, ?> future) throws Exception {
- future.get();
- }
-
- @Override
- public Throwable extractWrappedTestEx(final Exception from) {
- if (from instanceof ExecutionException) {
- return from.getCause();
- }
-
- return from;
- }
- };
-
- static final FutureInvoker TIMED_GET = new FutureInvoker() {
- @Override
- public void invokeGet(final CheckedFuture<?, ?> future) throws Exception {
- future.get(1, TimeUnit.HOURS);
- }
-
- @Override
- public Throwable extractWrappedTestEx(final Exception from) {
- if (from instanceof ExecutionException) {
- return from.getCause();
- }
-
- return from;
- }
- };
-
- static final FutureInvoker CHECKED_GET = new FutureInvoker() {
- @Override
- public void invokeGet(final CheckedFuture<?,?> future) throws Exception {
- future.checkedGet();
- }
-
- @Override
- public Throwable extractWrappedTestEx(final Exception from) {
- return from;
- }
- };
-
- static final FutureInvoker TIMED_CHECKED_GET = new FutureInvoker() {
- @Override
- public void invokeGet(final CheckedFuture<?,?> future) throws Exception {
- future.checkedGet(50, TimeUnit.MILLISECONDS);
- }
-
- @Override
- public Throwable extractWrappedTestEx(final Exception from) {
- return from;
- }
- };
-
- @Test
- public void testGet() throws Exception {
- SettableFuture<String> delegate = SettableFuture.create();
- MappingCheckedFuture<String,TestException> future = MappingCheckedFuture.create(delegate, MAPPER);
- delegate.set("test");
- assertEquals("get", "test", future.get());
- }
-
- @Test
- public void testGetWithExceptions() throws Exception {
- testExecutionException(GET, new RuntimeException());
- testExecutionException(GET, new TestException("mock", null));
- testCancellationException(GET);
- testInterruptedException(GET);
- }
-
- @Test
- public void testTimedGet() throws Exception {
- SettableFuture<String> delegate = SettableFuture.create();
- MappingCheckedFuture<String,TestException> future = MappingCheckedFuture.create(delegate, MAPPER);
- delegate.set("test");
- assertEquals("get", "test", future.get(50, TimeUnit.MILLISECONDS));
- }
-
- @Test
- public void testTimedGetWithExceptions() throws Exception {
- testExecutionException(TIMED_GET, new RuntimeException());
- testCancellationException(TIMED_GET);
- testInterruptedException(TIMED_GET);
- }
-
- @Test
- public void testCheckedGetWithExceptions() throws Exception {
- testExecutionException(CHECKED_GET, new RuntimeException());
- testCancellationException(CHECKED_GET);
- testInterruptedException(CHECKED_GET);
- }
-
- @Test
- public void testTimedCheckedWithExceptions() throws Exception {
- testExecutionException(TIMED_CHECKED_GET, new RuntimeException());
- testCancellationException(TIMED_CHECKED_GET);
- testInterruptedException(TIMED_CHECKED_GET);
- }
-
- @SuppressWarnings("checkstyle:illegalCatch")
- private static void testExecutionException(final FutureInvoker invoker, final Throwable cause) {
- SettableFuture<String> delegate = SettableFuture.create();
- MappingCheckedFuture<String, TestException> mappingFuture = MappingCheckedFuture.create(delegate, MAPPER);
-
- delegate.setException(cause);
-
- try {
- invoker.invokeGet(mappingFuture);
- fail("Expected exception thrown");
- } catch (Exception e) {
- Throwable expectedTestEx = invoker.extractWrappedTestEx(e);
- assertNotNull("Expected returned exception is null", expectedTestEx);
- assertEquals("Exception type", TestException.class, expectedTestEx.getClass());
-
- if (cause instanceof TestException) {
- assertNull("Expected null cause", expectedTestEx.getCause());
- } else {
- assertSame("TestException cause", cause, expectedTestEx.getCause());
- }
- }
- }
-
- @SuppressWarnings("checkstyle:illegalCatch")
- private static void testCancellationException(final FutureInvoker invoker) {
- SettableFuture<String> delegate = SettableFuture.create();
- MappingCheckedFuture<String, TestException> mappingFuture = MappingCheckedFuture.create(delegate, MAPPER);
-
- mappingFuture.cancel(false);
-
- try {
- invoker.invokeGet(mappingFuture);
- fail("Expected exception thrown");
- } catch (Exception e) {
- Throwable expectedTestEx = invoker.extractWrappedTestEx(e);
- assertNotNull("Expected returned exception is null", expectedTestEx);
- assertEquals("Exception type", TestException.class, expectedTestEx.getClass());
- assertEquals("TestException cause type", CancellationException.class, expectedTestEx.getCause().getClass());
- }
- }
-
- @SuppressWarnings("checkstyle:illegalCatch")
- private static void testInterruptedException(final FutureInvoker invoker) throws Exception {
- SettableFuture<String> delegate = SettableFuture.create();
- final MappingCheckedFuture<String, TestException> mappingFuture = MappingCheckedFuture.create(delegate, MAPPER);
-
- final AtomicReference<AssertionError> assertError = new AtomicReference<>();
- final CountDownLatch doneLatch = new CountDownLatch(1);
- Thread thread = new Thread() {
- @Override
- public void run() {
- try {
- doInvoke();
- } catch (AssertionError e) {
- assertError.set(e);
- } finally {
- doneLatch.countDown();
- }
- }
-
- void doInvoke() {
- try {
- invoker.invokeGet(mappingFuture);
- fail("Expected exception thrown");
- } catch (Exception e) {
- Throwable expectedTestEx = invoker.extractWrappedTestEx(e);
- assertNotNull("Expected returned exception is null", expectedTestEx);
- assertEquals("Exception type", TestException.class, expectedTestEx.getClass());
- assertEquals("TestException cause type", InterruptedException.class,
- expectedTestEx.getCause().getClass());
- }
- }
- };
- thread.start();
-
- thread.interrupt();
- assertTrue("get call completed", doneLatch.await(5, TimeUnit.SECONDS));
-
- if (assertError.get() != null) {
- throw assertError.get();
- }
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-parent</artifactId>
- <version>1.12.0-SNAPSHOT</version>
- <relativePath>../parent</relativePath>
- </parent>
-
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-common-impl</artifactId>
- <version>1.12.0-SNAPSHOT</version>
- <packaging>bundle</packaging>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-common-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-common-util</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-data-impl</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-model-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-parser-impl</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Export-Package>org.opendaylight.controller.md.sal.common.impl,
- org.opendaylight.controller.md.sal.common.impl.*</Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <scm>
- <connection>scm:git:http://git.opendaylight.org/gerrit/controller.git</connection>
- <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
- <tag>HEAD</tag>
- <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
- </scm>
-
-</project>
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.common.impl.util.compat;
-
-@Deprecated(forRemoval = true)
-public class DataNormalizationException extends Exception {
- private static final long serialVersionUID = 1L;
-
- public DataNormalizationException(String message) {
- super(message);
- }
-
- public DataNormalizationException(String message, Throwable cause) {
- super(message, cause);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.common.impl.util.compat;
-
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import org.eclipse.jdt.annotation.Nullable;
-import org.gaul.modernizer_maven_annotations.SuppressModernizer;
-import org.opendaylight.yangtools.concepts.Identifiable;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
-import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
-import org.opendaylight.yangtools.yang.model.api.AnyxmlSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.AugmentationTarget;
-import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaNode;
-import org.opendaylight.yangtools.yang.model.util.EffectiveAugmentationSchema;
-
-@Deprecated(forRemoval = true)
-public abstract class DataNormalizationOperation<T extends PathArgument> implements Identifiable<T> {
-
- private final T identifier;
- private final DataSchemaNode dataSchemaNode;
-
- @Override
- public T getIdentifier() {
- return identifier;
- }
-
- protected DataNormalizationOperation(final T identifier, final SchemaNode schema) {
- this.identifier = identifier;
- dataSchemaNode = schema instanceof DataSchemaNode ? (DataSchemaNode)schema : null;
- }
-
- public boolean isMixin() {
- return false;
- }
-
-
- public boolean isKeyedEntry() {
- return false;
- }
-
- protected Set<QName> getQNameIdentifiers() {
- return Collections.singleton(identifier.getNodeType());
- }
-
- public abstract DataNormalizationOperation<?> getChild(PathArgument child) throws DataNormalizationException;
-
- public abstract DataNormalizationOperation<?> getChild(QName child) throws DataNormalizationException;
-
- public abstract boolean isLeaf();
-
- @SuppressModernizer
- public Optional<DataSchemaNode> getDataSchemaNode() {
- return Optional.fromNullable(dataSchemaNode);
- }
-
- private abstract static class SimpleTypeNormalization<T extends PathArgument>
- extends DataNormalizationOperation<T> {
- SimpleTypeNormalization(final T identifier, final DataSchemaNode potential) {
- super(identifier,potential);
- }
-
- @Override
- public DataNormalizationOperation<?> getChild(final PathArgument child) {
- return null;
- }
-
- @Override
- public DataNormalizationOperation<?> getChild(final QName child) {
- return null;
- }
-
- @Override
- public NormalizedNode<?, ?> createDefault(final PathArgument currentArg) {
- return null;
- }
-
- @Override
- public boolean isLeaf() {
- return true;
- }
- }
-
- private static final class LeafNormalization extends SimpleTypeNormalization<NodeIdentifier> {
- LeafNormalization(final LeafSchemaNode potential) {
- super(new NodeIdentifier(potential.getQName()),potential);
- }
- }
-
- private static final class LeafListEntryNormalization extends SimpleTypeNormalization<NodeWithValue> {
- LeafListEntryNormalization(final LeafListSchemaNode potential) {
- super(new NodeWithValue(potential.getQName(), null),potential);
- }
-
- @Override
- public boolean isKeyedEntry() {
- return true;
- }
- }
-
- private abstract static class CompositeNodeNormalizationOperation<T extends PathArgument>
- extends DataNormalizationOperation<T> {
- CompositeNodeNormalizationOperation(final T identifier, final DataSchemaNode schema) {
- super(identifier,schema);
- }
-
- @Override
- public boolean isLeaf() {
- return false;
- }
- }
-
- private abstract static class DataContainerNormalizationOperation<T extends PathArgument>
- extends CompositeNodeNormalizationOperation<T> {
- private final DataNodeContainer schema;
- private final Map<QName, DataNormalizationOperation<?>> byQName;
- private final Map<PathArgument, DataNormalizationOperation<?>> byArg;
-
- DataContainerNormalizationOperation(final T identifier, final DataNodeContainer schema,
- final DataSchemaNode node) {
- super(identifier,node);
- this.schema = schema;
- this.byArg = new ConcurrentHashMap<>();
- this.byQName = new ConcurrentHashMap<>();
- }
-
- @Override
- public DataNormalizationOperation<?> getChild(final PathArgument child) throws DataNormalizationException {
- DataNormalizationOperation<?> potential = byArg.get(child);
- if (potential != null) {
- return potential;
- }
- potential = fromLocalSchema(child);
- return register(potential);
- }
-
- @Override
- public DataNormalizationOperation<?> getChild(final QName child) throws DataNormalizationException {
- DataNormalizationOperation<?> potential = byQName.get(child);
- if (potential != null) {
- return potential;
- }
- potential = fromLocalSchemaAndQName(schema, child);
- return register(potential);
- }
-
- private DataNormalizationOperation<?> fromLocalSchema(final PathArgument child)
- throws DataNormalizationException {
- if (child instanceof AugmentationIdentifier) {
- return fromSchemaAndQNameChecked(schema, ((AugmentationIdentifier) child).getPossibleChildNames()
- .iterator().next());
- }
- return fromSchemaAndQNameChecked(schema, child.getNodeType());
- }
-
- protected DataNormalizationOperation<?> fromLocalSchemaAndQName(final DataNodeContainer schema2,
- final QName child) throws DataNormalizationException {
- return fromSchemaAndQNameChecked(schema2, child);
- }
-
- private DataNormalizationOperation<?> register(final DataNormalizationOperation<?> potential) {
- if (potential != null) {
- byArg.put(potential.getIdentifier(), potential);
- for (final QName qname : potential.getQNameIdentifiers()) {
- byQName.put(qname, potential);
- }
- }
- return potential;
- }
-
- private static DataNormalizationOperation<?> fromSchemaAndQNameChecked(final DataNodeContainer schema,
- final QName child) throws DataNormalizationException {
-
- final DataSchemaNode result = findChildSchemaNode(schema, child);
- if (result == null) {
- throw new DataNormalizationException(String.format(
- "Supplied QName %s is not valid according to schema %s, potential children nodes: %s", child,
- schema,schema.getChildNodes()));
- }
-
- // We try to look up if this node was added by augmentation
- if (schema instanceof DataSchemaNode && result.isAugmenting()) {
- return fromAugmentation(schema, (AugmentationTarget) schema, result);
- }
- return fromDataSchemaNode(result);
- }
- }
-
- private static final class ListItemNormalization extends
- DataContainerNormalizationOperation<NodeIdentifierWithPredicates> {
- ListItemNormalization(final NodeIdentifierWithPredicates identifier, final ListSchemaNode schema) {
- super(identifier, schema, schema);
- }
-
- @Override
- @SuppressFBWarnings("BC_UNCONFIRMED_CAST")
- public NormalizedNode<?, ?> createDefault(final PathArgument currentArg) {
- final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> builder = Builders
- .mapEntryBuilder().withNodeIdentifier((NodeIdentifierWithPredicates) currentArg);
- for (final Entry<QName, Object> keyValue : ((NodeIdentifierWithPredicates) currentArg).entrySet()) {
- builder.addChild(Builders.leafBuilder()
- //
- .withNodeIdentifier(new NodeIdentifier(keyValue.getKey())).withValue(keyValue.getValue())
- .build());
- }
- return builder.build();
- }
-
- @Override
- public boolean isKeyedEntry() {
- return true;
- }
- }
-
- private static final class UnkeyedListItemNormalization
- extends DataContainerNormalizationOperation<NodeIdentifier> {
- UnkeyedListItemNormalization(final ListSchemaNode schema) {
- super(new NodeIdentifier(schema.getQName()), schema,schema);
- }
-
- @Override
- @SuppressFBWarnings("BC_UNCONFIRMED_CAST")
- public NormalizedNode<?, ?> createDefault(final PathArgument currentArg) {
- return Builders.unkeyedListEntryBuilder().withNodeIdentifier((NodeIdentifier) currentArg).build();
- }
- }
-
- private static final class ContainerNormalization extends DataContainerNormalizationOperation<NodeIdentifier> {
- ContainerNormalization(final ContainerSchemaNode schema) {
- super(new NodeIdentifier(schema.getQName()),schema, schema);
- }
-
- @Override
- @SuppressFBWarnings("BC_UNCONFIRMED_CAST")
- public NormalizedNode<?, ?> createDefault(final PathArgument currentArg) {
- return Builders.containerBuilder().withNodeIdentifier((NodeIdentifier) currentArg).build();
- }
- }
-
- private abstract static class MixinNormalizationOp<T extends PathArgument>
- extends CompositeNodeNormalizationOperation<T> {
-
- MixinNormalizationOp(final T identifier, final DataSchemaNode schema) {
- super(identifier,schema);
- }
-
- @Override
- public final boolean isMixin() {
- return true;
- }
- }
-
- private static final class OrderedLeafListMixinNormalization extends UnorderedLeafListMixinNormalization {
- OrderedLeafListMixinNormalization(final LeafListSchemaNode potential) {
- super(potential);
- }
-
- @Override
- public NormalizedNode<?, ?> createDefault(final PathArgument currentArg) {
- return Builders.orderedLeafSetBuilder().withNodeIdentifier(getIdentifier()).build();
- }
- }
-
- private static class UnorderedLeafListMixinNormalization extends MixinNormalizationOp<NodeIdentifier> {
-
- private final DataNormalizationOperation<?> innerOp;
-
- UnorderedLeafListMixinNormalization(final LeafListSchemaNode potential) {
- super(new NodeIdentifier(potential.getQName()),potential);
- innerOp = new LeafListEntryNormalization(potential);
- }
-
- @Override
- public NormalizedNode<?, ?> createDefault(final PathArgument currentArg) {
- return Builders.leafSetBuilder().withNodeIdentifier(getIdentifier()).build();
- }
-
- @Override
- public DataNormalizationOperation<?> getChild(final PathArgument child) {
- if (child instanceof NodeWithValue) {
- return innerOp;
- }
- return null;
- }
-
- @Override
- public DataNormalizationOperation<?> getChild(final QName child) {
- if (getIdentifier().getNodeType().equals(child)) {
- return innerOp;
- }
- return null;
- }
- }
-
- private static final class AugmentationNormalization
- extends DataContainerNormalizationOperation<AugmentationIdentifier> {
-
- AugmentationNormalization(final AugmentationSchemaNode augmentation, final DataNodeContainer schema) {
- super(augmentationIdentifierFrom(augmentation), augmentationProxy(augmentation,schema),null);
- }
-
- private static DataNodeContainer augmentationProxy(final AugmentationSchemaNode augmentation,
- final DataNodeContainer schema) {
- final Set<DataSchemaNode> children = new HashSet<>();
- for (final DataSchemaNode augNode : augmentation.getChildNodes()) {
- children.add(schema.getDataChildByName(augNode.getQName()));
- }
- return new EffectiveAugmentationSchema(augmentation, children);
- }
-
- @Override
- public boolean isMixin() {
- return true;
- }
-
- @Override
- protected DataNormalizationOperation<?> fromLocalSchemaAndQName(final DataNodeContainer schema,
- final QName child) {
- final DataSchemaNode result = findChildSchemaNode(schema, child);
- if (result == null) {
- return null;
- }
-
- // We try to look up if this node was added by augmentation
- if (schema instanceof DataSchemaNode && result.isAugmenting()) {
- return fromAugmentation(schema, (AugmentationTarget) schema, result);
- }
- return fromDataSchemaNode(result);
- }
-
- @Override
- protected Set<QName> getQNameIdentifiers() {
- return getIdentifier().getPossibleChildNames();
- }
-
- @Override
- public NormalizedNode<?, ?> createDefault(final PathArgument currentArg) {
- return Builders.augmentationBuilder().withNodeIdentifier(getIdentifier()).build();
- }
- }
-
- private static class UnorderedMapMixinNormalization extends MixinNormalizationOp<NodeIdentifier> {
- private final ListItemNormalization innerNode;
-
- UnorderedMapMixinNormalization(final ListSchemaNode list) {
- super(new NodeIdentifier(list.getQName()),list);
- this.innerNode = new ListItemNormalization(NodeIdentifierWithPredicates.of(list.getQName(),
- Collections.<QName, Object>emptyMap()), list);
- }
-
- @Override
- public NormalizedNode<?, ?> createDefault(final PathArgument currentArg) {
- return Builders.mapBuilder().withNodeIdentifier(getIdentifier()).build();
- }
-
- @Override
- public DataNormalizationOperation<?> getChild(final PathArgument child) {
- if (child.getNodeType().equals(getIdentifier().getNodeType())) {
- return innerNode;
- }
- return null;
- }
-
- @Override
- public DataNormalizationOperation<?> getChild(final QName child) {
- if (getIdentifier().getNodeType().equals(child)) {
- return innerNode;
- }
- return null;
- }
- }
-
- private static class UnkeyedListMixinNormalization extends MixinNormalizationOp<NodeIdentifier> {
- private final UnkeyedListItemNormalization innerNode;
-
- UnkeyedListMixinNormalization(final ListSchemaNode list) {
- super(new NodeIdentifier(list.getQName()),list);
- this.innerNode = new UnkeyedListItemNormalization(list);
- }
-
- @Override
- public NormalizedNode<?, ?> createDefault(final PathArgument currentArg) {
- return Builders.unkeyedListBuilder().withNodeIdentifier(getIdentifier()).build();
- }
-
- @Override
- public DataNormalizationOperation<?> getChild(final PathArgument child) {
- if (child.getNodeType().equals(getIdentifier().getNodeType())) {
- return innerNode;
- }
- return null;
- }
-
- @Override
- public DataNormalizationOperation<?> getChild(final QName child) {
- if (getIdentifier().getNodeType().equals(child)) {
- return innerNode;
- }
- return null;
- }
- }
-
- private static final class OrderedMapMixinNormalization extends UnorderedMapMixinNormalization {
- OrderedMapMixinNormalization(final ListSchemaNode list) {
- super(list);
- }
-
- @Override
- public NormalizedNode<?, ?> createDefault(final PathArgument currentArg) {
- return Builders.orderedMapBuilder().withNodeIdentifier(getIdentifier()).build();
- }
- }
-
- private static class ChoiceNodeNormalization extends MixinNormalizationOp<NodeIdentifier> {
- private final ImmutableMap<QName, DataNormalizationOperation<?>> byQName;
- private final ImmutableMap<PathArgument, DataNormalizationOperation<?>> byArg;
-
- ChoiceNodeNormalization(final ChoiceSchemaNode schema) {
- super(new NodeIdentifier(schema.getQName()),schema);
- final ImmutableMap.Builder<QName, DataNormalizationOperation<?>> byQNameBuilder = ImmutableMap.builder();
- final ImmutableMap.Builder<PathArgument, DataNormalizationOperation<?>> byArgBuilder =
- ImmutableMap.builder();
-
- for (final CaseSchemaNode caze : schema.getCases().values()) {
- for (final DataSchemaNode cazeChild : caze.getChildNodes()) {
- final DataNormalizationOperation<?> childOp = fromDataSchemaNode(cazeChild);
- byArgBuilder.put(childOp.getIdentifier(), childOp);
- for (final QName qname : childOp.getQNameIdentifiers()) {
- byQNameBuilder.put(qname, childOp);
- }
- }
- }
- byQName = byQNameBuilder.build();
- byArg = byArgBuilder.build();
- }
-
- @Override
- public DataNormalizationOperation<?> getChild(final PathArgument child) {
- return byArg.get(child);
- }
-
- @Override
- public DataNormalizationOperation<?> getChild(final QName child) {
- return byQName.get(child);
- }
-
- @Override
- public NormalizedNode<?, ?> createDefault(final PathArgument currentArg) {
- return Builders.choiceBuilder().withNodeIdentifier(getIdentifier()).build();
- }
- }
-
- private static class AnyxmlNormalization extends DataNormalizationOperation<NodeIdentifier> {
- AnyxmlNormalization(final AnyxmlSchemaNode schema) {
- super(new NodeIdentifier(schema.getQName()), schema);
- }
-
- @Override
- public DataNormalizationOperation<?> getChild(final PathArgument child) {
- return null;
- }
-
- @Override
- public DataNormalizationOperation<?> getChild(final QName child) {
- return null;
- }
-
- @Override
- public boolean isLeaf() {
- return false;
- }
-
- @Override
- public NormalizedNode<?, ?> createDefault(final PathArgument currentArg) {
- return null;
- }
- }
-
- private static @Nullable DataSchemaNode findChildSchemaNode(final DataNodeContainer parent, final QName child) {
- final DataSchemaNode potential = parent.getDataChildByName(child);
- return potential != null ? potential : findChoice(parent, child);
- }
-
- private static @Nullable ChoiceSchemaNode findChoice(final DataNodeContainer parent, final QName child) {
- for (final ChoiceSchemaNode choice : Iterables.filter(parent.getChildNodes(), ChoiceSchemaNode.class)) {
- for (final CaseSchemaNode caze : choice.getCases().values()) {
- if (findChildSchemaNode(caze, child) != null) {
- return choice;
- }
- }
- }
- return null;
- }
-
- public static AugmentationIdentifier augmentationIdentifierFrom(final AugmentationSchemaNode augmentation) {
- final ImmutableSet.Builder<QName> potentialChildren = ImmutableSet.builder();
- for (final DataSchemaNode child : augmentation.getChildNodes()) {
- potentialChildren.add(child.getQName());
- }
- return new AugmentationIdentifier(potentialChildren.build());
- }
-
- /**
- * Returns a DataNormalizationOperation for provided child node.
- *
- * <p>
- * If supplied child is added by Augmentation this operation returns
- * a DataNormalizationOperation for augmentation,
- * otherwise returns a DataNormalizationOperation for child as
- * call for {@link #fromDataSchemaNode(DataSchemaNode)}.
- */
- @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
- justification = "https://github.com/spotbugs/spotbugs/issues/811")
- private static DataNormalizationOperation<?> fromAugmentation(final DataNodeContainer parent,
- final AugmentationTarget parentAug, final DataSchemaNode child) {
- AugmentationSchemaNode augmentation = null;
- for (final AugmentationSchemaNode aug : parentAug.getAvailableAugmentations()) {
- final DataSchemaNode potential = aug.getDataChildByName(child.getQName());
- if (potential != null) {
- augmentation = aug;
- break;
- }
-
- }
- if (augmentation != null) {
- return new AugmentationNormalization(augmentation, parent);
- } else {
- return fromDataSchemaNode(child);
- }
- }
-
- public static DataNormalizationOperation<?> fromDataSchemaNode(final DataSchemaNode potential) {
- if (potential instanceof ContainerSchemaNode) {
- return new ContainerNormalization((ContainerSchemaNode) potential);
- } else if (potential instanceof ListSchemaNode) {
-
- return fromListSchemaNode((ListSchemaNode) potential);
- } else if (potential instanceof LeafSchemaNode) {
- return new LeafNormalization((LeafSchemaNode) potential);
- } else if (potential instanceof ChoiceSchemaNode) {
- return new ChoiceNodeNormalization((ChoiceSchemaNode) potential);
- } else if (potential instanceof LeafListSchemaNode) {
- return fromLeafListSchemaNode((LeafListSchemaNode) potential);
- } else if (potential instanceof AnyxmlSchemaNode) {
- return new AnyxmlNormalization((AnyxmlSchemaNode) potential);
- }
- return null;
- }
-
- private static DataNormalizationOperation<?> fromListSchemaNode(final ListSchemaNode potential) {
- final List<QName> keyDefinition = potential.getKeyDefinition();
- if (keyDefinition == null || keyDefinition.isEmpty()) {
- return new UnkeyedListMixinNormalization(potential);
- }
- if (potential.isUserOrdered()) {
- return new OrderedMapMixinNormalization(potential);
- }
- return new UnorderedMapMixinNormalization(potential);
- }
-
- private static DataNormalizationOperation<?> fromLeafListSchemaNode(final LeafListSchemaNode potential) {
- if (potential.isUserOrdered()) {
- return new OrderedLeafListMixinNormalization(potential);
- }
- return new UnorderedLeafListMixinNormalization(potential);
- }
-
-
- public static DataNormalizationOperation<?> from(final SchemaContext ctx) {
- return new ContainerNormalization(ctx);
- }
-
- public abstract NormalizedNode<?, ?> createDefault(PathArgument currentArg);
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.common.impl.util.compat;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-import com.google.common.collect.ImmutableList;
-import java.util.Iterator;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
-/**
- * Deprecated.
- *
- * @deprecated This class provides compatibility between XML semantics
- * and {@link org.opendaylight.yangtools.yang.data.util.DataSchemaContextTree}
- */
-@Deprecated(forRemoval = true)
-public class DataNormalizer {
-
- private final DataNormalizationOperation<?> operation;
-
- public DataNormalizer(final SchemaContext ctx) {
- operation = DataNormalizationOperation.from(ctx);
- }
-
- public YangInstanceIdentifier toNormalized(final YangInstanceIdentifier legacy) {
- ImmutableList.Builder<PathArgument> normalizedArgs = ImmutableList.builder();
-
- DataNormalizationOperation<?> currentOp = operation;
- Iterator<PathArgument> arguments = legacy.getPathArguments().iterator();
-
- try {
- while (arguments.hasNext()) {
- PathArgument legacyArg = arguments.next();
- currentOp = currentOp.getChild(legacyArg);
- checkArgument(currentOp != null,
- "Legacy Instance Identifier %s is not correct. Normalized Instance Identifier so far %s",
- legacy, normalizedArgs.build());
- while (currentOp.isMixin()) {
- normalizedArgs.add(currentOp.getIdentifier());
- currentOp = currentOp.getChild(legacyArg.getNodeType());
- }
- normalizedArgs.add(legacyArg);
- }
- } catch (DataNormalizationException e) {
- throw new IllegalArgumentException(String.format("Failed to normalize path %s", legacy), e);
- }
-
- return YangInstanceIdentifier.create(normalizedArgs.build());
- }
-
- public DataNormalizationOperation<?> getOperation(final YangInstanceIdentifier legacy)
- throws DataNormalizationException {
- DataNormalizationOperation<?> currentOp = operation;
-
- for (PathArgument pathArgument : legacy.getPathArguments()) {
- currentOp = currentOp.getChild(pathArgument);
- }
- return currentOp;
- }
-
- public YangInstanceIdentifier toLegacy(final YangInstanceIdentifier normalized) throws DataNormalizationException {
- ImmutableList.Builder<PathArgument> legacyArgs = ImmutableList.builder();
- DataNormalizationOperation<?> currentOp = operation;
- for (PathArgument normalizedArg : normalized.getPathArguments()) {
- currentOp = currentOp.getChild(normalizedArg);
- if (!currentOp.isMixin()) {
- legacyArgs.add(normalizedArg);
- }
- }
- return YangInstanceIdentifier.create(legacyArgs.build());
- }
-
- public DataNormalizationOperation<?> getRootOperation() {
- return operation;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.common.impl.util.compat;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
-import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.UsesNode;
-
-@Deprecated(forRemoval = true)
-class DataSchemaContainerProxy implements DataNodeContainer {
-
- private final Set<DataSchemaNode> realChildSchemas;
- private final Map<QName, DataSchemaNode> mappedChildSchemas;
-
- DataSchemaContainerProxy(final Set<DataSchemaNode> realChildSchema) {
- realChildSchemas = realChildSchema;
- mappedChildSchemas = new HashMap<>();
- for (DataSchemaNode schema : realChildSchemas) {
- mappedChildSchemas.put(schema.getQName(), schema);
- }
- }
-
- @Override
- public Optional<DataSchemaNode> findDataChildByName(final QName name) {
- return Optional.ofNullable(mappedChildSchemas.get(name));
- }
-
- @Override
- public Set<DataSchemaNode> getChildNodes() {
- return realChildSchemas;
- }
-
- @Override
- public Set<GroupingDefinition> getGroupings() {
- return Collections.emptySet();
- }
-
- @Override
- public Set<TypeDefinition<?>> getTypeDefinitions() {
- return Collections.emptySet();
- }
-
- @Override
- public Set<UsesNode> getUses() {
- return Collections.emptySet();
- }
-}
+++ /dev/null
-module normalization-test {
- yang-version 1;
- namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:normalization:test";
- prefix "norm-test";
-
- revision "2014-03-13" {
- description "Initial revision.";
- }
-
- grouping outer-grouping {
- }
-
- container test {
- list outer-list {
- key id;
- leaf id {
- type uint16;
- }
- choice outer-choice {
- case one {
- leaf one {
- type string;
- }
- }
- case two-three {
- leaf two {
- type string;
- }
- leaf three {
- type string;
- }
- }
- }
- list inner-list {
- key name;
- ordered-by user;
-
- leaf name {
- type string;
- }
- leaf value {
- type string;
- }
- }
- }
-
- list unkeyed-list {
- leaf name {
- type string;
- }
- }
-
- leaf-list unordered-leaf-list {
- type string;
- }
-
- leaf-list ordered-leaf-list {
- ordered-by user;
- type string;
- }
-
- container outer-container {
- }
-
- anyxml any-xml-data;
- }
-
- augment /norm-test:test/norm-test:outer-container {
-
- leaf augmented-leaf {
- type string;
- }
- }
-}
\ No newline at end of file
<packaging>bundle</packaging>
<dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-common-api</artifactId>
- </dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>concepts</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-api</artifactId>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-clustering-commons</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-common-api</artifactId>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-common-util</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-core-compat</artifactId>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-akka-segmented-journal</artifactId>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-dom-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-dom-spi</artifactId>
+ <artifactId>mdsal-binding-dom-codec</artifactId>
</dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-dom-broker</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-binding-dom-codec</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-core-spi</artifactId>
- </dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
+++ /dev/null
-/*
- * Copyright (c) 2016 Brocade Communications Systems, Inc. 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.cluster.datastore.compat;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.base.Optional;
-import com.google.common.collect.ForwardingObject;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.MoreExecutors;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface;
-import org.opendaylight.controller.md.sal.common.api.MappingCheckedFuture;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.sal.core.compat.ReadFailedExceptionAdapter;
-import org.opendaylight.controller.sal.core.spi.data.DOMStore;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-/**
- * Adapter between the legacy controller API-based DOMStore and the mdsal API-based DOMStore.
- *
- * @author Thomas Pantelis
- */
-@Deprecated(forRemoval = true)
-public class LegacyDOMStoreAdapter extends ForwardingObject implements DOMStore, AutoCloseable {
- private final DistributedDataStoreInterface delegate;
-
- public LegacyDOMStoreAdapter(DistributedDataStoreInterface delegate) {
- this.delegate = delegate;
- }
-
- @Override
- public DOMStoreReadTransaction newReadOnlyTransaction() {
- return new DOMStoreTransactionAdapter(delegate().newReadOnlyTransaction());
- }
-
- @Override
- public DOMStoreWriteTransaction newWriteOnlyTransaction() {
- return new DOMStoreTransactionAdapter(delegate().newWriteOnlyTransaction());
- }
-
- @Override
- public DOMStoreReadWriteTransaction newReadWriteTransaction() {
- return new DOMStoreTransactionAdapter(delegate().newReadWriteTransaction());
- }
-
- @Override
- public DOMStoreTransactionChain createTransactionChain() {
- final org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain delegateChain =
- delegate().createTransactionChain();
- return new DOMStoreTransactionChain() {
- @Override
- public DOMStoreReadTransaction newReadOnlyTransaction() {
- return new DOMStoreTransactionAdapter(delegateChain.newReadOnlyTransaction());
- }
-
- @Override
- public DOMStoreWriteTransaction newWriteOnlyTransaction() {
- return new DOMStoreTransactionAdapter(delegateChain.newWriteOnlyTransaction());
- }
-
- @Override
- public DOMStoreReadWriteTransaction newReadWriteTransaction() {
- return new DOMStoreTransactionAdapter(delegateChain.newReadWriteTransaction());
- }
-
- @Override
- public void close() {
- delegateChain.close();
- }
- };
- }
-
- @Override
- public void close() {
- }
-
- @Override
- protected DistributedDataStoreInterface delegate() {
- return delegate;
- }
-
- private static class DOMStoreTransactionAdapter implements DOMStoreReadWriteTransaction {
- private final org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction readDelegate;
- private final org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction writeDelegate;
- private final Object identifier;
-
- DOMStoreTransactionAdapter(org.opendaylight.mdsal.dom.spi.store.@NonNull DOMStoreReadTransaction readDelegate) {
- this.readDelegate = requireNonNull(readDelegate);
- this.identifier = readDelegate.getIdentifier();
- this.writeDelegate = null;
- }
-
- DOMStoreTransactionAdapter(
- org.opendaylight.mdsal.dom.spi.store.@NonNull DOMStoreWriteTransaction writeDelegate) {
- this.writeDelegate = requireNonNull(writeDelegate);
- this.identifier = writeDelegate.getIdentifier();
- this.readDelegate = null;
- }
-
- DOMStoreTransactionAdapter(
- org.opendaylight.mdsal.dom.spi.store.@NonNull DOMStoreReadWriteTransaction rwDelegate) {
- this.readDelegate = requireNonNull(rwDelegate);
- this.writeDelegate = rwDelegate;
- this.identifier = readDelegate.getIdentifier();
- }
-
- @Override
- public Object getIdentifier() {
- return identifier;
- }
-
- @Override
- public void close() {
- if (writeDelegate != null) {
- writeDelegate.close();
- } else {
- readDelegate.close();
- }
- }
-
- @Override
- public void write(YangInstanceIdentifier path, NormalizedNode<?, ?> data) {
- writeDelegate.write(path, data);
- }
-
- @Override
- public void merge(YangInstanceIdentifier path, NormalizedNode<?, ?> data) {
- writeDelegate.merge(path, data);
- }
-
- @Override
- public void delete(YangInstanceIdentifier path) {
- writeDelegate.delete(path);
- }
-
- @Override
- public DOMStoreThreePhaseCommitCohort ready() {
- final org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort cohort = writeDelegate.ready();
- return new DOMStoreThreePhaseCommitCohort() {
- @Override
- public ListenableFuture<Boolean> canCommit() {
- return cohort.canCommit();
- }
-
- @Override
- public ListenableFuture<Void> preCommit() {
- return cohort.preCommit();
- }
-
- @Override
- public ListenableFuture<Void> commit() {
- return cohort.commit();
- }
-
- @Override
- public ListenableFuture<Void> abort() {
- return cohort.abort();
- }
- };
- }
-
- @Override
- public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(YangInstanceIdentifier path) {
- return MappingCheckedFuture.create(readDelegate.read(path).transform(
- Optional::fromJavaUtil, MoreExecutors.directExecutor()), ReadFailedExceptionAdapter.INSTANCE);
- }
-
- @Override
- public CheckedFuture<Boolean, ReadFailedException> exists(YangInstanceIdentifier path) {
- return MappingCheckedFuture.create(readDelegate.exists(path), ReadFailedExceptionAdapter.INSTANCE);
- }
- }
-}
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
/**
- * Request a {@link org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener} registration be made on the
- * shard leader.
+ * Request a {@link org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener} registration be made on the shard leader.
*/
public final class RegisterDataTreeChangeListener implements Externalizable {
private static final long serialVersionUID = 1L;
<service ref="clusteredDOMDataBroker" interface="org.opendaylight.mdsal.dom.api.DOMDataBroker"
odl:type="default"/>
- <bean id="legacyDOMDataBroker" class="org.opendaylight.controller.sal.core.compat.LegacyDOMDataBrokerAdapter">
- <argument ref="clusteredDOMDataBroker"/>
- </bean>
-
- <service ref="legacyDOMDataBroker" interface="org.opendaylight.controller.md.sal.dom.api.DOMDataBroker"
- odl:type="default"/>
-
<!-- JMX beans for the data broker -->
<bean id="commitStatsMXBean" class="org.opendaylight.controller.cluster.datastore.jmx.mbeans.CommitStatsMXBeanImpl"
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-parent</artifactId>
- <version>1.12.0-SNAPSHOT</version>
- <relativePath>../parent</relativePath>
- </parent>
-
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-core-api</artifactId>
- <version>1.12.0-SNAPSHOT</version>
- <packaging>bundle</packaging>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-common-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-data-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-model-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-test-model</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-dom-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-data-impl</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <scm>
- <connection>scm:git:http://git.opendaylight.org/gerrit/controller.git</connection>
- <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
- <tag>HEAD</tag>
- <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
- </scm>
-
-</project>
+++ /dev/null
-/*
- * Copyright (c) 2015 Brocade Communications Systems, Inc. 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.md.sal.dom.api;
-
-/**
- * ClusteredDOMDataTreeChangeListener is a marker interface to enable data tree change notifications on all
- * instances in a cluster where this listener is registered.
- *
- * <p>
- * Applications should implement ClusteredDOMDataTreeChangeListener instead of {@link DOMDataTreeChangeListener},
- * if they want to listen for data tree change notifications on any node of a clustered data store.
- * {@link DOMDataTreeChangeListener} enables notifications only at the leader of the data store.
- *
- * @author Thomas Pantelis
- * @deprecated Use {@link org.opendaylight.mdsal.dom.api.ClusteredDOMDataTreeChangeListener} instead.
- */
-@Deprecated(forRemoval = true)
-public interface ClusteredDOMDataTreeChangeListener extends DOMDataTreeChangeListener {
-
-}
+++ /dev/null
-/*
- * 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.md.sal.dom.api;
-
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-
-/**
- * Bridge to action registration.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMActionProviderService} instead
- */
-@Deprecated(forRemoval = true)
-@SuppressFBWarnings(value = "NM_SAME_SIMPLE_NAME_AS_INTERFACE", justification = "Migration")
-public interface DOMActionProviderService extends DOMService, org.opendaylight.mdsal.dom.api.DOMActionProviderService {
-
-}
+++ /dev/null
-/*
- * 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.md.sal.dom.api;
-
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-
-/**
- * Bridge to action invocation.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMActionService} instead
- */
-@Deprecated(forRemoval = true)
-@SuppressFBWarnings(value = "NM_SAME_SIMPLE_NAME_AS_INTERFACE", justification = "Migration")
-public interface DOMActionService extends DOMService, org.opendaylight.mdsal.dom.api.DOMActionService {
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.api;
-
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionChainFactory;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-/**
- * Data Broker which provides data transaction and data change listener functionality
- * using {@link NormalizedNode} data format.
- *
- * <p>
- * This interface is type capture of generic interfaces and returns type captures
- * of results for client-code convenience.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMDataBroker} instead
- */
-@Deprecated(forRemoval = true)
-public interface DOMDataBroker extends
- AsyncDataBroker<YangInstanceIdentifier, NormalizedNode<?, ?>>,
- TransactionChainFactory<YangInstanceIdentifier, NormalizedNode<?, ?>>,
- DOMExtensibleService<DOMDataBroker, DOMDataBrokerExtension> {
-
- @Override
- DOMDataReadOnlyTransaction newReadOnlyTransaction();
-
- @Override
- DOMDataReadWriteTransaction newReadWriteTransaction();
-
- @Override
- DOMDataWriteTransaction newWriteOnlyTransaction();
-
- @Override
- DOMTransactionChain createTransactionChain(TransactionChainListener listener);
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.dom.api;
-
-/**
- * Type capture of a {@link DOMServiceExtension} applicable to {@link DOMDataBroker} implementations.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMDataBrokerExtension} instead.
- */
-@Deprecated(forRemoval = true)
-public interface DOMDataBrokerExtension extends DOMServiceExtension<DOMDataBroker, DOMDataBrokerExtension> {
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014, 2015 Cisco Systems, Inc. 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.md.sal.dom.api;
-
-import org.opendaylight.controller.md.sal.common.api.data.AsyncReadOnlyTransaction;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-@Deprecated(forRemoval = true)
-public interface DOMDataReadOnlyTransaction extends DOMDataReadTransaction,
- AsyncReadOnlyTransaction<YangInstanceIdentifier, NormalizedNode<?, ?>> {
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.api;
-
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncReadTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-/**
- * A transaction that provides read access to a logical data store.
- *
- * <p>
- * For more information on usage and examples, please see the documentation in {@link AsyncReadTransaction}.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction} instead.
- */
-@Deprecated(forRemoval = true)
-public interface DOMDataReadTransaction extends AsyncReadTransaction<YangInstanceIdentifier, NormalizedNode<?, ?>> {
- /**
- * Reads data from provided logical data store located at the provided path.
- *
- * <p>
- * If the target is a subtree, then the whole subtree is read (and will be
- * accessible from the returned data object).
- *
- * @param store
- * Logical data store from which read should occur.
- * @param path
- * Path which uniquely identifies subtree which client want to
- * read
- * @return a CheckFuture containing the result of the read. The Future blocks until the
- * commit operation is complete. Once complete:
- * <ul>
- * <li>If the data at the supplied path exists, the Future returns an Optional object
- * containing the data.</li>
- * <li>If the data at the supplied path does not exist, the Future returns
- * Optional#absent().</li>
- * <li>If the read of the data fails, the Future will fail with a
- * {@link ReadFailedException} or an exception derived from ReadFailedException.</li>
- * </ul>
- */
- CheckedFuture<Optional<NormalizedNode<?,?>>, ReadFailedException> read(
- LogicalDatastoreType store, YangInstanceIdentifier path);
-
- /**
- * Checks if data is available in the logical data store located at provided path.
- *
- * <p>
- * Note: a successful result from this method makes no guarantee that a subsequent call to {@link #read}
- * will succeed. It is possible that the data resides in a data store on a remote node and, if that
- * node goes down or a network failure occurs, a subsequent read would fail. Another scenario is if
- * the data is deleted in between the calls to <code>exists</code> and <code>read</code>
- *
- * @param store
- * Logical data store from which read should occur.
- * @param path
- * Path which uniquely identifies subtree which client want to
- * check existence of
- * @return a CheckFuture containing the result of the check.
- * <ul>
- * <li>If the data at the supplied path exists, the Future returns a Boolean
- * whose value is true, false otherwise</li>
- * <li>If checking for the data fails, the Future will fail with a
- * {@link ReadFailedException} or an exception derived from ReadFailedException.</li>
- * </ul>
- */
- CheckedFuture<Boolean, ReadFailedException> exists(LogicalDatastoreType store, YangInstanceIdentifier path);
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.api;
-
-import org.opendaylight.controller.md.sal.common.api.data.AsyncReadWriteTransaction;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-@Deprecated(forRemoval = true)
-public interface DOMDataReadWriteTransaction extends DOMDataReadTransaction, DOMDataWriteTransaction,
- AsyncReadWriteTransaction<YangInstanceIdentifier, NormalizedNode<?, ?>> {
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.dom.api;
-
-import java.util.Collection;
-import java.util.EventListener;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
-
-/**
- * Interface implemented by classes interested in receiving notifications about
- * data tree changes. This interface provides a cursor-based view of the change, which has potentially
- * lower overhead.
- *
- * <p>
- * Note: this interface enables notifications only at the leader of the data store, if clustered. If you want
- * notifications on all instances in a cluster, use the {@link ClusteredDOMDataTreeChangeListener}.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener} instead.
- */
-@Deprecated(forRemoval = true)
-public interface DOMDataTreeChangeListener extends EventListener {
- /**
- * Invoked when there was data change for the supplied path, which was used
- * to register this listener.
- *
- * <p>
- * This method may be also invoked during registration of the listener if
- * there is any pre-existing data in the conceptual data tree for supplied
- * path. This initial event will contain all pre-existing data as created.
- *
- * <p>
- * A data change event may be triggered spuriously, e.g. such that data before
- * and after compare as equal. Implementations of this interface are expected
- * to recover from such events. Event producers are expected to exert reasonable
- * effort to suppress such events.
- *
- * <p>
- * In other words, it is completely acceptable to observe
- * a {@link org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode},
- * which reports a {@link org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType}
- * other than UNMODIFIED, while the before- and after- data items compare as
- * equal.
- *
- * @param changes Collection of change events, may not be null or empty.
- */
- void onDataTreeChanged(@NonNull Collection<DataTreeCandidate> changes);
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.dom.api;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-
-/**
- * A {@link DOMServiceExtension} which allows users to register for changes to a subtree.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService} instead.
- */
-@Deprecated(forRemoval = true)
-public interface DOMDataTreeChangeService extends DOMDataBrokerExtension {
- /**
- * Registers a {@link DOMDataTreeChangeListener} to receive
- * notifications when data changes under a given path in the conceptual data
- * tree.
- *
- * <p>
- * You are able to register for notifications for any node or subtree
- * which can be represented using {@link DOMDataTreeIdentifier}.
- *
- * <p>
- * You are able to register for data change notifications for a subtree or leaf
- * even if it does not exist. You will receive notification once that node is
- * created.
- *
- * <p>
- * If there is any pre-existing data in the data tree for the path for which you are
- * registering, you will receive an initial data change event, which will
- * contain all pre-existing data, marked as created.
- *
- * <p>
- * This method returns a {@link ListenerRegistration} object. To
- * "unregister" your listener for changes call the {@link ListenerRegistration#close()}
- * method on the returned object.
- *
- * <p>
- * You MUST explicitly unregister your listener when you no longer want to receive
- * notifications. This is especially true in OSGi environments, where failure to
- * do so during bundle shutdown can lead to stale listeners being still registered.
- *
- * @param treeId
- * Data tree identifier of the subtree which should be watched for
- * changes.
- * @param listener
- * Listener instance which is being registered
- * @return Listener registration object, which may be used to unregister
- * your listener using {@link ListenerRegistration#close()} to stop
- * delivery of change events.
- */
- @NonNull <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerDataTreeChangeListener(
- @NonNull DOMDataTreeIdentifier treeId, @NonNull L listener);
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 2015 Brocade Communications Systems, Inc. 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.md.sal.dom.api;
-
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-
-/**
- * Interface for a DOM commit cohort registry.
- *
- * @author Thomas Pantelis
- * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry} instead.
- */
-@Deprecated(forRemoval = true)
-@SuppressFBWarnings("NM_SAME_SIMPLE_NAME_AS_INTERFACE")
-public interface DOMDataTreeCommitCohortRegistry extends DOMDataBrokerExtension,
- org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry {
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.dom.api;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.base.MoreObjects;
-import java.io.Serializable;
-import java.util.Iterator;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.yangtools.concepts.Immutable;
-import org.opendaylight.yangtools.concepts.Path;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
-
-/**
- * A unique identifier for a particular subtree. It is composed of the logical
- * data store type and the instance identifier of the root node.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier} instead.
- */
-@Deprecated(forRemoval = true)
-public final class DOMDataTreeIdentifier implements Immutable,
- Path<DOMDataTreeIdentifier>, Serializable, Comparable<DOMDataTreeIdentifier> {
- private static final long serialVersionUID = 1L;
- private final @NonNull YangInstanceIdentifier rootIdentifier;
- private final @NonNull LogicalDatastoreType datastoreType;
-
- public DOMDataTreeIdentifier(final LogicalDatastoreType datastoreType,
- final YangInstanceIdentifier rootIdentifier) {
- this.datastoreType = requireNonNull(datastoreType);
- this.rootIdentifier = requireNonNull(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.
- *
- * @return Logical data store type. Guaranteed to be non-null.
- */
- public @NonNull LogicalDatastoreType getDatastoreType() {
- return datastoreType;
- }
-
- /**
- * Return the {@link YangInstanceIdentifier} of the root node.
- *
- * @return Instance identifier corresponding to the root node.
- */
- public @NonNull YangInstanceIdentifier getRootIdentifier() {
- return rootIdentifier;
- }
-
- @Override
- public boolean contains(final DOMDataTreeIdentifier other) {
- return datastoreType == other.datastoreType && rootIdentifier.contains(other.rootIdentifier);
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + datastoreType.hashCode();
- result = prime * result + rootIdentifier.hashCode();
- return result;
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (!(obj instanceof DOMDataTreeIdentifier)) {
- return false;
- }
- DOMDataTreeIdentifier other = (DOMDataTreeIdentifier) obj;
- if (datastoreType != other.datastoreType) {
- return false;
- }
- return rootIdentifier.equals(other.rootIdentifier);
- }
-
- @Override
- public int compareTo(final DOMDataTreeIdentifier obj) {
- int cmp = datastoreType.compareTo(obj.datastoreType);
- if (cmp != 0) {
- return cmp;
- }
-
- final Iterator<PathArgument> mi = rootIdentifier.getPathArguments().iterator();
- final Iterator<PathArgument> oi = obj.rootIdentifier.getPathArguments().iterator();
-
- while (mi.hasNext()) {
- if (!oi.hasNext()) {
- return 1;
- }
-
- final PathArgument ma = mi.next();
- final PathArgument oa = oi.next();
- cmp = ma.compareTo(oa);
- if (cmp != 0) {
- return cmp;
- }
- }
-
- return oi.hasNext() ? -1 : 0;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this).add("datastore", datastoreType).add("root", rootIdentifier).toString();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.api;
-
-import org.opendaylight.controller.md.sal.common.api.data.AsyncWriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-/**
- * A transaction that provides mutation capabilities on a data tree.
- *
- * <p>
- * For more information on usage and examples, please see the documentation in {@link AsyncWriteTransaction}.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction} instead.
- */
-@Deprecated(forRemoval = true)
-public interface DOMDataWriteTransaction extends AsyncWriteTransaction<YangInstanceIdentifier, NormalizedNode<?, ?>> {
-
- @Override
- void delete(LogicalDatastoreType store, YangInstanceIdentifier path);
-
- /**
- * Stores a piece of data at the specified path. This acts as an add / replace
- * operation, which is to say that whole subtree will be replaced by the specified data.
- *
- * <p>
- * For more information on usage and examples, please see the documentation in {@link AsyncWriteTransaction}.
- *
- * <p>
- * If you need to make sure that a parent object exists but you do not want modify
- * its pre-existing state by using put, consider using {@link #merge} instead.
- *
- * @param store
- * the logical data store which should be modified
- * @param path
- * the data object path
- * @param data
- * the data object to be written to the specified path
- * @throws IllegalStateException
- * if the transaction has already been submitted
- */
- void put(LogicalDatastoreType store, YangInstanceIdentifier path, NormalizedNode<?, ?> data);
-
- /**
- * Merges a piece of data with the existing data at a specified path. Any pre-existing data
- * which is not explicitly overwritten will be preserved. This means that if you store a container,
- * its child lists will be merged.
- *
- * <p>
- * For more information on usage and examples, please see the documentation in {@link AsyncWriteTransaction}.
- *
- *<p>
- * If you require an explicit replace operation, use {@link #put} instead.
- *
- * @param store
- * the logical data store which should be modified
- * @param path
- * the data object path
- * @param data
- * the data object to be merged to the specified path
- * @throws IllegalStateException
- * if the transaction has already been submitted
- */
- void merge(LogicalDatastoreType store, YangInstanceIdentifier path, NormalizedNode<?, ?> data);
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.dom.api;
-
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import java.time.Instant;
-import java.util.Date;
-
-/**
- * Generic event interface.
- * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMEvent} instead.
- */
-@Deprecated(forRemoval = true)
-@SuppressFBWarnings(value = "NM_SAME_SIMPLE_NAME_AS_INTERFACE", justification = "Migration")
-public interface DOMEvent extends org.opendaylight.mdsal.dom.api.DOMEvent {
-
- @Override
- default Instant getEventInstant() {
- final Date eventTime = getEventTime();
- return eventTime != null ? eventTime.toInstant() : null;
- }
-
- /**
- * Get the time of the event occurrence.
- *
- * @return the event time
- */
- Date getEventTime();
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.dom.api;
-
-import com.google.common.annotations.Beta;
-import java.util.Map;
-import org.eclipse.jdt.annotation.NonNull;
-
-/**
- * Marker interface for services which can support {@link DOMServiceExtension}.
- * Aside for marking these, they also provide runtime query to detect whether
- * a particular trait is in fact available.
- *
- * @param <T> Base {@link DOMService}
- * @param <E> Extension type
- * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMExtensibleService} instead.
- */
-@Deprecated(forRemoval = true)
-@Beta
-public interface DOMExtensibleService<T extends DOMExtensibleService<T, E>,
- E extends DOMServiceExtension<T, E>> extends DOMService {
- /**
- * Return a map of currently-supported extensions, along with accessor services
- * which provide access to the specific functionality bound to this service.
- *
- * @return A map of supported functionality.
- */
- @NonNull Map<Class<? extends E>, E> getSupportedExtensions();
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.api;
-
-import com.google.common.base.Optional;
-import org.opendaylight.yangtools.concepts.Identifiable;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
-@Deprecated(forRemoval = true)
-public interface DOMMountPoint extends Identifiable<YangInstanceIdentifier> {
-
- <T extends DOMService> Optional<T> getService(Class<T> cls);
-
- SchemaContext getSchemaContext();
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.api;
-
-import com.google.common.base.Optional;
-import org.opendaylight.mdsal.dom.api.DOMMountPointListener;
-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;
-
-/**
- * Deprecated.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMMountPointService} instead
- */
-@Deprecated(forRemoval = true)
-public interface DOMMountPointService extends DOMService {
-
- Optional<DOMMountPoint> getMountPoint(YangInstanceIdentifier path);
-
- DOMMountPointBuilder createMountPoint(YangInstanceIdentifier path);
-
- ListenerRegistration<DOMMountPointListener> registerProvisionListener(DOMMountPointListener listener);
-
- interface DOMMountPointBuilder {
-
- <T extends DOMService> DOMMountPointBuilder addService(Class<T> type,T impl);
-
- DOMMountPointBuilder addInitialSchemaContext(SchemaContext ctx);
-
- ObjectRegistration<DOMMountPoint> register();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.api;
-
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-
-/**
- * A single YANG notification.
- * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMNotification} instead.
- */
-@Deprecated(forRemoval = true)
-@SuppressFBWarnings(value = "NM_SAME_SIMPLE_NAME_AS_INTERFACE", justification = "Migration")
-public interface DOMNotification extends org.opendaylight.mdsal.dom.api.DOMNotification {
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.api;
-
-import java.util.EventListener;
-import org.eclipse.jdt.annotation.NonNull;
-
-/**
- * Interface implemented by listeners interested in {@link DOMNotification}s.
- * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMNotificationListener} instead.
- */
-@Deprecated(forRemoval = true)
-public interface DOMNotificationListener extends EventListener {
- /**
- * Invoked whenever a {@link DOMNotification} matching the subscription
- * criteria is received.
- *
- * @param notification Received notification
- */
- void onNotification(@NonNull DOMNotification notification);
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.api;
-
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import java.util.concurrent.TimeUnit;
-import org.eclipse.jdt.annotation.NonNull;
-
-/**
- * A {@link DOMService} which allows its user to send {@link DOMNotification}s. It
- * provides two styles of initiating the notification delivery, similar to
- * {@link java.util.concurrent.BlockingQueue}:
- * - a put-style method which waits until the implementation can accept the notification
- * for delivery, and
- * - an offer-style method, which attempts to enqueue the notification, but allows
- * the caller to specify that it should never wait, or put an upper bound on how
- * long it is going to wait.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMNotificationPublishService} instead
- */
-@Deprecated(forRemoval = true)
-public interface DOMNotificationPublishService extends DOMService {
- /**
- * Well-known value indicating that the implementation is currently not
- * able to accept a notification.
- */
- ListenableFuture<Object> REJECTED = Futures.immediateFailedFuture(
- new DOMNotificationRejectedException("Unacceptable blocking conditions encountered"));
-
- /**
- * Publish a notification. The result of this method is a {@link ListenableFuture}
- * which will complete once the notification has been delivered to all immediate
- * registrants. The type of the object resulting from the future is not defined
- * and implementations may use it to convey additional information related to the
- * publishing process.
- *
- * <p>
- * Abstract subclasses can refine the return type as returning a promise of a
- * more specific type, e.g.:
- *
- * {@code
- * public interface DeliveryStatus { int getListenerCount(); }
- * ListenableFuture<? extends DeliveryStatus> putNotification(DOMNotification notification);
- * }
- *
- * <p>
- * Once the Future succeeds, the resulting object can be queried for traits using
- * instanceof, e.g:
- *
- * {@code
- * // Can block when (for example) the implemention's ThreadPool queue is full
- * Object o = service.putNotification(notif).get();
- * if (o instanceof DeliveryStatus) {
- * DeliveryStatus ds = (DeliveryStatus)o;
- * LOG.debug("Notification was received by {} listeners", ds.getListenerCount(););
- * }
- * }
- *
- * <p>
- * In case an implementation is running out of resources, it can block the calling
- * thread until enough resources become available to accept the notification for
- * processing, or it is interrupted.
- *
- * <p>
- * Caution: completion here means that the implementation has completed processing
- * of the notification. This does not mean that all existing registrants
- * have seen the notification. Most importantly, the delivery process at
- * other cluster nodes may have not begun yet.
- *
- * @param notification Notification to be published.
- * @return A listenable future which will report completion when the service
- * has finished propagating the notification to its immediate registrants.
- * @throws InterruptedException if interrupted while waiting
- * @throws NullPointerException if notification is null.
- */
- @NonNull ListenableFuture<?> putNotification(@NonNull DOMNotification notification) throws InterruptedException;
-
- /**
- * Attempt to publish a notification. The result of this method is a {@link ListenableFuture}
- * which will complete once the notification has been delivered to all immediate
- * registrants. The type of the object resulting from the future is not defined
- * and implementations may use it to convey additional information related to the
- * publishing process. Unlike {@link #putNotification(DOMNotification)}, this method
- * is guaranteed not to block if the underlying implementation encounters contention.
- *
- * @param notification Notification to be published.
- * @return A listenable future which will report completion when the service
- * has finished propagating the notification to its immediate registrants,
- * or {@link #REJECTED} if resource constraints prevent
- * the implementation from accepting the notification for delivery.
- * @throws NullPointerException if notification is null.
- */
- @NonNull ListenableFuture<?> offerNotification(@NonNull DOMNotification notification);
-
- /**
- * Attempt to publish a notification. The result of this method is a {@link ListenableFuture}
- * which will complete once the notification has been delivered to all immediate
- * registrants. The type of the object resulting from the future is not defined
- * and implementations may use it to convey additional information related to the
- * publishing process. Unlike {@link #putNotification(DOMNotification)}, this method
- * is guaranteed to block more than the specified timeout.
- *
- * @param notification Notification to be published.
- * @param timeout how long to wait before giving up, in units of unit, must not be negative
- * @param unit a TimeUnit determining how to interpret the timeout parameter
- * @return A listenable future which will report completion when the service
- * has finished propagating the notification to its immediate registrants,
- * or {@link #REJECTED} if resource constraints prevent
- * the implementation from accepting the notification for delivery.
- * @throws InterruptedException if interrupted while waiting
- * @throws NullPointerException if notification or unit is null.
- * @throws IllegalArgumentException if timeout is negative.
- */
- @NonNull ListenableFuture<?> offerNotification(@NonNull DOMNotification notification,
- long timeout, @NonNull TimeUnit unit) throws InterruptedException;
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.dom.api;
-
-/**
- * This exception indicates that given notification can not be processed by corresponding mechanism.
- * More info can be provided in message.
- *
- * <p>
- * Expected use: {@link DOMNotificationPublishService}
- * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMNotificationRejectedException} instead.
- */
-@Deprecated(forRemoval = true)
-public class DOMNotificationRejectedException extends Exception {
- private static final long serialVersionUID = 1L;
-
- public DOMNotificationRejectedException(final String message) {
- super(message);
- }
-
- public DOMNotificationRejectedException(final String message, final Throwable cause) {
- super(message, cause);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.api;
-
-import java.util.Collection;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-
-/**
- * A {@link DOMService} which allows its users to subscribe to receive
- * {@link DOMNotification}s.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMNotificationService} instead
- */
-@Deprecated(forRemoval = true)
-public interface DOMNotificationService extends DOMService {
- /**
- * Register a {@link DOMNotificationListener} to receive a set of notifications. As with
- * other ListenerRegistration-based interfaces, registering an instance multiple times
- * results in notifications being delivered for each registration.
- *
- * @param listener Notification instance to register
- * @param types Notification types which should be delivered to the listener. Duplicate
- * entries are processed only once, null entries are ignored.
- * @return Registration handle. Invoking {@link ListenerRegistration#close()}
- * will stop the delivery of notifications to the listener
- * @throws IllegalArgumentException if types is empty or contains an invalid element, such as
- * null or a SchemaPath which does not represent a valid {@link DOMNotification} type.
- * @throws NullPointerException if either of the arguments is null
- */
- <T extends DOMNotificationListener> ListenerRegistration<T> registerNotificationListener(
- @NonNull T listener, @NonNull Collection<SchemaPath> types);
-
- /**
- * Register a {@link DOMNotificationListener} to receive a set of notifications. As with
- * other ListenerRegistration-based interfaces, registering an instance multiple times
- * results in notifications being delivered for each registration.
- *
- * @param listener Notification instance to register
- * @param types Notification types which should be delivered to the listener. Duplicate
- * entries are processed only once, null entries are ignored.
- * @return Registration handle. Invoking {@link ListenerRegistration#close()}
- * will stop the delivery of notifications to the listener
- * @throws IllegalArgumentException if types is empty or contains an invalid element, such as
- * null or a SchemaPath which does not represent a valid {@link DOMNotification} type.
- * @throws NullPointerException if listener is null
- */
- // FIXME: Java 8: provide a default implementation of this method.
- <T extends DOMNotificationListener> ListenerRegistration<T> registerNotificationListener(
- @NonNull T listener, SchemaPath... types);
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.dom.api;
-
-import java.util.Collection;
-import java.util.EventListener;
-import org.eclipse.jdt.annotation.NonNull;
-
-/**
- * An {@link EventListener} used to track RPC implementations becoming (un)available a {@link DOMRpcService}. Note that
- * the reported {@link DOMRpcIdentifier}s form an identifier space shared between RFC7950 actions and RFC6020 RPCs,
- * the former being also known as 'Routed RPCs'.
- *
- * <p>
- * Interpretation of DOMRpcIdentifiers has to be evaluated in the context of one of these types, which need to be
- * determined by matching {@link DOMRpcIdentifier#getType()} against a
- * {@link org.opendaylight.yangtools.yang.model.api.SchemaContext}, which determines actual semantics of
- * {@link DOMRpcIdentifier#getContextReference()}. Corresponding SchemaNode is required to be a known sub-interface
- * of {@link org.opendaylight.yangtools.yang.model.api.OperationDefinition}.
- *
- * <p>
- * For RFC6020 RPCs, reported context reference is always non-null and empty. It indicates an RPC implementation has
- * been registered and invocations can be reasonably (with obvious distributed system caveats coming from asynchronous
- * events) expected to succeed.
- *
- * <p>
- * For RFC7950 actions with a non-empty context-reference, the indication is the same as for RFC6020 RPCs.
- *
- * <p>
- * For RFC7950 actions with an empty context-reference, the indication is that the corresponding actions are
- * potentially available, but are subject to dynamic lifecycle of their context references. This includes two primary
- * use cases:
- * <ul>
- * <li>dynamic action instantiation (when a device connects)</li>
- * <li>dynamic action translation, such as transforming one action into another</li>
- * </ul>
- * First use case will provide further availability events with non-empty context references as they become available,
- * which can be safely ignored if the listener is interested in pure invocation-type integration.
- *
- * <p>
- * Second use case will not be providing further events, but rather will attempt to map any incoming invocation onto
- * some other RPC or action, or similar, which can separately fail. If a sub-request fails, such implementations are
- * required do report {@link DOMRpcImplementationNotAvailableException} as the invocation result, with the underlying
- * failure being linked as a cause.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMRpcAvailabilityListener} instead.
- */
-@Deprecated(forRemoval = true)
-public interface DOMRpcAvailabilityListener extends EventListener {
- /**
- * Method invoked whenever an RPC type becomes available.
- *
- * @param rpcs RPC types newly available
- */
- void onRpcAvailable(@NonNull Collection<DOMRpcIdentifier> rpcs);
-
- /**
- * Method invoked whenever an RPC type becomes unavailable.
- *
- * @param rpcs RPC types which became unavailable
- */
- void onRpcUnavailable(@NonNull Collection<DOMRpcIdentifier> rpcs);
-
- /**
- * Implementation filtering method. This method is useful for forwarding RPC implementations,
- * which need to ensure they do not re-announce their own implementations. Without this method
- * a forwarder which registers an implementation would be notified of its own implementation,
- * potentially re-exporting it as local -- hence creating a forwarding loop.
- *
- * @param impl RPC implementation being registered
- * @return False if the implementation should not be reported, defaults to true.
- */
- default boolean acceptsImplementation(final DOMRpcImplementation impl) {
- return true;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.dom.api;
-
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-
-/**
- * Base class for failures that can occur during RPC invocation. This covers
- * transport and protocol-level failures.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMRpcException} instead.
- */
-@Deprecated(forRemoval = true)
-@SuppressFBWarnings(value = "NM_SAME_SIMPLE_NAME_AS_SUPERCLASS", justification = "Migration")
-public abstract class DOMRpcException extends org.opendaylight.mdsal.dom.api.DOMRpcException {
- private static final long serialVersionUID = 1L;
-
- /**
- * Construct an new instance with a message and an empty cause.
- *
- * @param message Exception message
- */
- protected DOMRpcException(final String message) {
- super(message);
- }
-
- /**
- * Construct an new instance with a message and a cause.
- *
- * @param message Exception message
- * @param cause Chained cause
- */
- protected DOMRpcException(final String message, final Throwable cause) {
- super(message, cause);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.dom.api;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.base.MoreObjects;
-import java.util.Objects;
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-
-/**
- * Identifier of a RPC context. This is an extension of the YANG RPC, which
- * always has global context. It allows an RPC to have a instance identifier
- * attached, so that there can be multiple implementations bound to different
- * contexts concurrently.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMRpcIdentifier} instead.
- */
-@Deprecated(forRemoval = true)
-public abstract class DOMRpcIdentifier {
-
- private static final class Global extends DOMRpcIdentifier {
- private Global(final @NonNull SchemaPath type) {
- super(type);
- }
-
- @Override
- public YangInstanceIdentifier getContextReference() {
- return YangInstanceIdentifier.empty();
- }
- }
-
- private static final class Local extends DOMRpcIdentifier {
- private final YangInstanceIdentifier contextReference;
-
- private Local(final @NonNull SchemaPath type, final @NonNull YangInstanceIdentifier contextReference) {
- super(type);
- this.contextReference = requireNonNull(contextReference);
- }
-
- @Override
- public YangInstanceIdentifier getContextReference() {
- return contextReference;
- }
- }
-
- private final SchemaPath type;
-
- private DOMRpcIdentifier(final SchemaPath type) {
- this.type = requireNonNull(type);
- }
-
- /**
- * Create a global RPC identifier.
- *
- * @param type RPC type, SchemaPath of its definition, may not be null
- * @return A global RPC identifier, guaranteed to be non-null.
- */
- public static @NonNull DOMRpcIdentifier create(final @NonNull SchemaPath type) {
- return new Global(type);
- }
-
- /**
- * Create an RPC identifier with a particular context reference.
- *
- * @param type RPC type, SchemaPath of its definition, may not be null
- * @param contextReference Context reference, null means a global RPC identifier.
- * @return A global RPC identifier, guaranteed to be non-null.
- */
- public static @NonNull DOMRpcIdentifier create(final @NonNull SchemaPath type,
- final @Nullable YangInstanceIdentifier contextReference) {
- if (contextReference == null || contextReference.isEmpty()) {
- return new Global(type);
- }
- 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.
- *
- * @return RPC type.
- */
- public final @NonNull SchemaPath getType() {
- return type;
- }
-
- /**
- * Return the RPC context reference. Null value indicates global context.
- *
- * @return RPC context reference.
- */
- public abstract @NonNull YangInstanceIdentifier getContextReference();
-
- @Override
- public final int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + type.hashCode();
- result = prime * result + getContextReference().hashCode();
- return result;
- }
-
- @Override
- public final boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (!(obj instanceof DOMRpcIdentifier)) {
- return false;
- }
- DOMRpcIdentifier other = (DOMRpcIdentifier) obj;
- if (!type.equals(other.type)) {
- return false;
- }
- return Objects.equals(getContextReference(), other.getContextReference());
- }
-
- @Override
- public final String toString() {
- return MoreObjects.toStringHelper(this).omitNullValues().add("type", type).add("contextReference",
- getContextReference()).toString();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.dom.api;
-
-import com.google.common.util.concurrent.CheckedFuture;
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-/**
- * Interface implemented by an individual RPC implementation. This API allows for dispatch
- * implementations, e.g. an individual object handling a multitude of RPCs.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMRpcImplementation} instead.
- */
-@Deprecated(forRemoval = true)
-public interface DOMRpcImplementation {
- /**
- * Initiate invocation of the RPC. Implementations of this method are
- * expected to not block on external resources.
- *
- * @param rpc RPC identifier which was invoked
- * @param input Input arguments, null if the RPC does not take any.
- * @return A {@link CheckedFuture} which will return either a result structure,
- * or report a subclass of {@link DOMRpcException} reporting a transport
- * error.
- */
- @NonNull CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(@NonNull DOMRpcIdentifier rpc,
- @Nullable NormalizedNode<?, ?> input);
-
- /**
- * Return the relative invocation cost of this implementation. Default implementation return 0.
- *
- * @return Non-negative cost of invoking this implementation.
- */
- default long invocationCost() {
- return 0;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.dom.api;
-
-import static java.util.Objects.requireNonNull;
-
-import org.eclipse.jdt.annotation.NonNull;
-
-/**
- * Exception indicating that no implementation of the requested RPC service is available.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException} instead.
- */
-@Deprecated(forRemoval = true)
-public class DOMRpcImplementationNotAvailableException extends DOMRpcException {
- private static final long serialVersionUID = 1L;
-
- public DOMRpcImplementationNotAvailableException(final @NonNull String format, final Object... args) {
- super(String.format(format, args));
- }
-
- public DOMRpcImplementationNotAvailableException(final @NonNull Throwable cause, final @NonNull String format,
- final Object... args) {
- super(String.format(format, args), requireNonNull(cause));
- }
-
- public DOMRpcImplementationNotAvailableException(final String message, final Throwable cause) {
- super(message, cause);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.dom.api;
-
-import org.opendaylight.yangtools.concepts.ObjectRegistration;
-
-/**
- * A registration of a {@link DOMRpcImplementation}. Used to track and revoke a registration
- * with a {@link DOMRpcProviderService}.
- *
- * @param <T> RPC implementation type
- * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMRpcImplementationRegistration} instead.
- */
-@Deprecated(forRemoval = true)
-public interface DOMRpcImplementationRegistration<T extends DOMRpcImplementation> extends ObjectRegistration<T> {
- @Override
- void close();
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.dom.api;
-
-import java.util.Set;
-import org.eclipse.jdt.annotation.NonNull;
-
-/**
- * A {@link DOMService} which allows registration of RPC implementations with a conceptual router. The client
- * counterpart of this service is {@link DOMRpcService}.
- *
- * <p>
- * This interface supports both RFC6020 RPCs and RFC7950 actions (formerly known as 'Routed RPCs'. Invocation for
- * RFC6020 RPCs is always based on an empty context reference. Invocation of actions requires a non-empty context
- * reference and is matched against registered implementations as follows:
- * <ul>
- * <li>First, attempt to look up the implementation based on exact match. If a match is found the invocation is
- * on that implementation, returning its result.</li>
- * <li>Second, attempt to look up the implementation which registered for empty context reference. If a such an
- * implementation exists, invoke that implementation, returning its result</li>
- * <li>Throw {@link DOMRpcImplementationNotAvailableException}
- * </ul>
- *
- * <p>
- * All implementations are required to perform these steps as specified above.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMRpcProviderService} instead
- */
-@Deprecated(forRemoval = true)
-public interface DOMRpcProviderService extends DOMService {
- /**
- * Register an {@link DOMRpcImplementation} object with this service.
- *
- * @param implementation RPC implementation, must not be null
- * @param rpcs Array of supported RPC identifiers. Must not be null, empty, or contain a null element.
- * Each identifier is added exactly once, no matter how many times it occurs.
- * @return A {@link DOMRpcImplementationRegistration} object, guaranteed to be non-null.
- * @throws NullPointerException if implementation or types is null
- * @throws IllegalArgumentException if types is empty or contains a null element.
- */
- @NonNull <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(
- @NonNull T implementation, @NonNull DOMRpcIdentifier... rpcs);
-
- /**
- * Register an {@link DOMRpcImplementation} object with this service.
- *
- * @param implementation RPC implementation, must not be null
- * @param rpcs Set of supported RPC identifiers. Must not be null, empty, or contain a null element.
- * @return A {@link DOMRpcImplementationRegistration} object, guaranteed to be non-null.
- * @throws NullPointerException if implementation or types is null
- * @throws IllegalArgumentException if types is empty or contains a null element.
- */
- @NonNull <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(
- @NonNull T implementation, @NonNull Set<DOMRpcIdentifier> rpcs);
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.dom.api;
-
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-
-/**
- * Interface defining a result of an RPC call.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMRpcResult} instead.
- */
-@Deprecated(forRemoval = true)
-@SuppressFBWarnings(value = "NM_SAME_SIMPLE_NAME_AS_INTERFACE", justification = "Migration")
-public interface DOMRpcResult extends org.opendaylight.mdsal.dom.api.DOMRpcResult {
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.dom.api;
-
-import com.google.common.util.concurrent.CheckedFuture;
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-
-/**
- * A {@link DOMService} which allows clients to invoke RPCs. The conceptual model of this
- * service is that of a dynamic router, where the set of available RPC services can change
- * dynamically. The service allows users to add a listener to track the process of
- * RPCs becoming available.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMRpcService} instead
- */
-@Deprecated(forRemoval = true)
-public interface DOMRpcService extends DOMService {
- /**
- * Initiate invocation of an RPC. This method is guaranteed to not block on any external
- * resources.
- *
- * @param type SchemaPath of the RPC to be invoked
- * @param input Input arguments, null if the RPC does not take any.
- * @return A {@link CheckedFuture} which will return either a result structure,
- * or report a subclass of {@link DOMRpcException} reporting a transport
- * error.
- */
- @NonNull CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(@NonNull SchemaPath type,
- @Nullable NormalizedNode<?, ?> input);
-
- /**
- * Register a {@link DOMRpcAvailabilityListener} with this service to receive notifications
- * about RPC implementations becoming (un)available. The listener will be invoked with the
- * current implementations reported and will be kept uptodate as implementations come and go.
- *
- * <p>
- * Users should note that using a listener does not necessarily mean that
- * {@link #invokeRpc(SchemaPath, NormalizedNode)} will not report a failure due to
- * {@link DOMRpcImplementationNotAvailableException} and need to be ready to handle it.
- *
- * <p>
- * Implementations of this interface are encouraged to take reasonable precautions to prevent this scenario from
- * occurring.
- *
- * @param listener {@link DOMRpcAvailabilityListener} instance to register
- * @return A {@link ListenerRegistration} representing this registration. Performing
- * a {@link ListenerRegistration#close()} will cancel it. Returned object
- * is guaranteed to be non-null.
- */
- @NonNull <T extends DOMRpcAvailabilityListener> ListenerRegistration<T> registerRpcListener(@NonNull T listener);
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.api;
-
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-
-/**
- * Marker interface for services which can be obtained from a {@link DOMMountPoint} instance. No further semantics are
- * implied.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMService} instead.
- */
-@Deprecated(forRemoval = true)
-@SuppressFBWarnings(value = "NM_SAME_SIMPLE_NAME_AS_INTERFACE", justification = "Migration")
-public interface DOMService extends org.opendaylight.mdsal.dom.api.DOMService {
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.dom.api;
-
-import com.google.common.annotations.Beta;
-
-/**
- * Marker interface for services which expose additional functionality on top of some base {@link DOMService}.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMServiceExtension} instead.
- */
-@Beta
-@Deprecated(forRemoval = true)
-public interface DOMServiceExtension<T extends DOMExtensibleService<T, E>, E extends DOMServiceExtension<T, E>> {
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.api;
-
-import org.opendaylight.controller.md.sal.common.api.data.TransactionChain;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-/**
- * A chain of DOM Data transactions.
- *
- * <p>
- * Transactions in a chain need to be committed in sequence and each
- * transaction should see the effects of previous transactions as if they happened. A chain
- * makes no guarantees of atomicity, in fact transactions are committed as soon as possible.
- *
- * <p>
- * This interface is type capture of {@link TransactionChain} for DOM Data Contracts.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMTransactionChain} instead.
- */
-@Deprecated(forRemoval = true)
-public interface DOMTransactionChain extends TransactionChain<YangInstanceIdentifier, NormalizedNode<?, ?>> {
-
- @Override
- DOMDataReadOnlyTransaction newReadOnlyTransaction();
-
- @Override
- DOMDataReadWriteTransaction newReadWriteTransaction();
-
- @Override
- DOMDataWriteTransaction newWriteOnlyTransaction();
-}
+++ /dev/null
-/*
- * Copyright (c) 2018 Inocybe Technologies 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.md.sal.dom.api;
-
-/**
- * Default implementation of DOMRpcException.
- *
- * @author Thomas Pantelis
- * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DefaultDOMRpcException} instead.
- */
-@Deprecated(forRemoval = true)
-public class DefaultDOMRpcException extends DOMRpcException {
- private static final long serialVersionUID = 1L;
-
- public DefaultDOMRpcException(String message, Throwable cause) {
- super(message, cause);
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-parent</artifactId>
- <version>1.12.0-SNAPSHOT</version>
- <relativePath>../parent</relativePath>
- </parent>
-
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-broker-impl</artifactId>
- <version>1.12.0-SNAPSHOT</version>
- <packaging>bundle</packaging>
-
- <dependencies>
- <dependency>
- <groupId>com.lmax</groupId>
- <artifactId>disruptor</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-eos-dom-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-dom-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-dom-broker</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-common-impl</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-common-util</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-core-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-core-spi</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-core-compat</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>util</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-data-impl</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>mockito-configuration</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-test-util</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-inmemory-datastore</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
- <Export-Package>
- <!-- Legacy code -->
- org.opendaylight.controller.sal.dom.broker,
- org.opendaylight.controller.sal.dom.broker.impl,
- org.opendaylight.controller.sal.dom.broker.util,
- org.opendaylight.controller.sal.dom.broker.spi,
- <!--sal.broker.impl is exported for sal-netconf-connector to use SchemaAwareRpcRegistry.-->
- <!-- TODO Remove sal.broker.impl from export when SchemaAwareRpcRegistry is not used in connector anymore -->
- org.opendaylight.controller.md.sal.dom.broker.impl,
- org.opendaylight.controller.md.sal.dom.broker.impl.*,
- org.opendaylight.controller.md.sal.dom.clustering.impl,
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <scm>
- <connection>scm:git:http://git.opendaylight.org/gerrit/controller.git</connection>
- <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
- <tag>HEAD</tag>
- <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
- </scm>
-
-</project>
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.broker.impl;
-
-import static com.google.common.base.Preconditions.checkState;
-
-import com.google.common.collect.ImmutableMap;
-import java.util.Collections;
-import java.util.EnumMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.concurrent.atomic.AtomicLong;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
-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.DOMDataTreeChangeListener;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeIdentifier;
-import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
-import org.opendaylight.controller.sal.core.spi.data.DOMStore;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTreeChangePublisher;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Deprecated(forRemoval = true)
-public abstract class AbstractDOMDataBroker extends AbstractDOMForwardedTransactionFactory<DOMStore>
- implements DOMDataBroker {
- private static final Logger LOG = LoggerFactory.getLogger(AbstractDOMDataBroker.class);
-
- private final AtomicLong txNum = new AtomicLong();
- private final AtomicLong chainNum = new AtomicLong();
- private final Map<Class<? extends DOMDataBrokerExtension>, DOMDataBrokerExtension> extensions;
- private volatile AutoCloseable closeable;
-
- protected AbstractDOMDataBroker(final Map<LogicalDatastoreType, DOMStore> datastores) {
- super(datastores);
-
- boolean treeChange = true;
- for (DOMStore ds : datastores.values()) {
- if (!(ds instanceof DOMStoreTreeChangePublisher)) {
- treeChange = false;
- break;
- }
- }
-
- if (treeChange) {
- extensions = ImmutableMap.<Class<? extends DOMDataBrokerExtension>, DOMDataBrokerExtension>of(
- DOMDataTreeChangeService.class, new DOMDataTreeChangeService() {
- @Override
- public <L extends DOMDataTreeChangeListener> ListenerRegistration<L>
- registerDataTreeChangeListener(final DOMDataTreeIdentifier treeId, final L listener) {
- DOMStore publisher = getTxFactories().get(treeId.getDatastoreType());
- checkState(publisher != null,
- "Requested logical data store is not available.");
-
- return ((DOMStoreTreeChangePublisher) publisher)
- .registerTreeChangeListener(treeId.getRootIdentifier(), listener);
- }
- });
- } else {
- extensions = Collections.emptyMap();
- }
- }
-
- public void setCloseable(final AutoCloseable closeable) {
- this.closeable = closeable;
- }
-
- @Override
- @SuppressWarnings("checkstyle:IllegalCatch")
- public void close() {
- super.close();
-
- if (closeable != null) {
- try {
- closeable.close();
- } catch (Exception e) {
- LOG.debug("Error closing instance", e);
- }
- }
- }
-
- @Override
- protected Object newTransactionIdentifier() {
- return "DOM-" + txNum.getAndIncrement();
- }
-
- @Override
- public Map<Class<? extends DOMDataBrokerExtension>, DOMDataBrokerExtension> getSupportedExtensions() {
- return extensions;
- }
-
- @Override
- public DOMTransactionChain createTransactionChain(final TransactionChainListener listener) {
- checkNotClosed();
-
- final Map<LogicalDatastoreType, DOMStoreTransactionChain> backingChains = new EnumMap<>(
- LogicalDatastoreType.class);
- for (Entry<LogicalDatastoreType, DOMStore> entry : getTxFactories().entrySet()) {
- backingChains.put(entry.getKey(), entry.getValue().createTransactionChain());
- }
-
- final long chainId = chainNum.getAndIncrement();
- LOG.debug("Transactoin chain {} created with listener {}, backing store chains {}", chainId, listener,
- backingChains);
- return new DOMDataBrokerTransactionChainImpl(chainId, backingChains, this, listener);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.broker.impl;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static java.util.Objects.requireNonNull;
-
-import java.util.Collection;
-import java.util.Map;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransaction;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-/**
- * Composite DOM Transaction backed by {@link DOMStoreTransaction}.
- *
- * <p>
- * Abstract base for composite transaction, which provides access only to common
- * functionality as retrieval of subtransaction, close method and retrieval of
- * identifier.
- *
- * @param <K>
- * Subtransaction distinguisher
- * @param <T>
- * Subtransaction type
- */
-@Deprecated(forRemoval = true)
-abstract class AbstractDOMForwardedCompositeTransaction<K, T extends DOMStoreTransaction> implements
- AsyncTransaction<YangInstanceIdentifier, NormalizedNode<?, ?>> {
-
- private final Map<K, T> backingTxs;
- private final Object identifier;
-
- /**
- * Creates new composite Transactions.
- *
- * @param identifier
- * Identifier of transaction.
- * @param backingTxs
- * Key,value map of backing transactions.
- */
- protected AbstractDOMForwardedCompositeTransaction(final Object identifier, final Map<K, T> backingTxs) {
- this.identifier = requireNonNull(identifier, "Identifier should not be null");
- this.backingTxs = requireNonNull(backingTxs, "Backing transactions should not be null");
- }
-
- /**
- * Returns subtransaction associated with supplied key.
- *
- * @param key key
- * @return subtransaction
- * @throws NullPointerException
- * if key is null
- * @throws IllegalArgumentException
- * if no subtransaction is associated with key.
- */
- protected final T getSubtransaction(final K key) {
- final T ret = backingTxs.get(requireNonNull(key, "key must not be null."));
- checkArgument(ret != null, "No subtransaction associated with %s", key);
- return ret;
- }
-
- /**
- * Returns immutable Iterable of all subtransactions.
- *
- */
- protected Collection<T> getSubtransactions() {
- return backingTxs.values();
- }
-
- @Override
- public Object getIdentifier() {
- return identifier;
- }
-
- @SuppressWarnings("checkstyle:IllegalCatch")
- protected void closeSubtransactions() {
- /*
- * We share one exception for all failures, which are added
- * as supressedExceptions to it.
- */
- IllegalStateException failure = null;
- for (T subtransaction : backingTxs.values()) {
- try {
- subtransaction.close();
- } catch (Exception e) {
- // If we did not allocated failure we allocate it
- if (failure == null) {
- failure = new IllegalStateException("Uncaught exception occured during closing transaction", e);
- } else {
- // We update it with additional exceptions, which occurred during error.
- failure.addSuppressed(e);
- }
- }
- }
- // If we have failure, we throw it at after all attempts to close.
- if (failure != null) {
- throw failure;
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.broker.impl;
-
-import com.google.common.base.Preconditions;
-import com.google.common.base.Supplier;
-import com.google.common.util.concurrent.ListenableFuture;
-import java.util.Collection;
-import java.util.EnumMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
-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.DOMDataReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionFactory;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
-import org.opendaylight.yangtools.concepts.Path;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-/**
- * Abstract composite transaction factory.
- *
- * <p>
- * Provides an convenience common implementation for composite DOM Transactions,
- * where subtransaction is identified by {@link LogicalDatastoreType} type and
- * implementation of subtransaction is provided by
- * {@link DOMStoreTransactionFactory}.
- *
- * <b>Note:</b>This class does not have thread-safe implementation of {@link #close()},
- * implementation may allow accessing and allocating new transactions during closing
- * this instance.
- *
- * @param <T>
- * Type of {@link DOMStoreTransactionFactory} factory.
- */
-@Deprecated(forRemoval = true)
-abstract class AbstractDOMForwardedTransactionFactory<T extends DOMStoreTransactionFactory> implements AutoCloseable {
- @SuppressWarnings("rawtypes")
- private static final AtomicIntegerFieldUpdater<AbstractDOMForwardedTransactionFactory> UPDATER =
- AtomicIntegerFieldUpdater.newUpdater(AbstractDOMForwardedTransactionFactory.class, "closed");
- private final Map<LogicalDatastoreType, T> storeTxFactories;
- private volatile int closed = 0;
-
- protected AbstractDOMForwardedTransactionFactory(final Map<LogicalDatastoreType, ? extends T> txFactories) {
- this.storeTxFactories = new EnumMap<>(txFactories);
- }
-
- /**
- * Implementations must return unique identifier for each and every call of
- * this method.
- *
- * @return new Unique transaction identifier.
- */
- protected abstract Object newTransactionIdentifier();
-
- /**
- * User-supplied implementation of {@link DOMDataWriteTransaction#commit()}
- * for transaction.
- *
- * <p>
- * Callback invoked when {@link DOMDataWriteTransaction#commit()} is invoked
- * on transaction created by this factory.
- *
- * @param transaction
- * Transaction on which {@link DOMDataWriteTransaction#commit()}
- * was invoked.
- * @param cohorts
- * Iteratable of cohorts for subtransactions associated with
- * the transaction being committed.
- * @return a ListenableFuture. if commit coordination on cohorts finished successfully,
- * a CommitInfo is returned from the Future, On failure,
- * the Future fails with a {@link TransactionCommitFailedException}.
- */
- protected abstract <T> ListenableFuture<T> commit(DOMDataWriteTransaction transaction,
- Collection<DOMStoreThreePhaseCommitCohort> cohorts, Supplier<T> futureValueSupplier);
-
- /**
- * Creates a new composite read-only transaction
- *
- * <p>
- * Creates a new composite read-only transaction backed by one transaction
- * per factory in {@link #getTxFactories()}.
- *
- * <p>
- * Subtransaction for reading is selected by supplied
- * {@link LogicalDatastoreType} as parameter for
- * {@link DOMDataReadOnlyTransaction#read(LogicalDatastoreType,
- * org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)}.
- *
- * <p>
- * Id of returned transaction is retrieved via
- * {@link #newTransactionIdentifier()}.
- *
- * @return New composite read-only transaction.
- */
- public final DOMDataReadOnlyTransaction newReadOnlyTransaction() {
- checkNotClosed();
-
- final Map<LogicalDatastoreType, DOMStoreReadTransaction> txns = new EnumMap<>(LogicalDatastoreType.class);
- for (Entry<LogicalDatastoreType, T> store : storeTxFactories.entrySet()) {
- txns.put(store.getKey(), store.getValue().newReadOnlyTransaction());
- }
- return new DOMForwardedReadOnlyTransaction(newTransactionIdentifier(), txns);
- }
-
- /**
- * Creates a new composite write-only transaction
- *
- * <p>
- * Creates a new composite write-only transaction backed by one write-only
- * transaction per factory in {@link #getTxFactories()}.
- *
- * <p>
- * Implementation of composite Write-only transaction is following:
- *
- * <p>
- * <ul><li>
- * {@link DOMDataWriteTransaction#put(LogicalDatastoreType, YangInstanceIdentifier, NormalizedNode)}
- * - backing subtransaction is selected by {@link LogicalDatastoreType},
- * {@link DOMStoreWriteTransaction#write(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier,
- * org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)}
- * is invoked on selected subtransaction.
- * </li><li>
- * {@link DOMDataWriteTransaction#merge(LogicalDatastoreType, YangInstanceIdentifier, NormalizedNode)}
- * - backing subtransaction is selected by {@link LogicalDatastoreType},
- * {@link DOMStoreWriteTransaction#merge(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier,
- * org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)}
- * is invoked on selected subtransaction.
- * </li><li>
- * {@link DOMDataWriteTransaction#delete(LogicalDatastoreType, Path)}
- * {@link DOMStoreWriteTransaction#delete(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)} is
- * invoked on
- * selected subtransaction.
- * </li><li> {@link DOMDataWriteTransaction#commit()} - results in invoking
- * {@link DOMStoreWriteTransaction#ready()}, gathering all resulting cohorts
- * and then invoking finalized implementation callback
- * {@link #commit} with transaction which was commited and gathered results.
- * </li>
- * </ul>
- *
- * <p>
- * Id of returned transaction is generated via
- * {@link #newTransactionIdentifier()}.
- *
- * @return New composite write-only transaction associated with this factory.
- */
- public final DOMDataWriteTransaction newWriteOnlyTransaction() {
- checkNotClosed();
-
- final Map<LogicalDatastoreType, DOMStoreWriteTransaction> txns = new EnumMap<>(LogicalDatastoreType.class);
- for (Entry<LogicalDatastoreType, T> store : storeTxFactories.entrySet()) {
- txns.put(store.getKey(), store.getValue().newWriteOnlyTransaction());
- }
- return new DOMForwardedWriteTransaction<>(newTransactionIdentifier(), txns, this);
- }
-
- /**
- * Creates a new composite write-only transaction
- *
- * <p>
- * Creates a new composite write-only transaction backed by one write-only transaction per factory in
- * {@link #getTxFactories()}.
- *
- * <p>
- * Implementation of composite Write-only transaction is following:
- *
- * <p>
- * <ul>
- * <li>
- * {@link org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction#read(LogicalDatastoreType,
- * YangInstanceIdentifier)}
- * - backing subtransaction is selected by {@link LogicalDatastoreType},
- * {@link DOMStoreReadTransaction#read(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)} is invoked
- * on selected subtransaction.
- * <li>
- * {@link DOMDataWriteTransaction#put(LogicalDatastoreType,
- * org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier,
- * org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)}
- * - backing subtransaction is selected by {@link LogicalDatastoreType},
- * {@link DOMStoreWriteTransaction#write(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier,
- * org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)}
- * is invoked on selected subtransaction.
- * <li>
- * {@link DOMDataWriteTransaction#merge(LogicalDatastoreType,
- * org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier,
- * org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)}
- * - backing subtransaction is selected by {@link LogicalDatastoreType},
- * {@link DOMStoreWriteTransaction#merge(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier,
- * org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)}
- * is invoked on selected subtransaction.
- * <li>
- * {@link DOMDataWriteTransaction#delete(LogicalDatastoreType,
- * org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)}
- * - backing subtransaction is selected by {@link LogicalDatastoreType},
- * {@link DOMStoreWriteTransaction#delete(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)} is
- * invoked on
- * selected subtransaction.
- * <li> {@link DOMDataWriteTransaction#commit()} - results in invoking
- * {@link DOMStoreWriteTransaction#ready()}, gathering all resulting cohorts
- * and then invoking finalized implementation callback
- * {@link #commit} with transaction which was committed and gathered results.
- * <li>
- * </ul>
- *
- * <p>
- * Id of returned transaction is generated via
- * {@link #newTransactionIdentifier()}.
- *
- * @return New composite read-write transaction associated with this factory.
- */
- public final DOMDataReadWriteTransaction newReadWriteTransaction() {
- checkNotClosed();
-
- final Map<LogicalDatastoreType, DOMStoreReadWriteTransaction> txns = new EnumMap<>(LogicalDatastoreType.class);
- for (Entry<LogicalDatastoreType, T> store : storeTxFactories.entrySet()) {
- txns.put(store.getKey(), store.getValue().newReadWriteTransaction());
- }
- return new DOMForwardedReadWriteTransaction(newTransactionIdentifier(), txns, this);
- }
-
- /**
- * Convenience accessor of backing factories intended to be used only by
- * finalization of this class.
- *
- * <b>Note:</b>
- * Finalization of this class may want to access other functionality of
- * supplied Transaction factories.
- *
- * @return Map of backing transaction factories.
- */
- protected final Map<LogicalDatastoreType, T> getTxFactories() {
- return storeTxFactories;
- }
-
- /**
- * Checks if instance is not closed.
- *
- * @throws IllegalStateException If instance of this class was closed.
- *
- */
- protected final void checkNotClosed() {
- Preconditions.checkState(closed == 0, "Transaction factory was closed. No further operations allowed.");
- }
-
- @Override
- public void close() {
- final boolean success = UPDATER.compareAndSet(this, 0, 1);
- Preconditions.checkState(success, "Transaction factory was already closed");
- }
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.dom.broker.impl;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableMap.Builder;
-import com.google.common.collect.Maps;
-import com.google.common.util.concurrent.CheckedFuture;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-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.DOMRpcImplementation;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-
-@Deprecated(forRemoval = true)
-abstract class AbstractDOMRpcRoutingTableEntry {
- private final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> implementations;
- private final SchemaPath schemaPath;
-
- AbstractDOMRpcRoutingTableEntry(final SchemaPath schemaPath,
- final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> implementations) {
- this.schemaPath = requireNonNull(schemaPath);
- this.implementations = requireNonNull(implementations);
- }
-
- final SchemaPath getSchemaPath() {
- return schemaPath;
- }
-
- final List<DOMRpcImplementation> getImplementations(final YangInstanceIdentifier context) {
- return implementations.get(context);
- }
-
- final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> getImplementations() {
- return implementations;
- }
-
- final boolean containsContext(final YangInstanceIdentifier contextReference) {
- return implementations.containsKey(contextReference);
- }
-
- final Set<YangInstanceIdentifier> registeredIdentifiers(final DOMRpcAvailabilityListener listener) {
- return Maps.filterValues(implementations, list -> list.stream().anyMatch(listener::acceptsImplementation))
- .keySet();
- }
-
- /**
- * Adds an entry to the DOM RPC routing table.
- *
- * @param implementation RPC implementation
- * @param newRpcs List of new RPCs, must be mutable
- */
- final AbstractDOMRpcRoutingTableEntry add(final DOMRpcImplementation implementation,
- final List<YangInstanceIdentifier> newRpcs) {
- final Builder<YangInstanceIdentifier, List<DOMRpcImplementation>> vb = ImmutableMap.builder();
- for (final Entry<YangInstanceIdentifier, List<DOMRpcImplementation>> ve : implementations.entrySet()) {
- if (newRpcs.remove(ve.getKey())) {
- final List<DOMRpcImplementation> i = new ArrayList<>(ve.getValue().size() + 1);
- i.addAll(ve.getValue());
- i.add(implementation);
-
- // New implementation is at the end, this will move it to be the last among implementations
- // with equal cost -- relying on sort() being stable.
- i.sort(Comparator.comparingLong(DOMRpcImplementation::invocationCost));
- vb.put(ve.getKey(), i);
- } else {
- vb.put(ve);
- }
- }
- for (final YangInstanceIdentifier ii : newRpcs) {
- final List<DOMRpcImplementation> impl = new ArrayList<>(1);
- impl.add(implementation);
- vb.put(ii, impl);
- }
-
- return newInstance(vb.build());
- }
-
- final AbstractDOMRpcRoutingTableEntry remove(final DOMRpcImplementation implementation,
- final List<YangInstanceIdentifier> removed) {
- final Builder<YangInstanceIdentifier, List<DOMRpcImplementation>> vb = ImmutableMap.builder();
- for (final Entry<YangInstanceIdentifier, List<DOMRpcImplementation>> ve : implementations.entrySet()) {
- if (removed.remove(ve.getKey())) {
- final List<DOMRpcImplementation> i = new ArrayList<>(ve.getValue());
- i.remove(implementation);
- // We could trimToSize(), but that may perform another copy just to get rid
- // of a single element. That is probably not worth the trouble.
- if (!i.isEmpty()) {
- vb.put(ve.getKey(), i);
- }
- } else {
- vb.put(ve);
- }
- }
-
- final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> v = vb.build();
- return v.isEmpty() ? null : newInstance(v);
- }
-
- protected abstract CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(NormalizedNode<?, ?> input);
-
- protected abstract AbstractDOMRpcRoutingTableEntry newInstance(
- Map<YangInstanceIdentifier, List<DOMRpcImplementation>> impls);
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.broker.impl;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.base.Supplier;
-import com.google.common.base.Throwables;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import java.util.Collection;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
-import org.opendaylight.yangtools.util.DurationStatisticsTracker;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Implementation of blocking three-phase commit-coordination tasks without
- * support of cancellation.
- */
-@Deprecated(forRemoval = true)
-final class CommitCoordinationTask<T> implements Callable<T> {
- private enum Phase {
- canCommit,
- preCommit,
- doCommit,
- }
-
- private static final Logger LOG = LoggerFactory.getLogger(CommitCoordinationTask.class);
- private final Collection<DOMStoreThreePhaseCommitCohort> cohorts;
- private final DurationStatisticsTracker commitStatTracker;
- private final DOMDataWriteTransaction tx;
- private final Supplier<T> futureValueSupplier;
-
- CommitCoordinationTask(final DOMDataWriteTransaction transaction,
- final Collection<DOMStoreThreePhaseCommitCohort> cohorts,
- final DurationStatisticsTracker commitStatTracker,
- final Supplier<T> futureValueSupplier) {
- this.tx = requireNonNull(transaction, "transaction must not be null");
- this.cohorts = requireNonNull(cohorts, "cohorts must not be null");
- this.commitStatTracker = commitStatTracker;
- this.futureValueSupplier = futureValueSupplier;
- }
-
- @Override
- public T call() throws TransactionCommitFailedException {
- final long startTime = commitStatTracker != null ? System.nanoTime() : 0;
-
- Phase phase = Phase.canCommit;
-
- try {
- LOG.debug("Transaction {}: canCommit Started", tx.getIdentifier());
- canCommitBlocking();
-
- phase = Phase.preCommit;
- LOG.debug("Transaction {}: preCommit Started", tx.getIdentifier());
- preCommitBlocking();
-
- phase = Phase.doCommit;
- LOG.debug("Transaction {}: doCommit Started", tx.getIdentifier());
- commitBlocking();
-
- LOG.debug("Transaction {}: doCommit completed", tx.getIdentifier());
- return futureValueSupplier.get();
- } catch (final TransactionCommitFailedException e) {
- LOG.warn("Tx: {} Error during phase {}, starting Abort", tx.getIdentifier(), phase, e);
- abortBlocking(e);
- throw e;
- } finally {
- if (commitStatTracker != null) {
- commitStatTracker.addDuration(System.nanoTime() - startTime);
- }
- }
- }
-
- /**
- * Invokes canCommit on underlying cohorts and blocks till
- * all results are returned.
- *
- * <p>
- * Valid state transition is from SUBMITTED to CAN_COMMIT,
- * if currentPhase is not SUBMITTED throws IllegalStateException.
- *
- * @throws TransactionCommitFailedException
- * If one of cohorts failed can Commit
- *
- */
- private void canCommitBlocking() throws TransactionCommitFailedException {
- for (final ListenableFuture<?> canCommit : canCommitAll()) {
- try {
- final Boolean result = (Boolean)canCommit.get();
- if (result == null || !result) {
- throw new TransactionCommitFailedException("Can Commit failed, no detailed cause available.");
- }
- } catch (InterruptedException | ExecutionException e) {
- throw TransactionCommitFailedExceptionMapper.CAN_COMMIT_ERROR_MAPPER.apply(e);
- }
- }
- }
-
- /**
- * Invokes canCommit on underlying cohorts and returns composite future
- * which will contains {@link Boolean#TRUE} only and only if
- * all cohorts returned true.
- *
- * <p>
- * Valid state transition is from SUBMITTED to CAN_COMMIT,
- * if currentPhase is not SUBMITTED throws IllegalStateException.
- *
- * @return List of all cohorts futures from can commit phase.
- *
- */
- private ListenableFuture<?>[] canCommitAll() {
- final ListenableFuture<?>[] ops = new ListenableFuture<?>[cohorts.size()];
- int index = 0;
- for (final DOMStoreThreePhaseCommitCohort cohort : cohorts) {
- ops[index++] = cohort.canCommit();
- }
- return ops;
- }
-
- /**
- * Invokes preCommit on underlying cohorts and blocks till
- * all results are returned.
- *
- * <p>
- * Valid state transition is from CAN_COMMIT to PRE_COMMIT, if current
- * state is not CAN_COMMIT
- * throws IllegalStateException.
- *
- * @throws TransactionCommitFailedException
- * If one of cohorts failed preCommit
- *
- */
- private void preCommitBlocking() throws TransactionCommitFailedException {
- final ListenableFuture<?>[] preCommitFutures = preCommitAll();
- try {
- for (final ListenableFuture<?> future : preCommitFutures) {
- future.get();
- }
- } catch (InterruptedException | ExecutionException e) {
- throw TransactionCommitFailedExceptionMapper.PRE_COMMIT_MAPPER.apply(e);
- }
- }
-
- /**
- * Invokes preCommit on underlying cohorts and returns future
- * which will complete once all preCommit on cohorts completed or
- * failed.
- *
- * <p>
- * Valid state transition is from CAN_COMMIT to PRE_COMMIT, if current
- * state is not CAN_COMMIT
- * throws IllegalStateException.
- *
- * @return List of all cohorts futures from can commit phase.
- *
- */
- private ListenableFuture<?>[] preCommitAll() {
- final ListenableFuture<?>[] ops = new ListenableFuture<?>[cohorts.size()];
- int index = 0;
- for (final DOMStoreThreePhaseCommitCohort cohort : cohorts) {
- ops[index++] = cohort.preCommit();
- }
- return ops;
- }
-
- /**
- * Invokes commit on underlying cohorts and blocks till
- * all results are returned.
- *
- * <p>
- * Valid state transition is from PRE_COMMIT to COMMIT, if not throws
- * IllegalStateException.
- *
- * @throws TransactionCommitFailedException
- * If one of cohorts failed preCommit
- *
- */
- private void commitBlocking() throws TransactionCommitFailedException {
- final ListenableFuture<?>[] commitFutures = commitAll();
- try {
- for (final ListenableFuture<?> future : commitFutures) {
- future.get();
- }
- } catch (InterruptedException | ExecutionException e) {
- throw TransactionCommitFailedExceptionMapper.COMMIT_ERROR_MAPPER.apply(e);
- }
- }
-
- /**
- * Invokes commit on underlying cohorts and returns future which
- * completes
- * once all commits on cohorts are completed.
- *
- * <p>
- * Valid state transition is from PRE_COMMIT to COMMIT, if not throws
- * IllegalStateException
- *
- * @return List of all cohorts futures from can commit phase.
- */
- private ListenableFuture<?>[] commitAll() {
- final ListenableFuture<?>[] ops = new ListenableFuture<?>[cohorts.size()];
- int index = 0;
- for (final DOMStoreThreePhaseCommitCohort cohort : cohorts) {
- ops[index++] = cohort.commit();
- }
- return ops;
- }
-
- /**
- * Aborts transaction.
- *
- * <p>
- * Invokes {@link DOMStoreThreePhaseCommitCohort#abort()} on all
- * cohorts, blocks
- * for all results. If any of the abort failed throws
- * IllegalStateException,
- * which will contains originalCause as suppressed Exception.
- *
- * <p>
- * If aborts we're successful throws supplied exception
- *
- * @param originalCause
- * Exception which should be used to fail transaction for
- * consumers of transaction
- * future and listeners of transaction failure.
- * @param phase phase in which the problem ensued
- * @throws TransactionCommitFailedException
- * on invocation of this method.
- * originalCa
- * @throws IllegalStateException
- * if abort failed.
- */
- private void abortBlocking(
- final TransactionCommitFailedException originalCause) throws TransactionCommitFailedException {
- Exception cause = originalCause;
- try {
- abortAsyncAll().get();
- } catch (InterruptedException | ExecutionException e) {
- LOG.error("Tx: {} Error during Abort.", tx.getIdentifier(), e);
- cause = new IllegalStateException("Abort failed.", e);
- cause.addSuppressed(e);
- }
- Throwables.propagateIfPossible(cause, TransactionCommitFailedException.class);
- }
-
- /**
- * Invokes abort on underlying cohorts and returns future which
- * completes once all abort on cohorts are completed.
- *
- * @return Future which will complete once all cohorts completed
- * abort.
- */
- @SuppressWarnings({"unchecked", "rawtypes"})
- private ListenableFuture<Void> abortAsyncAll() {
-
- final ListenableFuture<?>[] ops = new ListenableFuture<?>[cohorts.size()];
- int index = 0;
- for (final DOMStoreThreePhaseCommitCohort cohort : cohorts) {
- ops[index++] = cohort.abort();
- }
-
- /*
- * We are returning all futures as list, not only succeeded ones in
- * order to fail composite future if any of them failed.
- * See Futures.allAsList for this description.
- */
- return (ListenableFuture) Futures.allAsList(ops);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.broker.impl;
-
-import static com.google.common.base.Preconditions.checkState;
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.base.Supplier;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.MoreExecutors;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import java.util.Collection;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * NormalizedNode implementation of {@link org.opendaylight.controller.md.sal.common.api.data.TransactionChain} which
- * is backed
- * by several {@link DOMStoreTransactionChain} differentiated by provided
- * {@link org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType} type.
- */
-@Deprecated(forRemoval = true)
-final class DOMDataBrokerTransactionChainImpl extends
- AbstractDOMForwardedTransactionFactory<DOMStoreTransactionChain> implements DOMTransactionChain {
- private enum State {
- RUNNING, CLOSING, CLOSED, FAILED,
- }
-
- private static final AtomicIntegerFieldUpdater<DOMDataBrokerTransactionChainImpl> COUNTER_UPDATER
- = AtomicIntegerFieldUpdater.newUpdater(DOMDataBrokerTransactionChainImpl.class, "counter");
- private static final AtomicReferenceFieldUpdater<DOMDataBrokerTransactionChainImpl, State> STATE_UPDATER
- = AtomicReferenceFieldUpdater.newUpdater(DOMDataBrokerTransactionChainImpl.class, State.class, "state");
- private static final Logger LOG = LoggerFactory.getLogger(DOMDataBrokerTransactionChainImpl.class);
- private final AtomicLong txNum = new AtomicLong();
- private final AbstractDOMDataBroker broker;
- private final TransactionChainListener listener;
- private final long chainId;
-
- private volatile State state = State.RUNNING;
- private volatile int counter = 0;
-
- /**
- * DOMDataBrokerTransactionChainImpl constructor.
- *
- * @param chainId ID of transaction chain
- * @param chains Backing {@link DOMStoreTransactionChain}s.
- * @param broker Commit Coordinator which should be used to coordinate commits
- * of transaction
- * produced by this chain.
- * @param listener Listener, which listens on transaction chain events.
- * @throws NullPointerException If any of arguments is null.
- */
- DOMDataBrokerTransactionChainImpl(final long chainId,
- final Map<LogicalDatastoreType, DOMStoreTransactionChain> chains,
- final AbstractDOMDataBroker broker,
- final TransactionChainListener listener) {
- super(chains);
- this.chainId = chainId;
- this.broker = requireNonNull(broker);
- this.listener = requireNonNull(listener);
- }
-
- private void checkNotFailed() {
- checkState(state != State.FAILED, "Transaction chain has failed");
- }
-
- @Override
- protected Object newTransactionIdentifier() {
- return "DOM-CHAIN-" + chainId + "-" + txNum.getAndIncrement();
- }
-
- @Override
- public <T> ListenableFuture<T> commit(final DOMDataWriteTransaction transaction,
- final Collection<DOMStoreThreePhaseCommitCohort> cohorts, final Supplier<T> futureValueSupplier) {
- checkNotFailed();
- checkNotClosed();
-
- final ListenableFuture<T> ret = broker.commit(transaction, cohorts, futureValueSupplier);
-
- COUNTER_UPDATER.incrementAndGet(this);
- Futures.addCallback(ret, new FutureCallback<T>() {
- @Override
- public void onSuccess(final T result) {
- transactionCompleted();
- }
-
- @Override
- public void onFailure(final Throwable throwable) {
- transactionFailed(transaction, throwable);
- }
- }, MoreExecutors.directExecutor());
-
- return ret;
- }
-
- @Override
- public void close() {
- final boolean success = STATE_UPDATER.compareAndSet(this, State.RUNNING, State.CLOSING);
- if (!success) {
- LOG.debug("Chain {} is no longer running", this);
- return;
- }
-
- super.close();
- for (DOMStoreTransactionChain subChain : getTxFactories().values()) {
- subChain.close();
- }
-
- if (counter == 0) {
- finishClose();
- }
- }
-
- private void finishClose() {
- state = State.CLOSED;
- listener.onTransactionChainSuccessful(this);
- }
-
- @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
- justification = "https://github.com/spotbugs/spotbugs/issues/811")
- private void transactionCompleted() {
- if (COUNTER_UPDATER.decrementAndGet(this) == 0 && state == State.CLOSING) {
- finishClose();
- }
- }
-
- @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
- justification = "https://github.com/spotbugs/spotbugs/issues/811")
- private void transactionFailed(final DOMDataWriteTransaction tx, final Throwable cause) {
- state = State.FAILED;
- LOG.debug("Transaction chain {}Â failed.", this, cause);
- listener.onTransactionChainFailed(this, tx, cause);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.broker.impl;
-
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
-import java.util.Map;
-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.dom.api.DOMDataReadOnlyTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-/**
- * Read Only Transaction, which is composed of several
- * {@link DOMStoreReadTransaction} transactions. Subtransaction is selected by
- * {@link LogicalDatastoreType} type parameter in
- * {@link #read(LogicalDatastoreType, YangInstanceIdentifier)}.
- */
-@Deprecated(forRemoval = true)
-class DOMForwardedReadOnlyTransaction extends
- AbstractDOMForwardedCompositeTransaction<LogicalDatastoreType, DOMStoreReadTransaction> implements
- DOMDataReadOnlyTransaction {
-
- protected DOMForwardedReadOnlyTransaction(final Object identifier,
- final Map<LogicalDatastoreType, DOMStoreReadTransaction> backingTxs) {
- super(identifier, backingTxs);
- }
-
- @Override
- public CheckedFuture<Optional<NormalizedNode<?,?>>, ReadFailedException> read(
- final LogicalDatastoreType store, final YangInstanceIdentifier path) {
- return getSubtransaction(store).read(path);
- }
-
- @Override
- public CheckedFuture<Boolean, ReadFailedException> exists(
- final LogicalDatastoreType store,
- final YangInstanceIdentifier path) {
- return getSubtransaction(store).exists(path);
- }
-
- @Override
- public void close() {
- closeSubtransactions();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.broker.impl;
-
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
-import java.util.Map;
-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.dom.api.DOMDataReadWriteTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-/**
- * Read-Write Transaction, which is composed of several
- * {@link DOMStoreReadWriteTransaction} transactions. Subtransaction is selected by
- * {@link LogicalDatastoreType} type parameter in:
- *
- * <ul>
- * <li>{@link #read(LogicalDatastoreType, YangInstanceIdentifier)}
- * <li>{@link #put(LogicalDatastoreType, YangInstanceIdentifier, NormalizedNode)}
- * <li>{@link #delete(LogicalDatastoreType, YangInstanceIdentifier)}
- * <li>{@link #merge(LogicalDatastoreType, YangInstanceIdentifier, NormalizedNode)}
- * </ul>
- * {@link #commit()} will result in invocation of
- * {@link DOMDataCommitImplementation#submit(org.opendaylight.controller.md.sal.dom
- * .api.DOMDataWriteTransaction, Iterable)}
- * invocation with all {@link org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort}
- * for underlying transactions.
- *
- */
-@Deprecated(forRemoval = true)
-final class DOMForwardedReadWriteTransaction extends DOMForwardedWriteTransaction<DOMStoreReadWriteTransaction>
- implements DOMDataReadWriteTransaction {
- protected DOMForwardedReadWriteTransaction(final Object identifier,
- final Map<LogicalDatastoreType, DOMStoreReadWriteTransaction> backingTxs,
- final AbstractDOMForwardedTransactionFactory<?> commitImpl) {
- super(identifier, backingTxs, commitImpl);
- }
-
- @Override
- public CheckedFuture<Optional<NormalizedNode<?,?>>, ReadFailedException> read(
- final LogicalDatastoreType store, final YangInstanceIdentifier path) {
- return getSubtransaction(store).read(path);
- }
-
- @Override
- public CheckedFuture<Boolean, ReadFailedException> exists(
- final LogicalDatastoreType store,
- final YangInstanceIdentifier path) {
- return getSubtransaction(store).exists(path);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.broker.impl;
-
-import static com.google.common.base.Preconditions.checkState;
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.base.Supplier;
-import com.google.common.util.concurrent.FluentFuture;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Map;
-import java.util.concurrent.Future;
-import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
-import org.opendaylight.mdsal.common.api.CommitInfo;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Read-Write Transaction, which is composed of several
- * {@link DOMStoreWriteTransaction} transactions. A sub-transaction is selected by
- * {@link LogicalDatastoreType} type parameter in:
- *
- * <p>
- * <ul>
- * <li>{@link #put(LogicalDatastoreType, YangInstanceIdentifier, NormalizedNode)}
- * <li>{@link #delete(LogicalDatastoreType, YangInstanceIdentifier)}
- * <li>{@link #merge(LogicalDatastoreType, YangInstanceIdentifier, NormalizedNode)}
- * </ul>
- *
- * <p>
- * {@link #commit()} will result in invocation of
- * {@link DOMDataCommitImplementation#submit(org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction,
- * Iterable)} invocation with all {@link org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort}
- * for underlying transactions.
- *
- * @param <T> Subtype of {@link DOMStoreWriteTransaction} which is used as
- * subtransaction.
- */
-@Deprecated(forRemoval = true)
-class DOMForwardedWriteTransaction<T extends DOMStoreWriteTransaction> extends
- AbstractDOMForwardedCompositeTransaction<LogicalDatastoreType, T> implements DOMDataWriteTransaction {
- @SuppressWarnings("rawtypes")
- private static final AtomicReferenceFieldUpdater<DOMForwardedWriteTransaction,
- AbstractDOMForwardedTransactionFactory>
- IMPL_UPDATER = AtomicReferenceFieldUpdater
- .newUpdater(DOMForwardedWriteTransaction.class, AbstractDOMForwardedTransactionFactory.class, "commitImpl");
- @SuppressWarnings("rawtypes")
- private static final AtomicReferenceFieldUpdater<DOMForwardedWriteTransaction, Future> FUTURE_UPDATER
- = AtomicReferenceFieldUpdater.newUpdater(DOMForwardedWriteTransaction.class, Future.class, "commitFuture");
- private static final Logger LOG = LoggerFactory.getLogger(DOMForwardedWriteTransaction.class);
- private static final Future<?> CANCELLED_FUTURE = Futures.immediateCancelledFuture();
-
- /**
- * Implementation of real commit. It also acts as an indication that
- * the transaction is running -- which we flip atomically using
- * {@link #IMPL_UPDATER}.
- */
- private volatile AbstractDOMForwardedTransactionFactory<?> commitImpl;
-
- /**
- * Future task of transaction commit. It starts off as null, but is
- * set appropriately on {@link #commit()} and {@link #cancel()} via
- * {@link AtomicReferenceFieldUpdater#lazySet(Object, Object)}.
- *
- * <p>
- * Lazy set is safe for use because it is only referenced to in the
- * {@link #cancel()} slow path, where we will busy-wait for it. The
- * fast path gets the benefit of a store-store barrier instead of the
- * usual store-load barrier.
- */
- private volatile Future<?> commitFuture;
-
- protected DOMForwardedWriteTransaction(final Object identifier, final Map<LogicalDatastoreType, T> backingTxs,
- final AbstractDOMForwardedTransactionFactory<?> commitImpl) {
- super(identifier, backingTxs);
- this.commitImpl = requireNonNull(commitImpl, "commitImpl must not be null.");
- }
-
- @Override
- public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path,
- final NormalizedNode<?, ?> data) {
- checkRunning(commitImpl);
- getSubtransaction(store).write(path, data);
- }
-
- @Override
- public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
- checkRunning(commitImpl);
- getSubtransaction(store).delete(path);
- }
-
- @Override
- public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path,
- final NormalizedNode<?, ?> data) {
- checkRunning(commitImpl);
- getSubtransaction(store).merge(path, data);
- }
-
- @Override
- public boolean cancel() {
- final AbstractDOMForwardedTransactionFactory<?> impl = IMPL_UPDATER.getAndSet(this, null);
- if (impl != null) {
- LOG.trace("Transaction {} cancelled before submit", getIdentifier());
- FUTURE_UPDATER.lazySet(this, CANCELLED_FUTURE);
- closeSubtransactions();
- return true;
- }
-
- // The transaction is in process of being submitted or cancelled. Busy-wait
- // for the corresponding future.
- Future<?> future;
- do {
- future = commitFuture;
- } while (future == null);
-
- return future.cancel(false);
- }
-
- @Override
- public FluentFuture<? extends CommitInfo> commit() {
- return FluentFuture.from(doCommit(CommitInfo::empty));
- }
-
- @SuppressWarnings("checkstyle:IllegalCatch")
- private <V> ListenableFuture<V> doCommit(final Supplier<V> futureValueSupplier) {
- final AbstractDOMForwardedTransactionFactory<?> impl = IMPL_UPDATER.getAndSet(this, null);
- checkRunning(impl);
-
- final Collection<T> txns = getSubtransactions();
- final Collection<DOMStoreThreePhaseCommitCohort> cohorts = new ArrayList<>(txns.size());
-
- ListenableFuture<V> ret;
- try {
- for (DOMStoreWriteTransaction txn : txns) {
- cohorts.add(txn.ready());
- }
-
- ret = impl.commit(this, cohorts, futureValueSupplier);
- } catch (RuntimeException e) {
- ret = FluentFuture.from(Futures.immediateFailedFuture(
- TransactionCommitFailedExceptionMapper.COMMIT_ERROR_MAPPER.apply(e)));
- }
- FUTURE_UPDATER.lazySet(this, ret);
- return ret;
- }
-
- private void checkRunning(final AbstractDOMForwardedTransactionFactory<?> impl) {
- checkState(impl != null, "Transaction %s is no longer running", getIdentifier());
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.broker.impl;
-
-import com.google.common.util.concurrent.ListenableFuture;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import java.util.Collection;
-import java.util.concurrent.TimeUnit;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotificationPublishService;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService;
-import org.opendaylight.controller.md.sal.dom.spi.DOMNotificationSubscriptionListener;
-import org.opendaylight.controller.md.sal.dom.spi.DOMNotificationSubscriptionListenerRegistry;
-import org.opendaylight.controller.sal.core.compat.LegacyDOMNotificationServiceAdapter;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-
-/**
- * Joint implementation of {@link DOMNotificationPublishService} and {@link DOMNotificationService}. Provides
- * routing of notifications from publishers to subscribers.
- *
- * <p>
- * Internal implementation works by allocating a two-handler Disruptor. The first handler delivers notifications
- * to subscribed listeners and the second one notifies whoever may be listening on the returned future. Registration
- * state tracking is performed by a simple immutable multimap -- when a registration or unregistration occurs we
- * re-generate the entire map from scratch and set it atomically. While registrations/unregistrations synchronize
- * on this instance, notifications do not take any locks here.
- *
- * <p>
- * The fully-blocking {@link #offerNotification(DOMNotification)}
- * is realized using the Disruptor's native operations. The bounded-blocking
- * {@link #offerNotification(DOMNotification, long, TimeUnit)}
- * is realized by arming a background wakeup interrupt.
- */
-@Deprecated(forRemoval = true)
-@SuppressFBWarnings(value = "NP_NONNULL_PARAM_VIOLATION", justification = "Void is the only allowed value")
-public final class DOMNotificationRouter extends LegacyDOMNotificationServiceAdapter implements AutoCloseable,
- DOMNotificationPublishService, DOMNotificationSubscriptionListenerRegistry {
-
- private final org.opendaylight.mdsal.dom.api.DOMNotificationPublishService delegateNotificationPublishService;
- private final org.opendaylight.mdsal.dom.spi.DOMNotificationSubscriptionListenerRegistry delegateListenerRegistry;
-
- private DOMNotificationRouter(
- final org.opendaylight.mdsal.dom.api.DOMNotificationService delegateNotificationService,
- final org.opendaylight.mdsal.dom.api.DOMNotificationPublishService delegateNotificationPublishService,
- final org.opendaylight.mdsal.dom.spi.DOMNotificationSubscriptionListenerRegistry delegateListenerRegistry) {
- super(delegateNotificationService);
- this.delegateNotificationPublishService = delegateNotificationPublishService;
- this.delegateListenerRegistry = delegateListenerRegistry;
- }
-
- public static DOMNotificationRouter create(final int queueDepth) {
- final org.opendaylight.mdsal.dom.broker.DOMNotificationRouter delegate =
- org.opendaylight.mdsal.dom.broker.DOMNotificationRouter.create(queueDepth);
- return create(delegate, delegate, delegate);
- }
-
- public static DOMNotificationRouter create(final int queueDepth, final long spinTime, final long parkTime,
- final TimeUnit unit) {
- final org.opendaylight.mdsal.dom.broker.DOMNotificationRouter delegate =
- org.opendaylight.mdsal.dom.broker.DOMNotificationRouter.create(queueDepth, spinTime, parkTime, unit);
- return create(delegate, delegate, delegate);
- }
-
- public static DOMNotificationRouter create(
- final org.opendaylight.mdsal.dom.api.DOMNotificationService delegateNotificationService,
- final org.opendaylight.mdsal.dom.api.DOMNotificationPublishService delegateNotificationPublishService,
- final org.opendaylight.mdsal.dom.spi.DOMNotificationSubscriptionListenerRegistry delegateListenerRegistry) {
- return new DOMNotificationRouter(delegateNotificationService, delegateNotificationPublishService,
- delegateListenerRegistry);
- }
-
- @Override
- public synchronized <T extends DOMNotificationListener> ListenerRegistration<T> registerNotificationListener(
- final T listener, final Collection<SchemaPath> types) {
- return super.registerNotificationListener(listener, types);
- }
-
- @Override
- public <L extends DOMNotificationSubscriptionListener> ListenerRegistration<L> registerSubscriptionListener(
- final L listener) {
- return delegateListenerRegistry.registerSubscriptionListener(listener);
- }
-
- @Override
- public ListenableFuture<?> putNotification(final DOMNotification notification) throws InterruptedException {
- return delegateNotificationPublishService.putNotification(notification);
- }
-
- @Override
- public ListenableFuture<?> offerNotification(final DOMNotification notification) {
- return delegateNotificationPublishService.offerNotification(notification);
- }
-
- @Override
- public ListenableFuture<?> offerNotification(final DOMNotification notification, final long timeout,
- final TimeUnit unit) throws InterruptedException {
- return delegateNotificationPublishService.offerNotification(notification, timeout, unit);
- }
-
- @Override
- public void close() {
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.broker.impl;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.SettableFuture;
-import com.lmax.disruptor.EventFactory;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import java.util.Collection;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * A single notification event in the disruptor ringbuffer. These objects are reused,
- * so they do have mutable state.
- */
-@Deprecated(forRemoval = true)
-final class DOMNotificationRouterEvent {
- private static final Logger LOG = LoggerFactory.getLogger(DOMNotificationRouterEvent.class);
- public static final EventFactory<DOMNotificationRouterEvent> FACTORY = DOMNotificationRouterEvent::new;
-
- private Collection<ListenerRegistration<? extends DOMNotificationListener>> subscribers;
- private DOMNotification notification;
- private SettableFuture<Void> future;
-
- private DOMNotificationRouterEvent() {
- // Hidden on purpose, initialized in initialize()
- }
-
- @SuppressWarnings("checkstyle:hiddenField")
- ListenableFuture<Void> initialize(final DOMNotification notification,
- final Collection<ListenerRegistration<? extends DOMNotificationListener>>
- subscribers) {
- this.notification = requireNonNull(notification);
- this.subscribers = requireNonNull(subscribers);
- this.future = SettableFuture.create();
- return this.future;
- }
-
- void deliverNotification() {
- LOG.trace("Start delivery of notification {}", notification);
- for (ListenerRegistration<? extends DOMNotificationListener> r : subscribers) {
- final DOMNotificationListener listener = r.getInstance();
- LOG.trace("Notifying listener {}", listener);
- listener.onNotification(notification);
- LOG.trace("Listener notification completed");
- }
- LOG.trace("Delivery completed");
- }
-
- @SuppressFBWarnings(value = "NP_NONNULL_PARAM_VIOLATION", justification = "Void is the only allowed value")
- void setFuture() {
- future.set(null);
- notification = null;
- subscribers = null;
- future = null;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.dom.broker.impl;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.ListenableFuture;
-import java.util.Collections;
-import java.util.Map;
-import java.util.Set;
-import java.util.WeakHashMap;
-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;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationRegistration;
-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;
-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.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-
-@Deprecated(forRemoval = true)
-public final class DOMRpcRouter implements AutoCloseable, DOMRpcService, DOMRpcProviderService, SchemaContextListener {
- // This mapping is used to translate mdsal DOMRpcImplementations to their corresponding legacy
- // DOMRpcImplementations registered thru this interface when invoking a DOMRpcAvailabilityListener.
- private final Map<org.opendaylight.mdsal.dom.api.DOMRpcImplementation, DOMRpcImplementation> implMapping =
- Collections.synchronizedMap(new WeakHashMap<>());
-
- private final org.opendaylight.mdsal.dom.api.DOMRpcService delegateRpcService;
- private final org.opendaylight.mdsal.dom.api.DOMRpcProviderService delegateRpcProviderService;
-
- // Note - this is only used for backward compatibility for UTs that use the empty constructor which creates
- // a local mdsal DOMRpcRouter that needs to be updated with the SchemaContext. In production, the mdsal API
- // services are passed via the constructor and are set up externally with the SchemaContext.
- private final SchemaContextListener delegateSchemaContextListener;
-
- @VisibleForTesting
- public DOMRpcRouter() {
- org.opendaylight.mdsal.dom.broker.DOMRpcRouter delegate = new org.opendaylight.mdsal.dom.broker.DOMRpcRouter();
- this.delegateRpcService = delegate.getRpcService();
- this.delegateRpcProviderService = delegate.getRpcProviderService();
- this.delegateSchemaContextListener = delegate;
- }
-
- public DOMRpcRouter(final org.opendaylight.mdsal.dom.api.DOMRpcService delegateRpcService,
- final org.opendaylight.mdsal.dom.api.DOMRpcProviderService delegateRpcProviderService) {
- this.delegateRpcService = delegateRpcService;
- this.delegateRpcProviderService = delegateRpcProviderService;
- this.delegateSchemaContextListener = null;
- }
-
- @Override
- public <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(
- final T implementation, final DOMRpcIdentifier... rpcs) {
- return registerRpcImplementation(implementation, ImmutableSet.copyOf(rpcs));
- }
-
- @Override
- public synchronized <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(
- final T implementation, final Set<DOMRpcIdentifier> rpcs) {
- org.opendaylight.mdsal.dom.api.DOMRpcImplementation delegateImpl =
- new org.opendaylight.mdsal.dom.api.DOMRpcImplementation() {
- @Override
- public ListenableFuture<org.opendaylight.mdsal.dom.api.DOMRpcResult> invokeRpc(
- final org.opendaylight.mdsal.dom.api.DOMRpcIdentifier rpc, final NormalizedNode<?, ?> input) {
- return new MdsalDOMRpcResultFutureAdapter(implementation.invokeRpc(DOMRpcIdentifier.fromMdsal(rpc),
- input));
- }
-
-
- @Override
- public long invocationCost() {
- return implementation.invocationCost();
- }
- };
-
- implMapping.put(delegateImpl, implementation);
-
- final org.opendaylight.mdsal.dom.api.DOMRpcImplementationRegistration
- <org.opendaylight.mdsal.dom.api.DOMRpcImplementation> reg = delegateRpcProviderService
- .registerRpcImplementation(delegateImpl, DOMRpcServiceAdapter.convert(rpcs));
-
- return new AbstractDOMRpcImplementationRegistration<T>(implementation) {
- @Override
- protected void removeRegistration() {
- reg.close();
- implMapping.remove(delegateImpl);
- }
- };
- }
-
- @Override
- public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final SchemaPath type,
- final NormalizedNode<?, ?> input) {
- final ListenableFuture<org.opendaylight.mdsal.dom.api.DOMRpcResult> future =
- delegateRpcService.invokeRpc(type, input);
- return future instanceof MdsalDOMRpcResultFutureAdapter ? ((MdsalDOMRpcResultFutureAdapter)future).delegate()
- : new LegacyDOMRpcResultFutureAdapter(future);
- }
-
- @Override
- public synchronized <T extends DOMRpcAvailabilityListener> ListenerRegistration<T> registerRpcListener(
- final T listener) {
- final ListenerRegistration<org.opendaylight.mdsal.dom.api.DOMRpcAvailabilityListener> reg =
- delegateRpcService.registerRpcListener(new RpcAvailabilityListenerAdapter<T>(listener) {
- @Override
- public boolean acceptsImplementation(final org.opendaylight.mdsal.dom.api.DOMRpcImplementation impl) {
- // If the DOMRpcImplementation wasn't registered thru this interface then the mapping won't be
- // present - in this we can't call the listener so just assume acceptance which is the default
- // behavior. This should be fine since a legacy listener would not be aware of implementation types
- // registered via the new mdsal API.
- final DOMRpcImplementation legacyImpl = implMapping.get(impl);
- return legacyImpl != null ? delegate().acceptsImplementation(legacyImpl) : true;
- }
- });
-
- return new AbstractListenerRegistration<T>(listener) {
- @Override
- protected void removeRegistration() {
- reg.close();
- }
- };
- }
-
- @Override
- public void close() {
- }
-
- @Override
- @VisibleForTesting
- public void onGlobalContextUpdated(final SchemaContext context) {
- if (delegateSchemaContextListener != null) {
- delegateSchemaContextListener.onGlobalContextUpdated(context);
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.dom.broker.impl;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableMap.Builder;
-import com.google.common.collect.LinkedListMultimap;
-import com.google.common.collect.ListMultimap;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.Futures;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-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;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationNotAvailableException;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
-import org.opendaylight.controller.md.sal.dom.broker.spi.rpc.RpcRoutingStrategy;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-
-@Deprecated(forRemoval = true)
-final class DOMRpcRoutingTable {
-
- static final DOMRpcRoutingTable EMPTY = new DOMRpcRoutingTable(ImmutableMap.of(), null);
-
- private final Map<SchemaPath, AbstractDOMRpcRoutingTableEntry> rpcs;
- private final SchemaContext schemaContext;
-
- private DOMRpcRoutingTable(final Map<SchemaPath, AbstractDOMRpcRoutingTableEntry> rpcs,
- final SchemaContext schemaContext) {
- this.rpcs = requireNonNull(rpcs);
- this.schemaContext = schemaContext;
- }
-
- static ListMultimap<SchemaPath, YangInstanceIdentifier> decomposeIdentifiers(final Set<DOMRpcIdentifier> rpcs) {
- final ListMultimap<SchemaPath, YangInstanceIdentifier> ret = LinkedListMultimap.create();
- for (DOMRpcIdentifier i : rpcs) {
- ret.put(i.getType(), i.getContextReference());
- }
- return ret;
- }
-
- DOMRpcRoutingTable add(final DOMRpcImplementation implementation, final Set<DOMRpcIdentifier> rpcsToAdd) {
- if (rpcsToAdd.isEmpty()) {
- return this;
- }
-
- // First decompose the identifiers to a multimap
- final ListMultimap<SchemaPath, YangInstanceIdentifier> toAdd = decomposeIdentifiers(rpcsToAdd);
-
- // Now iterate over existing entries, modifying them as appropriate...
- final Builder<SchemaPath, AbstractDOMRpcRoutingTableEntry> mb = ImmutableMap.builder();
- for (Entry<SchemaPath, AbstractDOMRpcRoutingTableEntry> re : this.rpcs.entrySet()) {
- List<YangInstanceIdentifier> newRpcs = new ArrayList<>(toAdd.removeAll(re.getKey()));
- if (!newRpcs.isEmpty()) {
- final AbstractDOMRpcRoutingTableEntry ne = re.getValue().add(implementation, newRpcs);
- mb.put(re.getKey(), ne);
- } else {
- mb.put(re);
- }
- }
-
- // Finally add whatever is left in the decomposed multimap
- for (Entry<SchemaPath, Collection<YangInstanceIdentifier>> e : toAdd.asMap().entrySet()) {
- final Builder<YangInstanceIdentifier, List<DOMRpcImplementation>> vb = ImmutableMap.builder();
- final List<DOMRpcImplementation> v = Collections.singletonList(implementation);
- for (YangInstanceIdentifier i : e.getValue()) {
- vb.put(i, v);
- }
-
- mb.put(e.getKey(), createRpcEntry(schemaContext, e.getKey(), vb.build()));
- }
-
- return new DOMRpcRoutingTable(mb.build(), schemaContext);
- }
-
- DOMRpcRoutingTable remove(final DOMRpcImplementation implementation, final Set<DOMRpcIdentifier> rpcIds) {
- if (rpcIds.isEmpty()) {
- return this;
- }
-
- // First decompose the identifiers to a multimap
- final ListMultimap<SchemaPath, YangInstanceIdentifier> toRemove = decomposeIdentifiers(rpcIds);
-
- // Now iterate over existing entries, modifying them as appropriate...
- final Builder<SchemaPath, AbstractDOMRpcRoutingTableEntry> b = ImmutableMap.builder();
- for (Entry<SchemaPath, AbstractDOMRpcRoutingTableEntry> e : this.rpcs.entrySet()) {
- final List<YangInstanceIdentifier> removed = new ArrayList<>(toRemove.removeAll(e.getKey()));
- if (!removed.isEmpty()) {
- final AbstractDOMRpcRoutingTableEntry ne = e.getValue().remove(implementation, removed);
- if (ne != null) {
- b.put(e.getKey(), ne);
- }
- } else {
- b.put(e);
- }
- }
-
- // All done, whatever is in toRemove, was not there in the first place
- return new DOMRpcRoutingTable(b.build(), schemaContext);
- }
-
- boolean contains(final DOMRpcIdentifier input) {
- final AbstractDOMRpcRoutingTableEntry contexts = rpcs.get(input.getType());
- return contexts != null && contexts.containsContext(input.getContextReference());
- }
-
- Map<SchemaPath, Set<YangInstanceIdentifier>> getRpcs(final DOMRpcAvailabilityListener listener) {
- final Map<SchemaPath, Set<YangInstanceIdentifier>> ret = new HashMap<>(rpcs.size());
- for (Entry<SchemaPath, AbstractDOMRpcRoutingTableEntry> e : rpcs.entrySet()) {
- final Set<YangInstanceIdentifier> ids = e.getValue().registeredIdentifiers(listener);
- if (!ids.isEmpty()) {
- ret.put(e.getKey(), ids);
- }
- }
-
- return ret;
- }
-
- private static RpcDefinition findRpcDefinition(final SchemaContext context, final SchemaPath schemaPath) {
- if (context != null) {
- final QName qname = schemaPath.getPathFromRoot().iterator().next();
- final Module module = context.findModule(qname.getModule()).orElse(null);
- if (module != null && module.getRpcs() != null) {
- for (RpcDefinition rpc : module.getRpcs()) {
- if (qname.equals(rpc.getQName())) {
- return rpc;
- }
- }
- }
- }
-
- return null;
- }
-
- private static AbstractDOMRpcRoutingTableEntry createRpcEntry(final SchemaContext context, final SchemaPath key,
- final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> implementations) {
- final RpcDefinition rpcDef = findRpcDefinition(context, key);
- if (rpcDef == null) {
- return new UnknownDOMRpcRoutingTableEntry(key, implementations);
- }
-
- final RpcRoutingStrategy strategy = RpcRoutingStrategy.from(rpcDef);
- if (strategy.isContextBasedRouted()) {
- return new RoutedDOMRpcRoutingTableEntry(rpcDef, YangInstanceIdentifier.of(strategy.getLeaf()),
- implementations);
-
- }
-
- return new GlobalDOMRpcRoutingTableEntry(rpcDef, implementations);
- }
-
- CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final SchemaPath type, final NormalizedNode<?, ?> input) {
- final AbstractDOMRpcRoutingTableEntry entry = rpcs.get(type);
- if (entry == null) {
- return Futures.<DOMRpcResult, DOMRpcException>immediateFailedCheckedFuture(
- new DOMRpcImplementationNotAvailableException("No implementation of RPC %s available", type));
- }
-
- return entry.invokeRpc(input);
- }
-
- DOMRpcRoutingTable setSchemaContext(final SchemaContext context) {
- final Builder<SchemaPath, AbstractDOMRpcRoutingTableEntry> b = ImmutableMap.builder();
-
- for (Entry<SchemaPath, AbstractDOMRpcRoutingTableEntry> e : rpcs.entrySet()) {
- b.put(e.getKey(), createRpcEntry(context, e.getKey(), e.getValue().getImplementations()));
- }
-
- return new DOMRpcRoutingTable(b.build(), context);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.dom.broker.impl;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.util.concurrent.CheckedFuture;
-import java.util.List;
-import java.util.Map;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
-
-@Deprecated(forRemoval = true)
-final class GlobalDOMRpcRoutingTableEntry extends AbstractDOMRpcRoutingTableEntry {
- private final DOMRpcIdentifier rpcId;
-
- private GlobalDOMRpcRoutingTableEntry(final DOMRpcIdentifier rpcId,
- final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> impls) {
- super(rpcId.getType(), impls);
- this.rpcId = requireNonNull(rpcId);
- }
-
- // We do not need the RpcDefinition, but this makes sure we do not
- // forward something we don't know to be an RPC.
- GlobalDOMRpcRoutingTableEntry(final RpcDefinition def,
- final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> impls) {
- super(def.getPath(), impls);
- this.rpcId = DOMRpcIdentifier.create(def.getPath());
- }
-
- @Override
- protected CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final NormalizedNode<?, ?> input) {
- return getImplementations(YangInstanceIdentifier.empty()).get(0).invokeRpc(rpcId, input);
- }
-
- @Override
- protected GlobalDOMRpcRoutingTableEntry newInstance(
- final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> impls) {
- return new GlobalDOMRpcRoutingTableEntry(rpcId, impls);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.broker.impl;
-
-import static java.util.Objects.requireNonNull;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-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.controller.md.sal.dom.spi.ForwardingDOMDataBroker;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-
-/**
- * An implementation of a {@link DOMDataBroker}, which forwards most requests to a delegate.
- *
- * <p>
- * Its interpretation of the API contract is somewhat looser, specifically it does not
- * guarantee transaction ordering between transactions allocated directly from the broker
- * and its transaction chains.
- */
-@Deprecated(forRemoval = true)
-public final class PingPongDataBroker extends ForwardingDOMDataBroker implements AutoCloseable,
- DOMDataTreeChangeService {
- private final DOMDataBroker delegate;
-
- /**
- * Instantiate a new broker, backed by the the specified delegate
- * {@link DOMDataBroker}.
- *
- * @param delegate Backend broker, may not be null.
- */
- public PingPongDataBroker(final @NonNull DOMDataBroker delegate) {
- this.delegate = requireNonNull(delegate);
- }
-
- @Override
- protected DOMDataBroker delegate() {
- return delegate;
- }
-
- @Override
- public PingPongTransactionChain createTransactionChain(final TransactionChainListener listener) {
- return new PingPongTransactionChain(delegate, listener);
- }
-
- @Override
- public void close() {
- // intentionally NOOP
- }
-
- @Override
- public <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerDataTreeChangeListener(
- final DOMDataTreeIdentifier treeId, final L listener) {
- final DOMDataTreeChangeService treeService = (DOMDataTreeChangeService) delegate.getSupportedExtensions()
- .get(DOMDataTreeChangeService.class);
- if (treeService != null) {
- return treeService.registerDataTreeChangeListener(treeId, listener);
- }
-
- throw new UnsupportedOperationException("Delegate " + delegate + " does not support required functionality");
- }
-
- @Override
- public String toString() {
- return "PingPongDataBroker backed by " + delegate;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.broker.impl;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.MoreObjects.ToStringHelper;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.SettableFuture;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
-import org.opendaylight.mdsal.common.api.CommitInfo;
-
-/**
- * Transaction context. Tracks the relationship with the backend transaction.
- * We never leak this class to the user and have it implement the {@link FutureCallback}
- * interface so we have a simple way of propagating the result.
- */
-@Deprecated(forRemoval = true)
-final class PingPongTransaction implements FutureCallback<CommitInfo> {
- private final DOMDataReadWriteTransaction delegate;
- private final SettableFuture<CommitInfo> future;
- private DOMDataReadWriteTransaction frontendTransaction;
-
- PingPongTransaction(final DOMDataReadWriteTransaction delegate) {
- this.delegate = requireNonNull(delegate);
- future = SettableFuture.create();
- }
-
- DOMDataReadWriteTransaction getTransaction() {
- return delegate;
- }
-
- DOMDataReadWriteTransaction getFrontendTransaction() {
- return frontendTransaction;
- }
-
- ListenableFuture<CommitInfo> getCommitFuture() {
- return future;
- }
-
- @Override
- public void onSuccess(final CommitInfo result) {
- future.set(result);
- }
-
- @Override
- public void onFailure(final Throwable throwable) {
- future.setException(throwable);
- }
-
- void recordFrontendTransaction(final DOMDataReadWriteTransaction tx) {
- if (frontendTransaction != null) {
- frontendTransaction = tx;
- }
- }
-
- @Override
- public String toString() {
- return addToStringAttributes(MoreObjects.toStringHelper(this)).toString();
- }
-
- protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
- return toStringHelper.add("delegate", delegate);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.broker.impl;
-
-import static com.google.common.base.Preconditions.checkState;
-import static com.google.common.base.Verify.verify;
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.FluentFuture;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.MoreExecutors;
-import java.util.AbstractMap.SimpleImmutableEntry;
-import java.util.Map.Entry;
-import java.util.concurrent.CancellationException;
-import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
-import org.checkerframework.checker.lock.qual.GuardedBy;
-import org.checkerframework.checker.lock.qual.Holding;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
-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.TransactionChain;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-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.controller.md.sal.dom.spi.ForwardingDOMDataReadWriteTransaction;
-import org.opendaylight.mdsal.common.api.CommitInfo;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * An implementation of {@link DOMTransactionChain}, which has a very specific
- * behavior, which some users may find surprising. If keeps the general
- * intent of the contract, but it makes sure there are never more than two
- * transactions allocated at any given time: one of them is being committed,
- * and while that is happening, the other one acts as the scratch pad. Once
- * the committing transaction completes successfully, the scratch transaction
- * is enqueued as soon as it is ready.
- *
- * <p>
- * This mode of operation means that there is no inherent isolation between
- * the front-end transactions and transactions cannot be reasonably cancelled.
- *
- * <p>
- * It furthermore means that the transactions returned by {@link #newReadOnlyTransaction()}
- * counts as an outstanding transaction and the user may not allocate multiple
- * read-only transactions at the same time.
- */
-@Deprecated(forRemoval = true)
-public final class PingPongTransactionChain implements DOMTransactionChain {
- private static final Logger LOG = LoggerFactory.getLogger(PingPongTransactionChain.class);
- private final TransactionChainListener listener;
- private final DOMTransactionChain delegate;
-
- @GuardedBy("this")
- private boolean failed;
- @GuardedBy("this")
- private PingPongTransaction shutdownTx;
- @GuardedBy("this")
- private Entry<PingPongTransaction, Throwable> deadTx;
-
- /**
- * This updater is used to manipulate the "ready" transaction. We perform only atomic
- * get-and-set on it.
- */
- private static final AtomicReferenceFieldUpdater<PingPongTransactionChain, PingPongTransaction> READY_UPDATER
- = AtomicReferenceFieldUpdater
- .newUpdater(PingPongTransactionChain.class, PingPongTransaction.class, "readyTx");
- private volatile PingPongTransaction readyTx;
-
- /**
- * This updater is used to manipulate the "locked" transaction. A locked transaction
- * means we know that the user still holds a transaction and should at some point call
- * us. We perform on compare-and-swap to ensure we properly detect when a user is
- * attempting to allocated multiple transactions concurrently.
- */
- private static final AtomicReferenceFieldUpdater<PingPongTransactionChain, PingPongTransaction> LOCKED_UPDATER
- = AtomicReferenceFieldUpdater
- .newUpdater(PingPongTransactionChain.class, PingPongTransaction.class, "lockedTx");
- private volatile PingPongTransaction lockedTx;
-
- /**
- * This updater is used to manipulate the "inflight" transaction. There can be at most
- * one of these at any given time. We perform only compare-and-swap on these.
- */
- private static final AtomicReferenceFieldUpdater<PingPongTransactionChain, PingPongTransaction> INFLIGHT_UPDATER
- = AtomicReferenceFieldUpdater
- .newUpdater(PingPongTransactionChain.class, PingPongTransaction.class, "inflightTx");
- private volatile PingPongTransaction inflightTx;
-
- PingPongTransactionChain(final DOMDataBroker broker, final TransactionChainListener listener) {
- this.listener = requireNonNull(listener);
- this.delegate = broker.createTransactionChain(new TransactionChainListener() {
- @Override
- public void onTransactionChainFailed(final TransactionChain<?, ?> chain,
- final AsyncTransaction<?, ?> transaction, final Throwable cause) {
- LOG.debug("Transaction chain {} reported failure in {}", chain, transaction, cause);
- delegateFailed(chain, cause);
- }
-
- @Override
- public void onTransactionChainSuccessful(final TransactionChain<?, ?> chain) {
- delegateSuccessful(chain);
- }
- });
- }
-
- void delegateSuccessful(final TransactionChain<?, ?> chain) {
- final Entry<PingPongTransaction, Throwable> canceled;
- synchronized (this) {
- // This looks weird, but we need not hold the lock while invoking callbacks
- canceled = deadTx;
- }
-
- if (canceled == null) {
- listener.onTransactionChainSuccessful(this);
- return;
- }
-
- // Backend shutdown successful, but we have a batch of transactions we have to report as dead due to the
- // user calling cancel().
- final PingPongTransaction tx = canceled.getKey();
- final Throwable cause = canceled.getValue();
- LOG.debug("Transaction chain {} successful, failing cancelled transaction {}", chain, tx, cause);
-
- listener.onTransactionChainFailed(this, tx.getFrontendTransaction(), cause);
- tx.onFailure(cause);
- }
-
- void delegateFailed(final TransactionChain<?, ?> chain, final Throwable cause) {
-
- final DOMDataReadWriteTransaction frontend;
- final PingPongTransaction tx = inflightTx;
- if (tx == null) {
- LOG.warn("Transaction chain {} failed with no pending transactions", chain);
- frontend = null;
- } else {
- frontend = tx.getFrontendTransaction();
- }
-
- listener.onTransactionChainFailed(this, frontend, cause);
-
- synchronized (this) {
- failed = true;
-
- /*
- * If we do not have a locked transaction, we need to ensure that
- * the backend transaction is cancelled. Otherwise we can defer
- * until the user calls us.
- */
- if (lockedTx == null) {
- processIfReady();
- }
- }
- }
-
- private synchronized PingPongTransaction slowAllocateTransaction() {
- checkState(shutdownTx == null, "Transaction chain %s has been shut down", this);
-
- if (deadTx != null) {
- throw new IllegalStateException(
- String.format("Transaction chain %s has failed due to transaction %s being canceled", this,
- deadTx.getKey()), deadTx.getValue());
- }
-
- final DOMDataReadWriteTransaction delegateTx = delegate.newReadWriteTransaction();
- final PingPongTransaction newTx = new PingPongTransaction(delegateTx);
-
- if (!LOCKED_UPDATER.compareAndSet(this, null, newTx)) {
- delegateTx.cancel();
- throw new IllegalStateException(
- String.format("New transaction %s raced with transaction %s", newTx, lockedTx));
- }
-
- return newTx;
- }
-
- private PingPongTransaction allocateTransaction() {
- // Step 1: acquire current state
- final PingPongTransaction oldTx = READY_UPDATER.getAndSet(this, null);
-
- // Slow path: allocate a delegate transaction
- if (oldTx == null) {
- return slowAllocateTransaction();
- }
-
- // Fast path: reuse current transaction. We will check failures and similar on commit().
- if (!LOCKED_UPDATER.compareAndSet(this, null, oldTx)) {
- // Ouch. Delegate chain has not detected a duplicate transaction allocation. This is the best we can do.
- oldTx.getTransaction().cancel();
- throw new IllegalStateException(
- String.format("Reusable transaction %s raced with transaction %s", oldTx, lockedTx));
- }
-
- return oldTx;
- }
-
- /*
- * This forces allocateTransaction() on a slow path, which has to happen after
- * this method has completed executing. Also inflightTx may be updated outside
- * the lock, hence we need to re-check.
- */
- @Holding("this")
- private void processIfReady() {
- if (inflightTx == null) {
- final PingPongTransaction tx = READY_UPDATER.getAndSet(this, null);
- if (tx != null) {
- processTransaction(tx);
- }
- }
- }
-
- /**
- * Process a ready transaction. The caller needs to ensure that
- * each transaction is seen only once by this method.
- *
- * @param tx Transaction which needs processing.
- */
- @Holding("this")
- private void processTransaction(final @NonNull PingPongTransaction tx) {
- if (failed) {
- LOG.debug("Cancelling transaction {}", tx);
- tx.getTransaction().cancel();
- return;
- }
-
- LOG.debug("Submitting transaction {}", tx);
- if (!INFLIGHT_UPDATER.compareAndSet(this, null, tx)) {
- LOG.warn("Submitting transaction {} while {} is still running", tx, inflightTx);
- }
-
- tx.getTransaction().commit().addCallback(new FutureCallback<CommitInfo>() {
- @Override
- public void onSuccess(final CommitInfo result) {
- transactionSuccessful(tx, result);
- }
-
- @Override
- public void onFailure(final Throwable throwable) {
- transactionFailed(tx, throwable);
- }
- }, MoreExecutors.directExecutor());
- }
-
- /*
- * We got invoked from the data store thread. We need to do two things:
- * 1) release the in-flight transaction
- * 2) process the potential next transaction
- *
- * We have to perform 2) under lock. We could perform 1) without locking, but that means the CAS result may
- * not be accurate, as a user thread may submit the ready transaction before we acquire the lock -- and checking
- * for next transaction is not enough, as that may have also be allocated (as a result of a quick
- * submit/allocate/submit between 1) and 2)). Hence we'd end up doing the following:
- * 1) CAS of inflightTx
- * 2) take lock
- * 3) volatile read of inflightTx
- *
- * Rather than doing that, we keep this method synchronized, hence performing only:
- * 1) take lock
- * 2) CAS of inflightTx
- *
- * Since the user thread is barred from submitting the transaction (in processIfReady), we can then proceed with
- * the knowledge that inflightTx is null -- processTransaction() will still do a CAS, but that is only for
- * correctness.
- */
- private synchronized void processNextTransaction(final PingPongTransaction tx) {
- final boolean success = INFLIGHT_UPDATER.compareAndSet(this, tx, null);
- checkState(success, "Completed transaction %s while %s was submitted", tx, inflightTx);
-
- final PingPongTransaction nextTx = READY_UPDATER.getAndSet(this, null);
- if (nextTx != null) {
- processTransaction(nextTx);
- } else if (shutdownTx != null) {
- processTransaction(shutdownTx);
- delegate.close();
- shutdownTx = null;
- }
- }
-
- void transactionSuccessful(final PingPongTransaction tx, final CommitInfo result) {
- LOG.debug("Transaction {} completed successfully", tx);
-
- tx.onSuccess(result);
- processNextTransaction(tx);
- }
-
- void transactionFailed(final PingPongTransaction tx, final Throwable throwable) {
- LOG.debug("Transaction {} failed", tx, throwable);
-
- tx.onFailure(throwable);
- processNextTransaction(tx);
- }
-
- void readyTransaction(final @NonNull PingPongTransaction tx) {
- // First mark the transaction as not locked.
- final boolean lockedMatch = LOCKED_UPDATER.compareAndSet(this, tx, null);
- checkState(lockedMatch, "Attempted to submit transaction %s while we have %s", tx, lockedTx);
- LOG.debug("Transaction {} unlocked", tx);
-
- /*
- * The transaction is ready. It will then be picked up by either next allocation,
- * or a background transaction completion callback.
- */
- final boolean success = READY_UPDATER.compareAndSet(this, null, tx);
- checkState(success, "Transaction %s collided on ready state", tx, readyTx);
- LOG.debug("Transaction {} readied", tx);
-
- /*
- * We do not see a transaction being in-flight, so we need to take care of dispatching
- * the transaction to the backend. We are in the ready case, we cannot short-cut
- * the checking of readyTx, as an in-flight transaction may have completed between us
- * setting the field above and us checking.
- */
- if (inflightTx == null) {
- synchronized (this) {
- processIfReady();
- }
- }
- }
-
- /**
- * Transaction cancellation is a heavyweight operation. We only support cancelation of a locked transaction
- * and return false for everything else. Cancelling such a transaction will result in all transactions in the
- * batch to be cancelled.
- *
- * @param tx Backend shared transaction
- * @param frontendTx transaction
- * @param isOpen indicator whether the transaction was already closed
- */
- synchronized void cancelTransaction(final PingPongTransaction tx, final DOMDataReadWriteTransaction frontendTx) {
- // Attempt to unlock the operation.
- final boolean lockedMatch = LOCKED_UPDATER.compareAndSet(this, tx, null);
- verify(lockedMatch, "Cancelling transaction %s collided with locked transaction %s", tx, lockedTx);
-
- // Cancel the backend transaction, so we do not end up leaking it.
- final boolean backendCancelled = tx.getTransaction().cancel();
-
- if (failed) {
- // The transaction has failed, this is probably the user just clearing up the transaction they had. We have
- // already cancelled the transaction anyway,
- return;
- } else if (!backendCancelled) {
- LOG.warn("Backend transaction cannot be cancelled during cancellation of {}, attempting to continue", tx);
- }
-
- // We have dealt with canceling the backend transaction and have unlocked the transaction. Since we are still
- // inside the synchronized block, any allocations are blocking on the slow path. Now we have to decide the fate
- // of this transaction chain.
- //
- // If there are no other frontend transactions in this batch we are aligned with backend state and we can
- // continue processing.
- if (frontendTx.equals(tx.getFrontendTransaction())) {
- LOG.debug("Cancelled transaction {} was head of the batch, resuming processing", tx);
- return;
- }
-
- // There are multiple frontend transactions in this batch. We have to report them as failed, which dooms this
- // transaction chain, too. Since we just came off of a locked transaction, we do not have a ready transaction
- // at the moment, but there may be some transaction in-flight. So we proceed to shutdown the backend chain
- // and mark the fact that we should be turning its completion into a failure.
- deadTx = new SimpleImmutableEntry<>(tx, new CancellationException("Transaction " + frontendTx + " canceled")
- .fillInStackTrace());
- delegate.close();
- }
-
- @Override
- public synchronized void close() {
- final PingPongTransaction notLocked = lockedTx;
- checkState(notLocked == null, "Attempted to close chain with outstanding transaction %s", notLocked);
-
- // This is not reliable, but if we observe it to be null and the process has already completed,
- // the backend transaction chain will throw the appropriate error.
- checkState(shutdownTx == null, "Attempted to close an already-closed chain");
-
- // This may be a reaction to our failure callback, in that case the backend is already shutdown
- if (deadTx != null) {
- LOG.debug("Delegate {} is already closed due to failure {}", delegate, deadTx);
- return;
- }
-
- // Force allocations on slow path, picking up a potentially-outstanding transaction
- final PingPongTransaction tx = READY_UPDATER.getAndSet(this, null);
-
- if (tx != null) {
- // We have one more transaction, which needs to be processed somewhere. If we do not
- // a transaction in-flight, we need to push it down ourselves.
- // If there is an in-flight transaction we will schedule this last one into a dedicated
- // slot. Allocation slow path will check its presence and fail, the in-flight path will
- // pick it up, submit and immediately close the chain.
- if (inflightTx == null) {
- processTransaction(tx);
- delegate.close();
- } else {
- shutdownTx = tx;
- }
- } else {
- // Nothing outstanding, we can safely shutdown
- delegate.close();
- }
- }
-
- @Override
- public DOMDataReadOnlyTransaction newReadOnlyTransaction() {
- final PingPongTransaction tx = allocateTransaction();
-
- return new DOMDataReadOnlyTransaction() {
- @Override
- public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(
- final LogicalDatastoreType store, final YangInstanceIdentifier path) {
- return tx.getTransaction().read(store, path);
- }
-
- @Override
- public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store,
- final YangInstanceIdentifier path) {
- return tx.getTransaction().exists(store, path);
- }
-
- @Override
- public Object getIdentifier() {
- return tx.getTransaction().getIdentifier();
- }
-
- @Override
- public void close() {
- readyTransaction(tx);
- }
- };
- }
-
- @Override
- public DOMDataReadWriteTransaction newReadWriteTransaction() {
- final PingPongTransaction tx = allocateTransaction();
- final DOMDataReadWriteTransaction ret = new ForwardingDOMDataReadWriteTransaction() {
- private boolean isOpen = true;
-
- @Override
- protected DOMDataReadWriteTransaction delegate() {
- return tx.getTransaction();
- }
-
- @Override
- public FluentFuture<? extends CommitInfo> commit() {
- readyTransaction(tx);
- isOpen = false;
- return FluentFuture.from(tx.getCommitFuture()).transformAsync(
- ignored -> CommitInfo.emptyFluentFuture(), MoreExecutors.directExecutor());
- }
-
- @Override
- public boolean cancel() {
- if (isOpen) {
- cancelTransaction(tx, this);
- isOpen = false;
- return true;
- } else {
- return false;
- }
- }
- };
-
- tx.recordFrontendTransaction(ret);
- return ret;
- }
-
- @Override
- public DOMDataWriteTransaction newWriteOnlyTransaction() {
- return newReadWriteTransaction();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.dom.broker.impl;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.Futures;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationNotAvailableException;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
-import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Deprecated(forRemoval = true)
-final class RoutedDOMRpcRoutingTableEntry extends AbstractDOMRpcRoutingTableEntry {
- private static final Logger LOG = LoggerFactory.getLogger(RoutedDOMRpcRoutingTableEntry.class);
- private final DOMRpcIdentifier globalRpcId;
- private final YangInstanceIdentifier keyId;
-
- private RoutedDOMRpcRoutingTableEntry(final DOMRpcIdentifier globalRpcId, final YangInstanceIdentifier keyId,
- final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> impls) {
- super(globalRpcId.getType(), impls);
- this.keyId = requireNonNull(keyId);
- this.globalRpcId = requireNonNull(globalRpcId);
- }
-
- RoutedDOMRpcRoutingTableEntry(final RpcDefinition def, final YangInstanceIdentifier keyId,
- final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> impls) {
- super(def.getPath(), impls);
- this.keyId = requireNonNull(keyId);
- this.globalRpcId = DOMRpcIdentifier.create(def.getPath());
- }
-
- @Override
- protected CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final NormalizedNode<?, ?> input) {
- final Optional<NormalizedNode<?, ?>> maybeKey = NormalizedNodes.findNode(input, keyId);
-
- // Routing key is present, attempt to deliver as a routed RPC
- if (maybeKey.isPresent()) {
- final NormalizedNode<?, ?> key = maybeKey.get();
- final Object value = key.getValue();
- if (value instanceof YangInstanceIdentifier) {
- final YangInstanceIdentifier iid = (YangInstanceIdentifier) value;
-
- // Find a DOMRpcImplementation for a specific iid
- final List<DOMRpcImplementation> specificImpls = getImplementations(iid);
- if (specificImpls != null) {
- return specificImpls.get(0).invokeRpc(DOMRpcIdentifier.create(getSchemaPath(), iid), input);
- }
-
- LOG.debug("No implementation for context {} found will now look for wildcard id", iid);
-
- // Find a DOMRpcImplementation for a wild card. Usually remote-rpc-connector would register an
- // implementation this way
- final List<DOMRpcImplementation> mayBeRemoteImpls = getImplementations(YangInstanceIdentifier.empty());
-
- if (mayBeRemoteImpls != null) {
- return mayBeRemoteImpls.get(0).invokeRpc(DOMRpcIdentifier.create(getSchemaPath(), iid), input);
- }
-
- } else {
- LOG.warn("Ignoring wrong context value {}", value);
- }
- }
-
- final List<DOMRpcImplementation> impls = getImplementations(null);
- if (impls != null) {
- return impls.get(0).invokeRpc(globalRpcId, input);
- } else {
- return Futures.<DOMRpcResult, DOMRpcException>immediateFailedCheckedFuture(
- new DOMRpcImplementationNotAvailableException("No implementation of RPC %s available",
- getSchemaPath()));
- }
- }
-
- @Override
- protected RoutedDOMRpcRoutingTableEntry newInstance(
- final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> impls) {
- return new RoutedDOMRpcRoutingTableEntry(globalRpcId, keyId, impls);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.broker.impl;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.base.Supplier;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import java.util.Collection;
-import java.util.Map;
-import java.util.concurrent.RejectedExecutionException;
-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.DOMDataWriteTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStore;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
-import org.opendaylight.yangtools.util.DurationStatisticsTracker;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Implementation of blocking three phase commit coordinator, which which
- * supports coordination on multiple {@link DOMStoreThreePhaseCommitCohort}.
- *
- * <p>
- * This implementation does not support cancellation of commit,
- *
- * <p>
- * In order to advance to next phase of three phase commit all subtasks of
- * previous step must be finish.
- *
- * <p>
- * This executor does not have an upper bound on subtask timeout.
- */
-@Deprecated(forRemoval = true)
-public class SerializedDOMDataBroker extends AbstractDOMDataBroker {
- private static final Logger LOG = LoggerFactory.getLogger(SerializedDOMDataBroker.class);
- private final DurationStatisticsTracker commitStatsTracker = DurationStatisticsTracker.createConcurrent();
- private final ListeningExecutorService executor;
-
- /**
- * Construct DOMDataCommitCoordinator which uses supplied executor to
- * process commit coordinations.
- *
- * @param datastores data stores
- * @param executor executor service
- */
- public SerializedDOMDataBroker(final Map<LogicalDatastoreType, DOMStore> datastores,
- final ListeningExecutorService executor) {
- super(datastores);
- this.executor = requireNonNull(executor, "executor must not be null.");
- }
-
- public DurationStatisticsTracker getCommitStatsTracker() {
- return commitStatsTracker;
- }
-
- @Override
- protected <T> ListenableFuture<T> commit(final DOMDataWriteTransaction transaction,
- final Collection<DOMStoreThreePhaseCommitCohort> cohorts, final Supplier<T> futureValueSupplier) {
- checkArgument(transaction != null, "Transaction must not be null.");
- checkArgument(cohorts != null, "Cohorts must not be null.");
- LOG.debug("Tx: {} is submitted for execution.", transaction.getIdentifier());
-
- ListenableFuture<T> commitFuture;
- try {
- commitFuture = executor.submit(new CommitCoordinationTask<>(transaction, cohorts, commitStatsTracker,
- futureValueSupplier));
- } catch (RejectedExecutionException e) {
- LOG.error("The commit executor {} queue is full - submit task was rejected. \n", executor, e);
- commitFuture = Futures.immediateFailedFuture(new TransactionCommitFailedException(
- "Could not submit the commit task - the commit queue capacity has been exceeded.", e));
- }
-
- return commitFuture;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.broker.impl;
-
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.yangtools.util.concurrent.ExceptionMapper;
-
-/**
- * Utility exception mapper which translates Exception to {@link TransactionCommitFailedException}.
- *
- * @see ExceptionMapper
- */
-@Deprecated(forRemoval = true)
-public final class TransactionCommitFailedExceptionMapper extends ExceptionMapper<TransactionCommitFailedException> {
-
- public static final TransactionCommitFailedExceptionMapper PRE_COMMIT_MAPPER = create("preCommit");
-
- public static final TransactionCommitFailedExceptionMapper CAN_COMMIT_ERROR_MAPPER = create("canCommit");
-
- public static final TransactionCommitFailedExceptionMapper COMMIT_ERROR_MAPPER = create("commit");
-
- private TransactionCommitFailedExceptionMapper(final String opName) {
- super(opName, TransactionCommitFailedException.class);
- }
-
- public static TransactionCommitFailedExceptionMapper create(final String opName) {
- return new TransactionCommitFailedExceptionMapper(opName);
- }
-
- @Override
- protected TransactionCommitFailedException newWithCause(final String message, final Throwable cause) {
- return new TransactionCommitFailedException(message, cause);
- }
-
- @Override
- @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
- public TransactionCommitFailedException apply(Exception input) {
- return super.apply(input);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.dom.broker.impl;
-
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.Futures;
-import java.util.List;
-import java.util.Map;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationNotAvailableException;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-
-@Deprecated(forRemoval = true)
-final class UnknownDOMRpcRoutingTableEntry extends AbstractDOMRpcRoutingTableEntry {
- private final CheckedFuture<DOMRpcResult, DOMRpcException> unknownRpc;
-
- UnknownDOMRpcRoutingTableEntry(final SchemaPath schemaPath,
- final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> impls) {
- super(schemaPath, impls);
- unknownRpc = Futures.<DOMRpcResult, DOMRpcException>immediateFailedCheckedFuture(
- new DOMRpcImplementationNotAvailableException("SchemaPath %s is not resolved to an RPC", schemaPath));
- }
-
- @Override
- protected CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final NormalizedNode<?, ?> input) {
- return unknownRpc;
- }
-
- @Override
- protected UnknownDOMRpcRoutingTableEntry newInstance(
- final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> impls) {
- return new UnknownDOMRpcRoutingTableEntry(getSchemaPath(), impls);
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. 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.md.sal.dom.broker.impl.legacy.sharded.adapter;
-
-import static java.util.Objects.requireNonNull;
-
-import java.util.Collections;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicLong;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
-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.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.DOMSchemaService;
-import org.opendaylight.mdsal.dom.broker.ShardedDOMDataBrokerAdapter;
-
-/**
- * DOMDataBroker implementation that forwards calls to
- * {@link org.opendaylight.mdsal.dom.broker.ShardedDOMDataBrokerAdapter},
- * which in turn translates calls to shard aware implementation of
- * {@link org.opendaylight.mdsal.dom.api.DOMDataTreeService}
- *
- * <p>
- * The incompatibility between first and latter APIs, puts restriction on {@link DOMDataReadWriteTransaction}
- * and {@link DOMDataReadOnlyTransaction} provided by this data broker. See
- * {@link ShardedDOMDataBrokerDelegatingReadWriteTransaction}
- * and {@link ShardedDOMDataBrokerDelegatingReadTransaction} respectively.
- */
-// FIXME try to refactor some of the implementation to abstract class for better reusability
-@Deprecated(forRemoval = true)
-public class LegacyShardedDOMDataBrokerAdapter implements DOMDataBroker {
-
- private final org.opendaylight.mdsal.dom.api.DOMDataBroker delegateDataBroker;
- private final DOMSchemaService schemaService;
- private final AtomicLong txNum = new AtomicLong();
- private final AtomicLong chainNum = new AtomicLong();
-
- public LegacyShardedDOMDataBrokerAdapter(final ShardedDOMDataBrokerAdapter delegateDataBroker,
- final DOMSchemaService schemaService) {
- this.delegateDataBroker = requireNonNull(delegateDataBroker);
- this.schemaService = requireNonNull(schemaService);
- }
-
- @Override
- public DOMDataReadOnlyTransaction newReadOnlyTransaction() {
- return new ShardedDOMDataBrokerDelegatingReadTransaction(newTransactionIdentifier(),
- delegateDataBroker.newReadOnlyTransaction());
- }
-
- @Override
- public DOMDataReadWriteTransaction newReadWriteTransaction() {
- return new ShardedDOMDataBrokerDelegatingReadWriteTransaction(newTransactionIdentifier(),
- schemaService.getGlobalContext(),
- newReadOnlyTransaction(),
- newWriteOnlyTransaction());
- }
-
- @Override
- public DOMDataWriteTransaction newWriteOnlyTransaction() {
- return new ShardedDOMDataBrokerDelegatingWriteTransaction(newTransactionIdentifier(),
- delegateDataBroker.newWriteOnlyTransaction());
- }
-
- @Override
- public DOMTransactionChain createTransactionChain(final TransactionChainListener listener) {
- return new ShardedDOMDataBrokerDelegatingTransactionChain(chainNum.getAndIncrement(),
- schemaService.getGlobalContext(), delegateDataBroker,
- listener);
- }
-
- @Override
- public Map<Class<? extends DOMDataBrokerExtension>, DOMDataBrokerExtension> getSupportedExtensions() {
- return Collections.emptyMap();
- }
-
- private Object newTransactionIdentifier() {
- return "DOM-" + txNum.getAndIncrement();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. 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.md.sal.dom.broker.impl.legacy.sharded.adapter;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.MoreExecutors;
-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.dom.api.DOMDataReadOnlyTransaction;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-/**
- * Read transaction that delegates calls to {@link org.opendaylight.mdsal.dom.broker.ShardedDOMReadTransactionAdapter},
- * which in turn translates calls to shard aware implementation of
- * {@link org.opendaylight.mdsal.dom.api.DOMDataTreeService}.
- *
- * <p>
- * Since reading data distributed on different subshards is not guaranteed to
- * return all relevant data, we cannot guarantee it neither. Best effort is to
- * return all data we get from first initial data change event received.
- */
-@Deprecated(forRemoval = true)
-class ShardedDOMDataBrokerDelegatingReadTransaction implements DOMDataReadOnlyTransaction {
- private final DOMDataTreeReadTransaction delegateTx;
- private final Object txIdentifier;
-
- ShardedDOMDataBrokerDelegatingReadTransaction(final Object txIdentifier,
- final DOMDataTreeReadTransaction delegateTx) {
- this.delegateTx = requireNonNull(delegateTx);
- this.txIdentifier = requireNonNull(txIdentifier);
- }
-
- @Override
- public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final LogicalDatastoreType store,
- final YangInstanceIdentifier path) {
- return Futures.makeChecked(delegateTx.read(store.toMdsal(), path).transform(
- Optional::fromJavaUtil, MoreExecutors.directExecutor()), ReadFailedException.MAPPER);
- }
-
- @Override
- public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store,
- final YangInstanceIdentifier path) {
- return Futures.makeChecked(delegateTx.exists(store.toMdsal(), path), ReadFailedException.MAPPER);
- }
-
- @Override
- public Object getIdentifier() {
- return txIdentifier;
- }
-
- @Override
- public void close() {
- delegateTx.close();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. 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.md.sal.dom.broker.impl.legacy.sharded.adapter;
-
-import static com.google.common.base.Preconditions.checkState;
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.FluentFuture;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.MoreExecutors;
-import com.google.common.util.concurrent.SettableFuture;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import java.util.EnumMap;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.Queue;
-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.dom.api.DOMDataReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
-import org.opendaylight.mdsal.common.api.CommitInfo;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
-import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
-/**
- * Read/write transaction that delegates write and initial read to
- * {@link org.opendaylight.mdsal.dom.broker.ShardedDOMWriteTransactionAdapter}
- * and {@link org.opendaylight.mdsal.dom.broker.ShardedDOMReadTransactionAdapter}
- * respectively. These two in turn rely on shard aware implementation of
- * {@link org.opendaylight.mdsal.dom.api.DOMDataTreeService}.
- *
- * <p>
- * Since reading data distributed on different subshards is not guaranteed to
- * return all relevant data, best effort is to try to operate only on single
- * subtree in conceptual data tree. We define this subtree by first write
- * operation performed on transaction. All next read and write operations
- * should be performed just in this initial subtree.
- *
- */
-// FIXME explicitly enforce just one subtree requirement
-@Deprecated(forRemoval = true)
-class ShardedDOMDataBrokerDelegatingReadWriteTransaction implements DOMDataReadWriteTransaction {
- private final DOMDataReadOnlyTransaction readTxDelegate;
- private final DOMDataWriteTransaction writeTxDelegate;
- private final Object txIdentifier;
- private final ImmutableMap<LogicalDatastoreType, Queue<Modification>> modificationHistoryMap;
- private final ImmutableMap<LogicalDatastoreType, DataTreeSnapshot> snapshotMap;
- private final Map<LogicalDatastoreType, ListenableFuture<Optional<NormalizedNode<?, ?>>>> initialReadMap;
- private YangInstanceIdentifier root = null;
-
- ShardedDOMDataBrokerDelegatingReadWriteTransaction(final Object readWriteTxId, final SchemaContext ctx,
- final DOMDataReadOnlyTransaction readTxDelegate,
- final DOMDataWriteTransaction writeTxDelegate) {
- this.readTxDelegate = requireNonNull(readTxDelegate);
- this.writeTxDelegate = requireNonNull(writeTxDelegate);
- this.txIdentifier = requireNonNull(readWriteTxId);
- this.initialReadMap = new EnumMap<>(LogicalDatastoreType.class);
-
- final InMemoryDataTreeFactory treeFactory = new InMemoryDataTreeFactory();
- final ImmutableMap.Builder<LogicalDatastoreType, DataTreeSnapshot> snapshotMapBuilder = ImmutableMap.builder();
- final ImmutableMap.Builder<LogicalDatastoreType, Queue<Modification>> modificationHistoryMapBuilder
- = ImmutableMap.builder();
- for (final LogicalDatastoreType store : LogicalDatastoreType.values()) {
- final DataTree tree = treeFactory.create(treeConfigForStore(store));
- tree.setSchemaContext(ctx);
- snapshotMapBuilder.put(store, tree.takeSnapshot());
-
- modificationHistoryMapBuilder.put(store, new LinkedList<>());
- }
-
- modificationHistoryMap = modificationHistoryMapBuilder.build();
- snapshotMap = snapshotMapBuilder.build();
- }
-
- @Override
- public boolean cancel() {
- readTxDelegate.close();
- return writeTxDelegate.cancel();
- }
-
- @Override
- public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
- if (root == null) {
- initialRead(path);
- }
-
- modificationHistoryMap.get(store).add(new Modification(Modification.Operation.DELETE, path, null));
- writeTxDelegate.delete(store, path);
- }
-
- @Override
- public FluentFuture<? extends CommitInfo> commit() {
- return writeTxDelegate.commit();
- }
-
- @Override
- public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final LogicalDatastoreType store,
- final YangInstanceIdentifier path) {
- checkState(root != null,
- "A modify operation (put, merge or delete) must be performed prior to a read operation");
- final SettableFuture<Optional<NormalizedNode<?, ?>>> readResult = SettableFuture.create();
- final Queue<Modification> currentHistory = Lists.newLinkedList(modificationHistoryMap.get(store));
- Futures.addCallback(initialReadMap.get(store), new FutureCallback<Optional<NormalizedNode<?, ?>>>() {
- @Override
- public void onSuccess(final Optional<NormalizedNode<?, ?>> result) {
- final DataTreeModification mod = snapshotMap.get(store).newModification();
- if (result.isPresent()) {
- mod.write(path, result.get());
- }
- applyModificationHistoryToSnapshot(mod, currentHistory);
- readResult.set(Optional.fromJavaUtil(mod.readNode(path)));
- }
-
- @Override
- public void onFailure(final Throwable throwable) {
- readResult.setException(throwable);
- }
- }, MoreExecutors.directExecutor());
-
- return Futures.makeChecked(readResult, ReadFailedException.MAPPER);
- }
-
- @Override
- public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store,
- final YangInstanceIdentifier path) {
- checkState(root != null,
- "A modify operation (put, merge or delete) must be performed prior to an exists operation");
- return Futures.makeChecked(Futures.transform(read(store, path), Optional::isPresent,
- MoreExecutors.directExecutor()), ReadFailedException.MAPPER);
- }
-
- @Override
- public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path,
- final NormalizedNode<?, ?> data) {
- if (root == null) {
- initialRead(path);
- }
-
- modificationHistoryMap.get(store).add(new Modification(Modification.Operation.WRITE, path, data));
- writeTxDelegate.put(store, path, data);
- }
-
- @Override
- public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path,
- final NormalizedNode<?, ?> data) {
- if (root == null) {
- initialRead(path);
- }
-
- modificationHistoryMap.get(store).add(new Modification(Modification.Operation.MERGE, path, data));
- writeTxDelegate.merge(store, path, data);
- }
-
- @Override
- public Object getIdentifier() {
- return txIdentifier;
- }
-
- private void initialRead(final YangInstanceIdentifier path) {
- root = path;
-
- for (final LogicalDatastoreType store : LogicalDatastoreType.values()) {
- initialReadMap.put(store, readTxDelegate.read(store, path));
- }
- }
-
- private static DataTreeConfiguration treeConfigForStore(final LogicalDatastoreType store) {
- return store == LogicalDatastoreType.CONFIGURATION ? DataTreeConfiguration.DEFAULT_CONFIGURATION
- : DataTreeConfiguration.DEFAULT_OPERATIONAL;
- }
-
- @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
- justification = "https://github.com/spotbugs/spotbugs/issues/811")
- private static void applyModificationHistoryToSnapshot(final DataTreeModification dataTreeModification,
- final Queue<Modification> modificationHistory) {
- while (!modificationHistory.isEmpty()) {
- final Modification modification = modificationHistory.poll();
- switch (modification.getOperation()) {
- case WRITE:
- dataTreeModification.write(modification.getPath(), modification.getData());
- break;
- case MERGE:
- dataTreeModification.merge(modification.getPath(), modification.getData());
- break;
- case DELETE:
- dataTreeModification.delete(modification.getPath());
- break;
- default:
- // NOOP
- }
- }
- }
-
- static class Modification {
-
- enum Operation {
- WRITE, MERGE, DELETE
- }
-
- private final NormalizedNode<?, ?> data;
- private final YangInstanceIdentifier path;
- private final Operation operation;
-
- Modification(final Operation operation, final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
- this.data = data;
- this.path = requireNonNull(path);
- this.operation = requireNonNull(operation);
- }
-
- Operation getOperation() {
- return operation;
- }
-
- YangInstanceIdentifier getPath() {
- return path;
- }
-
- NormalizedNode<?, ?> getData() {
- return data;
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. 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.md.sal.dom.broker.impl.legacy.sharded.adapter;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.base.Preconditions;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicLong;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
-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.DOMDataTreeTransaction;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
-import org.opendaylight.mdsal.dom.api.DOMTransactionChainListener;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
-@Deprecated(forRemoval = true)
-class ShardedDOMDataBrokerDelegatingTransactionChain implements DOMTransactionChain, DOMTransactionChainListener {
- private final Map<Object, AsyncTransaction<?, ?>> transactionMap = new HashMap<>();
- private final org.opendaylight.mdsal.dom.api.DOMTransactionChain txChainDelegate;
- private final SchemaContext schemaContext;
- private final TransactionChainListener txChainListener;
- private final Object txChainIdentifier;
- private final AtomicLong txNum = new AtomicLong();
-
- ShardedDOMDataBrokerDelegatingTransactionChain(final Object txChainIdentifier,
- final SchemaContext schemaContext,
- final org.opendaylight.mdsal.dom.api.DOMDataBroker
- brokerDelegate,
- final TransactionChainListener txChainListener) {
- requireNonNull(brokerDelegate);
- this.schemaContext = requireNonNull(schemaContext);
- this.txChainIdentifier = requireNonNull(txChainIdentifier);
- this.txChainListener = requireNonNull(txChainListener);
- this.txChainDelegate = brokerDelegate.createTransactionChain(this);
- }
-
- @Override
- public DOMDataReadOnlyTransaction newReadOnlyTransaction() {
- final DOMDataTreeReadTransaction readTxDelegate = txChainDelegate.newReadOnlyTransaction();
- final DOMDataReadOnlyTransaction readTx = new ShardedDOMDataBrokerDelegatingReadTransaction(
- newTransactionIdentifier(), readTxDelegate);
- transactionMap.put(readTxDelegate.getIdentifier(), readTx);
-
- return readTx;
- }
-
- @Override
- public DOMDataReadWriteTransaction newReadWriteTransaction() {
- final Object readWriteTxId = newTransactionIdentifier();
- final DOMDataTreeReadTransaction readTxDelegate = txChainDelegate.newReadOnlyTransaction();
- final DOMDataReadOnlyTransaction readTx = new ShardedDOMDataBrokerDelegatingReadTransaction(readWriteTxId,
- readTxDelegate);
-
- final DOMDataTreeWriteTransaction writeTxDelegate = txChainDelegate.newWriteOnlyTransaction();
- final DOMDataWriteTransaction writeTx = new ShardedDOMDataBrokerDelegatingWriteTransaction(readWriteTxId,
- writeTxDelegate);
-
- final DOMDataReadWriteTransaction readWriteTx = new ShardedDOMDataBrokerDelegatingReadWriteTransaction(
- readWriteTxId, schemaContext, readTx, writeTx);
- transactionMap.put(readTxDelegate.getIdentifier(), readWriteTx);
- transactionMap.put(writeTxDelegate.getIdentifier(), readWriteTx);
-
- return readWriteTx;
- }
-
- @Override
- public DOMDataWriteTransaction newWriteOnlyTransaction() {
- final DOMDataTreeWriteTransaction writeTxDelegate = txChainDelegate.newWriteOnlyTransaction();
- final DOMDataWriteTransaction writeTx = new ShardedDOMDataBrokerDelegatingWriteTransaction(
- newTransactionIdentifier(), writeTxDelegate);
- transactionMap.put(writeTxDelegate.getIdentifier(), writeTx);
-
- return writeTx;
- }
-
- @Override
- public void close() {
- txChainDelegate.close();
- }
-
- @Override
- public void onTransactionChainFailed(final org.opendaylight.mdsal.dom.api.DOMTransactionChain chain,
- final DOMDataTreeTransaction transaction, final Throwable cause) {
- txChainListener.onTransactionChainFailed(this, transactionFromDelegate(transaction.getIdentifier()), cause);
- }
-
- @Override
- public void onTransactionChainSuccessful(final org.opendaylight.mdsal.dom.api.DOMTransactionChain chain) {
- txChainListener.onTransactionChainSuccessful(this);
- }
-
- private AsyncTransaction<?, ?> transactionFromDelegate(final Object delegateId) {
- Preconditions.checkState(transactionMap.containsKey(delegateId),
- "Delegate transaction {} is not present in transaction chain history", delegateId);
- return transactionMap.get(delegateId);
- }
-
- private Object newTransactionIdentifier() {
- return "DOM-CHAIN-" + txChainIdentifier + "-" + txNum.getAndIncrement();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. 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.md.sal.dom.broker.impl.legacy.sharded.adapter;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.util.concurrent.FluentFuture;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
-import org.opendaylight.mdsal.common.api.CommitInfo;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-@Deprecated(forRemoval = true)
-class ShardedDOMDataBrokerDelegatingWriteTransaction implements DOMDataWriteTransaction {
- private final DOMDataTreeWriteTransaction delegateTx;
- private final Object txIdentifier;
-
- ShardedDOMDataBrokerDelegatingWriteTransaction(final Object txIdentifier,
- final DOMDataTreeWriteTransaction delegateTx) {
- this.delegateTx = requireNonNull(delegateTx);
- this.txIdentifier = requireNonNull(txIdentifier);
- }
-
- @Override
- public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path,
- final NormalizedNode<?, ?> data) {
- delegateTx.put(store.toMdsal(), path, data);
- }
-
- @Override
- public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path,
- final NormalizedNode<?, ?> data) {
- delegateTx.merge(store.toMdsal(), path, data);
- }
-
- @Override
- public boolean cancel() {
- return delegateTx.cancel();
- }
-
- @Override
- public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
- delegateTx.delete(store.toMdsal(), path);
- }
-
- @Override
- public FluentFuture<? extends CommitInfo> commit() {
- return delegateTx.commit();
- }
-
- @Override
- public Object getIdentifier() {
- return txIdentifier;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.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;
-
-@Deprecated(forRemoval = true)
-public class DOMMountPointServiceImpl implements DOMMountPointService {
- @Deprecated
- 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
- public DOMMountPointServiceImpl() {
- this(new org.opendaylight.mdsal.dom.broker.DOMMountPointServiceImpl());
- }
-
- public DOMMountPointServiceImpl(final org.opendaylight.mdsal.dom.api.DOMMountPointService delegate) {
- this.delegate = delegate;
- }
-
- @Override
- public Optional<DOMMountPoint> getMountPoint(final YangInstanceIdentifier path) {
- return Optional.fromJavaUtil(delegate.getMountPoint(path).map(DOMMountPointAdapter::new));
- }
-
- @Override
- public DOMMountPointBuilder createMountPoint(final YangInstanceIdentifier path) {
- return new DOMMountPointBuilderImpl(path);
- }
-
- @Override
- public ListenerRegistration<DOMMountPointListener> registerProvisionListener(final DOMMountPointListener listener) {
- return delegate.registerProvisionListener(listener);
- }
-
- @SuppressWarnings("unchecked")
- ObjectRegistration<DOMMountPoint> registerMountPoint(final SimpleDOMMountPoint mountPoint) {
- final org.opendaylight.mdsal.dom.api.DOMMountPointService.DOMMountPointBuilder delegateBuilder =
- delegate.createMountPoint(mountPoint.getIdentifier());
-
- if (mountPoint.getSchemaContext() != null) {
- delegateBuilder.addInitialSchemaContext(mountPoint.getSchemaContext());
- }
-
- final ClassToInstanceMap<DOMService> myServices = mountPoint.getServices();
- for (Entry<Class<? extends DOMService>, DOMService> entry : myServices.entrySet()) {
- delegateBuilder.addService((Class<DOMService>)entry.getKey(), entry.getValue());
-
- 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
- protected void removeRegistration() {
- delegateReg.close();
- }
- };
- }
-
- public class DOMMountPointBuilderImpl implements DOMMountPointBuilder {
- private final ClassToInstanceMap<DOMService> services = MutableClassToInstanceMap.create();
- private final YangInstanceIdentifier path;
- private SimpleDOMMountPoint mountPoint;
- private SchemaContext schemaContext;
-
- public DOMMountPointBuilderImpl(final YangInstanceIdentifier path) {
- this.path = path;
- }
-
- @Override
- public <T extends DOMService> DOMMountPointBuilder addService(final Class<T> type, final T impl) {
- services.putInstance(type, impl);
- return this;
- }
-
- @Override
- public DOMMountPointBuilder addInitialSchemaContext(final SchemaContext ctx) {
- schemaContext = ctx;
- return this;
- }
-
- @Override
- public ObjectRegistration<DOMMountPoint> register() {
- Preconditions.checkState(mountPoint == null, "Mount point is already built.");
- mountPoint = SimpleDOMMountPoint.create(path, services, schemaContext);
- return registerMountPoint(mountPoint);
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. 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.dom.broker.impl;
-
-import org.opendaylight.mdsal.dom.api.DOMSchemaService;
-import org.opendaylight.yangtools.concepts.Delegator;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
-
-@Deprecated(forRemoval = true)
-public final class SchemaContextProviders {
-
- private SchemaContextProviders() {
- throw new UnsupportedOperationException("Utility class.");
- }
-
- public static SchemaContextProvider fromSchemaService(final DOMSchemaService schemaService) {
- if (schemaService instanceof SchemaContextProvider) {
- return (SchemaContextProvider) schemaService;
- }
- return new SchemaServiceAdapter(schemaService);
- }
-
- private static final class SchemaServiceAdapter implements SchemaContextProvider, Delegator<DOMSchemaService> {
-
- private final DOMSchemaService service;
-
- SchemaServiceAdapter(final DOMSchemaService service) {
- this.service = service;
- }
-
- @Override
- public SchemaContext getSchemaContext() {
- return service.getGlobalContext();
- }
-
- @Override
- public DOMSchemaService getDelegate() {
- return service;
- }
-
- @Override
- public String toString() {
- return "SchemaServiceAdapter [service=" + service + "]";
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.dom.broker.util;
-
-import com.google.common.base.Preconditions;
-import java.util.Collection;
-import java.util.List;
-import java.util.Optional;
-import java.util.Set;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.common.Revision;
-import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
-import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
-import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
-import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.opendaylight.yangtools.yang.model.api.Status;
-import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.UsesNode;
-
-/**
- * ProxySchema Context for SchemaContextProviders.
- */
-@Deprecated(forRemoval = true)
-public class ProxySchemaContext implements SchemaContext {
-
- private final SchemaContextProvider schemaProvider;
-
- public ProxySchemaContext(final SchemaContextProvider schemaProvider) {
- this.schemaProvider = schemaProvider;
- }
-
- private SchemaContext getCurrentSchema() {
- Preconditions.checkState(schemaProvider.getSchemaContext() != null, "Schema context unavailable from %s",
- schemaProvider);
- return schemaProvider.getSchemaContext();
- }
-
- @Override
- public Set<DataSchemaNode> getDataDefinitions() {
- return getCurrentSchema().getDataDefinitions();
- }
-
- @Override
- public Set<Module> getModules() {
- return getCurrentSchema().getModules();
- }
-
- @Override
- public Set<NotificationDefinition> getNotifications() {
- return getCurrentSchema().getNotifications();
- }
-
- @Override
- public Set<RpcDefinition> getOperations() {
- return getCurrentSchema().getOperations();
- }
-
- @Override
- public Set<ExtensionDefinition> getExtensions() {
- return getCurrentSchema().getExtensions();
- }
-
- @Override
- public boolean isPresenceContainer() {
- return getCurrentSchema().isPresenceContainer();
- }
-
- @Override
- public Set<TypeDefinition<?>> getTypeDefinitions() {
- return getCurrentSchema().getTypeDefinitions();
- }
-
- @Override
- public Collection<DataSchemaNode> getChildNodes() {
- return getCurrentSchema().getChildNodes();
- }
-
- @Override
- public Set<GroupingDefinition> getGroupings() {
- return getCurrentSchema().getGroupings();
- }
-
- @Override
- public Optional<DataSchemaNode> findDataChildByName(final QName name) {
- return getCurrentSchema().findDataChildByName(name);
- }
-
- @Override
- public Set<UsesNode> getUses() {
- return getCurrentSchema().getUses();
- }
-
- @Override
- public Set<AugmentationSchemaNode> getAvailableAugmentations() {
- return getCurrentSchema().getAvailableAugmentations();
- }
-
- @Override
- public boolean isAugmenting() {
- return getCurrentSchema().isAugmenting();
- }
-
- @Override
- public boolean isAddedByUses() {
- return getCurrentSchema().isAddedByUses();
- }
-
- @Override
- public boolean isConfiguration() {
- return getCurrentSchema().isConfiguration();
- }
-
- @Override
- public QName getQName() {
- return getCurrentSchema().getQName();
- }
-
- @Override
- public SchemaPath getPath() {
- return getCurrentSchema().getPath();
- }
-
- @Override
- public List<UnknownSchemaNode> getUnknownSchemaNodes() {
- return getCurrentSchema().getUnknownSchemaNodes();
- }
-
- @Override
- public Optional<String> getDescription() {
- return getCurrentSchema().getDescription();
- }
-
- @Override
- public Optional<String> getReference() {
- return getCurrentSchema().getReference();
- }
-
- @Override
- public Status getStatus() {
- return getCurrentSchema().getStatus();
- }
-
- @Override
- public Optional<Module> findModule(final String name, final Optional<Revision> revision) {
- return getCurrentSchema().findModule(name, revision);
- }
-
- @Override
- public Optional<Module> findModule(final QNameModule qnameModule) {
- return getCurrentSchema().findModule(qnameModule);
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
- xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
- odl:restart-dependents-on-updates="false">
-
- <cm:property-placeholder persistent-id="org.opendaylight.mdsal.dom.notification" update-strategy="none">
- <cm:default-properties>
- <cm:property name="notification-queue-depth" value="65536"/>
- <cm:property name="notification-queue-spin" value="0"/>
- <cm:property name="notification-queue-park" value="0"/>
- </cm:default-properties>
- </cm:property-placeholder>
-
- <!-- Schema Service -->
-
- <odl:static-reference id="schemaService" interface="org.opendaylight.mdsal.dom.api.DOMSchemaService"/>
-
- <!-- DOM Notification Service -->
-
- <reference id="domNotificationService" interface="org.opendaylight.mdsal.dom.api.DOMNotificationService"
- odl:type="default"/>
- <reference id="domNotificationPublishService" interface="org.opendaylight.mdsal.dom.api.DOMNotificationPublishService"
- odl:type="default"/>
- <reference id="domNotificationSubscriptionListenerRegistry" interface="org.opendaylight.mdsal.dom.spi.DOMNotificationSubscriptionListenerRegistry"
- odl:type="default"/>
-
- <bean id="domNotificationRouter" class="org.opendaylight.controller.md.sal.dom.broker.impl.DOMNotificationRouter"
- factory-method="create">
- <argument ref="domNotificationService"/>
- <argument ref="domNotificationPublishService"/>
- <argument ref="domNotificationSubscriptionListenerRegistry"/>
- </bean>
-
- <service ref="domNotificationRouter" odl:type="default">
- <interfaces>
- <value>org.opendaylight.controller.md.sal.dom.api.DOMNotificationService</value>
- <value>org.opendaylight.controller.md.sal.dom.api.DOMNotificationPublishService</value>
- <value>org.opendaylight.controller.md.sal.dom.spi.DOMNotificationSubscriptionListenerRegistry</value>
- </interfaces>
- </service>
-
- <!-- DOM RPC Service -->
-
- <reference id="domRpcService" interface="org.opendaylight.mdsal.dom.api.DOMRpcService"
- odl:type="default"/>
- <reference id="domRpcProviderService" interface="org.opendaylight.mdsal.dom.api.DOMRpcProviderService"
- odl:type="default"/>
-
- <bean id="domRpcRouter" class="org.opendaylight.controller.md.sal.dom.broker.impl.DOMRpcRouter">
- <argument ref="domRpcService"/>
- <argument ref="domRpcProviderService"/>
- </bean>
-
- <service ref="domRpcRouter" odl:type="default">
- <interfaces>
- <value>org.opendaylight.controller.md.sal.dom.api.DOMRpcService</value>
- <value>org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService</value>
- </interfaces>
- </service>
-
- <!-- DOM MountPoint Service -->
-
- <reference id="delegateDomMountPointService" interface="org.opendaylight.mdsal.dom.api.DOMMountPointService"
- odl:type="default"/>
-
- <bean id="domMountPointService" class="org.opendaylight.controller.md.sal.dom.broker.impl.mount.DOMMountPointServiceImpl">
- <argument ref="delegateDomMountPointService"/>
- </bean>
-
- <service ref="domMountPointService" interface="org.opendaylight.controller.md.sal.dom.api.DOMMountPointService"
- odl:type="default"/>
-
- <!-- DOM PingPong Data Broker -->
-
- <reference id="domDefaultDataBroker" interface="org.opendaylight.controller.md.sal.dom.api.DOMDataBroker"
- odl:type="default"/>
-
- <bean id="domPingPongDataBroker" class="org.opendaylight.controller.md.sal.dom.broker.impl.PingPongDataBroker">
- <argument ref="domDefaultDataBroker"/>
- </bean>
-
- <service ref="domPingPongDataBroker" interface="org.opendaylight.controller.md.sal.dom.api.DOMDataBroker"
- odl:type="pingpong"/>
-
-</blueprint>
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.broker.impl;
-
-import com.google.common.util.concurrent.SettableFuture;
-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;
-
-/**
- * Simple implementation of {@link TransactionChainListener} for testing.
- *
- * <p>
- * This transaction chain listener does not contain any logic, only update
- * futures ({@link #getFailFuture()} and {@link #getSuccessFuture()} when
- * transaction chain event is retrieved.
- */
-@Deprecated
-class BlockingTransactionChainListener implements TransactionChainListener {
-
- private final SettableFuture<Throwable> failFuture = SettableFuture.create();
- private final SettableFuture<Void> successFuture = SettableFuture.create();
-
- @Override
- public void onTransactionChainFailed(final TransactionChain<?, ?> chain, final AsyncTransaction<?, ?> transaction,
- final Throwable cause) {
- failFuture.set(cause);
- }
-
- @Override
- public void onTransactionChainSuccessful(final TransactionChain<?, ?> chain) {
- successFuture.set(null);
- }
-
- public SettableFuture<Throwable> getFailFuture() {
- return failFuture;
- }
-
- public SettableFuture<Void> getSuccessFuture() {
- return successFuture;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014, 2015 Cisco Systems, Inc. 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.md.sal.dom.broker.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION;
-import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.OPERATIONAL;
-
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.Callable;
-import java.util.concurrent.Executors;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
-import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
-import org.opendaylight.controller.md.sal.dom.store.impl.TestModel;
-import org.opendaylight.controller.sal.core.spi.data.DOMStore;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Deprecated
-public class DOMBrokerPerformanceTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(DOMBrokerPerformanceTest.class);
-
- private static NormalizedNode<?, ?> outerList(final int index) {
- return ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, index);
- }
-
- private static YangInstanceIdentifier outerListPath(final int index) {
- return YangInstanceIdentifier.builder(TestModel.OUTER_LIST_PATH)//
- .nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, index) //
- .build();
- }
-
- private SchemaContext schemaContext;
- private AbstractDOMDataBroker domBroker;
-
- private static <V> V measure(final String name, final Callable<V> callable) throws Exception {
- // TODO Auto-generated method stub
- LOG.debug("Measurement:{} Start", name);
- long startNano = System.nanoTime();
- try {
- return callable.call();
- } finally {
- long endNano = System.nanoTime();
- LOG.info("Measurement:\"{}\" Time:{} ms", name, (endNano - startNano) / 1000000.0d);
- }
- }
-
- @Before
- public void setupStore() {
- InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("OPER", MoreExecutors.newDirectExecutorService());
- InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG", MoreExecutors.newDirectExecutorService());
- schemaContext = TestModel.createTestContext();
-
- operStore.onGlobalContextUpdated(schemaContext);
- configStore.onGlobalContextUpdated(schemaContext);
-
- ImmutableMap<LogicalDatastoreType, DOMStore> stores = ImmutableMap.<LogicalDatastoreType, DOMStore>builder() //
- .put(CONFIGURATION, configStore) //
- .put(OPERATIONAL, operStore) //
- .build();
- ListeningExecutorService executor = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor());
- domBroker = new SerializedDOMDataBroker(stores, executor);
- }
-
- @Test
- public void testPerformance() throws Exception {
- measure("Test Suite (all tests)", (Callable<Void>) () -> {
- smallTestSuite(10, 1000);
- //smallTestSuite(10, 100);
- smallTestSuite(100, 100);
- //smallTestSuite(100, 100);
- //smallTestSuite(1000, 10);
- smallTestSuite(1000, 10);
- //smallTestSuite(1000, 1000);
- return null;
- });
- }
-
- private void smallTestSuite(final int txNum, final int innerListWriteNum) throws Exception {
- measure("TestSuite (Txs:" + txNum + " innerWrites:" + innerListWriteNum + ")", (Callable<Void>) () -> {
- measureOneTransactionTopContainer();
- measureSeparateWritesOneLevel(txNum, innerListWriteNum);
- return null;
- });
- }
-
- private void measureSeparateWritesOneLevel(final int txNum, final int innerNum) throws Exception {
- final List<DOMDataReadWriteTransaction> transactions = measure("Txs:" + txNum + " Allocate", () -> {
- List<DOMDataReadWriteTransaction> builder = new ArrayList<>(txNum);
- for (int i = 0; i < txNum; i++) {
- DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
- builder.add(writeTx);
- }
- return builder;
- });
- assertEquals(txNum, transactions.size());
- measure("Txs:" + txNum + " Writes:1", (Callable<Void>) () -> {
- int index = 0;
- for (DOMDataReadWriteTransaction writeTx : transactions) {
- // Writes /test/outer-list/i in writeTx
- writeTx.put(OPERATIONAL, outerListPath(index), outerList(index));
- index++;
- }
- return null;
- });
-
- measure("Txs:" + txNum + " Writes:" + innerNum, (Callable<Void>) () -> {
- int index = 0;
- for (DOMDataReadWriteTransaction writeTx : transactions) {
- // Writes /test/outer-list/i in writeTx
- YangInstanceIdentifier path = YangInstanceIdentifier.builder(outerListPath(index))
- .node(TestModel.INNER_LIST_QNAME).build();
- writeTx.put(OPERATIONAL, path, ImmutableNodes.mapNodeBuilder(TestModel.INNER_LIST_QNAME).build());
- for (int j = 0; j < innerNum; j++) {
- YangInstanceIdentifier innerPath = YangInstanceIdentifier.builder(path)
- .nodeWithKey(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, String.valueOf(j)).build();
- writeTx.put(OPERATIONAL, innerPath, ImmutableNodes
- .mapEntry(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, String.valueOf(j)));
- }
- index++;
- }
- return null;
- });
-
- measure("Txs:" + txNum + " Submit, Finish", (Callable<Void>) () -> {
- List<ListenableFuture<?>> allFutures = measure(txNum + " Submits", () -> {
- List<ListenableFuture<?>> builder = new ArrayList<>(txNum);
- for (DOMDataReadWriteTransaction tx : transactions) {
- builder.add(tx.commit());
- }
- return builder;
- });
- Futures.allAsList(allFutures).get();
- return null;
- });
-
- final DOMDataReadTransaction readTx = measure("Txs:1 (ro), Allocate",
- (Callable<DOMDataReadTransaction>) () -> domBroker
- .newReadOnlyTransaction());
-
-
- measure("Txs:1 (ro) Reads:" + txNum + " (1-level)", (Callable<Void>) () -> {
- for (int i = 0; i < txNum; i++) {
- ListenableFuture<Optional<NormalizedNode<?, ?>>> potential = readTx.read(OPERATIONAL, outerListPath(i));
- assertTrue("outerList/" + i, potential.get().isPresent());
- }
- return null;
- });
-
- measure("Txs:1 (ro) Reads:" + txNum * innerNum + " (2-level)", (Callable<Void>) () -> {
- for (int i = 0; i < txNum; i++) {
- for (int j = 0; j < innerNum; j++) {
- YangInstanceIdentifier path = YangInstanceIdentifier.builder(outerListPath(i))
- //
- .node(TestModel.INNER_LIST_QNAME)
- .nodeWithKey(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, String.valueOf(j)).build();
- ListenableFuture<Optional<NormalizedNode<?, ?>>> potential = readTx.read(OPERATIONAL, path);
- assertTrue("outer-list/" + i + "/inner-list/" + j, potential.get().isPresent());
- }
- }
- return null;
- });
- }
-
- private void measureOneTransactionTopContainer() throws Exception {
-
- final DOMDataReadWriteTransaction writeTx =
- measure("Txs:1 Allocate", () -> domBroker.newReadWriteTransaction());
-
- measure("Txs:1 Write", (Callable<Void>) () -> {
- writeTx.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
- writeTx.put(OPERATIONAL, TestModel.OUTER_LIST_PATH,
- ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build());
- return null;
- });
-
- measure("Txs:1 Reads:1", (Callable<Void>) () -> {
- // Reads /test in writeTx
- ListenableFuture<Optional<NormalizedNode<?, ?>>> writeTxContainer = writeTx
- .read(OPERATIONAL, TestModel.TEST_PATH);
- assertTrue(writeTxContainer.get().isPresent());
- return null;
- });
-
- measure("Txs:1 Reads:1", (Callable<Void>) () -> {
- // Reads /test in writeTx
- ListenableFuture<Optional<NormalizedNode<?, ?>>> writeTxContainer = writeTx
- .read(OPERATIONAL, TestModel.TEST_PATH);
- assertTrue(writeTxContainer.get().isPresent());
- return null;
- });
-
- measure("Txs:1 Submit, Finish", (Callable<Void>) () -> {
- measure("Txs:1 Submit", (Callable<ListenableFuture<?>>) writeTx::commit).get();
- return null;
- });
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014, 2015 Cisco Systems, Inc. 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.md.sal.dom.broker.impl;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION;
-import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.OPERATIONAL;
-
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.util.concurrent.ForwardingExecutorService;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
-import java.util.Collections;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.RejectedExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.concurrent.atomic.AtomicReference;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitDeadlockException;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction;
-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.store.impl.InMemoryDOMDataStore;
-import org.opendaylight.controller.md.sal.dom.store.impl.TestModel;
-import org.opendaylight.controller.sal.core.spi.data.DOMStore;
-import org.opendaylight.yangtools.util.concurrent.DeadlockDetectingListeningExecutorService;
-import org.opendaylight.yangtools.util.concurrent.SpecialExecutors;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
-@Deprecated
-public class DOMBrokerTest {
-
- private SchemaContext schemaContext;
- private AbstractDOMDataBroker domBroker;
- private ListeningExecutorService executor;
- private ExecutorService futureExecutor;
- private CommitExecutorService commitExecutor;
-
- @Before
- public void setupStore() {
-
- InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("OPER", MoreExecutors.newDirectExecutorService());
- InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG", MoreExecutors.newDirectExecutorService());
- schemaContext = TestModel.createTestContext();
-
- operStore.onGlobalContextUpdated(schemaContext);
- configStore.onGlobalContextUpdated(schemaContext);
-
- final ImmutableMap<LogicalDatastoreType, DOMStore> stores =
- ImmutableMap.<LogicalDatastoreType, DOMStore>builder() //
- .put(CONFIGURATION, configStore) //
- .put(OPERATIONAL, operStore) //
- .build();
-
- commitExecutor = new CommitExecutorService(Executors.newSingleThreadExecutor());
- futureExecutor = SpecialExecutors.newBlockingBoundedCachedThreadPool(1, 5, "FCB", DOMBrokerTest.class);
- executor = new DeadlockDetectingListeningExecutorService(commitExecutor,
- TransactionCommitDeadlockException
- .DEADLOCK_EXCEPTION_SUPPLIER,
- futureExecutor);
- domBroker = new SerializedDOMDataBroker(stores, executor);
- }
-
- @After
- public void tearDown() {
- if (executor != null) {
- executor.shutdownNow();
- }
-
- if (futureExecutor != null) {
- futureExecutor.shutdownNow();
- }
- }
-
- @Test(timeout = 10000)
- public void testTransactionIsolation() throws InterruptedException, ExecutionException {
-
- assertNotNull(domBroker);
-
- DOMDataReadTransaction readTx = domBroker.newReadOnlyTransaction();
- assertNotNull(readTx);
-
- DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
- assertNotNull(writeTx);
- /**
- *
- * Writes /test in writeTx
- *
- */
- writeTx.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
-
- /**
- * Reads /test from writeTx Read should return container.
- *
- */
- ListenableFuture<Optional<NormalizedNode<?, ?>>> writeTxContainer = writeTx
- .read(OPERATIONAL, TestModel.TEST_PATH);
- assertTrue(writeTxContainer.get().isPresent());
-
- /**
- * Reads /test from readTx Read should return Absent.
- *
- */
- ListenableFuture<Optional<NormalizedNode<?, ?>>> readTxContainer = readTx
- .read(OPERATIONAL, TestModel.TEST_PATH);
- assertFalse(readTxContainer.get().isPresent());
- }
-
- @Test(timeout = 10000)
- public void testTransactionCommit() throws InterruptedException, ExecutionException, TimeoutException {
-
- DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
- assertNotNull(writeTx);
- /**
- *
- * Writes /test in writeTx
- *
- */
- writeTx.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
-
- /**
- * Reads /test from writeTx Read should return container.
- *
- */
- ListenableFuture<Optional<NormalizedNode<?, ?>>> writeTxContainer = writeTx
- .read(OPERATIONAL, TestModel.TEST_PATH);
- assertTrue(writeTxContainer.get().isPresent());
-
- writeTx.commit().get(5, TimeUnit.SECONDS);
-
- Optional<NormalizedNode<?, ?>> afterCommitRead = domBroker.newReadOnlyTransaction()
- .read(OPERATIONAL, TestModel.TEST_PATH).get();
- assertTrue(afterCommitRead.isPresent());
- }
-
- @Test(timeout = 10000)
- @Deprecated
- public void testTransactionSubmit() throws InterruptedException, ExecutionException, TimeoutException {
-
- DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
- assertNotNull(writeTx);
- /**
- *
- * Writes /test in writeTx
- *
- */
- writeTx.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
-
- /**
- * Reads /test from writeTx Read should return container.
- *
- */
- ListenableFuture<Optional<NormalizedNode<?, ?>>> writeTxContainer = writeTx
- .read(OPERATIONAL, TestModel.TEST_PATH);
- assertTrue(writeTxContainer.get().isPresent());
-
- writeTx.submit().get(5, TimeUnit.SECONDS);
-
- Optional<NormalizedNode<?, ?>> afterCommitRead = domBroker.newReadOnlyTransaction()
- .read(OPERATIONAL, TestModel.TEST_PATH).get();
- assertTrue(afterCommitRead.isPresent());
- }
-
- @Test(expected = TransactionCommitFailedException.class)
- @SuppressWarnings({"checkstyle:IllegalThrows", "checkstyle:AvoidHidingCauseException"})
- public void testRejectedCommit() throws Throwable {
-
- commitExecutor.delegate = Mockito.mock(ExecutorService.class);
- Mockito.doThrow(new RejectedExecutionException("mock")).when(commitExecutor.delegate)
- .execute(Mockito.any(Runnable.class));
- Mockito.doNothing().when(commitExecutor.delegate).shutdown();
- Mockito.doReturn(Collections.emptyList()).when(commitExecutor.delegate).shutdownNow();
- Mockito.doReturn("").when(commitExecutor.delegate).toString();
- Mockito.doReturn(true).when(commitExecutor.delegate)
- .awaitTermination(Mockito.anyLong(), Mockito.any(TimeUnit.class));
-
- DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
- writeTx.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
-
- try {
- writeTx.commit().get(5, TimeUnit.SECONDS);
- } catch (ExecutionException e) {
- throw e.getCause();
- }
- }
-
- @SuppressWarnings("checkstyle:IllegalCatch")
- AtomicReference<Throwable> submitTxAsync(final DOMDataWriteTransaction writeTx) {
- final AtomicReference<Throwable> caughtEx = new AtomicReference<>();
- new Thread(() -> {
- try {
- writeTx.commit();
- } catch (Throwable e) {
- caughtEx.set(e);
- }
- }).start();
-
- return caughtEx;
- }
-
-
- static class CommitExecutorService extends ForwardingExecutorService {
-
- ExecutorService delegate;
-
- CommitExecutorService(final ExecutorService delegate) {
- this.delegate = delegate;
- }
-
- @Override
- protected ExecutorService delegate() {
- return delegate;
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.dom.broker.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION;
-import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.OPERATIONAL;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.util.concurrent.ForwardingExecutorService;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitDeadlockException;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBrokerExtension;
-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.controller.md.sal.dom.api.DOMDataWriteTransaction;
-import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
-import org.opendaylight.controller.md.sal.dom.store.impl.TestModel;
-import org.opendaylight.controller.sal.core.spi.data.DOMStore;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.util.concurrent.DeadlockDetectingListeningExecutorService;
-import org.opendaylight.yangtools.util.concurrent.SpecialExecutors;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
-import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
-@Deprecated
-public class DOMDataTreeListenerTest {
-
- private SchemaContext schemaContext;
- private AbstractDOMDataBroker domBroker;
- private ListeningExecutorService executor;
- private ExecutorService futureExecutor;
- private CommitExecutorService commitExecutor;
-
- private static final DataContainerChild<?, ?> OUTER_LIST = ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
- .withChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)).build();
-
- private static final DataContainerChild<?, ?> OUTER_LIST_2 = ImmutableNodes
- .mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
- .withChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 2)).build();
-
- private static final NormalizedNode<?, ?> TEST_CONTAINER = Builders.containerBuilder()
- .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME)).withChild(OUTER_LIST)
- .build();
-
- private static final NormalizedNode<?, ?> TEST_CONTAINER_2 = Builders.containerBuilder()
- .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME)).withChild(OUTER_LIST_2)
- .build();
-
- private static DOMDataTreeIdentifier ROOT_DATA_TREE_ID = new DOMDataTreeIdentifier(
- LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH);
-
- private static DOMDataTreeIdentifier OUTER_LIST_DATA_TREE_ID = new DOMDataTreeIdentifier(
- LogicalDatastoreType.CONFIGURATION, TestModel.OUTER_LIST_PATH);
-
- @Before
- public void setupStore() {
- InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("OPER", MoreExecutors.newDirectExecutorService());
- InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG", MoreExecutors.newDirectExecutorService());
- schemaContext = TestModel.createTestContext();
-
- operStore.onGlobalContextUpdated(schemaContext);
- configStore.onGlobalContextUpdated(schemaContext);
-
- final ImmutableMap<LogicalDatastoreType, DOMStore> stores = ImmutableMap.<LogicalDatastoreType,
- DOMStore>builder() //
- .put(CONFIGURATION, configStore) //
- .put(OPERATIONAL, operStore) //
- .build();
-
- commitExecutor = new CommitExecutorService(Executors.newSingleThreadExecutor());
- futureExecutor = SpecialExecutors.newBlockingBoundedCachedThreadPool(1, 5, "FCB",
- DOMDataTreeListenerTest.class);
- executor = new DeadlockDetectingListeningExecutorService(commitExecutor,
- TransactionCommitDeadlockException
- .DEADLOCK_EXCEPTION_SUPPLIER,
- futureExecutor);
- domBroker = new SerializedDOMDataBroker(stores, executor);
- }
-
- @After
- public void tearDown() {
- if (executor != null) {
- executor.shutdownNow();
- }
-
- if (futureExecutor != null) {
- futureExecutor.shutdownNow();
- }
- }
-
- @Test
- public void writeContainerEmptyTreeTest() throws InterruptedException {
- CountDownLatch latch = new CountDownLatch(1);
-
- DOMDataTreeChangeService dataTreeChangeService = getDOMDataTreeChangeService();
- assertNotNull("DOMDataTreeChangeService not found, cannot continue with test!", dataTreeChangeService);
-
- final TestDataTreeListener listener = new TestDataTreeListener(latch);
- final ListenerRegistration<TestDataTreeListener> listenerReg = dataTreeChangeService
- .registerDataTreeChangeListener(ROOT_DATA_TREE_ID, listener);
-
- final DOMDataWriteTransaction writeTx = domBroker.newWriteOnlyTransaction();
- writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, TEST_CONTAINER);
- writeTx.commit();
-
- latch.await(5, TimeUnit.SECONDS);
-
- assertEquals(1, listener.getReceivedChanges().size());
- final Collection<DataTreeCandidate> changes = listener.getReceivedChanges().get(0);
- assertEquals(1, changes.size());
-
- DataTreeCandidate candidate = changes.iterator().next();
- assertNotNull(candidate);
- DataTreeCandidateNode candidateRoot = candidate.getRootNode();
- checkChange(null, TEST_CONTAINER, ModificationType.WRITE, candidateRoot);
- listenerReg.close();
- }
-
- @Test
- public void replaceContainerContainerInTreeTest() throws InterruptedException, ExecutionException {
- final CountDownLatch latch = new CountDownLatch(2);
-
- DOMDataTreeChangeService dataTreeChangeService = getDOMDataTreeChangeService();
- assertNotNull("DOMDataTreeChangeService not found, cannot continue with test!", dataTreeChangeService);
-
- DOMDataWriteTransaction writeTx = domBroker.newWriteOnlyTransaction();
- writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, TEST_CONTAINER);
- writeTx.commit().get();
-
- final TestDataTreeListener listener = new TestDataTreeListener(latch);
- final ListenerRegistration<TestDataTreeListener> listenerReg = dataTreeChangeService
- .registerDataTreeChangeListener(ROOT_DATA_TREE_ID, listener);
- writeTx = domBroker.newWriteOnlyTransaction();
- writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, TEST_CONTAINER_2);
- writeTx.commit();
-
- latch.await(5, TimeUnit.SECONDS);
-
- assertEquals(2, listener.getReceivedChanges().size());
- Collection<DataTreeCandidate> changes = listener.getReceivedChanges().get(0);
- assertEquals(1, changes.size());
-
- DataTreeCandidate candidate = changes.iterator().next();
- assertNotNull(candidate);
- DataTreeCandidateNode candidateRoot = candidate.getRootNode();
- checkChange(null, TEST_CONTAINER, ModificationType.WRITE, candidateRoot);
-
- changes = listener.getReceivedChanges().get(1);
- assertEquals(1, changes.size());
-
- candidate = changes.iterator().next();
- assertNotNull(candidate);
- candidateRoot = candidate.getRootNode();
- checkChange(TEST_CONTAINER, TEST_CONTAINER_2, ModificationType.WRITE, candidateRoot);
- listenerReg.close();
- }
-
- @Test
- public void deleteContainerContainerInTreeTest() throws InterruptedException, ExecutionException {
- final CountDownLatch latch = new CountDownLatch(2);
-
- DOMDataTreeChangeService dataTreeChangeService = getDOMDataTreeChangeService();
- assertNotNull("DOMDataTreeChangeService not found, cannot continue with test!", dataTreeChangeService);
-
- DOMDataWriteTransaction writeTx = domBroker.newWriteOnlyTransaction();
- writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, TEST_CONTAINER);
- writeTx.commit().get();
-
- final TestDataTreeListener listener = new TestDataTreeListener(latch);
- final ListenerRegistration<TestDataTreeListener> listenerReg = dataTreeChangeService
- .registerDataTreeChangeListener(ROOT_DATA_TREE_ID, listener);
-
- writeTx = domBroker.newWriteOnlyTransaction();
- writeTx.delete(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH);
- writeTx.commit();
-
- latch.await(5, TimeUnit.SECONDS);
-
- assertEquals(2, listener.getReceivedChanges().size());
- Collection<DataTreeCandidate> changes = listener.getReceivedChanges().get(0);
- assertEquals(1, changes.size());
-
- DataTreeCandidate candidate = changes.iterator().next();
- assertNotNull(candidate);
- DataTreeCandidateNode candidateRoot = candidate.getRootNode();
- checkChange(null, TEST_CONTAINER, ModificationType.WRITE, candidateRoot);
-
- changes = listener.getReceivedChanges().get(1);
- assertEquals(1, changes.size());
-
- candidate = changes.iterator().next();
- assertNotNull(candidate);
- candidateRoot = candidate.getRootNode();
- checkChange(TEST_CONTAINER, null, ModificationType.DELETE, candidateRoot);
- listenerReg.close();
- }
-
- @Test
- public void replaceChildListContainerInTreeTest() throws InterruptedException, ExecutionException {
- final CountDownLatch latch = new CountDownLatch(2);
-
- DOMDataTreeChangeService dataTreeChangeService = getDOMDataTreeChangeService();
- assertNotNull("DOMDataTreeChangeService not found, cannot continue with test!", dataTreeChangeService);
-
- DOMDataWriteTransaction writeTx = domBroker.newWriteOnlyTransaction();
- writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, TEST_CONTAINER);
- writeTx.commit().get();
-
- final TestDataTreeListener listener = new TestDataTreeListener(latch);
- final ListenerRegistration<TestDataTreeListener> listenerReg = dataTreeChangeService
- .registerDataTreeChangeListener(ROOT_DATA_TREE_ID, listener);
-
- writeTx = domBroker.newWriteOnlyTransaction();
- writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.OUTER_LIST_PATH, OUTER_LIST_2);
- writeTx.commit();
-
- latch.await(5, TimeUnit.SECONDS);
-
- assertEquals(2, listener.getReceivedChanges().size());
- Collection<DataTreeCandidate> changes = listener.getReceivedChanges().get(0);
- assertEquals(1, changes.size());
-
- DataTreeCandidate candidate = changes.iterator().next();
- assertNotNull(candidate);
- DataTreeCandidateNode candidateRoot = candidate.getRootNode();
- checkChange(null, TEST_CONTAINER, ModificationType.WRITE, candidateRoot);
-
- changes = listener.getReceivedChanges().get(1);
- assertEquals(1, changes.size());
-
- candidate = changes.iterator().next();
- assertNotNull(candidate);
- candidateRoot = candidate.getRootNode();
- checkChange(TEST_CONTAINER, TEST_CONTAINER_2, ModificationType.SUBTREE_MODIFIED, candidateRoot);
- final DataTreeCandidateNode modifiedChild = candidateRoot
- .getModifiedChild(new YangInstanceIdentifier.NodeIdentifier(TestModel.OUTER_LIST_QNAME)).get();
- checkChange(OUTER_LIST, OUTER_LIST_2, ModificationType.WRITE, modifiedChild);
- listenerReg.close();
- }
-
- @Test
- public void rootModificationChildListenerTest() throws InterruptedException, ExecutionException {
- final CountDownLatch latch = new CountDownLatch(2);
-
- DOMDataTreeChangeService dataTreeChangeService = getDOMDataTreeChangeService();
- assertNotNull("DOMDataTreeChangeService not found, cannot continue with test!", dataTreeChangeService);
-
- DOMDataWriteTransaction writeTx = domBroker.newWriteOnlyTransaction();
- writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, TEST_CONTAINER);
- writeTx.commit().get();
-
- final TestDataTreeListener listener = new TestDataTreeListener(latch);
- final ListenerRegistration<TestDataTreeListener> listenerReg = dataTreeChangeService
- .registerDataTreeChangeListener(OUTER_LIST_DATA_TREE_ID, listener);
-
- writeTx = domBroker.newWriteOnlyTransaction();
- writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, TEST_CONTAINER_2);
- writeTx.commit().get();
-
- latch.await(1, TimeUnit.SECONDS);
-
- assertEquals(2, listener.getReceivedChanges().size());
- Collection<DataTreeCandidate> changes = listener.getReceivedChanges().get(0);
- assertEquals(1, changes.size());
-
- DataTreeCandidate candidate = changes.iterator().next();
- assertNotNull(candidate);
- DataTreeCandidateNode candidateRoot = candidate.getRootNode();
- checkChange(null, OUTER_LIST, ModificationType.WRITE, candidateRoot);
-
- changes = listener.getReceivedChanges().get(1);
- assertEquals(1, changes.size());
-
- candidate = changes.iterator().next();
- assertNotNull(candidate);
- candidateRoot = candidate.getRootNode();
- checkChange(OUTER_LIST, OUTER_LIST_2, ModificationType.WRITE, candidateRoot);
- listenerReg.close();
- }
-
- @Test
- public void listEntryChangeNonRootRegistrationTest() throws InterruptedException, ExecutionException {
- final CountDownLatch latch = new CountDownLatch(2);
-
- DOMDataTreeChangeService dataTreeChangeService = getDOMDataTreeChangeService();
- assertNotNull("DOMDataTreeChangeService not found, cannot continue with test!", dataTreeChangeService);
-
- DOMDataWriteTransaction writeTx = domBroker.newWriteOnlyTransaction();
- writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, TEST_CONTAINER);
- writeTx.commit().get();
-
- final TestDataTreeListener listener = new TestDataTreeListener(latch);
- final ListenerRegistration<TestDataTreeListener> listenerReg = dataTreeChangeService
- .registerDataTreeChangeListener(OUTER_LIST_DATA_TREE_ID, listener);
-
- final YangInstanceIdentifier.NodeIdentifierWithPredicates outerListEntryId1
- = YangInstanceIdentifier.NodeIdentifierWithPredicates.of(TestModel.OUTER_LIST_QNAME,
- TestModel.ID_QNAME, 1);
- final YangInstanceIdentifier.NodeIdentifierWithPredicates outerListEntryId2
- = YangInstanceIdentifier.NodeIdentifierWithPredicates.of(TestModel.OUTER_LIST_QNAME,
- TestModel.ID_QNAME, 2);
- final YangInstanceIdentifier.NodeIdentifierWithPredicates outerListEntryId3
- = YangInstanceIdentifier.NodeIdentifierWithPredicates.of(TestModel.OUTER_LIST_QNAME,
- TestModel.ID_QNAME, 3);
-
- final MapEntryNode outerListEntry1 = ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1);
- final MapEntryNode outerListEntry2 = ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 2);
- final MapEntryNode outerListEntry3 = ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 3);
-
- final MapNode listAfter = ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).withChild(outerListEntry2)
- .withChild(outerListEntry3).build();
-
- writeTx = domBroker.newWriteOnlyTransaction();
- writeTx.delete(LogicalDatastoreType.CONFIGURATION, TestModel.OUTER_LIST_PATH.node(outerListEntryId1));
- writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.OUTER_LIST_PATH.node(outerListEntryId2),
- outerListEntry2);
- writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.OUTER_LIST_PATH.node(outerListEntryId3),
- outerListEntry3);
- writeTx.commit();
-
- latch.await(5, TimeUnit.SECONDS);
-
- assertEquals(2, listener.getReceivedChanges().size());
- Collection<DataTreeCandidate> changes = listener.getReceivedChanges().get(0);
- assertEquals(1, changes.size());
-
- DataTreeCandidate candidate = changes.iterator().next();
- assertNotNull(candidate);
- DataTreeCandidateNode candidateRoot = candidate.getRootNode();
- checkChange(null, OUTER_LIST, ModificationType.WRITE, candidateRoot);
-
- changes = listener.getReceivedChanges().get(1);
- assertEquals(1, changes.size());
-
- candidate = changes.iterator().next();
- assertNotNull(candidate);
- candidateRoot = candidate.getRootNode();
- checkChange(OUTER_LIST, listAfter, ModificationType.SUBTREE_MODIFIED, candidateRoot);
- final DataTreeCandidateNode entry1Canditate = candidateRoot.getModifiedChild(outerListEntryId1).get();
- checkChange(outerListEntry1, null, ModificationType.DELETE, entry1Canditate);
- final DataTreeCandidateNode entry2Canditate = candidateRoot.getModifiedChild(outerListEntryId2).get();
- checkChange(null, outerListEntry2, ModificationType.WRITE, entry2Canditate);
- final DataTreeCandidateNode entry3Canditate = candidateRoot.getModifiedChild(outerListEntryId3).get();
- checkChange(null, outerListEntry3, ModificationType.WRITE, entry3Canditate);
- listenerReg.close();
- }
-
- private static void checkChange(final NormalizedNode<?, ?> expectedBefore, final NormalizedNode<?, ?> expectedAfter,
- final ModificationType expectedMod, final DataTreeCandidateNode candidateNode) {
- if (expectedBefore != null) {
- assertTrue(candidateNode.getDataBefore().isPresent());
- assertEquals(expectedBefore, candidateNode.getDataBefore().get());
- } else {
- assertFalse(candidateNode.getDataBefore().isPresent());
- }
-
- if (expectedAfter != null) {
- assertTrue(candidateNode.getDataAfter().isPresent());
- assertEquals(expectedAfter, candidateNode.getDataAfter().get());
- } else {
- assertFalse(candidateNode.getDataAfter().isPresent());
- }
-
- assertEquals(expectedMod, candidateNode.getModificationType());
- }
-
- private DOMDataTreeChangeService getDOMDataTreeChangeService() {
- final DOMDataBrokerExtension extension = domBroker.getSupportedExtensions().get(DOMDataTreeChangeService.class);
- if (extension == null) {
- return null;
- }
- DOMDataTreeChangeService dataTreeChangeService = null;
- if (extension instanceof DOMDataTreeChangeService) {
- dataTreeChangeService = (DOMDataTreeChangeService) extension;
- }
- return dataTreeChangeService;
- }
-
-
- static class CommitExecutorService extends ForwardingExecutorService {
-
- ExecutorService delegate;
-
- CommitExecutorService(final ExecutorService delegate) {
- this.delegate = delegate;
- }
-
- @Override
- protected ExecutorService delegate() {
- return delegate;
- }
- }
-
- static class TestDataTreeListener implements DOMDataTreeChangeListener {
-
- private final List<Collection<DataTreeCandidate>> receivedChanges = new ArrayList<>();
- private final CountDownLatch latch;
-
- TestDataTreeListener(final CountDownLatch latch) {
- this.latch = latch;
- }
-
- @Override
- public void onDataTreeChanged(final Collection<DataTreeCandidate> changes) {
- receivedChanges.add(changes);
- latch.countDown();
- }
-
- public List<Collection<DataTreeCandidate>> getReceivedChanges() {
- return receivedChanges;
- }
- }
-}
+++ /dev/null
-/*
- *
- * 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.md.sal.dom.broker.impl;
-
-import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.doThrow;
-
-import com.google.common.util.concurrent.CheckedFuture;
-import java.util.Collections;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
-
-@Deprecated
-public class DOMForwardedWriteTransactionTest {
-
- @Mock
- private AbstractDOMForwardedTransactionFactory abstractDOMForwardedTransactionFactory;
-
- @Mock
- private DOMStoreWriteTransaction domStoreWriteTransaction;
-
- @Before
- public void setup() {
- MockitoAnnotations.initMocks(this);
- }
-
- @Test
- public void readyRuntimeExceptionAndCancel() {
- RuntimeException thrown = new RuntimeException();
- doThrow(thrown).when(domStoreWriteTransaction).ready();
- DOMForwardedWriteTransaction<DOMStoreWriteTransaction> domForwardedWriteTransaction =
- new DOMForwardedWriteTransaction<>(
- new Object(),
- Collections.singletonMap(LogicalDatastoreType.OPERATIONAL, domStoreWriteTransaction),
- abstractDOMForwardedTransactionFactory);
- CheckedFuture<Void, TransactionCommitFailedException> submitFuture = domForwardedWriteTransaction.submit();
- try {
- submitFuture.checkedGet();
- Assert.fail("TransactionCommitFailedException expected");
- } catch (TransactionCommitFailedException e) {
- assertTrue(e.getCause() == thrown);
- domForwardedWriteTransaction.cancel();
- }
- }
-
- @Test
- public void submitRuntimeExceptionAndCancel() {
- RuntimeException thrown = new RuntimeException();
- doReturn(null).when(domStoreWriteTransaction).ready();
- doThrow(thrown).when(abstractDOMForwardedTransactionFactory).commit(any(), any(), any());
- DOMForwardedWriteTransaction<DOMStoreWriteTransaction> domForwardedWriteTransaction =
- new DOMForwardedWriteTransaction<>(
- new Object(),
- Collections.singletonMap(LogicalDatastoreType.OPERATIONAL, domStoreWriteTransaction),
- abstractDOMForwardedTransactionFactory);
- CheckedFuture<Void, TransactionCommitFailedException> submitFuture = domForwardedWriteTransaction.submit();
- try {
- submitFuture.checkedGet();
- Assert.fail("TransactionCommitFailedException expected");
- } catch (TransactionCommitFailedException e) {
- assertTrue(e.getCause() == thrown);
- domForwardedWriteTransaction.cancel();
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2018 Inocybe Technologies 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.md.sal.dom.broker.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.common.util.concurrent.SettableFuture;
-import com.google.common.util.concurrent.Uninterruptibles;
-import java.time.Instant;
-import java.time.temporal.ChronoUnit;
-import java.util.Date;
-import java.util.Set;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import org.eclipse.jdt.annotation.Nullable;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.opendaylight.controller.md.sal.dom.api.DOMEvent;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener;
-import org.opendaylight.controller.md.sal.dom.spi.DOMNotificationSubscriptionListener;
-import org.opendaylight.controller.md.sal.dom.store.impl.TestModel;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
-import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-
-/**
- * Unit tests for DOMNotificationRouter.
- *
- * @author Thomas Pantelis
- */
-@Deprecated
-public class DOMNotificationRouterTest {
- private static final ContainerNode BODY = ImmutableContainerNodeBuilder.create().withNodeIdentifier(
- new NodeIdentifier(QName.create(TestModel.TEST_QNAME.getModule(), "test-notification")))
- .withChild(ImmutableNodes.leafNode(QName.create(TestModel.TEST_QNAME.getModule(), "value-leaf"), "foo"))
- .build();
- // Truncate to milliseconds, as Java 9+ we get microsecond precision, which cannot be expressed in terms of Date
- private static final Instant INSTANT = Instant.now().truncatedTo(ChronoUnit.MILLIS);
-
- private static SchemaPath notificationSchemaPath;
-
- private final org.opendaylight.mdsal.dom.broker.DOMNotificationRouter mdsalRouter =
- org.opendaylight.mdsal.dom.broker.DOMNotificationRouter.create(16);
- private final DOMNotificationRouter legacyRouter =
- DOMNotificationRouter.create(mdsalRouter, mdsalRouter, mdsalRouter);
- private final TestLegacyDOMNotificationListener testLegacyListener = new TestLegacyDOMNotificationListener();
- private final TestMdsalDOMNotificationListener testMdsalListener = new TestMdsalDOMNotificationListener();
-
- @BeforeClass
- public static void staticSetup() {
- final SchemaContext schemaContext = TestModel.createTestContext();
-
- Module testModule = schemaContext.findModule("odl-datastore-test", TestModel.TEST_QNAME.getRevision()).get();
- NotificationDefinition notificationDefinition = null;
- for (NotificationDefinition def: testModule.getNotifications()) {
- if (def.getQName().getLocalName().equals("test-notification")) {
- notificationDefinition = def;
- break;
- }
- }
-
- assertNotNull("test-notification not found in " + testModule.getNotifications(), notificationDefinition);
- notificationSchemaPath = notificationDefinition.getPath();
- }
-
- @Test
- public void testLegacyListenerAndPublish() throws InterruptedException, ExecutionException, TimeoutException {
- final ListenerRegistration<TestLegacyDOMNotificationListener> reg =
- legacyRouter.registerNotificationListener(testLegacyListener, notificationSchemaPath);
-
- legacyRouter.putNotification(new TestLegacyDOMNotification()).get(5, TimeUnit.SECONDS);
- testLegacyListener.verifyReceived(notificationSchemaPath, BODY, null);
-
- legacyRouter.offerNotification(new TestLegacyDOMNotification()).get(5, TimeUnit.SECONDS);
- testLegacyListener.verifyReceived(notificationSchemaPath, BODY, null);
-
- legacyRouter.offerNotification(new TestLegacyDOMNotification(), 100, TimeUnit.MILLISECONDS)
- .get(5, TimeUnit.SECONDS);
- testLegacyListener.verifyReceived(notificationSchemaPath, BODY, null);
-
- legacyRouter.offerNotification(new TestLegacyDOMEvent()).get(5, TimeUnit.SECONDS);
- testLegacyListener.verifyReceived(notificationSchemaPath, BODY, Date.from(INSTANT));
-
- reg.close();
-
- legacyRouter.offerNotification(new TestLegacyDOMNotification()).get(5, TimeUnit.SECONDS);
- testLegacyListener.verifyNotReceived();
- }
-
- @Test
- public void testLegacyListenerAndMdsalPublish()
- throws InterruptedException, ExecutionException, TimeoutException {
- legacyRouter.registerNotificationListener(testLegacyListener, notificationSchemaPath);
-
- mdsalRouter.offerNotification(new TestMdsalDOMNotification()).get(5, TimeUnit.SECONDS);
- testLegacyListener.verifyReceived(notificationSchemaPath, BODY, null);
-
- mdsalRouter.offerNotification(new TestMdsalDOMEvent()).get(5, TimeUnit.SECONDS);
- testLegacyListener.verifyReceived(notificationSchemaPath, BODY, Date.from(INSTANT));
- }
-
- @Test
- public void testMdsalListenerAndLegacyPublish()
- throws InterruptedException, ExecutionException, TimeoutException {
- mdsalRouter.registerNotificationListener(testMdsalListener, notificationSchemaPath);
-
- legacyRouter.offerNotification(new TestLegacyDOMNotification()).get(5, TimeUnit.SECONDS);
- testMdsalListener.verifyReceived(notificationSchemaPath, BODY, null);
-
- legacyRouter.offerNotification(new TestLegacyDOMEvent()).get(5, TimeUnit.SECONDS);
- testMdsalListener.verifyReceived(notificationSchemaPath, BODY, INSTANT);
- }
-
- @Test
- public void testRegisterSubscriptionListener() throws InterruptedException, ExecutionException, TimeoutException {
- TestLegacyDOMNotificationSubscriptionListener listener = new TestLegacyDOMNotificationSubscriptionListener();
- final ListenerRegistration<TestLegacyDOMNotificationSubscriptionListener> subscriptionReg =
- legacyRouter.registerSubscriptionListener(listener);
-
- listener.verifyReceived();
-
- final ListenerRegistration<TestLegacyDOMNotificationListener> listenerReg =
- legacyRouter.registerNotificationListener(testLegacyListener, notificationSchemaPath);
-
- listener.verifyReceived(notificationSchemaPath);
-
- listenerReg.close();
-
- listener.verifyReceived();
-
- subscriptionReg.close();
-
- legacyRouter.registerNotificationListener(testLegacyListener, notificationSchemaPath);
-
- listener.verifyNotReceived();
- }
-
- private static class TestLegacyDOMNotificationListener implements DOMNotificationListener {
- SettableFuture<DOMNotification> receivedNotification = SettableFuture.create();
-
- @Override
- public void onNotification(final DOMNotification notification) {
- receivedNotification.set(notification);
- }
-
- void verifyReceived(final SchemaPath path, final ContainerNode body, final @Nullable Date eventTime)
- throws InterruptedException, ExecutionException, TimeoutException {
- final DOMNotification actual = receivedNotification.get(5, TimeUnit.SECONDS);
- assertEquals(path, actual.getType());
- assertEquals(body, actual.getBody());
-
- if (eventTime != null) {
- assertTrue("Expected DOMEvent", actual instanceof DOMEvent);
- assertEquals(eventTime, ((DOMEvent)actual).getEventTime());
- } else {
- assertFalse("Unexpected DOMEvent", actual instanceof DOMEvent);
- }
-
- receivedNotification = SettableFuture.create();
- }
-
- void verifyNotReceived() {
- Uninterruptibles.sleepUninterruptibly(200, TimeUnit.MILLISECONDS);
- assertFalse("Unexpected notification", receivedNotification.isDone());
- }
- }
-
- private static class TestMdsalDOMNotificationListener
- implements org.opendaylight.mdsal.dom.api.DOMNotificationListener {
- SettableFuture<org.opendaylight.mdsal.dom.api.DOMNotification> receivedNotification = SettableFuture.create();
-
- @Override
- public void onNotification(final org.opendaylight.mdsal.dom.api.DOMNotification notification) {
- receivedNotification.set(notification);
- }
-
- void verifyReceived(final SchemaPath path, final ContainerNode body, final @Nullable Instant eventTime)
- throws InterruptedException, ExecutionException, TimeoutException {
- final org.opendaylight.mdsal.dom.api.DOMNotification actual =
- receivedNotification.get(5, TimeUnit.SECONDS);
- assertEquals(path, actual.getType());
- assertEquals(body, actual.getBody());
-
- if (eventTime != null) {
- assertTrue("Expected DOMEvent", actual instanceof org.opendaylight.mdsal.dom.api.DOMEvent);
- assertEquals(eventTime, ((org.opendaylight.mdsal.dom.api.DOMEvent)actual).getEventInstant());
- } else {
- assertFalse("Unexpected DOMEvent", actual instanceof org.opendaylight.mdsal.dom.api.DOMEvent);
- }
-
- receivedNotification = SettableFuture.create();
- }
- }
-
- private static class TestLegacyDOMNotificationSubscriptionListener implements DOMNotificationSubscriptionListener {
- SettableFuture<Set<SchemaPath>> receivedNotification = SettableFuture.create();
-
- @Override
- public void onSubscriptionChanged(final Set<SchemaPath> currentTypes) {
- receivedNotification.set(currentTypes);
- }
-
- void verifyReceived(final SchemaPath... paths)
- throws InterruptedException, ExecutionException, TimeoutException {
- final Set<SchemaPath> actual = receivedNotification.get(5, TimeUnit.SECONDS);
- assertEquals(ImmutableSet.copyOf(paths), actual);
- receivedNotification = SettableFuture.create();
- }
-
- void verifyNotReceived() {
- Uninterruptibles.sleepUninterruptibly(200, TimeUnit.MILLISECONDS);
- assertFalse("Unexpected notification", receivedNotification.isDone());
- }
- }
-
- private static class TestLegacyDOMNotification implements DOMNotification {
- @Override
- public SchemaPath getType() {
- return notificationSchemaPath;
- }
-
- @Override
- public ContainerNode getBody() {
- return BODY;
- }
- }
-
- private static class TestLegacyDOMEvent extends TestLegacyDOMNotification implements DOMEvent {
- @Override
- public Date getEventTime() {
- return Date.from(INSTANT);
- }
- }
-
- private static class TestMdsalDOMNotification implements org.opendaylight.mdsal.dom.api.DOMNotification {
- @Override
- public SchemaPath getType() {
- return notificationSchemaPath;
- }
-
- @Override
- public ContainerNode getBody() {
- return BODY;
- }
- }
-
- private static class TestMdsalDOMEvent extends TestMdsalDOMNotification
- implements org.opendaylight.mdsal.dom.api.DOMEvent {
- @Override
- public Instant getEventInstant() {
- return INSTANT;
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2018 Inocybe Technologies 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.md.sal.dom.broker.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.after;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.reset;
-import static org.mockito.Mockito.timeout;
-import static org.mockito.Mockito.verify;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.FluentFuture;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import java.util.AbstractMap.SimpleEntry;
-import java.util.Collections;
-import java.util.Map.Entry;
-import java.util.concurrent.ExecutionException;
-import org.junit.Before;
-import org.junit.Test;
-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;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationNotAvailableException;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationRegistration;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
-import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult;
-import org.opendaylight.controller.md.sal.dom.store.impl.TestModel;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.util.concurrent.FluentFutures;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-
-/**
- * Unit tests for DOMRpcRouter.
- *
- * @author Thomas Pantelis
- */
-@Deprecated
-public class DOMRpcRouterTest {
-
- private static final NormalizedNode<?, ?> RPC_INPUT = ImmutableNodes.leafNode(
- QName.create(TestModel.TEST_QNAME.getModule(), "input-leaf"), "foo");
- private static final NormalizedNode<?, ?> RPC_OUTPUT = ImmutableNodes.leafNode(
- QName.create(TestModel.TEST_QNAME.getModule(), "output-leaf"), "bar");
- private final TestLegacyDOMRpcImplementation testLegacyRpcImpl = new TestLegacyDOMRpcImplementation();
- private final TestMdsalDOMRpcImplementation testMdsalRpcImpl = new TestMdsalDOMRpcImplementation();
- private org.opendaylight.mdsal.dom.broker.DOMRpcRouter mdsalRpcRouter;
- private DOMRpcRouter legacyRpcRouter;
- private DOMRpcIdentifier legacyTestRpcIdentifier;
- private DOMRpcIdentifier legacyTestRpcNoInputIdentifier;
- private org.opendaylight.mdsal.dom.api.DOMRpcIdentifier mdsalTestRpcIdentifier;
- private org.opendaylight.mdsal.dom.api.DOMRpcIdentifier mdsalTestRpcNoInputIdentifier;
-
- @Before
- public void setup() {
- mdsalRpcRouter = new org.opendaylight.mdsal.dom.broker.DOMRpcRouter();
- final SchemaContext schemaContext = TestModel.createTestContext();
- mdsalRpcRouter.onGlobalContextUpdated(schemaContext);
- legacyRpcRouter = new DOMRpcRouter(mdsalRpcRouter.getRpcService(), mdsalRpcRouter.getRpcProviderService());
-
- legacyTestRpcIdentifier = DOMRpcIdentifier.create(findRpc(schemaContext, "test-rpc"));
- legacyTestRpcNoInputIdentifier = DOMRpcIdentifier.create(findRpc(schemaContext, "test-rpc-no-input"));
- mdsalTestRpcIdentifier = org.opendaylight.mdsal.dom.api.DOMRpcIdentifier.create(
- findRpc(schemaContext, "test-rpc"));
- mdsalTestRpcNoInputIdentifier = org.opendaylight.mdsal.dom.api.DOMRpcIdentifier.create(
- findRpc(schemaContext, "test-rpc-no-input"));
- }
-
- @Test
- public void testLegacyRegistrationAndInvocation() throws InterruptedException, ExecutionException {
- final DOMRpcImplementationRegistration<TestLegacyDOMRpcImplementation> reg =
- legacyRpcRouter.registerRpcImplementation(testLegacyRpcImpl, legacyTestRpcIdentifier,
- legacyTestRpcNoInputIdentifier);
-
- // Test success
-
- DefaultDOMRpcResult result = new DefaultDOMRpcResult(RPC_OUTPUT);
- testLegacyRpcImpl.init(Futures.immediateCheckedFuture(result));
-
- ListenableFuture<DOMRpcResult> future = legacyRpcRouter.invokeRpc(legacyTestRpcIdentifier.getType(), RPC_INPUT);
-
- assertSame(result, future.get());
- testLegacyRpcImpl.verifyInput(legacyTestRpcIdentifier, RPC_INPUT);
-
- // Test exception returned
-
- TestLegacyDOMRpcException rpcEx = new TestLegacyDOMRpcException();
- testLegacyRpcImpl.init(Futures.immediateFailedCheckedFuture(rpcEx));
-
- try {
- legacyRpcRouter.invokeRpc(legacyTestRpcIdentifier.getType(), RPC_INPUT).get();
- fail("Expected exception");
- } catch (ExecutionException e) {
- assertEquals(rpcEx, e.getCause());
- }
-
- // Test no input or output
-
- testLegacyRpcImpl.init(Futures.immediateCheckedFuture(null));
-
- future = legacyRpcRouter.invokeRpc(legacyTestRpcNoInputIdentifier.getType(), null);
-
- assertNull(future.get());
- testLegacyRpcImpl.verifyInput(legacyTestRpcNoInputIdentifier, null);
-
- // Test close
-
- reg.close();
-
- try {
- legacyRpcRouter.invokeRpc(legacyTestRpcIdentifier.getType(), RPC_INPUT).get();
- fail("Expected exception");
- } catch (ExecutionException e) {
- assertTrue(e.getCause() instanceof DOMRpcImplementationNotAvailableException);
- }
- }
-
- @Test
- public void testLegacyRegistrationAndMdsalInvocation() throws InterruptedException, ExecutionException {
- legacyRpcRouter.registerRpcImplementation(testLegacyRpcImpl, legacyTestRpcIdentifier,
- legacyTestRpcNoInputIdentifier);
-
- // Test success
-
- DefaultDOMRpcResult result = new DefaultDOMRpcResult(RPC_OUTPUT,
- Collections.singleton(RpcResultBuilder.newError(ErrorType.RPC, "tag", "message")));
- testLegacyRpcImpl.init(Futures.immediateCheckedFuture(result));
-
- ListenableFuture<org.opendaylight.mdsal.dom.api.DOMRpcResult> future =
- mdsalRpcRouter.getRpcService().invokeRpc(mdsalTestRpcIdentifier.getType(), RPC_INPUT);
-
- assertEquals(RPC_OUTPUT, future.get().getResult());
- assertEquals(1, future.get().getErrors().size());
- assertEquals(ErrorType.RPC, future.get().getErrors().iterator().next().getErrorType());
- assertEquals("tag", future.get().getErrors().iterator().next().getTag());
- assertEquals("message", future.get().getErrors().iterator().next().getMessage());
- testLegacyRpcImpl.verifyInput(legacyTestRpcIdentifier, RPC_INPUT);
-
- // Test exception returned
-
- TestLegacyDOMRpcException rpcEx = new TestLegacyDOMRpcException();
- testLegacyRpcImpl.init(Futures.immediateFailedCheckedFuture(rpcEx));
-
- try {
- mdsalRpcRouter.getRpcService().invokeRpc(mdsalTestRpcIdentifier.getType(), RPC_INPUT).get();
- fail("Expected exception");
- } catch (ExecutionException e) {
- assertEquals(rpcEx, e.getCause());
- }
-
- // Test no input or output
-
- testLegacyRpcImpl.init(Futures.immediateCheckedFuture(null));
-
- future = mdsalRpcRouter.getRpcService().invokeRpc(mdsalTestRpcNoInputIdentifier.getType(), null);
-
- assertNull(future.get());
- testLegacyRpcImpl.verifyInput(legacyTestRpcNoInputIdentifier, null);
- }
-
- @Test
- public void testMdsalRegistrationAndLegacyInvocation() throws InterruptedException, ExecutionException {
- mdsalRpcRouter.getRpcProviderService().registerRpcImplementation(testMdsalRpcImpl, mdsalTestRpcIdentifier,
- mdsalTestRpcNoInputIdentifier);
-
- // Test success
-
- org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult result =
- new org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult(RPC_OUTPUT,
- Collections.singleton(RpcResultBuilder.newError(ErrorType.RPC, "tag", "message")));
- testMdsalRpcImpl.init(FluentFutures.immediateFluentFuture(result));
-
- ListenableFuture<DOMRpcResult> future = legacyRpcRouter.invokeRpc(legacyTestRpcIdentifier.getType(), RPC_INPUT);
-
- assertEquals(RPC_OUTPUT, future.get().getResult());
- assertEquals(1, future.get().getErrors().size());
- assertEquals(ErrorType.RPC, future.get().getErrors().iterator().next().getErrorType());
- assertEquals("tag", future.get().getErrors().iterator().next().getTag());
- assertEquals("message", future.get().getErrors().iterator().next().getMessage());
- testMdsalRpcImpl.verifyInput(mdsalTestRpcIdentifier, RPC_INPUT);
-
- // Test exception returned
-
- TestMdsalDOMRpcException rpcEx = new TestMdsalDOMRpcException();
- testMdsalRpcImpl.init(FluentFutures.immediateFailedFluentFuture(rpcEx));
-
- try {
- legacyRpcRouter.invokeRpc(legacyTestRpcIdentifier.getType(), RPC_INPUT).get();
- fail("Expected exception");
- } catch (ExecutionException e) {
- assertTrue("Unexpected exception " + e.getCause(), e.getCause() instanceof DOMRpcException);
- assertEquals(rpcEx, e.getCause().getCause());
- }
-
- // Test no input or output
-
- testMdsalRpcImpl.init(FluentFutures.immediateNullFluentFuture());
-
- future = legacyRpcRouter.invokeRpc(legacyTestRpcNoInputIdentifier.getType(), null);
-
- assertNull(future.get());
- testMdsalRpcImpl.verifyInput(mdsalTestRpcNoInputIdentifier, null);
- }
-
- @Test
- public void testRegisterRpcListener() {
- final TestLegacyDOMRpcImplementation2 testRpcImpl2 = new TestLegacyDOMRpcImplementation2();
-
- DOMRpcAvailabilityListener listener = mock(DOMRpcAvailabilityListener.class);
- doNothing().when(listener).onRpcAvailable(any());
- doNothing().when(listener).onRpcUnavailable(any());
- doReturn(true).when(listener).acceptsImplementation(any());
- final ListenerRegistration<?> listenerReg = legacyRpcRouter.registerRpcListener(listener);
-
- DOMRpcAvailabilityListener filteredListener = mock(DOMRpcAvailabilityListener.class);
- doNothing().when(filteredListener).onRpcAvailable(any());
- doNothing().when(filteredListener).onRpcUnavailable(any());
- doReturn(true).when(filteredListener).acceptsImplementation(testLegacyRpcImpl);
- doReturn(false).when(filteredListener).acceptsImplementation(testRpcImpl2);
- final ListenerRegistration<?> filteredListenerReg = legacyRpcRouter.registerRpcListener(filteredListener);
-
- final DOMRpcImplementationRegistration<?> testRpcReg =
- legacyRpcRouter.registerRpcImplementation(testLegacyRpcImpl, legacyTestRpcIdentifier);
-
- verify(listener, timeout(5000)).onRpcAvailable(ImmutableList.of(legacyTestRpcIdentifier));
- verify(filteredListener, timeout(5000)).onRpcAvailable(ImmutableList.of(legacyTestRpcIdentifier));
-
- final DOMRpcImplementationRegistration<?> testRpcNoInputReg =
- legacyRpcRouter.registerRpcImplementation(testRpcImpl2, legacyTestRpcNoInputIdentifier);
-
- verify(listener, timeout(5000)).onRpcAvailable(ImmutableList.of(legacyTestRpcNoInputIdentifier));
- verify(filteredListener, after(200).never()).onRpcAvailable(ImmutableList.of(legacyTestRpcNoInputIdentifier));
-
- testRpcReg.close();
-
- verify(listener, timeout(5000)).onRpcUnavailable(ImmutableList.of(legacyTestRpcIdentifier));
- verify(filteredListener, timeout(5000)).onRpcUnavailable(ImmutableList.of(legacyTestRpcIdentifier));
-
- testRpcNoInputReg.close();
-
- verify(listener, timeout(5000)).onRpcUnavailable(ImmutableList.of(legacyTestRpcNoInputIdentifier));
- verify(filteredListener, after(200).never()).onRpcUnavailable(ImmutableList.of(legacyTestRpcNoInputIdentifier));
-
- reset(listener, filteredListener);
-
- listenerReg.close();
- filteredListenerReg.close();
-
- legacyRpcRouter.registerRpcImplementation(testLegacyRpcImpl, legacyTestRpcIdentifier);
-
- verify(listener, after(200).never()).onRpcAvailable(ImmutableList.of(legacyTestRpcIdentifier));
- verify(filteredListener, never()).onRpcAvailable(ImmutableList.of(legacyTestRpcIdentifier));
- }
-
- private static SchemaPath findRpc(SchemaContext schemaContext, String name) {
- Module testModule = schemaContext.findModule("odl-datastore-test", TestModel.TEST_QNAME.getRevision()).get();
- RpcDefinition rpcDefinition = null;
- for (RpcDefinition def: testModule.getRpcs()) {
- if (def.getQName().getLocalName().equals(name)) {
- rpcDefinition = def;
- break;
- }
- }
-
- assertNotNull(name + " rpc not found in " + testModule.getRpcs(), rpcDefinition);
- return rpcDefinition.getPath();
- }
-
- private abstract static class AbstractDOMRpcImplementation<T> {
- Entry<T, NormalizedNode<?, ?>> rpcInput;
-
- void verifyInput(T expRpc, NormalizedNode<?, ?> expInput) {
- assertNotNull(rpcInput);
- assertEquals(expRpc, rpcInput.getKey());
- assertEquals(expInput, rpcInput.getValue());
- }
- }
-
- private static class TestLegacyDOMRpcImplementation extends AbstractDOMRpcImplementation<DOMRpcIdentifier>
- implements DOMRpcImplementation {
- CheckedFuture<DOMRpcResult, DOMRpcException> returnFuture;
-
- @Override
- public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(
- final DOMRpcIdentifier rpc, final NormalizedNode<?, ?> input) {
- rpcInput = new SimpleEntry<>(rpc, input);
- return returnFuture;
- }
-
- void init(CheckedFuture<DOMRpcResult, DOMRpcException> retFuture) {
- this.returnFuture = retFuture;
- rpcInput = null;
- }
- }
-
- private static class TestMdsalDOMRpcImplementation
- extends AbstractDOMRpcImplementation<org.opendaylight.mdsal.dom.api.DOMRpcIdentifier>
- implements org.opendaylight.mdsal.dom.api.DOMRpcImplementation {
- FluentFuture<org.opendaylight.mdsal.dom.api.DOMRpcResult> returnFuture;
-
- @Override
- public FluentFuture<org.opendaylight.mdsal.dom.api.DOMRpcResult> invokeRpc(
- final org.opendaylight.mdsal.dom.api.DOMRpcIdentifier rpc, final NormalizedNode<?, ?> input) {
- rpcInput = new SimpleEntry<>(rpc, input);
- return returnFuture;
- }
-
- void init(FluentFuture<org.opendaylight.mdsal.dom.api.DOMRpcResult> retFuture) {
- this.returnFuture = retFuture;
- rpcInput = null;
- }
- }
-
- private static class TestLegacyDOMRpcImplementation2 implements DOMRpcImplementation {
- @Override
- public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(
- final DOMRpcIdentifier rpc, final NormalizedNode<?, ?> input) {
- return null;
- }
- }
-
- private static class TestLegacyDOMRpcException extends DOMRpcException {
- private static final long serialVersionUID = 1L;
-
- TestLegacyDOMRpcException() {
- super("test");
- }
- }
-
- private static class TestMdsalDOMRpcException extends org.opendaylight.mdsal.dom.api.DOMRpcException {
- private static final long serialVersionUID = 1L;
-
- TestMdsalDOMRpcException() {
- super("test");
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.broker.impl;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION;
-import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.OPERATIONAL;
-
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
-import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
-import org.opendaylight.controller.md.sal.dom.store.impl.TestModel;
-import org.opendaylight.controller.sal.core.spi.data.DOMStore;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
-@Deprecated
-public class DOMTransactionChainTest {
-
- private SchemaContext schemaContext;
- private AbstractDOMDataBroker domBroker;
-
- @Before
- public void setupStore() {
- InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("OPER", MoreExecutors.newDirectExecutorService());
- InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG", MoreExecutors.newDirectExecutorService());
- schemaContext = TestModel.createTestContext();
-
- operStore.onGlobalContextUpdated(schemaContext);
- configStore.onGlobalContextUpdated(schemaContext);
-
- ImmutableMap<LogicalDatastoreType, DOMStore> stores = ImmutableMap.<LogicalDatastoreType, DOMStore>builder() //
- .put(CONFIGURATION, configStore) //
- .put(OPERATIONAL, operStore) //
- .build();
-
- ListeningExecutorService executor = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor());
- domBroker = new SerializedDOMDataBroker(stores, executor);
- }
-
- @Test
- public void testTransactionChainNoConflict() throws InterruptedException, ExecutionException, TimeoutException {
- BlockingTransactionChainListener listener = new BlockingTransactionChainListener();
- DOMTransactionChain txChain = domBroker.createTransactionChain(listener);
- assertNotNull(txChain);
-
- /**
- * We alocate new read-write transaction and write /test.
- */
- DOMDataReadWriteTransaction firstTx = allocateAndWrite(txChain);
-
- /**
- * First transaction is marked as ready, we are able to allocate chained
- * transactions.
- */
- ListenableFuture<?> firstWriteTxFuture = firstTx.commit();
-
- /**
- * We alocate chained transaction - read transaction.
- */
- DOMDataReadTransaction secondReadTx = txChain.newReadOnlyTransaction();
-
- /**
- *
- * We test if we are able to read data from tx, read should not fail
- * since we are using chained transaction.
- */
- assertTestContainerExists(secondReadTx);
-
- /**
- * We alocate next transaction, which is still based on first one, but
- * is read-write.
- *
- */
- DOMDataReadWriteTransaction thirdDeleteTx = allocateAndDelete(txChain);
-
- /**
- * We commit first transaction.
- *
- */
- assertCommitSuccessful(firstWriteTxFuture);
-
- /**
- * Allocates transaction from data store.
- */
- DOMDataReadTransaction storeReadTx = domBroker.newReadOnlyTransaction();
-
- /**
- * We verify transaction is commited to store, container should exists
- * in datastore.
- */
- assertTestContainerExists(storeReadTx);
-
- /**
- * third transaction is sealed and commited.
- */
- ListenableFuture<?> thirdDeleteTxFuture = thirdDeleteTx.commit();
- assertCommitSuccessful(thirdDeleteTxFuture);
-
- /**
- * We close transaction chain.
- */
- txChain.close();
-
- listener.getSuccessFuture().get(1000, TimeUnit.MILLISECONDS);
- }
-
- @Test
- @SuppressWarnings("checkstyle:IllegalCatch")
- public void testTransactionChainNotSealed() throws InterruptedException, ExecutionException {
- BlockingTransactionChainListener listener = new BlockingTransactionChainListener();
- DOMTransactionChain txChain = domBroker.createTransactionChain(listener);
- assertNotNull(txChain);
-
- /**
- * We alocate new read-write transaction and write /test
- */
- allocateAndWrite(txChain);
-
- /**
- * We alocate chained transaction - read transaction, note first one is
- * still not commited to datastore, so this allocation should fail with
- * IllegalStateException.
- */
- try {
- txChain.newReadOnlyTransaction();
- fail("Allocation of secondReadTx should fail with IllegalStateException");
- } catch (Exception e) {
- assertTrue(e instanceof IllegalStateException);
- }
- }
-
- private static DOMDataReadWriteTransaction allocateAndDelete(
- final DOMTransactionChain txChain) throws InterruptedException, ExecutionException {
- DOMDataReadWriteTransaction tx = txChain.newReadWriteTransaction();
-
- /**
- * We test existence of /test in third transaction container should
- * still be visible from first one (which is still uncommmited).
- *
- */
- assertTestContainerExists(tx);
-
- /**
- * We delete node in third transaction
- */
- tx.delete(LogicalDatastoreType.OPERATIONAL, TestModel.TEST_PATH);
- return tx;
- }
-
- private static DOMDataReadWriteTransaction allocateAndWrite(final DOMTransactionChain txChain)
- throws InterruptedException, ExecutionException {
- DOMDataReadWriteTransaction tx = txChain.newReadWriteTransaction();
- assertTestContainerWrite(tx);
- return tx;
- }
-
- private static void assertCommitSuccessful(final ListenableFuture<?> future)
- throws InterruptedException, ExecutionException {
- future.get();
- }
-
- private static void assertTestContainerExists(final DOMDataReadTransaction readTx)
- throws InterruptedException, ExecutionException {
- ListenableFuture<Optional<NormalizedNode<?, ?>>> readFuture = readTx.read(OPERATIONAL, TestModel.TEST_PATH);
- Optional<NormalizedNode<?, ?>> readedData = readFuture.get();
- assertTrue(readedData.isPresent());
- }
-
- private static void assertTestContainerWrite(final DOMDataReadWriteTransaction tx)
- throws InterruptedException, ExecutionException {
- tx.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
- assertTestContainerExists(tx);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.broker.impl;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import com.google.common.base.Optional;
-import org.junit.Before;
-import org.junit.Test;
-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.DOMMountPointService.DOMMountPointBuilder;
-import org.opendaylight.controller.md.sal.dom.broker.impl.mount.DOMMountPointServiceImpl;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-
-@Deprecated
-public class MountPointServiceTest {
-
- private DOMMountPointService mountService;
- private static final YangInstanceIdentifier PATH = YangInstanceIdentifier
- .of(QName.create("namespace", "2012-12-12", "top"));
-
- @Before
- public void setup() {
- mountService = new DOMMountPointServiceImpl();
- }
-
- @Test
- public void createSimpleMountPoint() {
- Optional<DOMMountPoint> mountNotPresent = mountService.getMountPoint(PATH);
- assertFalse(mountNotPresent.isPresent());
- DOMMountPointBuilder mountBuilder = mountService.createMountPoint(PATH);
- mountBuilder.register();
-
- Optional<DOMMountPoint> mountPresent = mountService.getMountPoint(PATH);
- assertTrue(mountPresent.isPresent());
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.dom.broker.impl.legacy.sharded.adapter;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.verify;
-
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.Futures;
-import org.gaul.modernizer_maven_annotations.SuppressModernizer;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Matchers;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
-import org.opendaylight.controller.md.sal.dom.store.impl.TestModel;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
-import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
-
-@Deprecated
-public class ShardedDOMDataBrokerDelegatingReadWriteTransactionTest {
-
- @Mock
- private DOMDataWriteTransaction writeTx;
-
- @Mock
- private DOMDataReadOnlyTransaction readTx;
-
- private ShardedDOMDataBrokerDelegatingReadWriteTransaction rwTx;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- doNothing().when(writeTx).put(any(), any(), any());
- doNothing().when(writeTx).merge(any(), any(), any());
- doNothing().when(writeTx).delete(any(), any());
- rwTx = new ShardedDOMDataBrokerDelegatingReadWriteTransaction("TEST-TX", TestModel.createTestContext(), readTx,
- writeTx);
- }
-
- @Test(expected = IllegalStateException.class)
- public void testFirstReadShouldFail() {
- rwTx.read(LogicalDatastoreType.OPERATIONAL, TestModel.TEST_PATH);
- }
-
- @Test
- public void testGetIdentifier() {
- assertEquals("TEST-TX", rwTx.getIdentifier());
- }
-
- @Test
- @SuppressModernizer
- public void testReadWriteOperations() throws Exception {
- doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(readTx).read(any(), any());
- rwTx.put(LogicalDatastoreType.OPERATIONAL, TestModel.TEST_PATH, testNodeWithOuter(1, 2, 3));
-
- verify(writeTx).put(eq(LogicalDatastoreType.OPERATIONAL), Matchers.eq(TestModel.TEST_PATH),
- Matchers.eq(testNodeWithOuter(1, 2, 3)));
- verify(readTx).read(eq(LogicalDatastoreType.OPERATIONAL), Matchers.eq(TestModel.TEST_PATH));
-
- assertEquals(testNodeWithOuter(1, 2, 3),
- rwTx.read(LogicalDatastoreType.OPERATIONAL, TestModel.TEST_PATH).checkedGet().get());
-
- rwTx.merge(LogicalDatastoreType.OPERATIONAL, TestModel.TEST_PATH, testNodeWithOuter(4, 5, 6));
- assertEquals(testNodeWithOuter(1, 2, 3, 4, 5, 6),
- rwTx.read(LogicalDatastoreType.OPERATIONAL, TestModel.TEST_PATH).checkedGet().get());
-
- rwTx.delete(LogicalDatastoreType.OPERATIONAL, TestModel.TEST_PATH);
-
- verify(writeTx).delete(eq(LogicalDatastoreType.OPERATIONAL), Matchers.eq(TestModel.TEST_PATH));
- assertEquals(Optional.absent(), rwTx.read(LogicalDatastoreType.OPERATIONAL, TestModel.TEST_PATH).checkedGet());
- }
-
- private static DataContainerChild<?, ?> outerNode(final int... ids) {
- CollectionNodeBuilder<MapEntryNode, MapNode> outer = ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME);
- for (int id : ids) {
- outer.addChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, id));
- }
-
- return outer.build();
- }
-
- private static NormalizedNode<?, ?> testNodeWithOuter(final int... ids) {
- return testNodeWithOuter(outerNode(ids));
- }
-
- private static NormalizedNode<?, ?> testNodeWithOuter(final DataContainerChild<?, ?> outer) {
- return ImmutableContainerNodeBuilder.create()
- .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME)).withChild(outer)
- .build();
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. 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.md.sal.dom.broker.impl.legacy.sharded.adapter;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
-import org.opendaylight.controller.md.sal.dom.store.impl.TestModel;
-import org.opendaylight.mdsal.dom.api.DOMDataBroker;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
-import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
-
-@Deprecated
-public class ShardedDOMDataBrokerDelegatingTransactionChainTest {
-
- @Mock
- private DOMDataBroker dataBroker;
-
- @Mock
- private DOMTransactionChain delegateTxChain;
-
- @Mock
- private TransactionChainListener txChainlistener;
-
- private ShardedDOMDataBrokerDelegatingTransactionChain txChain;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
-
- doReturn(delegateTxChain).when(dataBroker).createTransactionChain(any());
- txChain = new ShardedDOMDataBrokerDelegatingTransactionChain("1", TestModel.createTestContext(), dataBroker,
- txChainlistener);
- }
-
- @Test
- public void testClose() {
- doNothing().when(delegateTxChain).close();
- txChain.close();
- verify(delegateTxChain).close();
- }
-
- @Test
- public void testNewWriteTransaction() {
- DOMDataTreeWriteTransaction delegateWriteTx = mock(DOMDataTreeWriteTransaction.class);
- doReturn(delegateWriteTx).when(delegateTxChain).newWriteOnlyTransaction();
- doReturn("TEST-WRITE-TX-DELEGATE").when(delegateWriteTx).getIdentifier();
- txChain.newWriteOnlyTransaction();
- verify(delegateTxChain).newWriteOnlyTransaction();
- }
-
- @Test
- public void testNewReadOnlyTransaction() {
- DOMDataTreeReadTransaction delegateReadTx = mock(DOMDataTreeReadTransaction.class);
- doReturn("TEST-READ-TX-DELEGATE").when(delegateReadTx).getIdentifier();
- doReturn(delegateReadTx).when(delegateTxChain).newReadOnlyTransaction();
- txChain.newReadOnlyTransaction();
- verify(delegateTxChain).newReadOnlyTransaction();
- }
-
-
- @Test
- public void testNewReadWriteTransaction() {
- DOMDataTreeReadTransaction delegateReadTx = mock(DOMDataTreeReadTransaction.class);
- doReturn("TEST-READ-TX-DELEGATE").when(delegateReadTx).getIdentifier();
- doReturn(delegateReadTx).when(delegateTxChain).newReadOnlyTransaction();
-
- DOMDataTreeWriteTransaction delegateWriteTx = mock(DOMDataTreeWriteTransaction.class);
- doReturn(delegateWriteTx).when(delegateTxChain).newWriteOnlyTransaction();
- doReturn("TEST-WRITE-TX-DELEGATE").when(delegateWriteTx).getIdentifier();
-
- txChain.newReadWriteTransaction();
- verify(delegateTxChain).newReadOnlyTransaction();
- verify(delegateTxChain).newWriteOnlyTransaction();
- }
-
- @Test
- public void testTransactionChainFailed() {
- final DOMDataTreeWriteTransaction writeTxDelegate = mock(DOMDataTreeWriteTransaction.class);
- doReturn("DELEGATE-WRITE-TX-1").when(writeTxDelegate).getIdentifier();
- doReturn(writeTxDelegate).when(delegateTxChain).newWriteOnlyTransaction();
- doNothing().when(txChainlistener).onTransactionChainFailed(any(), any(), any());
-
- // verify writetx fail
- txChain.newWriteOnlyTransaction();
- txChain.onTransactionChainFailed(delegateTxChain, writeTxDelegate, new Throwable("Fail"));
-
- final ArgumentCaptor<AsyncTransaction> txCaptor = ArgumentCaptor.forClass(AsyncTransaction.class);
- final ArgumentCaptor<Throwable> throwableCaptor = ArgumentCaptor.forClass(Throwable.class);
- verify(txChainlistener).onTransactionChainFailed(eq(txChain), txCaptor.capture(), throwableCaptor.capture());
- assertEquals("DOM-CHAIN-1-0", txCaptor.getValue().getIdentifier());
- assertEquals("Fail", throwableCaptor.getValue().getMessage());
-
- // verify readtx fail
- final DOMDataTreeReadTransaction readTxDelegate = mock(DOMDataTreeReadTransaction.class);
- doReturn("DELEGATE-READ-TX-1").when(readTxDelegate).getIdentifier();
- doReturn(readTxDelegate).when(delegateTxChain).newReadOnlyTransaction();
- doNothing().when(txChainlistener).onTransactionChainFailed(any(), any(), any());
- txChain.newReadOnlyTransaction();
- txChain.onTransactionChainFailed(delegateTxChain, readTxDelegate, new Throwable("Fail"));
- verify(txChainlistener, times(2))
- .onTransactionChainFailed(eq(txChain), txCaptor.capture(), throwableCaptor.capture());
- assertEquals("DOM-CHAIN-1-1", txCaptor.getValue().getIdentifier());
- assertEquals("Fail", throwableCaptor.getValue().getMessage());
-
-
- // verify readwritetx fail, we must check both read and write failure
- // translates to returned readwritetx
-
- // we can reuse write and read tx delegates, just return different
- // identifiers to avoid conflicts in keys in tx dictionary
- doReturn("DELEGATE-WRITE-RWTX-1").when(writeTxDelegate).getIdentifier();
- doReturn("DELEGATE-READ-RWTX-1").when(readTxDelegate).getIdentifier();
- txChain.newReadWriteTransaction();
- txChain.onTransactionChainFailed(delegateTxChain, writeTxDelegate, new Throwable("Fail"));
- verify(txChainlistener, times(3))
- .onTransactionChainFailed(eq(txChain), txCaptor.capture(), throwableCaptor.capture());
- assertEquals("DOM-CHAIN-1-2", txCaptor.getValue().getIdentifier());
- assertEquals("Fail", throwableCaptor.getValue().getMessage());
-
- txChain.onTransactionChainFailed(delegateTxChain, readTxDelegate, new Throwable("Fail"));
- verify(txChainlistener, times(4))
- .onTransactionChainFailed(eq(txChain), txCaptor.capture(), throwableCaptor.capture());
- assertEquals("DOM-CHAIN-1-2", txCaptor.getValue().getIdentifier());
- assertEquals("Fail", throwableCaptor.getValue().getMessage());
- }
-
- @Test
- public void testTransactionChainSuccessful() {
- doNothing().when(txChainlistener).onTransactionChainSuccessful(any());
- txChain.onTransactionChainSuccessful(delegateTxChain);
- verify(txChainlistener).onTransactionChainSuccessful(eq(txChain));
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.store.impl;
-
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-
-@Deprecated
-public final class TestModel {
-
- private TestModel() {
- }
-
- public static final QName TEST_QNAME =
- QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13", "test");
- public static final QName TEST2_QNAME =
- QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13", "test2");
- public static final QName OUTER_LIST_QNAME = QName.create(TEST_QNAME, "outer-list");
- public static final QName INNER_LIST_QNAME = QName.create(TEST_QNAME, "inner-list");
- public static final QName OUTER_CHOICE_QNAME = QName.create(TEST_QNAME, "outer-choice");
- public static final QName ID_QNAME = QName.create(TEST_QNAME, "id");
- public static final QName NAME_QNAME = QName.create(TEST_QNAME, "name");
- public static final QName VALUE_QNAME = QName.create(TEST_QNAME, "value");
- public static final QName TWO_QNAME = QName.create(TEST_QNAME,"two");
- public static final QName THREE_QNAME = QName.create(TEST_QNAME,"three");
- public static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier.of(TEST_QNAME);
- public static final YangInstanceIdentifier TEST2_PATH = YangInstanceIdentifier.of(TEST2_QNAME);
- public static final YangInstanceIdentifier OUTER_LIST_PATH =
- YangInstanceIdentifier.builder(TEST_PATH).node(OUTER_LIST_QNAME).build();
- private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang";
-
- public static SchemaContext createTestContext() {
- return YangParserTestUtils.parseYangResource(DATASTORE_TEST_YANG);
- }
-}
+++ /dev/null
-module odl-datastore-test {
- yang-version 1;
- namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test";
- prefix "store-test";
-
- revision "2014-03-13" {
- description "Initial revision.";
- }
-
- container test {
- presence "needs to be present when empty";
-
- list outer-list {
- key id;
- leaf id {
- type uint16;
- }
- choice outer-choice {
- case one {
- leaf one {
- type string;
- }
- }
- case two-three {
- leaf two {
- type string;
- }
- leaf three {
- type string;
- }
- }
- }
- list inner-list {
- key name;
- leaf name {
- type string;
- }
- leaf value {
- type string;
- }
- }
- }
- }
-
- container test2 {
- }
-
- rpc test-rpc {
- input {
- leaf input-leaf {
- type string;
- }
- }
-
- output {
- leaf output-leaf {
- type string;
- }
- }
- }
-
- rpc test-rpc-no-input {
- }
-
- notification test-notification {
- leaf value-leaf {
- type string;
- }
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-parent</artifactId>
- <version>1.12.0-SNAPSHOT</version>
- <relativePath>../parent</relativePath>
- </parent>
-
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-core-compat</artifactId>
- <version>1.12.0-SNAPSHOT</version>
- <packaging>bundle</packaging>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-core-spi</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-dom-spi</artifactId>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-dom-broker</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <scm>
- <connection>scm:git:http://git.opendaylight.org/gerrit/controller.git</connection>
- <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
- <tag>HEAD</tag>
- <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
- </scm>
-
-</project>
+++ /dev/null
-/*
- * Copyright (c) 2018 Inocybe Technologies 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 com.google.common.util.concurrent.AbstractFuture;
-import com.google.common.util.concurrent.ListenableFuture;
-import java.util.Optional;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Executor;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import org.opendaylight.mdsal.dom.api.DOMRpcException;
-import org.opendaylight.mdsal.dom.api.DOMRpcResult;
-import org.opendaylight.yangtools.util.concurrent.ExceptionMapper;
-
-/**
- * Base for a DOMRpcResult future adapter.
- *
- * @author Thomas Pantelis
- */
-@Deprecated(forRemoval = true)
-@SuppressWarnings("checkstyle:ClassTypeParameterName")
-public abstract class AbstractDOMRpcResultFutureAdapter<T extends DOMRpcResult, F extends DOMRpcResult,
- D extends ListenableFuture<F>, E extends DOMRpcException> extends AbstractFuture<T> {
- private final D delegate;
- private final ExceptionMapper<E> exMapper;
- private volatile Optional<T> result;
-
- AbstractDOMRpcResultFutureAdapter(D delegate, ExceptionMapper<E> exMapper) {
- this.delegate = delegate;
- this.exMapper = exMapper;
- }
-
- protected abstract T transform(F fromResult);
-
- public D delegate() {
- return delegate;
- }
-
- @Override
- public void addListener(Runnable listener, Executor executor) {
- delegate.addListener(listener, executor);
- }
-
- @Override
- public boolean cancel(boolean mayInterruptIfRunning) {
- return delegate.cancel(mayInterruptIfRunning);
- }
-
- @Override
- public boolean isCancelled() {
- return delegate.isCancelled();
- }
-
- @Override
- public boolean isDone() {
- return delegate.isDone();
- }
-
- @Override
- public T get() throws InterruptedException, ExecutionException {
- if (result != null) {
- return result.orElse(null);
- }
-
- try {
- return transformIfNecessary(delegate.get());
- } catch (ExecutionException e) {
- throw new ExecutionException(e.getMessage(), exMapper.apply(e));
- }
- }
-
- @Override
- public T get(final long timeout, final TimeUnit unit) throws InterruptedException, ExecutionException,
- TimeoutException {
- if (result != null) {
- return result.orElse(null);
- }
-
- try {
- return transformIfNecessary(delegate.get(timeout, unit));
- } catch (ExecutionException e) {
- throw new ExecutionException(e.getMessage(), exMapper.apply(e));
- }
- }
-
- private synchronized T transformIfNecessary(F delegateResult) {
- if (result == null) {
- if (delegateResult == null) {
- result = Optional.empty();
- } else {
- result = Optional.of(transform(delegateResult));
- }
- }
-
- return result.orElse(null);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Inocybe Technologies 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.base.Optional;
-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 com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.FluentFuture;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.MoreExecutors;
-import com.google.common.util.concurrent.SettableFuture;
-import java.util.Collection;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.function.Supplier;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.controller.md.sal.common.api.MappingCheckedFuture;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.DataStoreUnavailableException;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.OptimisticLockFailedException;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionChainClosedException;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.controller.md.sal.dom.api.ClusteredDOMDataTreeChangeListener;
-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.DOMDataReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
-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.DOMDataTreeCommitCohortRegistry;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeIdentifier;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
-import org.opendaylight.mdsal.common.api.CommitInfo;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeReadOperations;
-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.DOMTransactionChainClosedException;
-import org.opendaylight.mdsal.dom.api.DOMTransactionChainListener;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.util.concurrent.ExceptionMapper;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
-
-/**
- * Adapter between the legacy controller API-based DOMDataBroker and the mdsal API-based DOMDataBroker.
- *
- * @author Thomas Pantelis
- */
-@Deprecated(forRemoval = true)
-public abstract class AbstractLegacyDOMDataBrokerAdapter extends ForwardingObject implements DOMDataBroker {
- private static final ExceptionMapper<TransactionCommitFailedException> COMMIT_EX_MAPPER =
- new ExceptionMapper<TransactionCommitFailedException>("commit", TransactionCommitFailedException.class) {
- @Override
- protected TransactionCommitFailedException newWithCause(final String message, final Throwable cause) {
- if (cause instanceof org.opendaylight.mdsal.common.api.OptimisticLockFailedException) {
- return new OptimisticLockFailedException(cause.getMessage(), cause.getCause());
- } else if (cause instanceof org.opendaylight.mdsal.common.api.TransactionCommitFailedException) {
- Throwable rootCause = cause.getCause();
- if (rootCause instanceof org.opendaylight.mdsal.common.api.DataStoreUnavailableException) {
- rootCause = new DataStoreUnavailableException(rootCause.getMessage(), rootCause.getCause());
- }
-
- return new TransactionCommitFailedException(cause.getMessage(), rootCause);
- }
-
- return new TransactionCommitFailedException(message, cause);
- }
- };
-
- private final org.opendaylight.mdsal.dom.api.DOMDataBroker delegate;
- private final ClassToInstanceMap<DOMDataBrokerExtension> extensions;
-
- public AbstractLegacyDOMDataBrokerAdapter(final org.opendaylight.mdsal.dom.api.DOMDataBroker delegate) {
- this.delegate = delegate;
-
- ClassToInstanceMap<org.opendaylight.mdsal.dom.api.DOMDataBrokerExtension> delegateExtensions =
- delegate.getExtensions();
-
- Builder<DOMDataBrokerExtension> extBuilder = ImmutableClassToInstanceMap.builder();
- final org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService delegateTreeChangeService =
- (org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService) delegateExtensions.get(
- org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService.class);
- if (delegateTreeChangeService != null) {
- extBuilder.put(DOMDataTreeChangeService.class, new DOMDataTreeChangeService() {
- @Override
- public <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerDataTreeChangeListener(
- final DOMDataTreeIdentifier treeId, final L listener) {
- final org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener delegateListener;
- if (listener instanceof ClusteredDOMDataTreeChangeListener) {
- delegateListener = new ClusteredProxyListener(listener);
- } else {
- delegateListener = new ProxyListener(listener);
- }
-
- final ListenerRegistration<org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener> reg =
- delegateTreeChangeService.registerDataTreeChangeListener(treeId.toMdsal(), delegateListener);
-
- return new ListenerRegistration<L>() {
- @Override
- public L getInstance() {
- return listener;
- }
-
- @Override
- public void close() {
- reg.close();
- }
- };
- }
- });
- }
-
- final org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry delegateCohortRegistry =
- (org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry) delegateExtensions.get(
- org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry.class);
- if (delegateCohortRegistry != null) {
- extBuilder.put(DOMDataTreeCommitCohortRegistry.class, delegateCohortRegistry::registerCommitCohort);
- }
-
- extensions = extBuilder.build();
- }
-
- @Override
- protected org.opendaylight.mdsal.dom.api.DOMDataBroker delegate() {
- return delegate;
- }
-
- @Override
- public Map<Class<? extends DOMDataBrokerExtension>, DOMDataBrokerExtension> getSupportedExtensions() {
- return extensions;
- }
-
- @Override
- public DOMDataReadOnlyTransaction newReadOnlyTransaction() {
- return new DOMDataReadOnlyTransactionAdapter(delegate().newReadOnlyTransaction());
- }
-
- @Override
- public DOMDataReadWriteTransaction newReadWriteTransaction() {
- return new DOMDataTransactionAdapter(delegate().newReadWriteTransaction());
- }
-
- @Override
- public DOMDataWriteTransaction newWriteOnlyTransaction() {
- return new DOMDataTransactionAdapter(delegate().newWriteOnlyTransaction());
- }
-
- @Override
- public DOMTransactionChain createTransactionChain(final TransactionChainListener listener) {
- AtomicReference<DOMTransactionChain> legacyChain = new AtomicReference<>();
- DOMTransactionChainListener delegateListener =
- new DOMTransactionChainListener() {
- @Override
- @SuppressWarnings("rawtypes")
- public void onTransactionChainFailed(final org.opendaylight.mdsal.dom.api.DOMTransactionChain chain,
- final DOMDataTreeTransaction transaction, final Throwable cause) {
- listener.onTransactionChainFailed(legacyChain.get(),
- (AsyncTransaction) () -> transaction.getIdentifier(),
- cause instanceof Exception ? COMMIT_EX_MAPPER.apply((Exception)cause) : cause);
- }
-
- @Override
- public void onTransactionChainSuccessful(final org.opendaylight.mdsal.dom.api.DOMTransactionChain chain) {
- listener.onTransactionChainSuccessful(legacyChain.get());
- }
- };
-
- final org.opendaylight.mdsal.dom.api.DOMTransactionChain delegateChain =
- delegate().createTransactionChain(delegateListener);
- legacyChain.set(new DOMTransactionChain() {
- @Override
- public DOMDataReadOnlyTransaction newReadOnlyTransaction() {
- return new DOMDataReadOnlyTransactionAdapter(wrapException(delegateChain::newReadOnlyTransaction));
- }
-
- @Override
- public DOMDataReadWriteTransaction newReadWriteTransaction() {
- return new DOMDataTransactionAdapter(wrapException(delegateChain::newReadWriteTransaction));
- }
-
- @Override
- public DOMDataWriteTransaction newWriteOnlyTransaction() {
- return new DOMDataTransactionAdapter(wrapException(delegateChain::newWriteOnlyTransaction));
- }
-
- @Override
- public void close() {
- delegateChain.close();
- }
- });
-
- return legacyChain.get();
- }
-
- abstract org.opendaylight.mdsal.dom.api.DOMTransactionChain createDelegateChain(
- DOMTransactionChainListener listener);
-
- static <T> T wrapException(final Supplier<T> supplier) {
- try {
- return supplier.get();
- } catch (DOMTransactionChainClosedException e) {
- throw new TransactionChainClosedException("Transaction chain already closed", e);
- }
- }
-
- private static class DOMDataTransactionAdapter implements DOMDataReadWriteTransaction {
- private final DOMDataTreeReadOperations readDelegate;
- private final DOMDataTreeWriteTransaction writeDelegate;
- private final Object identifier;
-
- DOMDataTransactionAdapter(final @NonNull DOMDataTreeReadOperations readDelegate, final Object identifier) {
- this.readDelegate = requireNonNull(readDelegate);
- this.identifier = requireNonNull(identifier);
- this.writeDelegate = null;
- }
-
- DOMDataTransactionAdapter(final @NonNull DOMDataTreeWriteTransaction writeDelegate) {
- this.writeDelegate = requireNonNull(writeDelegate);
- this.identifier = writeDelegate.getIdentifier();
- this.readDelegate = null;
- }
-
- DOMDataTransactionAdapter(final @NonNull DOMDataTreeReadWriteTransaction rwDelegate) {
- this.readDelegate = requireNonNull(rwDelegate);
- this.writeDelegate = rwDelegate;
- this.identifier = rwDelegate.getIdentifier();
- }
-
- DOMDataTreeReadOperations readDelegate() {
- return readDelegate;
- }
-
- DOMDataTreeWriteTransaction writeDelegate() {
- return writeDelegate;
- }
-
- @Override
- public Object getIdentifier() {
- return identifier;
- }
-
- @Override
- 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(final LogicalDatastoreType store,
- final YangInstanceIdentifier path) {
- return MappingCheckedFuture.create(readDelegate().exists(store.toMdsal(), path),
- ReadFailedExceptionAdapter.INSTANCE);
- }
-
- @Override
- public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
- writeDelegate().delete(store.toMdsal(), path);
- }
-
- @Override
- public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path,
- final NormalizedNode<?, ?> data) {
- writeDelegate().put(store.toMdsal(), path, data);
- }
-
- @Override
- public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path,
- final NormalizedNode<?, ?> data) {
- writeDelegate().merge(store.toMdsal(), path, data);
- }
-
- @Override
- public boolean cancel() {
- return writeDelegate().cancel();
- }
-
- @Override
- public FluentFuture<? extends CommitInfo> commit() {
- final SettableFuture<CommitInfo> resultFuture = SettableFuture.create();
- writeDelegate().commit().addCallback(new FutureCallback<CommitInfo>() {
- @Override
- public void onSuccess(final CommitInfo result) {
- resultFuture.set(result);
- }
-
- @Override
- public void onFailure(final Throwable ex) {
- if (ex instanceof Exception) {
- resultFuture.setException(COMMIT_EX_MAPPER.apply((Exception)ex));
- } else {
- resultFuture.setException(ex);
- }
- }
- }, MoreExecutors.directExecutor());
-
- return FluentFuture.from(resultFuture);
- }
- }
-
- private static class DOMDataReadOnlyTransactionAdapter implements DOMDataReadOnlyTransaction {
- private final DOMDataTreeReadTransaction transaction;
- private final DOMDataTransactionAdapter adapter;
-
- DOMDataReadOnlyTransactionAdapter(final DOMDataTreeReadTransaction delegateTx) {
- this.transaction = requireNonNull(delegateTx);
- adapter = new DOMDataTransactionAdapter(delegateTx, transaction.getIdentifier());
- }
-
- @Override
- public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final LogicalDatastoreType store,
- final YangInstanceIdentifier path) {
- return adapter.read(store, path);
- }
-
- @Override
- public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store,
- final YangInstanceIdentifier path) {
- return adapter.exists(store, path);
- }
-
- @Override
- public Object getIdentifier() {
- return adapter.getIdentifier();
- }
-
- @Override
- public void close() {
- transaction.close();
- }
- }
-
- private static class ProxyListener extends ForwardingObject
- implements org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener {
- private final DOMDataTreeChangeListener delegate;
-
- ProxyListener(final DOMDataTreeChangeListener delegate) {
- this.delegate = requireNonNull(delegate);
- }
-
- @Override
- public void onDataTreeChanged(Collection<DataTreeCandidate> changes) {
- delegate.onDataTreeChanged(changes);
- }
-
- @Override
- protected DOMDataTreeChangeListener delegate() {
- return delegate;
- }
- }
-
- private static final class ClusteredProxyListener extends ProxyListener
- implements org.opendaylight.mdsal.dom.api.ClusteredDOMDataTreeChangeListener {
-
- ClusteredProxyListener(DOMDataTreeChangeListener delegate) {
- super(delegate);
- }
- }
-}
+++ /dev/null
-/*
- * 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;
-import org.opendaylight.mdsal.dom.spi.PingPongMergingDOMDataBroker;
-
-@Deprecated(forRemoval = true)
-public class DOMDataBrokerAdapter extends ForwardingObject implements PingPongMergingDOMDataBroker {
- 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;
- }
-}
+++ /dev/null
-/*
- * 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(forRemoval = true)
-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;
- }
-}
+++ /dev/null
-/*
- * 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;
-
-@Deprecated(forRemoval = true)
-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;
- }
-}
+++ /dev/null
-/*
- * 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;
-
-@Deprecated(forRemoval = true)
-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 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;
- }
-}
+++ /dev/null
-/*
- * 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;
-
-@Deprecated(forRemoval = true)
-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;
- }
-}
+++ /dev/null
-/*
- * 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.base.Optional;
-import com.google.common.collect.ForwardingObject;
-import com.google.common.collect.ImmutableMap;
-import java.util.Map;
-import org.eclipse.jdt.annotation.Nullable;
-import org.gaul.modernizer_maven_annotations.SuppressModernizer;
-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.DOMNotificationService;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
-import org.opendaylight.controller.md.sal.dom.api.DOMService;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
-/**
- * Adapter providing Controller DOMMountPoint implementation based on an MD-SAL DOMMountPoint delegate. Services are
- * looked up in the delegate first. If a lookup is unsuccessful, this class attempts to transparently proxy well-known
- * Controller DOMServices on top of their MD-SAL counterparts available from delegate.
- */
-@Deprecated(forRemoval = true)
-public class DOMMountPointAdapter extends ForwardingObject implements DOMMountPoint {
- private abstract static class CompatFactory<M extends org.opendaylight.mdsal.dom.api.DOMService,
- C extends DOMService> {
- private final Class<M> mdsalClass;
-
- CompatFactory(final Class<M> mdsalClass) {
- this.mdsalClass = requireNonNull(mdsalClass);
- }
-
- final @Nullable C createService(final org.opendaylight.mdsal.dom.api.DOMMountPoint mountPoint) {
- return mountPoint.getService(mdsalClass).map(this::createService).orElse(null);
- }
-
- abstract C createService(M delegate);
- }
-
- private static final Map<Class<? extends DOMService>, CompatFactory<?, ?>> KNOWN_SERVICES = ImmutableMap.of(
- DOMActionService.class, new CompatFactory<org.opendaylight.mdsal.dom.api.DOMActionService, DOMActionService>(
- org.opendaylight.mdsal.dom.api.DOMActionService.class) {
- @Override
- DOMActionService createService(final org.opendaylight.mdsal.dom.api.DOMActionService delegate) {
- return new LegacyDOMActionServiceAdapter(delegate);
- }
- },
- DOMDataBroker.class, new CompatFactory<org.opendaylight.mdsal.dom.api.DOMDataBroker, DOMDataBroker>(
- org.opendaylight.mdsal.dom.api.DOMDataBroker.class) {
- @Override
- DOMDataBroker createService(final org.opendaylight.mdsal.dom.api.DOMDataBroker delegate) {
- return new LegacyDOMDataBrokerAdapter(delegate);
- }
- },
- DOMNotificationService.class, new CompatFactory<org.opendaylight.mdsal.dom.api.DOMNotificationService,
- DOMNotificationService>(org.opendaylight.mdsal.dom.api.DOMNotificationService.class) {
- @Override
- DOMNotificationService createService(final org.opendaylight.mdsal.dom.api.DOMNotificationService delegate) {
- return new LegacyDOMNotificationServiceAdapter(delegate);
- }
- },
- DOMRpcService.class, new CompatFactory<org.opendaylight.mdsal.dom.api.DOMRpcService, DOMRpcService>(
- org.opendaylight.mdsal.dom.api.DOMRpcService.class) {
- @Override
- DOMRpcService createService(final org.opendaylight.mdsal.dom.api.DOMRpcService delegate) {
- return new LegacyDOMRpcServiceAdapter(delegate);
- }
- });
-
- private final org.opendaylight.mdsal.dom.api.DOMMountPoint delegate;
-
- public DOMMountPointAdapter(final org.opendaylight.mdsal.dom.api.DOMMountPoint delegate) {
- this.delegate = requireNonNull(delegate);
- }
-
- @Override
- public YangInstanceIdentifier getIdentifier() {
- return delegate().getIdentifier();
- }
-
- @Override
- @SuppressModernizer
- public <T extends DOMService> Optional<T> getService(final Class<T> cls) {
- final java.util.Optional<T> found = delegate.getService(cls);
- if (found.isPresent()) {
- return Optional.of(found.get());
- }
-
- final CompatFactory<?, ?> compat = KNOWN_SERVICES.get(cls);
- return Optional.fromNullable(cls.cast(compat == null ? null : compat.createService(delegate)));
- }
-
- @Override
- public SchemaContext getSchemaContext() {
- return delegate().getSchemaContext();
- }
-
- @Override
- public int hashCode() {
- return getIdentifier().hashCode();
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (!(obj instanceof DOMMountPoint)) {
- return false;
- }
-
- DOMMountPoint other = (DOMMountPoint) obj;
- return getIdentifier().equals(other.getIdentifier());
- }
-
- @Override
- protected org.opendaylight.mdsal.dom.api.DOMMountPoint delegate() {
- return delegate;
- }
-}
+++ /dev/null
-/*
- * 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(forRemoval = true)
-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;
- }
-}
+++ /dev/null
-/*
- * 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.ListenableFuture;
-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(forRemoval = true)
-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 ListenableFuture<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());
- }
-}
+++ /dev/null
-/*
- * 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 com.google.common.collect.ForwardingObject;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
-import org.opendaylight.controller.sal.core.spi.data.DOMStore;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTreeChangePublisher;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
-import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-
-@Deprecated(forRemoval = true)
-public abstract class DOMStoreAdapter<T extends org.opendaylight.mdsal.dom.spi.store.DOMStore
- & org.opendaylight.mdsal.dom.spi.store.DOMStoreTreeChangePublisher> extends ForwardingObject
- implements DOMStore, DOMStoreTreeChangePublisher {
- @Override
- protected abstract T delegate();
-
- @Override
- public DOMStoreReadTransaction newReadOnlyTransaction() {
- return new DOMStoreReadTransactionAdapter<>(delegate().newReadOnlyTransaction());
- }
-
- @Override
- public DOMStoreReadWriteTransaction newReadWriteTransaction() {
- return new DOMStoreReadWriteTransactionAdapter(delegate().newReadWriteTransaction());
- }
-
- @Override
- public DOMStoreWriteTransaction newWriteOnlyTransaction() {
- return new DOMStoreWriteTransactionAdapter(delegate().newWriteOnlyTransaction());
- }
-
- @Override
- public DOMStoreTransactionChain createTransactionChain() {
- return new DOMStoreTransactionChainAdapter(delegate().createTransactionChain());
- }
-
- @Override
- public <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerTreeChangeListener(
- final YangInstanceIdentifier treeId, final L listener) {
- final ListenerRegistration<?> reg = delegate().registerTreeChangeListener(treeId, listener::onDataTreeChanged);
- return new AbstractListenerRegistration<L>(listener) {
- @Override
- protected void removeRegistration() {
- reg.close();
- }
- };
- }
-}
+++ /dev/null
-/*
- * 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.base.Optional;
-import com.google.common.collect.ForwardingObject;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.MoreExecutors;
-import org.opendaylight.controller.md.sal.common.api.MappingCheckedFuture;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-@Deprecated(forRemoval = true)
-public class DOMStoreReadTransactionAdapter<T extends org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction>
- extends ForwardingObject implements DOMStoreReadTransaction {
- private final T delegate;
-
- public DOMStoreReadTransactionAdapter(final T delegate) {
- this.delegate = requireNonNull(delegate);
- }
-
- @Override
- protected T delegate() {
- return delegate;
- }
-
- @Override
- public Object getIdentifier() {
- return delegate.getIdentifier();
- }
-
- @Override
- public void close() {
- delegate.close();
- }
-
- @Override
- public CheckedFuture<com.google.common.base.Optional<NormalizedNode<?, ?>>, ReadFailedException> read(
- final YangInstanceIdentifier path) {
- return MappingCheckedFuture.create(delegate.read(path).transform(
- Optional::fromJavaUtil, MoreExecutors.directExecutor()), ReadFailedExceptionAdapter.INSTANCE);
- }
-
- @Override
- public CheckedFuture<Boolean, ReadFailedException> exists(final YangInstanceIdentifier path) {
- return MappingCheckedFuture.create(delegate.exists(path), ReadFailedExceptionAdapter.INSTANCE);
- }
-}
+++ /dev/null
-/*
- * 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 org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-@Deprecated(forRemoval = true)
-public class DOMStoreReadWriteTransactionAdapter
- extends DOMStoreReadTransactionAdapter<org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction>
- implements DOMStoreReadWriteTransaction {
- public DOMStoreReadWriteTransactionAdapter(
- final org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction delegate) {
- super(delegate);
- }
-
- @Override
- public void write(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
- delegate().write(path, data);
- }
-
- @Override
- public DOMStoreThreePhaseCommitCohort ready() {
- return new DOMStoreThreePhaseCommitCohortAdapter(delegate().ready());
- }
-
- @Override
- public void merge(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
- delegate().merge(path, data);
- }
-
- @Override
- public void delete(final YangInstanceIdentifier path) {
- delegate().delete(path);
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * 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.ListenableFuture;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
-
-@Deprecated(forRemoval = true)
-public class DOMStoreThreePhaseCommitCohortAdapter extends ForwardingObject implements DOMStoreThreePhaseCommitCohort {
- private final org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort delegate;
-
- public DOMStoreThreePhaseCommitCohortAdapter(
- final org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort delegate) {
- this.delegate = requireNonNull(delegate);
- }
-
- @Override
- protected org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort delegate() {
- return delegate;
- }
-
- @Override
- public ListenableFuture<Void> preCommit() {
- return delegate.preCommit();
- }
-
- @Override
- public ListenableFuture<Void> commit() {
- return delegate.commit();
- }
-
- @Override
- public ListenableFuture<Boolean> canCommit() {
- return delegate.canCommit();
- }
-
- @Override
- public ListenableFuture<Void> abort() {
- return delegate.abort();
- }
-}
+++ /dev/null
-/*
- * 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.sal.core.spi.data.DOMStoreReadTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
-
-@Deprecated(forRemoval = true)
-public class DOMStoreTransactionChainAdapter extends ForwardingObject implements DOMStoreTransactionChain {
- private final org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain delegate;
-
- public DOMStoreTransactionChainAdapter(
- final org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain delegate) {
- this.delegate = requireNonNull(delegate);
- }
-
- @Override
- protected org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain delegate() {
- return delegate;
- }
-
- @Override
- public DOMStoreWriteTransaction newWriteOnlyTransaction() {
- return new DOMStoreWriteTransactionAdapter(delegate.newWriteOnlyTransaction());
- }
-
- @Override
- public DOMStoreReadWriteTransaction newReadWriteTransaction() {
- return new DOMStoreReadWriteTransactionAdapter(delegate.newReadWriteTransaction());
- }
-
- @Override
- public DOMStoreReadTransaction newReadOnlyTransaction() {
- return new DOMStoreReadTransactionAdapter<>(delegate.newReadOnlyTransaction());
- }
-
- @Override
- public void close() {
- delegate.close();
- }
-}
+++ /dev/null
-/*
- * 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.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-@Deprecated(forRemoval = true)
-public class DOMStoreWriteTransactionAdapter extends ForwardingObject implements DOMStoreWriteTransaction {
- private final org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction delegate;
-
- public DOMStoreWriteTransactionAdapter(
- final org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction delegate) {
- this.delegate = requireNonNull(delegate);
- }
-
- @Override
- protected org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction delegate() {
- return delegate;
- }
-
- @Override
- public Object getIdentifier() {
- return delegate.getIdentifier();
- }
-
- @Override
- public void close() {
- delegate.close();
- }
-
- @Override
- public void write(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
- delegate.write(path, data);
- }
-
- @Override
- public DOMStoreThreePhaseCommitCohort ready() {
- return new DOMStoreThreePhaseCommitCohortAdapter(delegate.ready());
- }
-
- @Override
- public void merge(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
- delegate.merge(path, data);
- }
-
- @Override
- public void delete(final YangInstanceIdentifier path) {
- delegate.delete(path);
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * 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(forRemoval = true)
-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 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);
- }
-}
+++ /dev/null
-/*
- * 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.util.concurrent.ListenableFuture;
-import org.opendaylight.controller.md.sal.dom.api.DOMActionService;
-import org.opendaylight.mdsal.dom.api.DOMActionResult;
-import org.opendaylight.mdsal.dom.api.DOMActionServiceExtension;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-
-@Deprecated(forRemoval = true)
-public class LegacyDOMActionServiceAdapter extends ForwardingObject implements DOMActionService {
- private final org.opendaylight.mdsal.dom.api.DOMActionService delegate;
-
- public LegacyDOMActionServiceAdapter(final org.opendaylight.mdsal.dom.api.DOMActionService delegate) {
- this.delegate = requireNonNull(delegate);
- }
-
- @Override
- protected org.opendaylight.mdsal.dom.api.DOMActionService delegate() {
- return delegate;
- }
-
- @Override
- public ListenableFuture<? extends DOMActionResult> invokeAction(final SchemaPath type,
- final DOMDataTreeIdentifier path, final ContainerNode input) {
- return delegate.invokeAction(type, path, input);
- }
-
- @Override
- public ClassToInstanceMap<DOMActionServiceExtension> getExtensions() {
- return delegate.getExtensions();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Inocybe Technologies 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 org.opendaylight.mdsal.dom.api.DOMTransactionChain;
-import org.opendaylight.mdsal.dom.api.DOMTransactionChainListener;
-
-/**
- * Adapter between the legacy controller API-based DOMDataBroker and the mdsal API-based DOMDataBroker.
- *
- * @author Thomas Pantelis
- */
-@Deprecated(forRemoval = true)
-public class LegacyDOMDataBrokerAdapter extends AbstractLegacyDOMDataBrokerAdapter {
- public LegacyDOMDataBrokerAdapter(final org.opendaylight.mdsal.dom.api.DOMDataBroker delegate) {
- super(delegate);
- }
-
- @Override
- DOMTransactionChain createDelegateChain(DOMTransactionChainListener listener) {
- return delegate().createTransactionChain(listener);
- }
-}
+++ /dev/null
-/*
- * 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.time.Instant;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Date;
-import org.opendaylight.controller.md.sal.dom.api.DOMEvent;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService;
-import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-
-@Deprecated(forRemoval = true)
-public class LegacyDOMNotificationServiceAdapter extends ForwardingObject implements DOMNotificationService {
- private final org.opendaylight.mdsal.dom.api.DOMNotificationService delegate;
-
- public LegacyDOMNotificationServiceAdapter(final org.opendaylight.mdsal.dom.api.DOMNotificationService delegate) {
- this.delegate = requireNonNull(delegate);
- }
-
- @Override
- public <T extends DOMNotificationListener> ListenerRegistration<T> registerNotificationListener(final T listener,
- final Collection<SchemaPath> types) {
- final ListenerRegistration<org.opendaylight.mdsal.dom.api.DOMNotificationListener> reg =
- delegate().registerNotificationListener(notification -> {
- if (notification instanceof DOMNotification) {
- listener.onNotification((DOMNotification)notification);
- return;
- }
-
- if (notification instanceof org.opendaylight.mdsal.dom.api.DOMEvent) {
- listener.onNotification(new DefaultDOMEvent(notification,
- (org.opendaylight.mdsal.dom.api.DOMEvent)notification));
- return;
- }
-
- listener.onNotification(new DefaultDOMNotification(notification));
- }, 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 org.opendaylight.mdsal.dom.api.DOMNotificationService delegate() {
- return delegate;
- }
-
- private static class DefaultDOMNotification implements DOMNotification {
- private final org.opendaylight.mdsal.dom.api.DOMNotification delegate;
-
- DefaultDOMNotification(final org.opendaylight.mdsal.dom.api.DOMNotification delegate) {
- this.delegate = requireNonNull(delegate);
- }
-
- @Override
- public SchemaPath getType() {
- return delegate.getType();
- }
-
- @Override
- public ContainerNode getBody() {
- return delegate.getBody();
- }
- }
-
- private static class DefaultDOMEvent extends DefaultDOMNotification implements DOMEvent {
- private final Date eventTime;
-
- DefaultDOMEvent(final org.opendaylight.mdsal.dom.api.DOMNotification fromNotification,
- final org.opendaylight.mdsal.dom.api.DOMEvent fromEvent) {
- super(fromNotification);
- final Instant eventInstant = fromEvent.getEventInstant();
- this.eventTime = eventInstant != null ? Date.from(eventInstant) : null;
- }
-
- @Override
- public Date getEventTime() {
- return eventTime;
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2018 Inocybe Technologies 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 com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.ListenableFuture;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationNotAvailableException;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
-import org.opendaylight.controller.md.sal.dom.api.DefaultDOMRpcException;
-import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult;
-import org.opendaylight.yangtools.util.concurrent.ExceptionMapper;
-
-/**
- * Adapts a {@link org.opendaylight.mdsal.dom.api.DOMRpcResult} CheckedFuture to a {@link DOMRpcResult} CheckedFuture.
- *
- * @author Thomas Pantelis
- */
-@Deprecated(forRemoval = true)
-public class LegacyDOMRpcResultFutureAdapter extends AbstractDOMRpcResultFutureAdapter<DOMRpcResult,
- org.opendaylight.mdsal.dom.api.DOMRpcResult, ListenableFuture<org.opendaylight.mdsal.dom.api.DOMRpcResult>,
- DOMRpcException> implements CheckedFuture<DOMRpcResult, DOMRpcException> {
-
- private static final ExceptionMapper<DOMRpcException> LEGACY_DOM_RPC_EX_MAPPER =
- new ExceptionMapper<DOMRpcException>("rpc", DOMRpcException.class) {
- @Override
- protected DOMRpcException newWithCause(String message, Throwable cause) {
- return cause instanceof DOMRpcException ? (DOMRpcException)cause
- : cause instanceof org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException
- ? new DOMRpcImplementationNotAvailableException(cause.getMessage(), cause.getCause())
- : new DefaultDOMRpcException("RPC failed", cause);
- }
- };
-
- public LegacyDOMRpcResultFutureAdapter(ListenableFuture<org.opendaylight.mdsal.dom.api.DOMRpcResult> delegate) {
- super(delegate, LEGACY_DOM_RPC_EX_MAPPER);
- }
-
- @Override
- @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
- public DOMRpcResult checkedGet() throws DOMRpcException {
- try {
- return get();
- } catch (InterruptedException | ExecutionException e) {
- throw LEGACY_DOM_RPC_EX_MAPPER.apply(e);
- }
- }
-
- @Override
- @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
- public DOMRpcResult checkedGet(final long timeout, final TimeUnit unit) throws TimeoutException, DOMRpcException {
- try {
- return get(timeout, unit);
- } catch (InterruptedException | ExecutionException e) {
- throw LEGACY_DOM_RPC_EX_MAPPER.apply(e);
- }
- }
-
- @Override
- protected DOMRpcResult transform(org.opendaylight.mdsal.dom.api.DOMRpcResult fromResult) {
- return new DefaultDOMRpcResult(fromResult.getResult(), fromResult.getErrors());
- }
-}
+++ /dev/null
-/*
- * 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.CheckedFuture;
-import com.google.common.util.concurrent.ListenableFuture;
-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.DOMRpcResult;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
-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(forRemoval = true)
-public class LegacyDOMRpcServiceAdapter extends ForwardingObject implements DOMRpcService {
- private final org.opendaylight.mdsal.dom.api.DOMRpcService delegate;
-
- public LegacyDOMRpcServiceAdapter(final org.opendaylight.mdsal.dom.api.DOMRpcService delegate) {
- this.delegate = requireNonNull(delegate);
- }
-
- @Override
- public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final SchemaPath type,
- final NormalizedNode<?, ?> input) {
- final ListenableFuture<org.opendaylight.mdsal.dom.api.DOMRpcResult> future = delegate().invokeRpc(type, input);
- return future instanceof MdsalDOMRpcResultFutureAdapter ? ((MdsalDOMRpcResultFutureAdapter)future).delegate()
- : new LegacyDOMRpcResultFutureAdapter(future);
- }
-
- @Override
- public <T extends DOMRpcAvailabilityListener> ListenerRegistration<T> registerRpcListener(final T listener) {
- final ListenerRegistration<org.opendaylight.mdsal.dom.api.DOMRpcAvailabilityListener> reg =
- delegate().registerRpcListener(new RpcAvailabilityListenerAdapter<>(listener));
-
- return new AbstractListenerRegistration<T>(listener) {
- @Override
- protected void removeRegistration() {
- reg.close();
- }
- };
- }
-
- @Override
- protected org.opendaylight.mdsal.dom.api.DOMRpcService delegate() {
- return delegate;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2019 PANTHEON.tech 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 org.opendaylight.mdsal.dom.api.DOMTransactionChain;
-import org.opendaylight.mdsal.dom.api.DOMTransactionChainListener;
-
-/**
- * Adapter between the legacy controller API-based DOMDataBroker and the mdsal API-based DOMDataBroker, equivalent
- * to PingPongDOMDataBroker.
- */
-@Deprecated(forRemoval = true)
-public class LegacyPingPongDOMDataBrokerAdapter extends AbstractLegacyDOMDataBrokerAdapter {
- public LegacyPingPongDOMDataBrokerAdapter(final org.opendaylight.mdsal.dom.api.DOMDataBroker delegate) {
- super(delegate);
- }
-
- @Override
- DOMTransactionChain createDelegateChain(DOMTransactionChainListener listener) {
- return delegate().createMergingTransactionChain(listener);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2018 Inocybe Technologies 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 com.google.common.util.concurrent.CheckedFuture;
-import org.opendaylight.mdsal.dom.api.DOMRpcException;
-import org.opendaylight.mdsal.dom.api.DOMRpcResult;
-import org.opendaylight.mdsal.dom.api.DefaultDOMRpcException;
-import org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult;
-import org.opendaylight.yangtools.util.concurrent.ExceptionMapper;
-
-/**
- * Adapts a {@link org.opendaylight.controller.md.sal.dom.api.DOMRpcResult} CheckedFuture to a
- * {@link DOMRpcResult} CheckedFuture.
- *
- * @author Thomas Pantelis
- */
-@Deprecated(forRemoval = true)
-public class MdsalDOMRpcResultFutureAdapter extends AbstractDOMRpcResultFutureAdapter<
- DOMRpcResult, org.opendaylight.controller.md.sal.dom.api.DOMRpcResult,
- CheckedFuture<org.opendaylight.controller.md.sal.dom.api.DOMRpcResult,
- org.opendaylight.controller.md.sal.dom.api.DOMRpcException>, DOMRpcException> {
- private static final ExceptionMapper<DOMRpcException> MDSAL_DOM_RPC_EX_MAPPER =
- new ExceptionMapper<DOMRpcException>("rpc", DOMRpcException.class) {
- @Override
- protected DOMRpcException newWithCause(String message, Throwable cause) {
- return cause instanceof DOMRpcException ? (DOMRpcException) cause
- : new DefaultDOMRpcException("RPC failed", cause);
- }
- };
-
- public MdsalDOMRpcResultFutureAdapter(CheckedFuture<org.opendaylight.controller.md.sal.dom.api.DOMRpcResult,
- org.opendaylight.controller.md.sal.dom.api.DOMRpcException> delegate) {
- super(delegate, MDSAL_DOM_RPC_EX_MAPPER);
- }
-
- @Override
- protected DOMRpcResult transform(org.opendaylight.controller.md.sal.dom.api.DOMRpcResult fromResult) {
- return new DefaultDOMRpcResult(fromResult.getResult(), fromResult.getErrors());
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2018 Inocybe Technologies 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 org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.yangtools.util.concurrent.ExceptionMapper;
-
-/**
- * Adapter that maps the controller API-based ReadFailedException to the mdsal API-based ReadFailedException.
- *
- * @author Thomas Pantelis
- */
-@Deprecated(forRemoval = true)
-public final class ReadFailedExceptionAdapter extends ExceptionMapper<ReadFailedException> {
- public static final ReadFailedExceptionAdapter INSTANCE = new ReadFailedExceptionAdapter();
-
- private ReadFailedExceptionAdapter() {
- super("read", ReadFailedException.class);
- }
-
- @Override
- protected ReadFailedException newWithCause(String message, Throwable cause) {
- if (cause instanceof org.opendaylight.mdsal.common.api.ReadFailedException) {
- return new ReadFailedException(cause.getMessage(), cause.getCause());
- }
-
- return new ReadFailedException(message, cause);
- }
-}
+++ /dev/null
-/*
- * 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.Collection;
-import java.util.stream.Collectors;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcAvailabilityListener;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier;
-
-@Deprecated(forRemoval = true)
-public class RpcAvailabilityListenerAdapter<T extends DOMRpcAvailabilityListener> extends ForwardingObject
- implements org.opendaylight.mdsal.dom.api.DOMRpcAvailabilityListener {
- private final @NonNull T delegate;
-
- public RpcAvailabilityListenerAdapter(final T delegate) {
- this.delegate = requireNonNull(delegate);
- }
-
- @Override
- public void onRpcAvailable(final Collection<org.opendaylight.mdsal.dom.api.DOMRpcIdentifier> rpcs) {
- delegate.onRpcAvailable(convert(rpcs));
- }
-
- @Override
- public void onRpcUnavailable(final Collection<org.opendaylight.mdsal.dom.api.DOMRpcIdentifier> rpcs) {
- delegate.onRpcUnavailable(convert(rpcs));
- }
-
- @Override
- protected T delegate() {
- return delegate;
- }
-
- private static @NonNull Collection<DOMRpcIdentifier> convert(
- final Collection<org.opendaylight.mdsal.dom.api.DOMRpcIdentifier> from) {
- return from.stream().map(DOMRpcIdentifier::fromMdsal).collect(Collectors.toList());
- }
-}
+++ /dev/null
-/*
- * 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;
-
-@Deprecated(forRemoval = true)
-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);
- }
-}
+++ /dev/null
-/*
- * 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
- */
-/**
- * Controller/MDSAL compatibility library. Contains classes useful for bridging Controller's sal-core-{api,spi}
- * to MD-SAL's mdsal-dom-{api,spi}.
- */
-@Deprecated(forRemoval = true)
-package org.opendaylight.controller.sal.core.compat;
\ No newline at end of file
+++ /dev/null
-/*
- * 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.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-
-import com.google.common.collect.ImmutableClassToInstanceMap;
-import java.util.Optional;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-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.DOMNotificationService;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
-import org.opendaylight.mdsal.dom.api.DOMMountPoint;
-
-@Deprecated
-@RunWith(MockitoJUnitRunner.StrictStubs.class)
-public class DOMMountPointAdapterTest {
- @Mock
- private DOMMountPoint delegate;
-
- private DOMMountPointAdapter adapter;
-
- @Before
- public void before() {
- doReturn(Optional.empty()).when(delegate).getService(any());
- adapter = new DOMMountPointAdapter(delegate);
- }
-
- @Test
- public void testDOMActionService() {
- assertFalse(adapter.getService(DOMActionService.class).isPresent());
-
- org.opendaylight.mdsal.dom.api.DOMActionService mdsal =
- mock(org.opendaylight.mdsal.dom.api.DOMActionService.class);
-
- doReturn(Optional.of(mdsal)).when(delegate).getService(org.opendaylight.mdsal.dom.api.DOMActionService.class);
- assertTrue(adapter.getService(DOMActionService.class).isPresent());
- }
-
- @Test
- public void testDOMDataBroker() {
- assertFalse(adapter.getService(DOMDataBroker.class).isPresent());
-
- org.opendaylight.mdsal.dom.api.DOMDataBroker mdsal = mock(org.opendaylight.mdsal.dom.api.DOMDataBroker.class);
- doReturn(ImmutableClassToInstanceMap.of()).when(mdsal).getExtensions();
-
- doReturn(Optional.of(mdsal)).when(delegate).getService(org.opendaylight.mdsal.dom.api.DOMDataBroker.class);
- assertTrue(adapter.getService(DOMDataBroker.class).isPresent());
- }
-
- @Test
- public void testDOMNotificationService() {
- assertFalse(adapter.getService(DOMNotificationService.class).isPresent());
-
- org.opendaylight.mdsal.dom.api.DOMNotificationService mdsal =
- mock(org.opendaylight.mdsal.dom.api.DOMNotificationService.class);
-
- doReturn(Optional.of(mdsal)).when(delegate).getService(
- org.opendaylight.mdsal.dom.api.DOMNotificationService.class);
- assertTrue(adapter.getService(DOMNotificationService.class).isPresent());
- }
-
- @Test
- public void testDOMRpcService() {
- assertFalse(adapter.getService(DOMRpcService.class).isPresent());
-
- org.opendaylight.mdsal.dom.api.DOMRpcService mdsal = mock(org.opendaylight.mdsal.dom.api.DOMRpcService.class);
-
- doReturn(Optional.of(mdsal)).when(delegate).getService(org.opendaylight.mdsal.dom.api.DOMRpcService.class);
- assertTrue(adapter.getService(DOMRpcService.class).isPresent());
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Inocybe Technologies 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.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyObject;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.inOrder;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-
-import com.google.common.collect.ClassToInstanceMap;
-import com.google.common.collect.ImmutableClassToInstanceMap;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.MoreExecutors;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Optional;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-import org.mockito.InOrder;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.DataStoreUnavailableException;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.OptimisticLockFailedException;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.controller.md.sal.dom.api.ClusteredDOMDataTreeChangeListener;
-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.DOMDataTreeChangeListener;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeIdentifier;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
-import org.opendaylight.mdsal.dom.api.DOMDataBrokerExtension;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohort;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistration;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry;
-import org.opendaylight.mdsal.dom.broker.SerializedDOMDataBroker;
-import org.opendaylight.mdsal.dom.spi.store.DOMStore;
-import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction;
-import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction;
-import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
-import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain;
-import org.opendaylight.mdsal.dom.spi.store.DOMStoreTreeChangePublisher;
-import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.util.concurrent.FluentFutures;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.ConflictingModificationAppliedException;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-
-/**
- * Unit tests for LegacyDOMDataBrokerAdapter.
- *
- * @author Thomas Pantelis
- */
-@Deprecated
-public class LegacyDOMDataBrokerAdapterTest {
- public static final QName TEST_QNAME = QName.create("test", "2018-07-11", "test");
- private static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier.of(TEST_QNAME);
-
- @Mock
- private TestDOMStore mockOperStore;
-
- @Mock
- private TestDOMStore mockConfigStore;
-
- @Mock
- private DOMStoreReadTransaction mockConfigReadTx;
-
- @Mock
- private DOMStoreWriteTransaction mockConfigWriteTx;
-
- @Mock
- private DOMStoreReadWriteTransaction mockConfigReadWriteTx;
-
- @Mock
- private DOMStoreThreePhaseCommitCohort mockConfigCommitCohort;
-
- @Mock
- private DOMStoreReadTransaction mockOperReadTx;
-
- @Mock
- private DOMStoreWriteTransaction mockOperWriteTx;
-
- @Mock
- private DOMStoreReadWriteTransaction mockOperReadWriteTx;
-
- @Mock
- private DOMStoreThreePhaseCommitCohort mockOperCommitCohort;
-
- @Mock
- private DOMDataTreeCommitCohortRegistry mockCommitCohortRegistry;
-
- private LegacyDOMDataBrokerAdapter adapter;
- private NormalizedNode<?,?> dataNode;
-
- @Before
- public void setup() {
- MockitoAnnotations.initMocks(this);
-
- SerializedDOMDataBroker backendBroker = new SerializedDOMDataBroker(ImmutableMap.of(
- org.opendaylight.mdsal.common.api.LogicalDatastoreType.OPERATIONAL, mockOperStore,
- org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION, mockConfigStore),
- MoreExecutors.newDirectExecutorService()) {
- @Override
- public ClassToInstanceMap<DOMDataBrokerExtension> getExtensions() {
- return ImmutableClassToInstanceMap.<DOMDataBrokerExtension>builder().putAll(super.getExtensions())
- .put(DOMDataTreeCommitCohortRegistry.class, mockCommitCohortRegistry).build();
- }
- };
-
- adapter = new LegacyDOMDataBrokerAdapter(backendBroker);
-
- doReturn(Futures.immediateFuture(Boolean.TRUE)).when(mockConfigCommitCohort).canCommit();
- doReturn(Futures.immediateFuture(null)).when(mockConfigCommitCohort).preCommit();
- doReturn(Futures.immediateFuture(null)).when(mockConfigCommitCohort).commit();
- doReturn(Futures.immediateFuture(null)).when(mockConfigCommitCohort).abort();
-
- dataNode = ImmutableNodes.containerNode(TEST_QNAME);
-
- doReturn(mockConfigWriteTx).when(mockConfigStore).newWriteOnlyTransaction();
- doNothing().when(mockConfigWriteTx).write(TEST_PATH, dataNode);
- doNothing().when(mockConfigWriteTx).merge(TEST_PATH, dataNode);
- doNothing().when(mockConfigWriteTx).delete(TEST_PATH);
- doNothing().when(mockConfigWriteTx).close();
- doReturn(mockConfigCommitCohort).when(mockConfigWriteTx).ready();
-
- doReturn(mockConfigReadTx).when(mockConfigStore).newReadOnlyTransaction();
- doReturn(FluentFutures.immediateFluentFuture(Optional.of(dataNode))).when(mockConfigReadTx).read(TEST_PATH);
- doReturn(FluentFutures.immediateFluentFuture(Boolean.TRUE)).when(mockConfigReadTx).exists(TEST_PATH);
-
- doReturn(mockConfigReadWriteTx).when(mockConfigStore).newReadWriteTransaction();
- doNothing().when(mockConfigReadWriteTx).write(TEST_PATH, dataNode);
- doReturn(mockConfigCommitCohort).when(mockConfigReadWriteTx).ready();
- doReturn(FluentFutures.immediateFluentFuture(Optional.of(dataNode)))
- .when(mockConfigReadWriteTx).read(TEST_PATH);
-
- DOMStoreTransactionChain mockTxChain = mock(DOMStoreTransactionChain.class);
- doReturn(mockConfigReadTx).when(mockTxChain).newReadOnlyTransaction();
- doReturn(mockConfigWriteTx).when(mockTxChain).newWriteOnlyTransaction();
- doReturn(mockConfigReadWriteTx).when(mockTxChain).newReadWriteTransaction();
- doReturn(mockTxChain).when(mockConfigStore).createTransactionChain();
-
- doReturn(mock(DOMStoreTransactionChain.class)).when(mockOperStore).createTransactionChain();
-
- doReturn(Futures.immediateFuture(Boolean.TRUE)).when(mockOperCommitCohort).canCommit();
- doReturn(Futures.immediateFuture(null)).when(mockOperCommitCohort).preCommit();
- doReturn(Futures.immediateFuture(null)).when(mockOperCommitCohort).commit();
- doReturn(Futures.immediateFuture(null)).when(mockOperCommitCohort).abort();
-
- doReturn(mockOperReadTx).when(mockOperStore).newReadOnlyTransaction();
-
- doReturn(mockOperWriteTx).when(mockOperStore).newWriteOnlyTransaction();
- doReturn(mockOperCommitCohort).when(mockOperWriteTx).ready();
-
- doReturn(mockOperReadWriteTx).when(mockOperStore).newReadWriteTransaction();
- doReturn(mockOperCommitCohort).when(mockOperReadWriteTx).ready();
-
- DOMStoreTransactionChain mockOperTxChain = mock(DOMStoreTransactionChain.class);
- doReturn(mockOperReadTx).when(mockOperTxChain).newReadOnlyTransaction();
- doReturn(mockOperWriteTx).when(mockOperTxChain).newWriteOnlyTransaction();
- doReturn(mockOperReadWriteTx).when(mockOperTxChain).newReadWriteTransaction();
- doReturn(mockOperTxChain).when(mockOperStore).createTransactionChain();
- }
-
- @Test
- public void testReadOnlyTransaction() throws Exception {
- DOMDataReadOnlyTransaction tx = adapter.newReadOnlyTransaction();
-
- // Test successful read
-
- CheckedFuture<com.google.common.base.Optional<NormalizedNode<?, ?>>, ReadFailedException> readFuture =
- tx.read(LogicalDatastoreType.CONFIGURATION, TEST_PATH);
- com.google.common.base.Optional<NormalizedNode<?, ?>> readOptional = readFuture.get();
- assertEquals("isPresent", true, readOptional.isPresent());
- assertEquals("NormalizedNode", dataNode, readOptional.get());
-
- // Test successful exists
-
- CheckedFuture<Boolean, ReadFailedException> existsFuture =
- tx.exists(LogicalDatastoreType.CONFIGURATION, TEST_PATH);
- assertEquals("exists", Boolean.TRUE, existsFuture.get());
-
- // Test failed read
-
- String errorMsg = "mock read error";
- Throwable cause = new RuntimeException();
- doReturn(FluentFutures.immediateFailedFluentFuture(new org.opendaylight.mdsal.common.api.ReadFailedException(
- errorMsg, cause))).when(mockConfigReadTx).read(TEST_PATH);
-
- try {
- tx.read(LogicalDatastoreType.CONFIGURATION, TEST_PATH).checkedGet();
- fail("Expected ReadFailedException");
- } catch (ReadFailedException e) {
- assertEquals("getMessage", errorMsg, e.getMessage());
- assertEquals("getCause", cause, e.getCause());
- }
-
- // Test close
- tx.close();
- verify(mockConfigReadTx).close();
- }
-
- @Test
- public void testWriteOnlyTransaction() throws Exception {
- // Test successful write operations and submit
-
- DOMDataWriteTransaction tx = adapter.newWriteOnlyTransaction();
-
- tx.put(LogicalDatastoreType.CONFIGURATION, TEST_PATH, dataNode);
- verify(mockConfigWriteTx).write(TEST_PATH, dataNode);
-
- tx.merge(LogicalDatastoreType.CONFIGURATION, TEST_PATH, dataNode);
- verify(mockConfigWriteTx).merge(TEST_PATH, dataNode);
-
- tx.delete(LogicalDatastoreType.CONFIGURATION, TEST_PATH);
- verify(mockConfigWriteTx).delete(TEST_PATH);
-
- tx.commit().get(5, TimeUnit.SECONDS);
-
- InOrder inOrder = inOrder(mockConfigCommitCohort);
- inOrder.verify(mockConfigCommitCohort).canCommit();
- inOrder.verify(mockConfigCommitCohort).preCommit();
- inOrder.verify(mockConfigCommitCohort).commit();
-
- // Test cancel
-
- tx = adapter.newWriteOnlyTransaction();
- tx.put(LogicalDatastoreType.CONFIGURATION, TEST_PATH, dataNode);
- tx.cancel();
- verify(mockConfigWriteTx).close();
-
- // Test submit with OptimisticLockFailedException
-
- String errorMsg = "mock OptimisticLockFailedException";
- Throwable cause = new ConflictingModificationAppliedException(TEST_PATH, "mock");
- doReturn(Futures.immediateFailedFuture(new org.opendaylight.mdsal.common.api.OptimisticLockFailedException(
- errorMsg, cause))).when(mockConfigCommitCohort).canCommit();
-
- try {
- tx = adapter.newWriteOnlyTransaction();
- tx.put(LogicalDatastoreType.CONFIGURATION, TEST_PATH, dataNode);
- commit(tx);
- fail("Expected OptimisticLockFailedException");
- } catch (OptimisticLockFailedException e) {
- assertEquals("getMessage", errorMsg, e.getMessage());
- assertEquals("getCause", cause, e.getCause());
- }
-
- // Test submit with TransactionCommitFailedException
-
- errorMsg = "mock TransactionCommitFailedException";
- cause = new DataValidationFailedException(TEST_PATH, "mock");
- doReturn(Futures.immediateFailedFuture(new org.opendaylight.mdsal.common.api.TransactionCommitFailedException(
- errorMsg, cause))).when(mockConfigCommitCohort).canCommit();
-
- try {
- tx = adapter.newWriteOnlyTransaction();
- tx.put(LogicalDatastoreType.CONFIGURATION, TEST_PATH, dataNode);
- commit(tx);
- fail("Expected TransactionCommitFailedException");
- } catch (TransactionCommitFailedException e) {
- assertEquals("getMessage", errorMsg, e.getMessage());
- assertEquals("getCause", cause, e.getCause());
- }
-
- // Test submit with DataStoreUnavailableException
-
- errorMsg = "mock NoShardLeaderException";
- cause = new DataStoreUnavailableException("mock", new RuntimeException());
- doReturn(Futures.immediateFailedFuture(cause)).when(mockConfigCommitCohort).canCommit();
-
- try {
- tx = adapter.newWriteOnlyTransaction();
- tx.put(LogicalDatastoreType.CONFIGURATION, TEST_PATH, dataNode);
- commit(tx);
- fail("Expected TransactionCommitFailedException");
- } catch (TransactionCommitFailedException e) {
- assertEquals("getCause type", DataStoreUnavailableException.class, e.getCause().getClass());
- }
-
- // Test submit with RuntimeException
-
- errorMsg = "mock RuntimeException";
- cause = new RuntimeException(errorMsg);
- doReturn(Futures.immediateFailedFuture(cause)).when(mockConfigCommitCohort).canCommit();
-
- try {
- tx = adapter.newWriteOnlyTransaction();
- tx.put(LogicalDatastoreType.CONFIGURATION, TEST_PATH, dataNode);
- commit(tx);
- fail("Expected TransactionCommitFailedException");
- } catch (TransactionCommitFailedException e) {
- assertEquals("getCause", cause, e.getCause());
- }
- }
-
- @Test
- public void testReadWriteTransaction() throws Exception {
- DOMDataReadWriteTransaction tx = adapter.newReadWriteTransaction();
-
- CheckedFuture<com.google.common.base.Optional<NormalizedNode<?, ?>>, ReadFailedException> readFuture =
- tx.read(LogicalDatastoreType.CONFIGURATION, TEST_PATH);
- com.google.common.base.Optional<NormalizedNode<?, ?>> readOptional = readFuture.get();
- assertEquals("isPresent", true, readOptional.isPresent());
- assertEquals("NormalizedNode", dataNode, readOptional.get());
-
- tx.put(LogicalDatastoreType.CONFIGURATION, TEST_PATH, dataNode);
- verify(mockConfigReadWriteTx).write(TEST_PATH, dataNode);
-
- tx.commit().get(5, TimeUnit.SECONDS);
-
- InOrder inOrder = inOrder(mockConfigCommitCohort);
- inOrder.verify(mockConfigCommitCohort).canCommit();
- inOrder.verify(mockConfigCommitCohort).preCommit();
- inOrder.verify(mockConfigCommitCohort).commit();
- }
-
- @SuppressWarnings("rawtypes")
- @Test
- public void testTransactionChain() throws Exception {
- TransactionChainListener mockListener = mock(TransactionChainListener.class);
- doNothing().when(mockListener).onTransactionChainSuccessful(anyObject());
- doNothing().when(mockListener).onTransactionChainFailed(anyObject(), anyObject(), anyObject());
-
- DOMTransactionChain chain = adapter.createTransactionChain(mockListener);
-
- // Test read-only tx
-
- DOMDataReadOnlyTransaction readTx = chain.newReadOnlyTransaction();
-
- CheckedFuture<com.google.common.base.Optional<NormalizedNode<?, ?>>, ReadFailedException> readFuture =
- readTx.read(LogicalDatastoreType.CONFIGURATION, TEST_PATH);
- com.google.common.base.Optional<NormalizedNode<?, ?>> readOptional = readFuture.get();
- assertEquals("isPresent", true, readOptional.isPresent());
- assertEquals("NormalizedNode", dataNode, readOptional.get());
-
- // Test write-only tx
-
- DOMDataWriteTransaction writeTx = chain.newWriteOnlyTransaction();
-
- writeTx.put(LogicalDatastoreType.CONFIGURATION, TEST_PATH, dataNode);
- verify(mockConfigWriteTx).write(TEST_PATH, dataNode);
- writeTx.commit().get(5, TimeUnit.SECONDS);
-
- InOrder inOrder = inOrder(mockConfigCommitCohort);
- inOrder.verify(mockConfigCommitCohort).canCommit();
- inOrder.verify(mockConfigCommitCohort).preCommit();
- inOrder.verify(mockConfigCommitCohort).commit();
-
- // Test read-write tx
-
- DOMDataReadWriteTransaction readWriteTx = chain.newReadWriteTransaction();
-
- readFuture = readWriteTx.read(LogicalDatastoreType.CONFIGURATION, TEST_PATH);
- readOptional = readFuture.get();
- assertEquals("isPresent", true, readOptional.isPresent());
- assertEquals("NormalizedNode", dataNode, readOptional.get());
-
- chain.close();
- verify(mockListener).onTransactionChainSuccessful(chain);
-
- // Test failed chain
-
- doReturn(Futures.immediateFailedFuture(new org.opendaylight.mdsal.common.api.TransactionCommitFailedException(
- "mock", (Throwable)null))).when(mockConfigCommitCohort).canCommit();
-
- chain = adapter.createTransactionChain(mockListener);
-
- writeTx = chain.newWriteOnlyTransaction();
-
- try {
- writeTx.put(LogicalDatastoreType.CONFIGURATION, TEST_PATH, dataNode);
- commit(writeTx);
- fail("Expected TransactionCommitFailedException");
- } catch (TransactionCommitFailedException e) {
- // expected
- }
-
- ArgumentCaptor<AsyncTransaction> failedTx = ArgumentCaptor.forClass(AsyncTransaction.class);
- verify(mockListener).onTransactionChainFailed(eq(chain), failedTx.capture(),
- any(TransactionCommitFailedException.class));
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void testDataTreeChangeListener() {
- DOMDataTreeChangeService domDTCLService =
- (DOMDataTreeChangeService) adapter.getSupportedExtensions().get(DOMDataTreeChangeService.class);
- assertNotNull("DOMDataTreeChangeService not found", domDTCLService);
-
- ArgumentCaptor<org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener> storeDTCL =
- ArgumentCaptor.forClass(org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener.class);
- ListenerRegistration<org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener> mockReg =
- mock(ListenerRegistration.class);
- doNothing().when(mockReg).close();
- doAnswer(invocation -> storeDTCL.getValue()).when(mockReg).getInstance();
- doReturn(mockReg).when(mockConfigStore).registerTreeChangeListener(eq(TEST_PATH),
- storeDTCL.capture());
-
- DOMDataTreeChangeListener brokerDTCL = mock(DOMDataTreeChangeListener.class);
- ListenerRegistration<DOMDataTreeChangeListener> reg = domDTCLService.registerDataTreeChangeListener(
- new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, TEST_PATH), brokerDTCL);
- assertEquals("getInstance", brokerDTCL, reg.getInstance());
-
- Collection<DataTreeCandidate> changes = Arrays.asList(mock(DataTreeCandidate.class));
- storeDTCL.getValue().onDataTreeChanged(changes);
- verify(brokerDTCL).onDataTreeChanged(changes);
-
- reg.close();
- verify(mockReg).close();
-
- // Test ClusteredDOMDataTreeChangeListener
-
- ArgumentCaptor<org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener> storeClusteredDTCL =
- ArgumentCaptor.forClass(org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener.class);
- mockReg = mock(ListenerRegistration.class);
- doReturn(mockReg).when(mockConfigStore).registerTreeChangeListener(eq(TEST_PATH),
- storeClusteredDTCL.capture());
-
- final ClusteredDOMDataTreeChangeListener brokerClusteredDTCL = mock(ClusteredDOMDataTreeChangeListener.class);
- domDTCLService.registerDataTreeChangeListener(new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION,
- TEST_PATH), brokerClusteredDTCL);
-
- assertTrue("Expected ClusteredDOMDataTreeChangeListener: " + storeClusteredDTCL.getValue(),
- storeClusteredDTCL.getValue()
- instanceof org.opendaylight.mdsal.dom.api.ClusteredDOMDataTreeChangeListener);
- storeClusteredDTCL.getValue().onDataTreeChanged(changes);
- verify(brokerClusteredDTCL).onDataTreeChanged(changes);
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void testDataTreeCommitCohortRegistry() {
- org.opendaylight.controller.md.sal.dom.api.DOMDataTreeCommitCohortRegistry domCohortRegistry =
- (org.opendaylight.controller.md.sal.dom.api.DOMDataTreeCommitCohortRegistry)
- adapter.getSupportedExtensions().get(
- org.opendaylight.controller.md.sal.dom.api.DOMDataTreeCommitCohortRegistry.class);
- assertNotNull("DOMDataTreeCommitCohortRegistry not found", domCohortRegistry);
-
- DOMDataTreeCommitCohort mockCohort = mock(DOMDataTreeCommitCohort.class);
- org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier treeId =
- new org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier(
- org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION, TEST_PATH);
- DOMDataTreeCommitCohortRegistration<DOMDataTreeCommitCohort> mockReg =
- mock(DOMDataTreeCommitCohortRegistration.class);
- doReturn(mockReg).when(mockCommitCohortRegistry).registerCommitCohort(treeId, mockCohort);
-
- DOMDataTreeCommitCohortRegistration<DOMDataTreeCommitCohort> reg = domCohortRegistry.registerCommitCohort(
- treeId, mockCohort);
- assertEquals("DOMDataTreeCommitCohortRegistration", mockReg, reg);
-
- verify(mockCommitCohortRegistry).registerCommitCohort(treeId, mockCohort);
- }
-
- @Test
- @Deprecated
- public void testSubmit() throws Exception {
- DOMDataWriteTransaction tx = adapter.newWriteOnlyTransaction();
-
- tx.put(LogicalDatastoreType.CONFIGURATION, TEST_PATH, dataNode);
- verify(mockConfigWriteTx).write(TEST_PATH, dataNode);
-
- tx.submit().get(5, TimeUnit.SECONDS);
-
- InOrder inOrder = inOrder(mockConfigCommitCohort);
- inOrder.verify(mockConfigCommitCohort).canCommit();
- inOrder.verify(mockConfigCommitCohort).preCommit();
- inOrder.verify(mockConfigCommitCohort).commit();
-
- String errorMsg = "mock OptimisticLockFailedException";
- Throwable cause = new ConflictingModificationAppliedException(TEST_PATH, "mock");
- doReturn(Futures.immediateFailedFuture(new org.opendaylight.mdsal.common.api.TransactionCommitFailedException(
- errorMsg, cause))).when(mockConfigCommitCohort).canCommit();
-
- try {
- tx = adapter.newWriteOnlyTransaction();
- tx.put(LogicalDatastoreType.CONFIGURATION, TEST_PATH, dataNode);
- commit(tx);
- fail("Expected TransactionCommitFailedException");
- } catch (TransactionCommitFailedException e) {
- assertEquals("getMessage", errorMsg, e.getMessage());
- assertEquals("getCause", cause, e.getCause());
- }
- }
-
- @SuppressWarnings("checkstyle:AvoidHidingCauseException")
- private static void commit(final DOMDataWriteTransaction tx)
- throws TransactionCommitFailedException, InterruptedException, TimeoutException {
- try {
- tx.commit().get(5, TimeUnit.SECONDS);
- } catch (ExecutionException e) {
- assertTrue("Expected TransactionCommitFailedException. Actual: " + e.getCause(),
- e.getCause() instanceof TransactionCommitFailedException);
- throw (TransactionCommitFailedException)e.getCause();
- }
- }
-
- private interface TestDOMStore extends DOMStore, DOMStoreTreeChangePublisher,
- org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry {
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-parent</artifactId>
- <version>1.12.0-SNAPSHOT</version>
- <relativePath>../parent</relativePath>
- </parent>
-
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-core-spi</artifactId>
- <version>1.12.0-SNAPSHOT</version>
- <packaging>bundle</packaging>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-core-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-dom-spi</artifactId>
- </dependency>
- </dependencies>
-
- <scm>
- <connection>scm:git:http://git.opendaylight.org/gerrit/controller.git</connection>
- <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
- <tag>HEAD</tag>
- <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
- </scm>
-
-</project>
+++ /dev/null
-/*
- * Copyright (c) 2014, 2015 Cisco Systems, Inc. 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.md.sal.dom.broker.spi.mount;
-
-import com.google.common.base.Optional;
-import com.google.common.collect.ClassToInstanceMap;
-import com.google.common.collect.ImmutableClassToInstanceMap;
-import java.util.Map.Entry;
-import java.util.Set;
-import org.gaul.modernizer_maven_annotations.SuppressModernizer;
-import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
-import org.opendaylight.controller.md.sal.dom.api.DOMService;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
-@Deprecated(forRemoval = true)
-public final class SimpleDOMMountPoint implements DOMMountPoint {
-
- private final YangInstanceIdentifier identifier;
- private final ClassToInstanceMap<DOMService> services;
- private final SchemaContext schemaContext;
-
- public static SimpleDOMMountPoint create(final YangInstanceIdentifier identifier,
- final ClassToInstanceMap<DOMService> services, final SchemaContext ctx) {
- return new SimpleDOMMountPoint(identifier, services, ctx);
- }
-
- private SimpleDOMMountPoint(final YangInstanceIdentifier identifier,
- final ClassToInstanceMap<DOMService> services, final SchemaContext ctx) {
- this.identifier = identifier;
- this.services = ImmutableClassToInstanceMap.copyOf(services);
- this.schemaContext = ctx;
- }
-
- @Override
- public YangInstanceIdentifier getIdentifier() {
- return identifier;
- }
-
- @Override
- public SchemaContext getSchemaContext() {
- return schemaContext;
- }
-
- @Override
- @SuppressModernizer
- public <T extends DOMService> Optional<T> getService(final Class<T> cls) {
- return Optional.fromNullable(services.getInstance(cls));
- }
-
- public Set<Entry<Class<? extends DOMService>, DOMService>> getAllServices() {
- return services.entrySet();
- }
-
- public ClassToInstanceMap<DOMService> getServices() {
- return services;
- }
-
- @Override
- public int hashCode() {
- return identifier.hashCode();
- }
-
- @Override
- public boolean equals(final Object obj) {
- return this == obj || obj instanceof DOMMountPoint && identifier.equals(((DOMMountPoint) obj).getIdentifier());
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.broker.spi.rpc;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.base.Optional;
-import org.gaul.modernizer_maven_annotations.SuppressModernizer;
-import org.opendaylight.yangtools.concepts.Identifiable;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
-import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
-
-@Deprecated(forRemoval = true)
-public abstract class RpcRoutingStrategy implements Identifiable<QName> {
- private static final QName CONTEXT_REFERENCE = QName.create("urn:opendaylight:yang:extension:yang-ext",
- "2013-07-09", "context-reference").intern();
-
- private final QName identifier;
-
- private RpcRoutingStrategy(final QName identifier) {
- this.identifier = requireNonNull(identifier);
- }
-
- /**
- * Returns leaf QName in which RPC Route is stored.
- *
- * @return leaf QName in which RPC Route is stored
- * @throws UnsupportedOperationException If RPC is not content routed.
- * ({@link #isContextBasedRouted()} returned <code>false</code>)
- */
- public abstract QName getLeaf();
-
- /**
- * Returns identity QName which represents RPC Routing context.
- *
- * @return identity QName which represents RPC Routing context
- * @throws UnsupportedOperationException If RPC is not content routed.
- * ({@link #isContextBasedRouted()} returned <code>false</code>)
- */
- public abstract QName getContext();
-
- @Override
- public final QName getIdentifier() {
- return identifier;
- }
-
- /**
- * Returns true if RPC is routed by context.
- *
- * @return true if RPC is routed by content.
- */
- public abstract boolean isContextBasedRouted();
-
- public static RpcRoutingStrategy from(final RpcDefinition rpc) {
- ContainerSchemaNode input = rpc.getInput();
- if (input != null) {
- for (DataSchemaNode schemaNode : input.getChildNodes()) {
- Optional<QName> context = getRoutingContext(schemaNode);
- if (context.isPresent()) {
- return new RoutedRpcStrategy(rpc.getQName(), context.get(), schemaNode.getQName());
- }
- }
- }
- return new GlobalRpcStrategy(rpc.getQName());
- }
-
- @SuppressModernizer
- public static Optional<QName> getRoutingContext(final DataSchemaNode schemaNode) {
- for (UnknownSchemaNode extension : schemaNode.getUnknownSchemaNodes()) {
- if (CONTEXT_REFERENCE.equals(extension.getNodeType())) {
- return Optional.fromNullable(extension.getQName());
- }
- }
- return Optional.absent();
- }
-
- private static final class RoutedRpcStrategy extends RpcRoutingStrategy {
- private final QName context;
- private final QName leaf;
-
- private RoutedRpcStrategy(final QName identifier, final QName ctx, final QName leaf) {
- super(identifier);
- this.context = requireNonNull(ctx);
- this.leaf = requireNonNull(leaf);
- }
-
- @Override
- public QName getContext() {
- return context;
- }
-
- @Override
- public QName getLeaf() {
- return leaf;
- }
-
- @Override
- public boolean isContextBasedRouted() {
- return true;
- }
- }
-
- private static final class GlobalRpcStrategy extends RpcRoutingStrategy {
- GlobalRpcStrategy(final QName identifier) {
- super(identifier);
- }
-
- @Override
- public boolean isContextBasedRouted() {
- return false;
- }
-
- @Override
- public QName getContext() {
- throw new UnsupportedOperationException("Non-routed strategy does not have a context");
- }
-
- @Override
- public QName getLeaf() {
- throw new UnsupportedOperationException("Non-routed strategy does not have a context");
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.dom.spi;
-
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
-import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
-
-/**
- * Abstract implementation of a ListenerRegistration constrained to subclasses
- * of {@link DOMDataTreeChangeListener}.
- *
- * @param <T> type of listener
- * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.AbstractDOMDataTreeChangeListenerRegistration} instead.
- */
-@Deprecated(forRemoval = true)
-public abstract class AbstractDOMDataTreeChangeListenerRegistration<T extends DOMDataTreeChangeListener>
- extends AbstractListenerRegistration<T> {
- protected AbstractDOMDataTreeChangeListenerRegistration(final T listener) {
- super(listener);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.dom.spi;
-
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationRegistration;
-import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
-
-/**
- * Abstract base class for {@link DOMRpcImplementationRegistration} implementations.
- * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.AbstractDOMRpcImplementationRegistration} instead.
- */
-@Deprecated(forRemoval = true)
-public abstract class AbstractDOMRpcImplementationRegistration<T extends DOMRpcImplementation>
- extends AbstractObjectRegistration<T> implements DOMRpcImplementationRegistration<T> {
- protected AbstractDOMRpcImplementationRegistration(final T instance) {
- super(instance);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.dom.spi;
-
-import com.google.common.collect.ImmutableSet;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationRegistration;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService;
-
-/**
- * Convenience abstract base class for {@link DOMRpcProviderService} implementations.
- * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.AbstractDOMRpcProviderService} instead.
- */
-@Deprecated(forRemoval = true)
-public abstract class AbstractDOMRpcProviderService implements DOMRpcProviderService {
- @Override
- public final <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(
- final T implementation, final DOMRpcIdentifier... types) {
- return registerRpcImplementation(implementation, ImmutableSet.copyOf(types));
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.dom.spi;
-
-import com.google.common.annotations.Beta;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-
-/**
- * Listener which is notified when subscriptions changes and
- * provides set of notification types for which currently
- * subscriptions are in place.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.DOMNotificationSubscriptionListener} instead.
- */
-@Beta
-@Deprecated(forRemoval = true)
-@SuppressFBWarnings(value = "NM_SAME_SIMPLE_NAME_AS_INTERFACE", justification = "Migration")
-public interface DOMNotificationSubscriptionListener
- extends org.opendaylight.mdsal.dom.spi.DOMNotificationSubscriptionListener {
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.dom.spi;
-
-import com.google.common.annotations.Beta;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-
-/**
- * Registry of {@link DOMNotificationSubscriptionListener}
- * which listens for changes in notification types.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.DOMNotificationSubscriptionListenerRegistry} instead.
- */
-@Deprecated(forRemoval = true)
-@Beta
-public interface DOMNotificationSubscriptionListenerRegistry {
-
- <L extends DOMNotificationSubscriptionListener> ListenerRegistration<L> registerSubscriptionListener(L listener);
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.dom.spi;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.annotations.Beta;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import java.io.Serializable;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Objects;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
-import org.opendaylight.yangtools.concepts.Immutable;
-import org.opendaylight.yangtools.yang.common.RpcError;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-/**
- * Utility class implementing {@link DefaultDOMRpcResult}.
- * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult} instead.
- */
-@Deprecated(forRemoval = true)
-@Beta
-public final class DefaultDOMRpcResult implements DOMRpcResult, Immutable, Serializable {
- private static final long serialVersionUID = 1L;
-
- // Flagged as "Non-transient non-serializable instance field" - the Collection is Serializable but the RpcError
- // interface isn't. In lieu of changing the interface, we assume the implementation is Serializable which is
- // reasonable since the only implementation that is actually used is from the RpcResultBuilder.
- @SuppressFBWarnings("SE_BAD_FIELD")
- private final Collection<? extends RpcError> errors;
-
- // Unfortunately the NormalizedNode interface isn't Serializable but we assume the implementations are.
- @SuppressFBWarnings("SE_BAD_FIELD")
- private final NormalizedNode<?, ?> result;
-
- private static Collection<RpcError> asCollection(final RpcError... errors) {
- if (errors.length == 0) {
- return Collections.emptyList();
- } else {
- return Arrays.asList(errors);
- }
- }
-
- public DefaultDOMRpcResult(final NormalizedNode<?, ?> result, final RpcError... errors) {
- this(result, asCollection(errors));
- }
-
- public DefaultDOMRpcResult(final RpcError... errors) {
- this(null, asCollection(errors));
- }
-
- public DefaultDOMRpcResult(final NormalizedNode<?, ?> result) {
- this(result, Collections.emptyList());
- }
-
- public DefaultDOMRpcResult(final NormalizedNode<?, ?> result,
- final @NonNull Collection<? extends RpcError> errors) {
- this.result = result;
- this.errors = requireNonNull(errors);
- }
-
- public DefaultDOMRpcResult(final @NonNull Collection<RpcError> errors) {
- this(null, errors);
- }
-
- @Override
- public Collection<? extends RpcError> getErrors() {
- return errors;
- }
-
- @Override
- public NormalizedNode<?, ?> getResult() {
- return result;
- }
-
- @Override
- public int hashCode() {
- int ret = errors.hashCode();
- if (result != null) {
- ret = 31 * ret + result.hashCode();
- }
- return ret;
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (!(obj instanceof DefaultDOMRpcResult)) {
- return false;
- }
-
- final DefaultDOMRpcResult other = (DefaultDOMRpcResult) obj;
- if (!errors.equals(other.errors)) {
- return false;
- }
- return Objects.equals(result, other.result);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.spi;
-
-import com.google.common.collect.ForwardingObject;
-import java.util.Map;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
-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.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;
-
-/**
- * Utility {@link DOMDataBroker} implementation which forwards all interface
- * method invocation to a delegate instance.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.ForwardingDOMDataBroker} instead.
- */
-@Deprecated(forRemoval = true)
-public abstract class ForwardingDOMDataBroker extends ForwardingObject implements DOMDataBroker {
- @Override
- protected abstract @NonNull DOMDataBroker delegate();
-
- @Override
- public DOMDataReadOnlyTransaction newReadOnlyTransaction() {
- return delegate().newReadOnlyTransaction();
- }
-
- @Override
- public DOMDataReadWriteTransaction newReadWriteTransaction() {
- return delegate().newReadWriteTransaction();
- }
-
- @Override
- public DOMDataWriteTransaction newWriteOnlyTransaction() {
- return delegate().newWriteOnlyTransaction();
- }
-
- @Override
- public DOMTransactionChain createTransactionChain(final TransactionChainListener listener) {
- return delegate().createTransactionChain(listener);
- }
-
- @Override
- public Map<Class<? extends DOMDataBrokerExtension>, DOMDataBrokerExtension> getSupportedExtensions() {
- return delegate().getSupportedExtensions();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.spi;
-
-import com.google.common.base.Optional;
-import com.google.common.collect.ForwardingObject;
-import com.google.common.util.concurrent.CheckedFuture;
-import org.eclipse.jdt.annotation.NonNull;
-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.dom.api.DOMDataReadOnlyTransaction;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-/**
- * Utility {@link DOMDataReadOnlyTransaction} implementation which forwards all interface
- * method invocation to a delegate instance.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.ForwardingDOMDataReadOnlyTransaction} instead.
- */
-@Deprecated(forRemoval = true)
-public abstract class ForwardingDOMDataReadOnlyTransaction extends ForwardingObject
- implements DOMDataReadOnlyTransaction {
- @Override
- protected abstract @NonNull DOMDataReadOnlyTransaction delegate();
-
- @Override
- public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final LogicalDatastoreType store,
- final YangInstanceIdentifier path) {
- return delegate().read(store, path);
- }
-
- @Override
- public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store,
- final YangInstanceIdentifier path) {
- return delegate().exists(store, path);
- }
-
- @Override
- public Object getIdentifier() {
- return delegate().getIdentifier();
- }
-
- @Override
- public void close() {
- delegate().close();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.spi;
-
-import com.google.common.base.Optional;
-import com.google.common.collect.ForwardingObject;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.FluentFuture;
-import org.eclipse.jdt.annotation.NonNull;
-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.dom.api.DOMDataReadWriteTransaction;
-import org.opendaylight.mdsal.common.api.CommitInfo;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-/**
- * Utility {@link DOMDataReadWriteTransaction} implementation which forwards all interface
- * method invocation to a delegate instance.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.ForwardingDOMDataReadWriteTransaction} instead.
- */
-@Deprecated(forRemoval = true)
-public abstract class ForwardingDOMDataReadWriteTransaction extends ForwardingObject
- implements DOMDataReadWriteTransaction {
- @Override
- protected abstract @NonNull DOMDataReadWriteTransaction delegate();
-
- @Override
- public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final LogicalDatastoreType store,
- final YangInstanceIdentifier path) {
- return delegate().read(store, path);
- }
-
- @Override
- public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store,
- final YangInstanceIdentifier path) {
- return delegate().exists(store, path);
- }
-
- @Override
- public Object getIdentifier() {
- return delegate().getIdentifier();
- }
-
- @Override
- public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path,
- final NormalizedNode<?, ?> data) {
- delegate().put(store, path, data);
- }
-
- @Override
- public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path,
- final NormalizedNode<?, ?> data) {
- delegate().merge(store, path, data);
- }
-
- @Override
- public boolean cancel() {
- return delegate().cancel();
- }
-
- @Override
- public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
- delegate().delete(store, path);
- }
-
- @Override
- public FluentFuture<? extends CommitInfo> commit() {
- return delegate().commit();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.spi;
-
-import com.google.common.collect.ForwardingObject;
-import com.google.common.util.concurrent.FluentFuture;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
-import org.opendaylight.mdsal.common.api.CommitInfo;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-/**
- * Utility {@link DOMDataWriteTransaction} implementation which forwards all interface
- * method invocation to a delegate instance.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.ForwardingDOMDataWriteTransaction} instead.
- */
-@Deprecated(forRemoval = true)
-public abstract class ForwardingDOMDataWriteTransaction extends ForwardingObject implements DOMDataWriteTransaction {
- @Override
- protected abstract @NonNull DOMDataWriteTransaction delegate();
-
- @Override
- public Object getIdentifier() {
- return delegate().getIdentifier();
- }
-
- @Override
- public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path,
- final NormalizedNode<?, ?> data) {
- delegate().put(store, path, data);
- }
-
- @Override
- public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path,
- final NormalizedNode<?, ?> data) {
- delegate().merge(store, path, data);
- }
-
- @Override
- public boolean cancel() {
- return delegate().cancel();
- }
-
- @Override
- public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
- delegate().delete(store, path);
- }
-
- @Override
- public FluentFuture<? extends CommitInfo> commit() {
- return delegate().commit();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.spi;
-
-import com.google.common.collect.ForwardingObject;
-import com.google.common.util.concurrent.ListenableFuture;
-import java.util.concurrent.TimeUnit;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotificationPublishService;
-
-/**
- * Utility implementations of {@link DOMNotificationPublishService} which forwards
- * all requests to a delegate instance.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.ForwardingDOMNotificationPublishService} instead.
- */
-@Deprecated(forRemoval = true)
-public abstract class ForwardingDOMNotificationPublishService extends ForwardingObject
- implements DOMNotificationPublishService {
- @Override
- protected abstract DOMNotificationPublishService delegate();
-
- @Override
- public ListenableFuture<?> putNotification(final DOMNotification notification) throws InterruptedException {
- return delegate().putNotification(notification);
- }
-
- @Override
- public ListenableFuture<?> offerNotification(final DOMNotification notification) {
- return delegate().offerNotification(notification);
- }
-
- @Override
- public ListenableFuture<?> offerNotification(final DOMNotification notification, final long timeout,
- final TimeUnit unit) throws InterruptedException {
- return delegate().offerNotification(notification, timeout, unit);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.spi;
-
-import com.google.common.collect.ForwardingObject;
-import java.util.Collection;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-
-/**
- * Utility implementation of a {@link DOMNotificationService} which forwards all requests
- * to a delegate instance.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.ForwardingDOMNotificationService} instead.
- */
-@Deprecated(forRemoval = true)
-public abstract class ForwardingDOMNotificationService extends ForwardingObject implements DOMNotificationService {
- @Override
- protected abstract DOMNotificationService delegate();
-
- @Override
- public <T extends DOMNotificationListener> ListenerRegistration<T> registerNotificationListener(final T listener,
- final Collection<SchemaPath> types) {
- return delegate().registerNotificationListener(listener, types);
- }
-
- @Override
- public <T extends DOMNotificationListener> ListenerRegistration<T> registerNotificationListener(final T listener,
- final SchemaPath... types) {
- return delegate().registerNotificationListener(listener, types);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.dom.spi;
-
-import com.google.common.collect.ForwardingObject;
-import com.google.common.util.concurrent.CheckedFuture;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-/**
- * Utility implementation which implements {@link DOMRpcImplementation} by forwarding it to
- * a backing delegate.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.ForwardingDOMRpcImplementation} instead.
- */
-@Deprecated(forRemoval = true)
-public abstract class ForwardingDOMRpcImplementation extends ForwardingObject implements DOMRpcImplementation {
- @Override
- protected abstract @NonNull DOMRpcImplementation delegate();
-
- @Override
- public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final DOMRpcIdentifier type,
- final NormalizedNode<?, ?> input) {
- return delegate().invokeRpc(type, input);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.dom.spi;
-
-import com.google.common.collect.ForwardingObject;
-import java.util.Set;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationRegistration;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService;
-
-/**
- * Utility class which implements {@link DOMRpcProviderService} by forwarding
- * requests to a backing instance.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.ForwardingDOMRpcProviderService} instead.
- */
-@Deprecated(forRemoval = true)
-public abstract class ForwardingDOMRpcProviderService extends ForwardingObject implements DOMRpcProviderService {
- @Override
- protected abstract @NonNull DOMRpcProviderService delegate();
-
- @Override
- public <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(
- final T implementation, final DOMRpcIdentifier... types) {
- return delegate().registerRpcImplementation(implementation, types);
- }
-
- @Override
- public <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(
- final T implementation, final Set<DOMRpcIdentifier> types) {
- return delegate().registerRpcImplementation(implementation, types);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.dom.spi;
-
-import com.google.common.collect.ForwardingObject;
-import java.util.Collection;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
-import org.opendaylight.yangtools.yang.common.RpcError;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-/**
- * Utility class which implements {@link DOMRpcResult} by forwarding all methods
- * to a backing instance.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.ForwardingDOMRpcResult} instead.
- */
-@Deprecated(forRemoval = true)
-public abstract class ForwardingDOMRpcResult extends ForwardingObject implements DOMRpcResult {
- @Override
- protected abstract @NonNull DOMRpcResult delegate();
-
- @Override
- public Collection<? extends RpcError> getErrors() {
- return delegate().getErrors();
- }
-
- @Override
- public NormalizedNode<?, ?> getResult() {
- return delegate().getResult();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.md.sal.dom.spi;
-
-import com.google.common.collect.ForwardingObject;
-import com.google.common.util.concurrent.CheckedFuture;
-import org.eclipse.jdt.annotation.NonNull;
-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.DOMRpcResult;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-
-/**
- * Utility {@link DOMRpcService} which forwards all requests to a backing delegate instance.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.ForwardingDOMRpcService} instead.
- */
-@Deprecated(forRemoval = true)
-public abstract class ForwardingDOMRpcService extends ForwardingObject implements DOMRpcService {
- @Override
- protected abstract @NonNull DOMRpcService delegate();
-
- @Override
- public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final SchemaPath type,
- final NormalizedNode<?, ?> input) {
- return delegate().invokeRpc(type, input);
- }
-
- @Override
- public <T extends DOMRpcAvailabilityListener> ListenerRegistration<T> registerRpcListener(final T listener) {
- return delegate().registerRpcListener(listener);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.spi;
-
-import com.google.common.collect.ForwardingObject;
-import org.eclipse.jdt.annotation.NonNull;
-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;
-
-/**
- * Utility {@link DOMTransactionChain} implementation which forwards all interface
- * method invocation to a delegate instance.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.ForwardingDOMTransactionChain} instead.
- */
-@Deprecated(forRemoval = true)
-public abstract class ForwardingDOMTransactionChain extends ForwardingObject implements DOMTransactionChain {
- @Override
- protected abstract @NonNull DOMTransactionChain delegate();
-
- @Override
- public void close() {
- delegate().close();
- }
-
- @Override
- public DOMDataReadOnlyTransaction newReadOnlyTransaction() {
- return delegate().newReadOnlyTransaction();
- }
-
- @Override
- public DOMDataReadWriteTransaction newReadWriteTransaction() {
- return delegate().newReadWriteTransaction();
- }
-
- @Override
- public DOMDataWriteTransaction newWriteOnlyTransaction() {
- return delegate().newWriteOnlyTransaction();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.spi.data;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.annotations.Beta;
-import com.google.common.base.MoreObjects;
-import com.google.common.base.MoreObjects.ToStringHelper;
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.Nullable;
-
-/**
- * Abstract DOM Store Transaction.
- *
- * <p>
- * Convenience super implementation of DOM Store transaction which provides
- * common implementation of {@link #toString()} and {@link #getIdentifier()}.
- *
- * <p>
- * It can optionally capture the context where it was allocated.
- *
- * @param <T> identifier type
- * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.store.AbstractDOMStoreTransaction} instead.
- */
-@Deprecated(forRemoval = true)
-@Beta
-public abstract class AbstractDOMStoreTransaction<T> implements DOMStoreTransaction {
- private final Throwable debugContext;
- private final @NonNull T identifier;
-
- protected AbstractDOMStoreTransaction(final @NonNull T identifier) {
- this(identifier, false);
- }
-
- protected AbstractDOMStoreTransaction(final @NonNull T identifier, final boolean debug) {
- this.identifier = requireNonNull(identifier, "Identifier must not be null.");
- this.debugContext = debug ? new Throwable().fillInStackTrace() : null;
- }
-
- @Override
- public final T getIdentifier() {
- return identifier;
- }
-
- /**
- * Return the context in which this transaction was allocated.
- *
- * @return The context in which this transaction was allocated, or null if the context was not recorded.
- */
- public final @Nullable Throwable getDebugContext() {
- return debugContext;
- }
-
- @Override
- public final String toString() {
- return addToStringAttributes(MoreObjects.toStringHelper(this)).toString();
- }
-
- /**
- * Add class-specific toString attributes.
- *
- * @param toStringHelper
- * ToStringHelper instance
- * @return ToStringHelper instance which was passed in
- */
- protected ToStringHelper addToStringAttributes(final @NonNull ToStringHelper toStringHelper) {
- return toStringHelper.add("id", identifier);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.spi.data;
-
-import java.util.Collection;
-import java.util.List;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
-import org.opendaylight.controller.md.sal.dom.spi.AbstractDOMDataTreeChangeListenerRegistration;
-import org.opendaylight.mdsal.dom.spi.AbstractRegistrationTree;
-import org.opendaylight.mdsal.dom.spi.RegistrationTreeNode;
-import org.opendaylight.mdsal.dom.spi.RegistrationTreeSnapshot;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Abstract base class for {@link DOMStoreTreeChangePublisher} implementations.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.store.AbstractDOMStoreTreeChangePublisher} instead.
- */
-@Deprecated(forRemoval = true)
-public abstract class AbstractDOMStoreTreeChangePublisher
- extends AbstractRegistrationTree<AbstractDOMDataTreeChangeListenerRegistration<?>>
- implements DOMStoreTreeChangePublisher {
- private static final Logger LOG = LoggerFactory.getLogger(AbstractDOMStoreTreeChangePublisher.class);
-
- /**
- * Callback for subclass to notify specified registrations of a candidate at a specified path. This method is
- * guaranteed to be only called from within {@link #processCandidateTree(DataTreeCandidate)}.
- *
- * @param registrations Registrations which are affected by the candidate node
- * @param path Path of changed candidate node. Guaranteed to match the path specified by the registration
- * @param node Candidate node
- */
- protected abstract void notifyListeners(@NonNull Collection<AbstractDOMDataTreeChangeListenerRegistration<?>>
- registrations, @NonNull YangInstanceIdentifier path, @NonNull DataTreeCandidateNode node);
-
- /**
- * Callback notifying the subclass that the specified registration is being closed and it's user no longer
- * wishes to receive notifications. This notification is invoked while the
- * {@link org.opendaylight.yangtools.concepts.ListenerRegistration#close()}
- * method is executing. Subclasses can use this callback to properly remove any delayed notifications pending
- * towards the registration.
- *
- * @param registration Registration which is being closed
- */
- protected abstract void registrationRemoved(@NonNull AbstractDOMDataTreeChangeListenerRegistration<?> registration);
-
- /**
- * Process a candidate tree with respect to registered listeners.
- *
- * @param candidate candidate three which needs to be processed
- */
- protected final void processCandidateTree(final @NonNull DataTreeCandidate candidate) {
- final DataTreeCandidateNode node = candidate.getRootNode();
- if (node.getModificationType() == ModificationType.UNMODIFIED) {
- LOG.debug("Skipping unmodified candidate {}", candidate);
- return;
- }
-
- try (RegistrationTreeSnapshot<AbstractDOMDataTreeChangeListenerRegistration<?>> snapshot = takeSnapshot()) {
- lookupAndNotify(candidate.getRootPath().getPathArguments(), 0, snapshot.getRootNode(), candidate);
- }
- }
-
- @Override
- public final <L extends DOMDataTreeChangeListener> AbstractDOMDataTreeChangeListenerRegistration<L>
- registerTreeChangeListener(final YangInstanceIdentifier treeId, final L listener) {
- // Take the write lock
- takeLock();
- try {
- final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> node =
- findNodeFor(treeId.getPathArguments());
- final AbstractDOMDataTreeChangeListenerRegistration<L> reg =
- new AbstractDOMDataTreeChangeListenerRegistration<L>(listener) {
- @Override
- protected void removeRegistration() {
- AbstractDOMStoreTreeChangePublisher.this.removeRegistration(node, this);
- registrationRemoved(this);
- }
- };
-
- addRegistration(node, reg);
- return reg;
- } finally {
- // Always release the lock
- releaseLock();
- }
- }
-
- private void lookupAndNotify(final List<PathArgument> args, final int offset,
- final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> node,
- final DataTreeCandidate candidate) {
- if (args.size() != offset) {
- final PathArgument arg = args.get(offset);
-
- final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> exactChild =
- node.getExactChild(arg);
- if (exactChild != null) {
- lookupAndNotify(args, offset + 1, exactChild, candidate);
- }
-
- for (RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> c :
- node.getInexactChildren(arg)) {
- lookupAndNotify(args, offset + 1, c, candidate);
- }
- } else {
- notifyNode(candidate.getRootPath(), node, candidate.getRootNode());
- }
- }
-
- private void notifyNode(final YangInstanceIdentifier path,
- final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> regNode,
- final DataTreeCandidateNode candNode) {
- if (candNode.getModificationType() == ModificationType.UNMODIFIED) {
- LOG.debug("Skipping unmodified candidate {}", path);
- return;
- }
-
- final Collection<AbstractDOMDataTreeChangeListenerRegistration<?>> regs = regNode.getRegistrations();
- if (!regs.isEmpty()) {
- notifyListeners(regs, path, candNode);
- }
-
- for (DataTreeCandidateNode candChild : candNode.getChildNodes()) {
- if (candChild.getModificationType() != ModificationType.UNMODIFIED) {
- final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> regChild =
- regNode.getExactChild(candChild.getIdentifier());
- if (regChild != null) {
- notifyNode(path.node(candChild.getIdentifier()), regChild, candChild);
- }
-
- for (RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> rc :
- regNode.getInexactChildren(candChild.getIdentifier())) {
- notifyNode(path.node(candChild.getIdentifier()), rc, candChild);
- }
- }
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.spi.data;
-
-import static com.google.common.base.Preconditions.checkState;
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.annotations.Beta;
-import java.util.AbstractMap.SimpleEntry;
-import java.util.Map.Entry;
-import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
-import org.opendaylight.controller.sal.core.spi.data.SnapshotBackedReadTransaction.TransactionClosePrototype;
-import org.opendaylight.controller.sal.core.spi.data.SnapshotBackedWriteTransaction.TransactionReadyPrototype;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Abstract implementation of the {@link DOMStoreTransactionChain} interface relying on {@link DataTreeSnapshot}
- * supplier and backend commit coordinator.
- *
- * @param <T> transaction identifier type
- * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.store.AbstractSnapshotBackedTransactionChain} instead.
- */
-@Deprecated(forRemoval = true)
-@Beta
-public abstract class AbstractSnapshotBackedTransactionChain<T> extends TransactionReadyPrototype<T>
- implements DOMStoreTransactionChain, TransactionClosePrototype<T> {
- private abstract static class State {
- /**
- * Allocate a new snapshot.
- *
- * @return A new snapshot
- */
- protected abstract DataTreeSnapshot getSnapshot(Object transactionId);
- }
-
- private static final class Idle extends State {
- private final AbstractSnapshotBackedTransactionChain<?> chain;
-
- Idle(final AbstractSnapshotBackedTransactionChain<?> chain) {
- this.chain = requireNonNull(chain);
- }
-
- @Override
- protected DataTreeSnapshot getSnapshot(final Object transactionId) {
- return chain.takeSnapshot();
- }
- }
-
- /**
- * We have a transaction out there.
- */
- private static final class Allocated extends State {
- private static final AtomicReferenceFieldUpdater<Allocated, DataTreeSnapshot> SNAPSHOT_UPDATER =
- AtomicReferenceFieldUpdater.newUpdater(Allocated.class, DataTreeSnapshot.class, "snapshot");
- private final DOMStoreWriteTransaction transaction;
- private volatile DataTreeSnapshot snapshot;
-
- Allocated(final DOMStoreWriteTransaction transaction) {
- this.transaction = requireNonNull(transaction);
- }
-
- public DOMStoreWriteTransaction getTransaction() {
- return transaction;
- }
-
- @Override
- protected DataTreeSnapshot getSnapshot(final Object transactionId) {
- final DataTreeSnapshot ret = snapshot;
- checkState(ret != null,
- "Could not get snapshot for transaction %s - previous transaction %s is not ready yet",
- transactionId, transaction.getIdentifier());
- return ret;
- }
-
- void setSnapshot(final DataTreeSnapshot snapshot) {
- final boolean success = SNAPSHOT_UPDATER.compareAndSet(this, null, snapshot);
- checkState(success, "Transaction %s has already been marked as ready", transaction.getIdentifier());
- }
- }
-
- /**
- * Chain is logically shut down, no further allocation allowed.
- */
- private static final class Shutdown extends State {
- private final String message;
-
- Shutdown(final String message) {
- this.message = requireNonNull(message);
- }
-
- @Override
- protected DataTreeSnapshot getSnapshot(final Object transactionId) {
- throw new IllegalStateException(message);
- }
- }
-
- @SuppressWarnings("rawtypes")
- private static final AtomicReferenceFieldUpdater<AbstractSnapshotBackedTransactionChain, State> STATE_UPDATER =
- AtomicReferenceFieldUpdater.newUpdater(AbstractSnapshotBackedTransactionChain.class, State.class, "state");
- private static final Logger LOG = LoggerFactory.getLogger(AbstractSnapshotBackedTransactionChain.class);
- private static final Shutdown CLOSED = new Shutdown("Transaction chain is closed");
- private static final Shutdown FAILED = new Shutdown("Transaction chain has failed");
- private final Idle idleState;
- private volatile State state;
-
- protected AbstractSnapshotBackedTransactionChain() {
- idleState = new Idle(this);
- state = idleState;
- }
-
- private Entry<State, DataTreeSnapshot> getSnapshot(final T transactionId) {
- final State localState = state;
- return new SimpleEntry<>(localState, localState.getSnapshot(transactionId));
- }
-
- private boolean recordTransaction(final State expected, final DOMStoreWriteTransaction transaction) {
- final State localState = new Allocated(transaction);
- return STATE_UPDATER.compareAndSet(this, expected, localState);
- }
-
- @Override
- public final DOMStoreReadTransaction newReadOnlyTransaction() {
- return newReadOnlyTransaction(nextTransactionIdentifier());
- }
-
- protected DOMStoreReadTransaction newReadOnlyTransaction(final T transactionId) {
- final Entry<State, DataTreeSnapshot> entry = getSnapshot(transactionId);
- return SnapshotBackedTransactions.newReadTransaction(transactionId, getDebugTransactions(), entry.getValue(),
- this);
- }
-
- @Override
- public void transactionClosed(final SnapshotBackedReadTransaction<T> tx) {
- // Defaults to no-op
- }
-
- @Override
- public final DOMStoreReadWriteTransaction newReadWriteTransaction() {
- return newReadWriteTransaction(nextTransactionIdentifier());
- }
-
- protected DOMStoreReadWriteTransaction newReadWriteTransaction(final T transactionId) {
- Entry<State, DataTreeSnapshot> entry;
- DOMStoreReadWriteTransaction ret;
-
- do {
- entry = getSnapshot(transactionId);
- ret = new SnapshotBackedReadWriteTransaction<>(transactionId, getDebugTransactions(), entry.getValue(),
- this);
- } while (!recordTransaction(entry.getKey(), ret));
-
- return ret;
- }
-
- @Override
- public final DOMStoreWriteTransaction newWriteOnlyTransaction() {
- return newWriteOnlyTransaction(nextTransactionIdentifier());
- }
-
- protected DOMStoreWriteTransaction newWriteOnlyTransaction(final T transactionId) {
- Entry<State, DataTreeSnapshot> entry;
- DOMStoreWriteTransaction ret;
-
- do {
- entry = getSnapshot(transactionId);
- ret = new SnapshotBackedWriteTransaction<>(transactionId, getDebugTransactions(), entry.getValue(), this);
- } while (!recordTransaction(entry.getKey(), ret));
-
- return ret;
- }
-
- @Override
- protected final void transactionAborted(final SnapshotBackedWriteTransaction<T> tx) {
- final State localState = state;
- if (localState instanceof Allocated) {
- final Allocated allocated = (Allocated)localState;
- if (allocated.getTransaction().equals(tx)) {
- final boolean success = STATE_UPDATER.compareAndSet(this, localState, idleState);
- if (!success) {
- LOG.warn(
- "Transaction {} aborted, but chain {} state already transitioned from {} to {}, very strange",
- tx, this, localState, state);
- }
- }
- }
- }
-
- @Override
- protected final DOMStoreThreePhaseCommitCohort transactionReady(
- final SnapshotBackedWriteTransaction<T> tx,
- final DataTreeModification tree,
- final Exception readyError) {
-
- final State localState = state;
-
- if (localState instanceof Allocated) {
- final Allocated allocated = (Allocated)localState;
- final DOMStoreWriteTransaction transaction = allocated.getTransaction();
- checkState(tx.equals(transaction), "Mis-ordered ready transaction %s last allocated was %s", tx,
- transaction);
- allocated.setSnapshot(tree);
- } else {
- LOG.debug("Ignoring transaction {} readiness due to state {}", tx, localState);
- }
-
- return createCohort(tx, tree, readyError);
- }
-
- @Override
- public final void close() {
- final State localState = state;
-
- do {
- checkState(!CLOSED.equals(localState), "Transaction chain %s has been closed", this);
- if (FAILED.equals(localState)) {
- LOG.debug("Ignoring user close in failed state");
- return;
- }
- } while (!STATE_UPDATER.compareAndSet(this, localState, CLOSED));
- }
-
- /**
- * Notify the base logic that a previously-submitted transaction has been committed successfully.
- *
- * @param transaction Transaction which completed successfully.
- */
- protected final void onTransactionCommited(final SnapshotBackedWriteTransaction<T> transaction) {
- // If the committed transaction was the one we allocated last,
- // we clear it and the ready snapshot, so the next transaction
- // allocated refers to the data tree directly.
- final State localState = state;
-
- if (!(localState instanceof Allocated)) {
- // This can legally happen if the chain is shut down before the transaction was committed
- // by the backend.
- LOG.debug("Ignoring successful transaction {} in state {}", transaction, localState);
- return;
- }
-
- final Allocated allocated = (Allocated)localState;
- final DOMStoreWriteTransaction tx = allocated.getTransaction();
- if (!tx.equals(transaction)) {
- LOG.debug("Ignoring non-latest successful transaction {} in state {}", transaction, allocated);
- return;
- }
-
- if (!STATE_UPDATER.compareAndSet(this, localState, idleState)) {
- LOG.debug("Transaction chain {} has already transitioned from {} to {}, not making it idle",
- this, localState, state);
- }
- }
-
- /**
- * Notify the base logic that a previously-submitted transaction has failed.
- *
- * @param transaction Transaction which failed.
- * @param cause Failure cause
- */
- protected final void onTransactionFailed(final SnapshotBackedWriteTransaction<T> transaction,
- final Throwable cause) {
- LOG.debug("Transaction chain {} failed on transaction {}", this, transaction, cause);
- state = FAILED;
- }
-
- /**
- * Return the next transaction identifier.
- *
- * @return transaction identifier.
- */
- protected abstract T nextTransactionIdentifier();
-
- /**
- * Inquire as to whether transactions should record their allocation context.
- *
- * @return True if allocation context should be recorded.
- */
- protected abstract boolean getDebugTransactions();
-
- /**
- * Take a fresh {@link DataTreeSnapshot} from the backend.
- *
- * @return A new snapshot.
- */
- protected abstract DataTreeSnapshot takeSnapshot();
-
- /**
- * Create a cohort for driving the transaction through the commit process.
- *
- * @param transaction Transaction handle
- * @param modification {@link DataTreeModification} which needs to be applied to the backend
- * @param operationError Any previous error that could be reported through three phase commit
- * @return A {@link DOMStoreThreePhaseCommitCohort} cohort.
- */
- protected abstract DOMStoreThreePhaseCommitCohort createCohort(SnapshotBackedWriteTransaction<T> transaction,
- DataTreeModification modification,
- Exception operationError);
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.spi.data;
-
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-/**
- * DOM Data Store
- *
- * <p>
- * DOM Data Store provides transactional tree-like storage for YANG-modeled
- * entities described by YANG schema and represented by {@link NormalizedNode}.
- *
- * <p>
- * Read and write access to stored data is provided only via transactions
- * created using {@link #newReadOnlyTransaction()},
- * {@link #newWriteOnlyTransaction()} and {@link #newReadWriteTransaction()}, or
- * by creating {@link org.opendaylight.controller.md.sal.common.api.data.TransactionChain}.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.store.DOMStore} instead.
- */
-@Deprecated(forRemoval = true)
-public interface DOMStore extends DOMStoreTransactionFactory {
- /**
- * Creates new transaction chain.
- *
- * <p>
- * Transactions in a chain need to be committed in sequence and each
- * transaction should see the effects of previous transactions as if they
- * happened.
- *
- * @see DOMStoreTransactionChain for more information.
- * @return Newly created transaction chain.
- */
- DOMStoreTransactionChain createTransactionChain();
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.spi.data;
-
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-@Deprecated(forRemoval = true)
-public interface DOMStoreReadTransaction extends DOMStoreTransaction {
-
- /**
- * Reads data from provided logical data store located at provided path.
- *
- * @param path
- * Path which uniquely identifies subtree which client want to
- * read
- * @return a CheckFuture containing the result of the read. The Future blocks until the
- * commit operation is complete. Once complete:
- * <ul>
- * <li>If the data at the supplied path exists, the Future returns an Optional object
- * containing the data.</li>
- * <li>If the data at the supplied path does not exist, the Future returns
- * Optional#absent().</li>
- * <li>If the read of the data fails, the Future will fail with a
- * {@link ReadFailedException} or an exception derived from ReadFailedException.</li>
- * </ul>
- */
- CheckedFuture<Optional<NormalizedNode<?,?>>, ReadFailedException> read(YangInstanceIdentifier path);
-
- /**
- * Checks if data is available in the logical data store located at provided path.
- *
- * <p>
- * Note: a successful result from this method makes no guarantee that a subsequent call to {@link #read}
- * will succeed. It is possible that the data resides in a data store on a remote node and, if that
- * node goes down or a network failure occurs, a subsequent read would fail. Another scenario is if
- * the data is deleted in between the calls to <code>exists</code> and <code>read</code>
- *
- * @param path
- * Path which uniquely identifies subtree which client want to
- * check existence of
- * @return a CheckFuture containing the result of the check.
- * <ul>
- * <li>If the data at the supplied path exists, the Future returns a Boolean
- * whose value is true, false otherwise</li>
- * <li>If checking for the data fails, the Future will fail with a
- * {@link ReadFailedException} or an exception derived from ReadFailedException.</li>
- * </ul>
- */
- CheckedFuture<Boolean, ReadFailedException> exists(YangInstanceIdentifier path);
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.spi.data;
-
-/**
- * Combination of a {@link DOMStoreReadTransaction} and {@link DOMStoreWriteTransaction}.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction} instead.
- */
-@Deprecated(forRemoval = true)
-public interface DOMStoreReadWriteTransaction extends DOMStoreReadTransaction, DOMStoreWriteTransaction {
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.spi.data;
-
-import com.google.common.util.concurrent.ListenableFuture;
-
-/**
- * Interface implemented by the {@link DOMStore} and exposed for each {@link DOMStoreWriteTransaction}
- * upon its transition to Ready state. The frontend (DOMStore user) uses this interface to drive the
- * commit procedure across potentially multiple DOMStores using the Three-Phase-Commit (3PC) Protocol,
- * as described in <a href="https://en.wikipedia.org/wiki/Three-phase_commit">Three-Phase-Commit Protocol</a>.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort} instead.
- */
-@Deprecated(forRemoval = true)
-public interface DOMStoreThreePhaseCommitCohort {
-
- /**
- * Sends transaction associated with this three phase commit instance to the
- * participant, participant votes on the transaction, if the transaction
- * should be committed or aborted.
- *
- * @return ListenableFuture with vote of the participant. Vote
- * {@link ListenableFuture#get()} is following:
- * <ul>
- * <li>
- * true if transaction is approved by data store.
- * <li>false if the transaction is not approved by data store and
- * should be aborted.
- * </ul>
- */
- ListenableFuture<Boolean> canCommit();
-
- /**
- * Initiates a pre-commit phase of associated transaction on datastore.
- *
- * <p>
- * This message is valid only and only if and only if the participant responded
- * on {@link #canCommit()} call with positive response.
- *
- * @return ListenableFuture representing acknowledgment for participant
- * that pre-commit message was received and processed.
- */
- ListenableFuture<Void> preCommit();
-
- /**
- * Initiates a abort phase of associated transaction on data store.
- *
- * @return ListenableFuture representing acknowledgment for participant
- * that abort message was received.
- */
- ListenableFuture<Void> abort();
-
- /**
- * Initiates a commit phase on of associated transaction on data store.
- *
- * @return ListenableFuture representing acknowledgment for participant
- * that commit message was received and commit of transaction was
- * processed.
- */
- ListenableFuture<Void> commit();
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.spi.data;
-
-import org.opendaylight.yangtools.concepts.Identifiable;
-
-/**
- * DOM Data Store transaction.
- *
- * @see DOMStoreReadTransaction
- * @see DOMStoreWriteTransaction
- * @see DOMStoreReadWriteTransaction
- * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.store.DOMStoreTransaction} instead.
- */
-@Deprecated(forRemoval = true)
-public interface DOMStoreTransaction extends AutoCloseable, Identifiable<Object> {
- /**
- * Unique identifier of the transaction.
- */
- @Override
- Object getIdentifier();
-
- @Override
- void close();
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.spi.data;
-
-/**
- * A chain of transactions. Transactions in a chain need to be committed in
- * sequence and each transaction must see the effects of previous transactions
- * as if they happened. A chain makes no guarantees of atomicity, in fact
- * transactions are committed as soon as possible.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain} instead.
- */
-@Deprecated(forRemoval = true)
-public interface DOMStoreTransactionChain extends DOMStoreTransactionFactory, AutoCloseable {
-
- /**
- * Create a new read only transaction which will continue the chain. The
- * previous write transaction has to be either READY or CANCELLED.
- *
- * <p>
- * If previous write transaction was already commited to data store, new
- * read-only transaction is same as obtained via {@link DOMStore#newReadOnlyTransaction()}
- * and contains merged result of previous one and current state of data store.
- *
- * <p>
- * Otherwise read-only transaction presents isolated view as if previous read-write
- * transaction was successful. State which was introduced by other transactions
- * outside this transaction chain after creation of previous transaction is not visible.
- *
- * @return New transaction in the chain.
- * @throws IllegalStateException
- * if the previous transaction was not READY or CANCELLED, or
- * if the chain has been closed.
- */
- @Override
- DOMStoreReadTransaction newReadOnlyTransaction();
-
- /**
- * Create a new read write transaction which will continue the chain. The
- * previous read-write transaction has to be either COMMITED or CANCELLED.
- *
- * <p>
- * If previous write transaction was already commited to data store, new
- * read-write transaction is same as obtained via {@link DOMStore#newReadWriteTransaction()}
- * and contains merged result of previous one and current state of data store.
- *
- * <p>
- * Otherwise read-write transaction presents isolated view as if previous read-write
- * transaction was successful. State which was introduced by other transactions
- * outside this transaction chain after creation of previous transaction is not visible.
- *
- * @return New transaction in the chain.
- * @throws IllegalStateException
- * if the previous transaction was not READY or CANCELLED, or
- * if the chain has been closed.
- */
- @Override
- DOMStoreReadWriteTransaction newReadWriteTransaction();
-
- /**
- * Create a new write-only transaction which will continue the chain. The
- * previous read-write transaction has to be either READY or CANCELLED.
- *
- *
- * @return New transaction in the chain.
- * @throws IllegalStateException
- * if the previous transaction was not READY or CANCELLED, or
- * if the chain has been closed.
- */
- @Override
- DOMStoreWriteTransaction newWriteOnlyTransaction();
-
- /**
- * Closes Transaction Chain.
- *
- * <p>
- * Close method of transaction chain does not guarantee that
- * last alocated transaction is ready or was submitted.
- *
- * @throws IllegalStateException If any of the outstanding created transactions was not canceled or ready.
- */
- @Override
- void close();
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.spi.data;
-
-/**
- * Factory for DOM Store Transactions
- *
- * <p>
- * Factory provides method to construct read-only, read-write and write-only
- * transactions, which may be used to retrieve and modify stored information in
- * Underlying {@link DOMStore} or {@link DOMStoreTransactionChain}.
- *
- * <p>
- * See DOMStore, DOMStoreTransactionChain for concrete variations of this factory.
- *
- * <p>
- * <b>Note:</b> This interface is used only to define common functionality
- * between {@link DOMStore} and {@link DOMStoreTransactionChain}, which
- * further specify behaviour of returned transactions.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionFactory} instead.
- */
-@Deprecated(forRemoval = true)
-public interface DOMStoreTransactionFactory {
-
- /**
- * Creates a read only transaction.
- *
- * <p>
- * Creates a new read-only transaction, which provides read access to
- * snapshot of current state.
- *
- * @see DOMStoreReadTransaction for more information.
- * @return new {@link DOMStoreReadTransaction}
- * @throws IllegalStateException
- * If state of factory prevents allocating new transaction.
- *
- */
- DOMStoreReadTransaction newReadOnlyTransaction();
-
- /**
- * Creates write only transaction.
- *
- * @see DOMStoreWriteTransaction for more information.
- * @return new {@link DOMStoreWriteTransaction}
- * @throws IllegalStateException If state of factory prevents allocating new transaction.
- */
- DOMStoreWriteTransaction newWriteOnlyTransaction();
-
- /**
- * Creates Read-Write transaction.
- *
- * @see DOMStoreReadWriteTransaction for more information.
- * @return new {@link DOMStoreWriteTransaction}
- * @throws IllegalStateException If state of factory prevents allocating new transaction.
- */
- DOMStoreReadWriteTransaction newReadWriteTransaction();
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.spi.data;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-
-/**
- * Interface implemented by DOMStore implementations which allow registration
- * of {@link DOMDataTreeChangeListener} instances.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.store.DOMStoreTreeChangePublisher} instead.
- */
-@Deprecated(forRemoval = true)
-public interface DOMStoreTreeChangePublisher {
- /**
- * Registers a {@link DOMDataTreeChangeListener} to receive
- * notifications when data changes under a given path in the conceptual data
- * tree.
- *
- * <p>
- * You are able to register for notifications for any node or subtree
- * which can be represented using {@link YangInstanceIdentifier}.
- *
- * <p>
- * You are able to register for data change notifications for a subtree or leaf
- * even if it does not exist. You will receive notification once that node is
- * created.
- *
- * <p>
- * If there is any pre-existing data in data tree on path for which you are
- * registering, you will receive initial data change event, which will
- * contain all pre-existing data, marked as created.
- *
- * <p>
- * This method returns a {@link ListenerRegistration} object. To
- * "unregister" your listener for changes call the {@link ListenerRegistration#close()}
- * method on this returned object.
- *
- * <p>
- * You MUST explicitly unregister your listener when you no longer want to receive
- * notifications. This is especially true in OSGi environments, where failure to
- * do so during bundle shutdown can lead to stale listeners being still registered.
- *
- * @param treeId
- * Data tree identifier of the subtree which should be watched for
- * changes.
- * @param listener
- * Listener instance which is being registered
- * @return Listener registration object, which may be used to unregister
- * your listener using {@link ListenerRegistration#close()} to stop
- * delivery of change events.
- */
- <L extends DOMDataTreeChangeListener> @NonNull ListenerRegistration<L> registerTreeChangeListener(
- @NonNull YangInstanceIdentifier treeId, @NonNull L listener);
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.spi.data;
-
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-@Deprecated(forRemoval = true)
-public interface DOMStoreWriteTransaction extends DOMStoreTransaction {
-
- /**
- * Store a provided data at specified path. This acts as a add / replace
- * operation, which is to say that whole subtree will be replaced by
- * specified path.
- *
- * <p>
- * If you need add or merge of current object with specified use
- * {@link #merge(YangInstanceIdentifier, NormalizedNode)}.
- *
- * @param path the path to write
- * @param data data object to be written
- * @throws IllegalStateException
- * if the client code already sealed transaction and invoked
- * {@link #ready()}
- */
- void write(YangInstanceIdentifier path, NormalizedNode<?, ?> data);
-
- /**
- * Store a provided data at specified path. This acts as a add / replace
- * operation, which is to say that whole subtree will be replaced by
- * specified path.
- *
- * @param path the path to write
- * @param data data object to be written
- * @throws IllegalStateException
- * if the client code already sealed transaction and invoked
- * {@link #ready()}
- */
- void merge(YangInstanceIdentifier path, NormalizedNode<?, ?> data);
-
- /**
- * Deletes data and whole subtree located at provided path.
- *
- * @param path path to delete
- * @throws IllegalStateException
- * if the client code already sealed transaction and invoked
- * {@link #ready()}
- */
- void delete(YangInstanceIdentifier path);
-
- /**
- * Seals transaction, and returns three-phase commit cohort associated
- * with this transaction and DOM Store to be coordinated by coordinator.
- *
- * @return Three Phase Commit Cohort instance for this transaction.
- */
- DOMStoreThreePhaseCommitCohort ready();
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.spi.data;
-
-import com.google.common.annotations.Beta;
-import com.google.common.collect.ForwardingObject;
-import com.google.common.util.concurrent.ListenableFuture;
-
-/**
- * Abstract base class for {@link DOMStoreThreePhaseCommitCohort} implementations,
- * which forward most of their functionality to a backend {@link #delegate()}.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.store.ForwardingDOMStoreThreePhaseCommitCohort} instead.
- */
-@Deprecated(forRemoval = true)
-@Beta
-public abstract class ForwardingDOMStoreThreePhaseCommitCohort extends ForwardingObject
- implements DOMStoreThreePhaseCommitCohort {
- @Override
- protected abstract DOMStoreThreePhaseCommitCohort delegate();
-
- @Override
- public ListenableFuture<Boolean> canCommit() {
- return delegate().canCommit();
- }
-
- @Override
- public ListenableFuture<Void> preCommit() {
- return delegate().preCommit();
- }
-
- @Override
- public ListenableFuture<Void> abort() {
- return delegate().abort();
- }
-
- @Override
- public ListenableFuture<Void> commit() {
- return delegate().commit();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.spi.data;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.annotations.Beta;
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.Futures;
-import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Implementation of read-only transaction backed by {@link DataTreeSnapshot}.
- *
- * <p>
- * Implementation of read-only transaction backed by {@link DataTreeSnapshot}
- * which delegates most of its calls to similar methods provided by underlying snapshot.
- *
- * @param <T> identifier type
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.store.SnapshotBackedReadTransaction} instead.
- */
-@Deprecated(forRemoval = true)
-@Beta
-public final class SnapshotBackedReadTransaction<T> extends AbstractDOMStoreTransaction<T>
- implements DOMStoreReadTransaction {
- private static final Logger LOG = LoggerFactory.getLogger(SnapshotBackedReadTransaction.class);
-
- @SuppressWarnings("rawtypes")
- private static final AtomicReferenceFieldUpdater<SnapshotBackedReadTransaction, DataTreeSnapshot> SNAPSHOT_UPDATER =
- AtomicReferenceFieldUpdater.newUpdater(SnapshotBackedReadTransaction.class, DataTreeSnapshot.class,
- "stableSnapshot");
-
- // Guarded by stableSnapshot CAS, hence it does not need to be volatile
- private TransactionClosePrototype<T> closeImpl;
- private volatile DataTreeSnapshot stableSnapshot;
-
- /**
- * Creates a new read-only transaction.
- *
- * @param identifier Transaction Identifier
- * @param debug Enable transaction debugging
- * @param snapshot Snapshot which will be modified.
- */
- SnapshotBackedReadTransaction(final T identifier, final boolean debug, final DataTreeSnapshot snapshot,
- final TransactionClosePrototype<T> closeImpl) {
- super(identifier, debug);
- this.stableSnapshot = requireNonNull(snapshot);
- this.closeImpl = closeImpl;
- LOG.debug("ReadOnly Tx: {} allocated with snapshot {}", identifier, snapshot);
- }
-
- @Override
- public void close() {
- final DataTreeSnapshot prev = SNAPSHOT_UPDATER.getAndSet(this, null);
- if (prev == null) {
- LOG.debug("Store transaction: {} : previously closed", getIdentifier());
- return;
- }
-
- LOG.debug("Store transaction: {} : Closed", getIdentifier());
- if (closeImpl != null) {
- closeImpl.transactionClosed(this);
- closeImpl = null;
- }
- }
-
- @Override
- @SuppressWarnings("checkstyle:IllegalCatch")
- public CheckedFuture<Optional<NormalizedNode<?,?>>, ReadFailedException> read(final YangInstanceIdentifier path) {
- LOG.debug("Tx: {} Read: {}", getIdentifier(), path);
- requireNonNull(path, "Path must not be null.");
-
- final DataTreeSnapshot snapshot = stableSnapshot;
- if (snapshot == null) {
- return Futures.immediateFailedCheckedFuture(new ReadFailedException("Transaction is closed"));
- }
-
- try {
- return Futures.immediateCheckedFuture(Optional.fromJavaUtil(snapshot.readNode(path)));
- } catch (RuntimeException e) {
- LOG.error("Tx: {} Failed Read of {}", getIdentifier(), path, e);
- return Futures.immediateFailedCheckedFuture(new ReadFailedException("Read failed",e));
- }
- }
-
- @Override
- public CheckedFuture<Boolean, ReadFailedException> exists(final YangInstanceIdentifier path) {
- LOG.debug("Tx: {} Exists: {}", getIdentifier(), path);
- requireNonNull(path, "Path must not be null.");
-
- try {
- return Futures.immediateCheckedFuture(read(path).checkedGet().isPresent());
- } catch (ReadFailedException e) {
- return Futures.immediateFailedCheckedFuture(e);
- }
- }
-
- /**
- * Prototype implementation of {@link SnapshotBackedReadTransaction#close()}.
- *
- * <p>
- * This class is intended to be implemented by Transaction factories responsible for allocation
- * of {@link org.opendaylight.mdsal.dom.spi.store.SnapshotBackedReadTransaction} and
- * providing underlying logic for applying implementation.
- *
- * @param <T> identifier type
- */
- public interface TransactionClosePrototype<T> {
- /**
- * Called when a transaction is closed. This is not invoked at most once for every transaction.
- *
- * @param tx Transaction which got closed.
- */
- void transactionClosed(SnapshotBackedReadTransaction<T> tx);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.spi.data;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.annotations.Beta;
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.Futures;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Implementation of Read-Write transaction which is backed by {@link DataTreeSnapshot}
- * and executed according to {@link TransactionReadyPrototype}.
- *
- * @param <T> identifier type
- * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.store.SnapshotBackedReadWriteTransaction} instead.
- */
-@Deprecated(forRemoval = true)
-@Beta
-public final class SnapshotBackedReadWriteTransaction<T> extends SnapshotBackedWriteTransaction<T>
- implements DOMStoreReadWriteTransaction {
- private static final Logger LOG = LoggerFactory.getLogger(SnapshotBackedReadWriteTransaction.class);
-
- SnapshotBackedReadWriteTransaction(final T identifier, final boolean debug,
- final DataTreeSnapshot snapshot, final TransactionReadyPrototype<T> readyImpl) {
- super(identifier, debug, snapshot, readyImpl);
- }
-
- @Override
- @SuppressWarnings("checkstyle:IllegalCatch")
- public CheckedFuture<Optional<NormalizedNode<?,?>>, ReadFailedException> read(final YangInstanceIdentifier path) {
- LOG.debug("Tx: {} Read: {}", getIdentifier(), path);
- requireNonNull(path, "Path must not be null.");
-
- final Optional<NormalizedNode<?, ?>> result;
- try {
- result = readSnapshotNode(path);
- } catch (RuntimeException e) {
- LOG.error("Tx: {} Failed Read of {}", getIdentifier(), path, e);
- return Futures.immediateFailedCheckedFuture(new ReadFailedException("Read failed", e));
- }
-
- if (result == null) {
- return Futures.immediateFailedCheckedFuture(new ReadFailedException("Transaction is closed"));
- } else {
- return Futures.immediateCheckedFuture(result);
- }
- }
-
- @Override
- public CheckedFuture<Boolean, ReadFailedException> exists(final YangInstanceIdentifier path) {
- try {
- return Futures.immediateCheckedFuture(
- read(path).checkedGet().isPresent());
- } catch (ReadFailedException e) {
- return Futures.immediateFailedCheckedFuture(e);
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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.spi.data;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.annotations.Beta;
-import org.opendaylight.controller.sal.core.spi.data.SnapshotBackedReadTransaction.TransactionClosePrototype;
-import org.opendaylight.controller.sal.core.spi.data.SnapshotBackedWriteTransaction.TransactionReadyPrototype;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
-
-/**
- * Public utility class for instantiating snapshot-backed transactions.
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.store.SnapshotBackedTransactions} instead.
- */
-@Deprecated(forRemoval = true)
-@Beta
-public final class SnapshotBackedTransactions {
- private SnapshotBackedTransactions() {
- throw new UnsupportedOperationException("Utility class");
- }
-
- /**
- * Creates a new read-only transaction.
- *
- * @param identifier Transaction Identifier
- * @param debug Enable transaction debugging
- * @param snapshot Snapshot which will be modified.
- * @return A new read-only transaction
- */
- public static <T> SnapshotBackedReadTransaction<T> newReadTransaction(final T identifier, final boolean debug,
- final DataTreeSnapshot snapshot) {
- return new SnapshotBackedReadTransaction<>(identifier, debug, snapshot, null);
- }
-
- /**
- * Creates a new read-only transaction.
- *
- * @param identifier Transaction Identifier
- * @param debug Enable transaction debugging
- * @param snapshot Snapshot which will be modified.
- * @param closeImpl Implementation of close method
- * @return A new read-only transaction
- */
- public static <T> SnapshotBackedReadTransaction<T> newReadTransaction(final T identifier,
- final boolean debug, final DataTreeSnapshot snapshot, final TransactionClosePrototype<T> closeImpl) {
- return new SnapshotBackedReadTransaction<>(identifier, debug, snapshot, requireNonNull(closeImpl));
- }
-
- /**
- * Creates a new read-write transaction.
- *
- * @param identifier transaction Identifier
- * @param debug Enable transaction debugging
- * @param snapshot Snapshot which will be modified.
- * @param readyImpl Implementation of ready method.
- * @return A new read-write transaction
- */
- public static <T> SnapshotBackedReadWriteTransaction<T> newReadWriteTransaction(final T identifier,
- final boolean debug, final DataTreeSnapshot snapshot, final TransactionReadyPrototype<T> readyImpl) {
- return new SnapshotBackedReadWriteTransaction<>(identifier, debug, snapshot, readyImpl);
- }
-
- /**
- * Creates a new write-only transaction.
- *
- * @param identifier transaction Identifier
- * @param debug Enable transaction debugging
- * @param snapshot Snapshot which will be modified.
- * @param readyImpl Implementation of ready method.
- * @return A new write transaction
- */
- public static <T> SnapshotBackedWriteTransaction<T> newWriteTransaction(final T identifier, final boolean debug,
- final DataTreeSnapshot snapshot, final TransactionReadyPrototype<T> readyImpl) {
- return new SnapshotBackedWriteTransaction<>(identifier, debug, snapshot, readyImpl);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.spi.data;
-
-import static com.google.common.base.Preconditions.checkState;
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.annotations.Beta;
-import com.google.common.base.MoreObjects.ToStringHelper;
-import com.google.common.base.Optional;
-import com.google.common.base.Throwables;
-import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
-import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Implementation of Write transaction which is backed by
- * {@link DataTreeSnapshot} and executed according to
- * {@link org.opendaylight.controller.sal.core.spi.data.SnapshotBackedWriteTransaction.TransactionReadyPrototype}.
- *
- * @param <T> Identifier type
- * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.store.SnapshotBackedWriteTransaction} instead.
- */
-@Deprecated(forRemoval = true)
-@Beta
-public class SnapshotBackedWriteTransaction<T> extends AbstractDOMStoreTransaction<T>
- implements DOMStoreWriteTransaction {
- private static final Logger LOG = LoggerFactory.getLogger(SnapshotBackedWriteTransaction.class);
- @SuppressWarnings("rawtypes")
- private static final AtomicReferenceFieldUpdater<SnapshotBackedWriteTransaction, TransactionReadyPrototype>
- READY_UPDATER = AtomicReferenceFieldUpdater.newUpdater(SnapshotBackedWriteTransaction.class,
- TransactionReadyPrototype.class, "readyImpl");
- @SuppressWarnings("rawtypes")
- private static final AtomicReferenceFieldUpdater<SnapshotBackedWriteTransaction, DataTreeModification>
- TREE_UPDATER = AtomicReferenceFieldUpdater.newUpdater(SnapshotBackedWriteTransaction.class,
- DataTreeModification.class, "mutableTree");
-
- // non-null when not ready
- private volatile TransactionReadyPrototype<T> readyImpl;
- // non-null when not committed/closed
- private volatile DataTreeModification mutableTree;
-
- SnapshotBackedWriteTransaction(final T identifier, final boolean debug,
- final DataTreeSnapshot snapshot, final TransactionReadyPrototype<T> readyImpl) {
- super(identifier, debug);
- this.readyImpl = requireNonNull(readyImpl, "readyImpl must not be null.");
- mutableTree = snapshot.newModification();
- LOG.debug("Write Tx: {} allocated with snapshot {}", identifier, snapshot);
- }
-
- @Override
- @SuppressWarnings("checkstyle:IllegalCatch")
- public void write(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
- checkNotReady();
-
- final DataTreeModification tree = mutableTree;
- LOG.debug("Tx: {} Write: {}:{}", getIdentifier(), path, data);
-
- try {
- tree.write(path, data);
- // FIXME: Add checked exception
- } catch (RuntimeException e) {
- LOG.error("Tx: {}, failed to write {}:{} in {}", getIdentifier(), path, data, tree, e);
- // Rethrow original ones if they are subclasses of RuntimeException
- // or Error
- Throwables.propagateIfPossible(e);
- // FIXME: Introduce proper checked exception
- throw new IllegalArgumentException("Illegal input data.", e);
- }
- }
-
- @Override
- @SuppressWarnings("checkstyle:IllegalCatch")
- public void merge(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
- checkNotReady();
-
- final DataTreeModification tree = mutableTree;
- LOG.debug("Tx: {} Merge: {}:{}", getIdentifier(), path, data);
-
- try {
- tree.merge(path, data);
- // FIXME: Add checked exception
- } catch (RuntimeException e) {
- LOG.error("Tx: {}, failed to write {}:{} in {}", getIdentifier(), path, data, tree, e);
- // Rethrow original ones if they are subclasses of RuntimeException
- // or Error
- Throwables.propagateIfPossible(e);
- // FIXME: Introduce proper checked exception
- throw new IllegalArgumentException("Illegal input data.", e);
- }
- }
-
- @Override
- @SuppressWarnings("checkstyle:IllegalCatch")
- public void delete(final YangInstanceIdentifier path) {
- checkNotReady();
-
- final DataTreeModification tree = mutableTree;
- LOG.debug("Tx: {} Delete: {}", getIdentifier(), path);
-
- try {
- tree.delete(path);
- // FIXME: Add checked exception
- } catch (RuntimeException e) {
- LOG.error("Tx: {}, failed to delete {} in {}", getIdentifier(), path, tree, e);
- // Rethrow original ones if they are subclasses of RuntimeException
- // or Error
- Throwables.propagateIfPossible(e);
- // FIXME: Introduce proper checked exception
- throw new IllegalArgumentException("Illegal path to delete.", e);
- }
- }
-
- /**
- * Exposed for {@link SnapshotBackedReadWriteTransaction}'s sake only. The contract does
- * not allow data access after the transaction has been closed or readied.
- *
- * @param path Path to read
- * @return null if the the transaction has been closed;
- */
- final Optional<NormalizedNode<?, ?>> readSnapshotNode(final YangInstanceIdentifier path) {
- return readyImpl == null ? null : Optional.fromJavaUtil(mutableTree.readNode(path));
- }
-
- private void checkNotReady() {
- checkState(readyImpl != null, "Transaction %s is no longer open. No further modifications allowed.",
- getIdentifier());
- }
-
- @Override
- @SuppressWarnings("checkstyle:IllegalCatch")
- public DOMStoreThreePhaseCommitCohort ready() {
- @SuppressWarnings("unchecked")
- final TransactionReadyPrototype<T> wasReady = READY_UPDATER.getAndSet(this, null);
- checkState(wasReady != null, "Transaction %s is no longer open", getIdentifier());
-
- LOG.debug("Store transaction: {} : Ready", getIdentifier());
-
- final DataTreeModification tree = mutableTree;
- TREE_UPDATER.lazySet(this, null);
- try {
- tree.ready();
- return wasReady.transactionReady(this, tree, null);
- } catch (RuntimeException e) {
- LOG.debug("Store transaction: {}: unexpected failure when readying", getIdentifier(), e);
- return wasReady.transactionReady(this, tree, e);
- }
- }
-
- @Override
- public void close() {
- @SuppressWarnings("unchecked")
- final TransactionReadyPrototype<T> wasReady = READY_UPDATER.getAndSet(this, null);
- if (wasReady != null) {
- LOG.debug("Store transaction: {} : Closed", getIdentifier());
- TREE_UPDATER.lazySet(this, null);
- wasReady.transactionAborted(this);
- } else {
- LOG.debug("Store transaction: {} : Closed after submit", getIdentifier());
- }
- }
-
- @Override
- protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
- return toStringHelper.add("ready", readyImpl == null);
- }
-
- /**
- * This class is intended to be implemented by Transaction factories responsible for allocation of
- * {@link org.opendaylight.controller.sal.core.spi.data.SnapshotBackedWriteTransaction} and
- * providing underlying logic for applying implementation.
- *
- * @param <T> identifier type
- */
- @Deprecated
- public abstract static class TransactionReadyPrototype<T> {
- /**
- * Called when a transaction is closed without being readied. This is not invoked for
- * transactions which are ready.
- *
- * @param tx Transaction which got aborted.
- */
- protected abstract void transactionAborted(SnapshotBackedWriteTransaction<T> tx);
-
- /**
- * Returns a commit coordinator associated with supplied transactions.
- *
- * <p>
- * This call must not fail.
- *
- * @param tx
- * Transaction on which ready was invoked.
- * @param tree
- * Modified data tree which has been constructed.
- * @param readyError
- * Any error that has already happened when readying.
- * @return DOMStoreThreePhaseCommitCohort associated with transaction
- */
- protected abstract DOMStoreThreePhaseCommitCohort transactionReady(SnapshotBackedWriteTransaction<T> tx,
- DataTreeModification tree,
- @Nullable Exception readyError);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.spi.data;
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2014 Brocade Communications Systems, Inc. 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.spi.data.statistics;
-
-import java.util.concurrent.ExecutorService;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager;
-
-/**
- * Interface for a class that tracks statistics for a data store.
- *
- * @author Thomas Pantelis
- */
-@Deprecated(forRemoval = true)
-public interface DOMStoreStatsTracker {
-
- /**
- * Sets the executor used for DataChangeListener notifications.
- *
- * @param dclExecutor the executor
- */
- void setDataChangeListenerExecutor(@NonNull ExecutorService dclExecutor);
-
- /**
- * Sets the executor used internally by the data store.
- *
- * @param dsExecutor the executor
- */
- void setDataStoreExecutor(@NonNull ExecutorService dsExecutor);
-
- /**
- * Sets the QueuedNotificationManager use for DataChangeListener notifications.
- *
- * @param manager the manager
- */
- void setNotificationManager(@NonNull QueuedNotificationManager<?, ?> manager);
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-parent</artifactId>
- <version>1.12.0-SNAPSHOT</version>
- <relativePath>../parent</relativePath>
- </parent>
-
- <artifactId>sal-inmemory-datastore</artifactId>
- <version>1.12.0-SNAPSHOT</version>
- <packaging>bundle</packaging>
-
- <dependencies>
- <!-- SAL Dependencies -->
-
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-api</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-common-api</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-common-util</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-core-compat</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>concepts</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>util</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>yang-binding</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-data-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-data-impl</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-dom-inmemory-datastore</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
-
- <!-- Test Dependencies -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-binding-generator-impl</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>mockito-configuration</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-test-model</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-test-util</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
- <Export-Package>org.opendaylight.controller.md.sal.dom.store.impl.*</Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <scm>
- <connection>scm:git:http://git.opendaylight.org/gerrit/controller.git</connection>
- <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
- <tag>HEAD</tag>
- <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL:Architecture:Clustering</url>
- </scm>
-
-</project>
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.store.impl;
-
-import java.util.concurrent.ExecutorService;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.sal.core.compat.DOMStoreAdapter;
-import org.opendaylight.yangtools.concepts.Identifiable;
-import org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
-
-/**
- * In-memory DOM Data Store providing Controller MD-SAL APIs on top of MD-SAL's
- * {@link org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore}.
- *
- * @deprecated Please use {@link org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore} instead.
- */
-@Deprecated(forRemoval = true)
-public class InMemoryDOMDataStore
- extends DOMStoreAdapter<org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore>
- implements Identifiable<String>, SchemaContextListener, AutoCloseable {
- private final org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore delegate;
-
- public InMemoryDOMDataStore(final String name, final ExecutorService dataChangeListenerExecutor) {
- this(name, LogicalDatastoreType.OPERATIONAL, dataChangeListenerExecutor,
- InMemoryDOMDataStoreConfigProperties.DEFAULT_MAX_DATA_CHANGE_LISTENER_QUEUE_SIZE, false);
- }
-
- public InMemoryDOMDataStore(final String name, final LogicalDatastoreType type,
- final ExecutorService dataChangeListenerExecutor,
- final int maxDataChangeListenerQueueSize, final boolean debugTransactions) {
- delegate = new org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore(name, type.toMdsal(),
- dataChangeListenerExecutor, maxDataChangeListenerQueueSize, debugTransactions);
- }
-
- @Override
- protected org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore delegate() {
- return delegate;
- }
-
- public void setCloseable(final AutoCloseable closeable) {
- delegate.setCloseable(closeable);
- }
-
- public QueuedNotificationManager<?, ?> getDataChangeListenerNotificationManager() {
- return delegate.getDataChangeListenerNotificationManager();
- }
-
- @Override
- public final String getIdentifier() {
- return delegate.getIdentifier();
- }
-
- @Override
- public void onGlobalContextUpdated(final SchemaContext ctx) {
- delegate.onGlobalContextUpdated(ctx);
- }
-
- @Override
- public void close() {
- delegate.close();
- }
-
- public final boolean getDebugTransactions() {
- return delegate.getDebugTransactions();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Brocade Communications Systems, Inc. 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.md.sal.dom.store.impl;
-
-/**
- * Holds configuration properties when creating an {@link InMemoryDOMDataStore} instance via the
- * {@link InMemoryDOMDataStoreFactory}.
- *
- * @author Thomas Pantelis
- * @see InMemoryDOMDataStoreFactory
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStoreConfigProperties} instead.
- */
-@Deprecated(forRemoval = true)
-public final class InMemoryDOMDataStoreConfigProperties {
-
- public static final int DEFAULT_MAX_DATA_CHANGE_EXECUTOR_QUEUE_SIZE = 1000;
- public static final int DEFAULT_MAX_DATA_CHANGE_EXECUTOR_POOL_SIZE = 20;
- public static final int DEFAULT_MAX_DATA_CHANGE_LISTENER_QUEUE_SIZE = 1000;
- public static final int DEFAULT_MAX_DATA_STORE_EXECUTOR_QUEUE_SIZE = 5000;
-
- private static final InMemoryDOMDataStoreConfigProperties DEFAULT =
- create(DEFAULT_MAX_DATA_CHANGE_EXECUTOR_POOL_SIZE,
- DEFAULT_MAX_DATA_CHANGE_EXECUTOR_QUEUE_SIZE,
- DEFAULT_MAX_DATA_CHANGE_LISTENER_QUEUE_SIZE,
- DEFAULT_MAX_DATA_STORE_EXECUTOR_QUEUE_SIZE);
-
- private final int maxDataChangeExecutorQueueSize;
- private final int maxDataChangeExecutorPoolSize;
- private final int maxDataChangeListenerQueueSize;
- private final int maxDataStoreExecutorQueueSize;
-
- /**
- * Constructs an instance with the given property values.
- *
- * @param maxDataChangeExecutorPoolSize
- * maximum thread pool size for the data change notification executor.
- * @param maxDataChangeExecutorQueueSize
- * maximum queue size for the data change notification executor.
- * @param maxDataChangeListenerQueueSize
- * maximum queue size for the data change listeners.
- * @param maxDataStoreExecutorQueueSize
- * maximum queue size for the data store executor.
- */
- public static InMemoryDOMDataStoreConfigProperties create(int maxDataChangeExecutorPoolSize,
- int maxDataChangeExecutorQueueSize, int maxDataChangeListenerQueueSize,
- int maxDataStoreExecutorQueueSize) {
- return new InMemoryDOMDataStoreConfigProperties(maxDataChangeExecutorPoolSize,
- maxDataChangeExecutorQueueSize, maxDataChangeListenerQueueSize,
- maxDataStoreExecutorQueueSize);
- }
-
- public static InMemoryDOMDataStoreConfigProperties create(int maxDataChangeExecutorPoolSize,
- int maxDataChangeExecutorQueueSize, int maxDataChangeListenerQueueSize) {
- return new InMemoryDOMDataStoreConfigProperties(maxDataChangeExecutorPoolSize,
- maxDataChangeExecutorQueueSize, maxDataChangeListenerQueueSize,
- DEFAULT_MAX_DATA_STORE_EXECUTOR_QUEUE_SIZE);
- }
-
- /**
- * Returns the InMemoryDOMDataStoreConfigProperties instance with default values.
- */
- public static InMemoryDOMDataStoreConfigProperties getDefault() {
- return DEFAULT;
- }
-
- private InMemoryDOMDataStoreConfigProperties(int maxDataChangeExecutorPoolSize,
- int maxDataChangeExecutorQueueSize, int maxDataChangeListenerQueueSize,
- int maxDataStoreExecutorQueueSize) {
- this.maxDataChangeExecutorQueueSize = maxDataChangeExecutorQueueSize;
- this.maxDataChangeExecutorPoolSize = maxDataChangeExecutorPoolSize;
- this.maxDataChangeListenerQueueSize = maxDataChangeListenerQueueSize;
- this.maxDataStoreExecutorQueueSize = maxDataStoreExecutorQueueSize;
- }
-
- /**
- * Returns the maximum queue size for the data change notification executor.
- */
- public int getMaxDataChangeExecutorQueueSize() {
- return maxDataChangeExecutorQueueSize;
- }
-
- /**
- * Returns the maximum thread pool size for the data change notification executor.
- */
- public int getMaxDataChangeExecutorPoolSize() {
- return maxDataChangeExecutorPoolSize;
- }
-
- /**
- * Returns the maximum queue size for the data change listeners.
- */
- public int getMaxDataChangeListenerQueueSize() {
- return maxDataChangeListenerQueueSize;
- }
-
- /**
- * Returns the maximum queue size for the data store executor.
- */
- public int getMaxDataStoreExecutorQueueSize() {
- return maxDataStoreExecutorQueueSize;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Brocade Communications Systems, Inc. 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.md.sal.dom.store.impl;
-
-import java.util.concurrent.ExecutorService;
-import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.mdsal.dom.api.DOMSchemaService;
-import org.opendaylight.yangtools.util.concurrent.SpecialExecutors;
-
-/**
- * A factory for creating InMemoryDOMDataStore instances.
- *
- * @author Thomas Pantelis
- *
- * @deprecated Use {@link org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStoreFactory} instead.
- */
-@Deprecated(forRemoval = true)
-public final class InMemoryDOMDataStoreFactory {
-
- private InMemoryDOMDataStoreFactory() {
- }
-
- public static InMemoryDOMDataStore create(final String name, final @Nullable DOMSchemaService schemaService) {
- return create(name, schemaService, null);
- }
-
- /**
- * Creates an InMemoryDOMDataStore instance.
- *
- * @param name the name of the data store
- * @param schemaService the SchemaService to which to register the data store.
- * @param properties configuration properties for the InMemoryDOMDataStore instance. If null,
- * default property values are used.
- * @return an InMemoryDOMDataStore instance
- */
- public static InMemoryDOMDataStore create(final String name, final @Nullable DOMSchemaService schemaService,
- final @Nullable InMemoryDOMDataStoreConfigProperties properties) {
- return create(name, LogicalDatastoreType.OPERATIONAL, schemaService, false, properties);
- }
-
- /**
- * Creates an InMemoryDOMDataStore instance.
- *
- * @param name the name of the data store
- * @param type Data store type
- * @param schemaService the SchemaService to which to register the data store.
- * @param debugTransactions enable transaction debugging
- * @param properties configuration properties for the InMemoryDOMDataStore instance. If null,
- * default property values are used.
- * @return an InMemoryDOMDataStore instance
- */
- public static InMemoryDOMDataStore create(final String name, final LogicalDatastoreType type,
- final @Nullable DOMSchemaService schemaService, final boolean debugTransactions,
- final @Nullable InMemoryDOMDataStoreConfigProperties properties) {
-
- InMemoryDOMDataStoreConfigProperties actualProperties = properties;
- if (actualProperties == null) {
- actualProperties = InMemoryDOMDataStoreConfigProperties.getDefault();
- }
-
- // For DataChangeListener notifications we use an executor that provides the fastest
- // task execution time to get higher throughput as DataChangeListeners typically provide
- // much of the business logic for a data model. If the executor queue size limit is reached,
- // subsequent submitted notifications will block the calling thread.
- int dclExecutorMaxQueueSize = actualProperties.getMaxDataChangeExecutorQueueSize();
- int dclExecutorMaxPoolSize = actualProperties.getMaxDataChangeExecutorPoolSize();
-
- ExecutorService dataChangeListenerExecutor = SpecialExecutors.newBlockingBoundedFastThreadPool(
- dclExecutorMaxPoolSize, dclExecutorMaxQueueSize, name + "-DCL", InMemoryDOMDataStore.class);
-
- final InMemoryDOMDataStore dataStore = new InMemoryDOMDataStore(name, type, dataChangeListenerExecutor,
- actualProperties.getMaxDataChangeListenerQueueSize(), debugTransactions);
-
- if (schemaService != null) {
- schemaService.registerSchemaContextListener(dataStore);
- }
-
- return dataStore;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.store.impl;
-
-import java.util.Collection;
-import java.util.Optional;
-import java.util.concurrent.ExecutorService;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
-import org.opendaylight.controller.md.sal.dom.spi.AbstractDOMDataTreeChangeListenerRegistration;
-import org.opendaylight.controller.sal.core.spi.data.AbstractDOMStoreTreeChangePublisher;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-final class InMemoryDOMStoreTreeChangePublisher extends AbstractDOMStoreTreeChangePublisher {
- private static final Logger LOG = LoggerFactory.getLogger(InMemoryDOMStoreTreeChangePublisher.class);
-
- private final QueuedNotificationManager<AbstractDOMDataTreeChangeListenerRegistration<?>, DataTreeCandidate>
- notificationManager;
-
- InMemoryDOMStoreTreeChangePublisher(final ExecutorService listenerExecutor, final int maxQueueSize) {
- notificationManager = QueuedNotificationManager.create(listenerExecutor, (listener, notifications) -> {
- // FIXME: we are not checking for listener being closed
- listener.getInstance().onDataTreeChanged(notifications);
- }, maxQueueSize,
- "DataTreeChangeListenerQueueMgr");
- }
-
- private InMemoryDOMStoreTreeChangePublisher(final QueuedNotificationManager<
- AbstractDOMDataTreeChangeListenerRegistration<?>, DataTreeCandidate> notificationManager) {
- this.notificationManager = notificationManager;
- }
-
- QueuedNotificationManager<AbstractDOMDataTreeChangeListenerRegistration<?>, DataTreeCandidate>
- getNotificationManager() {
- return notificationManager;
- }
-
- @Override
- protected void notifyListeners(final Collection<AbstractDOMDataTreeChangeListenerRegistration<?>> registrations,
- final YangInstanceIdentifier path, final DataTreeCandidateNode node) {
- final DataTreeCandidate candidate = DataTreeCandidates.newDataTreeCandidate(path, node);
-
- for (AbstractDOMDataTreeChangeListenerRegistration<?> reg : registrations) {
- LOG.debug("Enqueueing candidate {} to registration {}", candidate, registrations);
- notificationManager.submitNotification(reg, candidate);
- }
- }
-
- @Override
- protected synchronized void registrationRemoved(
- final AbstractDOMDataTreeChangeListenerRegistration<?> registration) {
- LOG.debug("Closing registration {}", registration);
-
- // FIXME: remove the queue for this registration and make sure we clear it
- }
-
- <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerTreeChangeListener(
- final YangInstanceIdentifier treeId, final L listener, final DataTreeSnapshot snapshot) {
- final AbstractDOMDataTreeChangeListenerRegistration<L> reg = registerTreeChangeListener(treeId, listener);
-
- final Optional<NormalizedNode<?, ?>> node = snapshot.readNode(YangInstanceIdentifier.empty());
- if (node.isPresent()) {
- final DataTreeCandidate candidate = DataTreeCandidates.fromNormalizedNode(
- YangInstanceIdentifier.empty(), node.get());
-
- InMemoryDOMStoreTreeChangePublisher publisher =
- new InMemoryDOMStoreTreeChangePublisher(notificationManager);
- publisher.registerTreeChangeListener(treeId, listener);
- publisher.publishChange(candidate);
- }
-
- return reg;
- }
-
- synchronized void publishChange(final @NonNull DataTreeCandidate candidate) {
- // Runs synchronized with registrationRemoved()
- processCandidateTree(candidate);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Brocade Communications Systems, Inc. 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.md.sal.dom.store.impl.jmx;
-
-import org.opendaylight.controller.md.sal.common.util.jmx.AbstractMXBean;
-import org.opendaylight.controller.md.sal.common.util.jmx.QueuedNotificationManagerMXBeanImpl;
-import org.opendaylight.controller.md.sal.common.util.jmx.ThreadExecutorStatsMXBeanImpl;
-import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
-import org.opendaylight.yangtools.concepts.AbstractRegistration;
-import org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager;
-
-/**
- * Wrapper class for data store MXbeans.
- *
- * @author Thomas Pantelis
- */
-public class InMemoryDataStoreStats extends AbstractRegistration {
-
- private final AbstractMXBean notificationExecutorStatsBean;
- private final QueuedNotificationManagerMXBeanImpl notificationManagerStatsBean;
-
- public InMemoryDataStoreStats(final String beanType, final QueuedNotificationManager<?, ?> manager) {
-
- notificationManagerStatsBean = new QueuedNotificationManagerMXBeanImpl(manager,
- "notification-manager", beanType, null);
- notificationManagerStatsBean.registerMBean();
-
- notificationExecutorStatsBean = ThreadExecutorStatsMXBeanImpl.create(manager.getExecutor(),
- "notification-executor", beanType, null);
- if (notificationExecutorStatsBean != null) {
- notificationExecutorStatsBean.registerMBean();
- }
- }
-
- public InMemoryDataStoreStats(final String name, final InMemoryDOMDataStore dataStore) {
- this(name, dataStore.getDataChangeListenerNotificationManager());
- }
-
- @Override
- protected void removeRegistration() {
- if (notificationExecutorStatsBean != null) {
- notificationExecutorStatsBean.unregisterMBean();
- }
-
- if (notificationManagerStatsBean != null) {
- notificationManagerStatsBean.unregisterMBean();
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.store.impl;
-
-import java.util.Collection;
-import java.util.Map;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.opendaylight.controller.md.sal.dom.store.impl.DatastoreTestTask.WriteTransactionCustomizer;
-import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TwoLevelList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.top.level.list.NestedList;
-import org.opendaylight.yangtools.util.concurrent.SpecialExecutors;
-import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
-import org.opendaylight.yangtools.yang.data.api.schema.OrderedMapNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
-public abstract class AbstractDataTreeChangeListenerTest {
-
- protected static final YangInstanceIdentifier TOP_LEVEL = YangInstanceIdentifier
- .of(Top.QNAME);
- private static final QName NAME_QNAME = QName.create(Top.QNAME, "name");
- protected static final String FOO = "foo";
- protected static final String BAR = "bar";
- protected static final String BAZ = "baz";
-
- private InMemoryDOMDataStore datastore;
- private SchemaContext schemaContext;
- private TestDCLExecutorService dclExecutorService;
-
- @Before
- public final void setup() throws Exception {
- final YangModuleInfo moduleInfo = BindingReflections
- .getModuleInfo(TwoLevelList.class);
- final ModuleInfoBackedContext context = ModuleInfoBackedContext.create();
- context.registerModuleInfo(moduleInfo);
- this.schemaContext = context.tryToCreateSchemaContext().get();
-
- this.dclExecutorService = new TestDCLExecutorService(
- SpecialExecutors.newBlockingBoundedFastThreadPool(1, 10, "DCL",
- AbstractDataTreeChangeListenerTest.class));
-
- this.datastore = new InMemoryDOMDataStore("TEST", this.dclExecutorService);
- this.datastore.onGlobalContextUpdated(this.schemaContext);
- }
-
- @After
- public void tearDown() {
- if (this.dclExecutorService != null) {
- this.dclExecutorService.shutdownNow();
- }
- }
-
- /**
- * Create a new test task. The task will operate on the backed database,
- * and will use the proper background executor service.
- *
- * @return Test task initialized to clean up {@value #TOP_LEVEL} and its
- * children.
- */
- public final DatastoreTestTask newTestTask() {
- return new DatastoreTestTask(this.datastore, this.dclExecutorService).cleanup(DatastoreTestTask
- .simpleDelete(TOP_LEVEL));
- }
-
-
- public static final YangInstanceIdentifier path(final String topName,
- final String nestedName) {
- return path(topName).node(NestedList.QNAME).node(
- NodeIdentifierWithPredicates.of(NestedList.QNAME, NAME_QNAME,
- nestedName));
- }
-
- public static final YangInstanceIdentifier path(final String topName) {
- return TOP_LEVEL.node(TopLevelList.QNAME).node(
- NodeIdentifierWithPredicates.of(TopLevelList.QNAME,
- NAME_QNAME, topName));
- }
-
- protected static DataContainerNodeBuilder<NodeIdentifier, ContainerNode> top() {
- return Builders.containerBuilder().withNodeIdentifier(
- new NodeIdentifier(Top.QNAME));
- }
-
-
-
- protected static void assertEmpty(final Collection<?> set) {
- Assert.assertTrue(set.isEmpty());
- }
-
- protected static void assertEmpty(final Map<?,?> set) {
- Assert.assertTrue(set.isEmpty());
- }
-
- protected static <K> void assertContains(final Collection<K> set, final K... values) {
- for (final K key : values) {
- Assert.assertTrue(set.contains(key));
- }
-
- }
-
- protected static <K> void assertContains(final Map<K,?> map, final K... values) {
- for (final K key : values) {
- Assert.assertTrue(map.containsKey(key));
- }
- }
-
- protected static <K> void assertNotContains(final Collection<K> set, final K... values) {
- for (final K key : values) {
- Assert.assertFalse(set.contains(key));
- }
- }
-
- protected static <K> void assertNotContains(final Map<K,?> map, final K... values) {
- for (final K key : values) {
- Assert.assertFalse(map.containsKey(key));
- }
- }
-
- protected static CollectionNodeBuilder<MapEntryNode, MapNode> topLevelMap() {
- return ImmutableNodes.mapNodeBuilder(TopLevelList.QNAME);
- }
-
- protected static CollectionNodeBuilder<MapEntryNode, OrderedMapNode> nestedMap() {
- return Builders.orderedMapBuilder().withNodeIdentifier(new NodeIdentifier(NestedList.QNAME));
- }
-
- public static DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> topLevelList(
- final String key) {
- return ImmutableNodes.mapEntryBuilder(TopLevelList.QNAME, NAME_QNAME,
- key);
- }
-
- public static DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> nestedList(
- final String key) {
- return ImmutableNodes
- .mapEntryBuilder(NestedList.QNAME, NAME_QNAME, key);
- }
-
- public static final WriteTransactionCustomizer writeOneTopMultipleNested(
- final String topName, final String... nestedName) {
- final CollectionNodeBuilder<MapEntryNode, OrderedMapNode> nestedMapBuilder = nestedMap();
- for (final String nestedItem : nestedName) {
- nestedMapBuilder.addChild(nestedList(nestedItem).build());
- }
-
- final ContainerNode data = top().addChild(
- topLevelMap().addChild(
- topLevelList(topName)
- .addChild(nestedMapBuilder.build()).build())
- .build()).build();
-
- return DatastoreTestTask.simpleWrite(TOP_LEVEL, data);
- }
-
- public static final WriteTransactionCustomizer deleteNested(final String topName,
- final String nestedName) {
- return DatastoreTestTask.simpleDelete(path(topName, nestedName));
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.store.impl;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.SettableFuture;
-import com.google.common.util.concurrent.Uninterruptibles;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.function.Function;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
-import org.opendaylight.controller.sal.core.spi.data.DOMStore;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTreeChangePublisher;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType;
-
-public class DatastoreTestTask {
-
- private final DOMStore store;
-
- private WriteTransactionCustomizer setup;
- private WriteTransactionCustomizer write;
- private ReadTransactionVerifier read;
- private WriteTransactionCustomizer cleanup;
- private YangInstanceIdentifier changePath;
- private DOMStoreTreeChangePublisher storeTreeChangePublisher;
- private ChangeEventListener internalListener;
- private final TestDCLExecutorService dclExecutorService;
-
- public DatastoreTestTask(final DOMStore datastore, final TestDCLExecutorService dclExecutorService) {
- this.store = datastore;
- this.dclExecutorService = dclExecutorService;
- }
-
- @SafeVarargs
- public final DatastoreTestTask changeListener(final YangInstanceIdentifier path,
- Function<DataTreeCandidate, Boolean>... matchers) {
- assertTrue(store instanceof DOMStoreTreeChangePublisher);
- this.storeTreeChangePublisher = (DOMStoreTreeChangePublisher)store;
- this.changePath = path;
- this.internalListener = new ChangeEventListener(matchers);
- return this;
- }
-
- public static Function<DataTreeCandidate, Boolean> added(YangInstanceIdentifier path) {
- return candidate -> candidate.getRootNode().getModificationType() == ModificationType.WRITE
- && path.equals(candidate.getRootPath()) && !candidate.getRootNode().getDataBefore().isPresent()
- && candidate.getRootNode().getDataAfter().isPresent();
- }
-
- public static Function<DataTreeCandidate, Boolean> replaced(YangInstanceIdentifier path) {
- return candidate -> candidate.getRootNode().getModificationType() == ModificationType.WRITE
- && path.equals(candidate.getRootPath()) && candidate.getRootNode().getDataBefore().isPresent()
- && candidate.getRootNode().getDataAfter().isPresent();
- }
-
- public static Function<DataTreeCandidate, Boolean> deleted(YangInstanceIdentifier path) {
- return candidate -> candidate.getRootNode().getModificationType() == ModificationType.DELETE
- && path.equals(candidate.getRootPath()) && candidate.getRootNode().getDataBefore().isPresent()
- && !candidate.getRootNode().getDataAfter().isPresent();
- }
-
- public static Function<DataTreeCandidate, Boolean> subtreeModified(YangInstanceIdentifier path) {
- return candidate -> candidate.getRootNode().getModificationType() == ModificationType.SUBTREE_MODIFIED
- && path.equals(candidate.getRootPath()) && candidate.getRootNode().getDataBefore().isPresent()
- && candidate.getRootNode().getDataAfter().isPresent();
- }
-
- public DatastoreTestTask setup(final WriteTransactionCustomizer customizer) {
- this.setup = customizer;
- return this;
- }
-
- public DatastoreTestTask test(final WriteTransactionCustomizer customizer) {
- this.write = customizer;
- return this;
- }
-
- public DatastoreTestTask read(final ReadTransactionVerifier customizer) {
- this.read = customizer;
- return this;
- }
-
- public DatastoreTestTask cleanup(final WriteTransactionCustomizer customizer) {
- this.cleanup = customizer;
- return this;
- }
-
- public void run() throws Exception {
- if (setup != null) {
- execute(setup);
- }
- ListenerRegistration<ChangeEventListener> registration = null;
- if (changePath != null) {
- registration = storeTreeChangePublisher.registerTreeChangeListener(changePath, internalListener);
- }
-
- Preconditions.checkState(write != null, "Write Transaction must be set.");
-
- dclExecutorService.afterTestSetup();
-
- execute(write);
- if (registration != null) {
- // DCL is asynchronous, we need to make sure all tasks are executed before we close the registration,
- // otherwise they would get lost
- dclExecutorService.shutdown();
- dclExecutorService.awaitTermination(5, TimeUnit.SECONDS);
- registration.close();
- }
-
- if (read != null) {
- read.verify(store.newReadOnlyTransaction());
- }
- if (cleanup != null) {
- execute(cleanup);
- }
- }
-
- public void verifyChangeEvents() {
- internalListener.verifyChangeEvents();
- }
-
- public void verifyNoChangeEvent() {
- internalListener.verifyNoChangeEvent();
- }
-
- private void execute(final WriteTransactionCustomizer writeCustomizer) throws InterruptedException,
- ExecutionException {
- DOMStoreReadWriteTransaction tx = store.newReadWriteTransaction();
- writeCustomizer.customize(tx);
- DOMStoreThreePhaseCommitCohort cohort = tx.ready();
- assertTrue(cohort.canCommit().get());
- cohort.preCommit().get();
- cohort.commit().get();
- }
-
- public interface WriteTransactionCustomizer {
- void customize(DOMStoreReadWriteTransaction tx);
- }
-
- public interface ReadTransactionVerifier {
- void verify(DOMStoreReadTransaction tx);
- }
-
- private final class ChangeEventListener implements DOMDataTreeChangeListener {
-
- final SettableFuture<Collection<DataTreeCandidate>> future = SettableFuture.create();
- final Collection<DataTreeCandidate> accumulatedChanges = new ArrayList<>();
- final Function<DataTreeCandidate, Boolean>[] matchers;
- final int expChangeCount;
-
- ChangeEventListener(Function<DataTreeCandidate, Boolean>[] matchers) {
- this.expChangeCount = matchers.length;
- this.matchers = matchers;
- }
-
- Collection<DataTreeCandidate> changes() {
- try {
- Collection<DataTreeCandidate> changes = internalListener.future.get(10, TimeUnit.SECONDS);
- Uninterruptibles.sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
- return changes;
- } catch (TimeoutException e) {
- throw new AssertionError(String.format(
- "Data tree change notifications not received. Expected: %s. Actual: %s - %s",
- expChangeCount, accumulatedChanges.size(), accumulatedChanges), e);
- } catch (InterruptedException | ExecutionException e) {
- throw new AssertionError("Data tree change notifications failed", e);
- }
- }
-
- void verifyChangeEvents() {
- Collection<DataTreeCandidate> changes = new ArrayList<>(changes());
- Iterator<DataTreeCandidate> iter = changes.iterator();
- while (iter.hasNext()) {
- DataTreeCandidate dataTreeModification = iter.next();
- for (Function<DataTreeCandidate, Boolean> matcher: matchers) {
- if (matcher.apply(dataTreeModification)) {
- iter.remove();
- break;
- }
- }
- }
-
- if (!changes.isEmpty()) {
- DataTreeCandidate mod = changes.iterator().next();
- fail(String.format("Received unexpected notification: type: %s, path: %s, before: %s, after: %s",
- mod.getRootNode().getModificationType(), mod.getRootPath(),
- mod.getRootNode().getDataBefore(), mod.getRootNode().getDataAfter()));
- }
- }
-
- void verifyNoChangeEvent() {
- try {
- Object unexpected = internalListener.future.get(500, TimeUnit.MILLISECONDS);
- fail("Got unexpected Data tree change notifications: " + unexpected);
- } catch (TimeoutException e) {
- // Expected
- } catch (InterruptedException | ExecutionException e) {
- throw new AssertionError("Data tree change notifications failed", e);
- }
- }
-
- @Override
- public void onDataTreeChanged(Collection<DataTreeCandidate> changes) {
- synchronized (accumulatedChanges) {
- accumulatedChanges.addAll(changes);
- if (expChangeCount == accumulatedChanges.size()) {
- future.set(new ArrayList<>(accumulatedChanges));
- }
- }
- }
- }
-
- public static final WriteTransactionCustomizer simpleWrite(final YangInstanceIdentifier path,
- final NormalizedNode<?, ?> data) {
- return tx -> tx.write(path, data);
- }
-
- public static final WriteTransactionCustomizer simpleMerge(final YangInstanceIdentifier path,
- final NormalizedNode<?, ?> data) {
- return tx -> tx.merge(path, data);
- }
-
- public static final WriteTransactionCustomizer simpleDelete(final YangInstanceIdentifier path) {
- return tx -> tx.delete(path);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.store.impl;
-
-import org.junit.Test;
-
-/**
- * Base template for a test suite for testing DataTreeChangeListener functionality.
- */
-public abstract class DefaultDataTreeChangeListenerTestSuite extends AbstractDataTreeChangeListenerTest {
-
- protected static final String FOO_SIBLING = "foo-sibling";
-
- @Test
- public final void putTopLevelOneNested() throws Exception {
-
- DatastoreTestTask task = newTestTask().test(writeOneTopMultipleNested(FOO, BAR));
- putTopLevelOneNestedSetup(task);
- task.run();
- putTopLevelOneNestedVerify(task);
- }
-
- protected abstract void putTopLevelOneNestedSetup(DatastoreTestTask task);
-
- protected abstract void putTopLevelOneNestedVerify(DatastoreTestTask task);
-
- @Test
- public final void existingTopWriteSibling() throws Exception {
- DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO)).test(
- tx -> tx.write(path(FOO_SIBLING), topLevelList(FOO_SIBLING).build()));
- existingTopWriteSiblingSetup(task);
- task.run();
- existingTopWriteSiblingVerify(task);
- }
-
- protected abstract void existingTopWriteSiblingSetup(DatastoreTestTask task);
-
- protected abstract void existingTopWriteSiblingVerify(DatastoreTestTask task);
-
- @Test
- public final void existingTopWriteTwoNested() throws Exception {
- DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO)).test(
- tx -> {
- tx.write(path(FOO,BAR), nestedList(BAR).build());
- tx.write(path(FOO,BAZ), nestedList(BAZ).build());
- });
- existingTopWriteTwoNestedSetup(task);
- task.run();
- existingTopWriteTwoNestedVerify(task);
- }
-
- protected abstract void existingTopWriteTwoNestedSetup(DatastoreTestTask task);
-
- protected abstract void existingTopWriteTwoNestedVerify(DatastoreTestTask task);
-
-
- @Test
- public final void existingOneNestedWriteAdditionalNested() throws Exception {
- DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO, BAR)).test(
- tx -> tx.write(path(FOO,BAZ), nestedList(BAZ).build()));
- existingOneNestedWriteAdditionalNestedSetup(task);
- task.run();
- existingOneNestedWriteAdditionalNestedVerify(task);
- }
-
- protected abstract void existingOneNestedWriteAdditionalNestedSetup(DatastoreTestTask task);
-
- protected abstract void existingOneNestedWriteAdditionalNestedVerify(DatastoreTestTask task);
-
- @Test
- public final void replaceTopLevelNestedChanged() throws Exception {
- DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO, BAR)).test(
- writeOneTopMultipleNested(FOO, BAZ));
- replaceTopLevelNestedSetup(task);
- task.run();
- replaceTopLevelNestedVerify(task);
- }
-
- protected abstract void replaceTopLevelNestedSetup(DatastoreTestTask task);
-
- protected abstract void replaceTopLevelNestedVerify(DatastoreTestTask task);
-
- @Test
- public final void putTopLevelWithTwoNested() throws Exception {
-
- DatastoreTestTask task = newTestTask().test(writeOneTopMultipleNested(FOO, BAR, BAZ));
- putTopLevelWithTwoNestedSetup(task);
- task.run();
- putTopLevelWithTwoNestedVerify(task);
- }
-
- protected abstract void putTopLevelWithTwoNestedSetup(DatastoreTestTask task);
-
- protected abstract void putTopLevelWithTwoNestedVerify(DatastoreTestTask task);
-
- @Test
- public final void twoNestedExistsOneIsDeleted() throws Exception {
-
- DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO, BAR, BAZ)).test(
- deleteNested(FOO, BAZ));
- twoNestedExistsOneIsDeletedSetup(task);
- task.run();
- twoNestedExistsOneIsDeletedVerify(task);
- }
-
- protected abstract void twoNestedExistsOneIsDeletedSetup(DatastoreTestTask task);
-
- protected abstract void twoNestedExistsOneIsDeletedVerify(DatastoreTestTask task);
-
- @Test
- public final void nestedListExistsRootDeleted() throws Exception {
-
- DatastoreTestTask task = newTestTask().cleanup(null).setup(writeOneTopMultipleNested(FOO, BAR, BAZ))
- .test(DatastoreTestTask.simpleDelete(TOP_LEVEL));
- nestedListExistsRootDeletedSetup(task);
- task.run();
- nestedListExistsRootDeletedVerify(task);
- }
-
- protected abstract void nestedListExistsRootDeletedSetup(DatastoreTestTask task);
-
- protected abstract void nestedListExistsRootDeletedVerify(DatastoreTestTask task);
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.store.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.MoreExecutors;
-import java.util.concurrent.ExecutionException;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
-import org.opendaylight.controller.sal.core.spi.data.SnapshotBackedTransactions;
-import org.opendaylight.controller.sal.core.spi.data.SnapshotBackedWriteTransaction.TransactionReadyPrototype;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
-public class InMemoryDataStoreTest {
-
- private SchemaContext schemaContext;
- private InMemoryDOMDataStore domStore;
-
- @Before
- public void setupStore() {
- domStore = new InMemoryDOMDataStore("TEST", MoreExecutors.newDirectExecutorService());
- schemaContext = TestModel.createTestContext();
- domStore.onGlobalContextUpdated(schemaContext);
- }
-
- @Test
- public void testTransactionIsolation() throws InterruptedException, ExecutionException {
-
- assertNotNull(domStore);
-
- DOMStoreReadTransaction readTx = domStore.newReadOnlyTransaction();
- assertNotNull(readTx);
-
- DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
- assertNotNull(writeTx);
-
- /*
- * Writes /test in writeTx
- */
- NormalizedNode<?, ?> testNode = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
- writeTx.write(TestModel.TEST_PATH, testNode);
-
- /*
- * Reads /test from writeTx Read should return container.
- */
- ListenableFuture<Optional<NormalizedNode<?, ?>>> writeTxContainer = writeTx.read(TestModel.TEST_PATH);
- assertEquals("read: isPresent", true, writeTxContainer.get().isPresent());
- assertEquals("read: data", testNode, writeTxContainer.get().get());
-
- /*
- * Reads /test from readTx Read should return Absent.
- */
- ListenableFuture<Optional<NormalizedNode<?, ?>>> readTxContainer = readTx.read(TestModel.TEST_PATH);
- assertEquals("read: isPresent", false, readTxContainer.get().isPresent());
- }
-
- @Test
- public void testTransactionCommit() throws InterruptedException, ExecutionException {
-
- DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
- assertNotNull(writeTx);
-
- /*
- * Writes /test in writeTx
- */
- NormalizedNode<?, ?> testNode = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
- writeTx.write(TestModel.TEST_PATH, testNode);
-
- /*
- * Reads /test from writeTx Read should return container.
- */
- ListenableFuture<Optional<NormalizedNode<?, ?>>> writeTxContainer = writeTx.read(TestModel.TEST_PATH);
- assertEquals("read: isPresent", true, writeTxContainer.get().isPresent());
- assertEquals("read: data", testNode, writeTxContainer.get().get());
-
- DOMStoreThreePhaseCommitCohort cohort = writeTx.ready();
-
- assertThreePhaseCommit(cohort);
-
- Optional<NormalizedNode<?, ?>> afterCommitRead = domStore.newReadOnlyTransaction().read(TestModel.TEST_PATH)
- .get();
- assertEquals("After commit read: isPresent", true, afterCommitRead.isPresent());
- assertEquals("After commit read: data", testNode, afterCommitRead.get());
- }
-
- @Test
- public void testDelete() throws Exception {
-
- DOMStoreWriteTransaction writeTx = domStore.newWriteOnlyTransaction();
- assertNotNull(writeTx);
-
- // Write /test and commit
-
- writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
-
- assertThreePhaseCommit(writeTx.ready());
-
- Optional<NormalizedNode<?, ?>> afterCommitRead = domStore.newReadOnlyTransaction().read(TestModel.TEST_PATH)
- .get();
- assertEquals("After commit read: isPresent", true, afterCommitRead.isPresent());
-
- // Delete /test and verify
-
- writeTx = domStore.newWriteOnlyTransaction();
-
- writeTx.delete(TestModel.TEST_PATH);
-
- assertThreePhaseCommit(writeTx.ready());
-
- afterCommitRead = domStore.newReadOnlyTransaction().read(TestModel.TEST_PATH).get();
- assertEquals("After commit read: isPresent", false, afterCommitRead.isPresent());
- }
-
- @Test
- public void testMerge() throws Exception {
-
- DOMStoreWriteTransaction writeTx = domStore.newWriteOnlyTransaction();
- assertNotNull(writeTx);
-
- ContainerNode containerNode = ImmutableContainerNodeBuilder.create()
- .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
- .addChild(ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
- .addChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)).build())
- .build();
-
- writeTx.merge(TestModel.TEST_PATH, containerNode);
-
- assertThreePhaseCommit(writeTx.ready());
-
- Optional<NormalizedNode<?, ?>> afterCommitRead = domStore.newReadOnlyTransaction().read(TestModel.TEST_PATH)
- .get();
- assertEquals("After commit read: isPresent", true, afterCommitRead.isPresent());
- assertEquals("After commit read: data", containerNode, afterCommitRead.get());
-
- // Merge a new list entry node
-
- writeTx = domStore.newWriteOnlyTransaction();
- assertNotNull(writeTx);
-
- containerNode = ImmutableContainerNodeBuilder.create()
- .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
- .addChild(ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
- .addChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1))
- .addChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 2)).build())
- .build();
-
- writeTx.merge(TestModel.TEST_PATH, containerNode);
-
- assertThreePhaseCommit(writeTx.ready());
-
- afterCommitRead = domStore.newReadOnlyTransaction().read(TestModel.TEST_PATH).get();
- assertEquals("After commit read: isPresent", true, afterCommitRead.isPresent());
- assertEquals("After commit read: data", containerNode, afterCommitRead.get());
- }
-
-
- @Test
- public void testExistsForExistingData() throws Exception {
-
- DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
- assertNotNull(writeTx);
-
- ContainerNode containerNode = ImmutableContainerNodeBuilder.create()
- .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
- .addChild(ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
- .addChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)).build())
- .build();
-
- writeTx.merge(TestModel.TEST_PATH, containerNode);
-
- CheckedFuture<Boolean, ReadFailedException> exists =
- writeTx.exists(TestModel.TEST_PATH);
-
- assertEquals(true, exists.checkedGet());
-
- DOMStoreThreePhaseCommitCohort ready = writeTx.ready();
-
- ready.preCommit().get();
-
- ready.commit().get();
-
- DOMStoreReadTransaction readTx = domStore.newReadOnlyTransaction();
- assertNotNull(readTx);
-
- exists =
- readTx.exists(TestModel.TEST_PATH);
-
- assertEquals(true, exists.checkedGet());
- }
-
- @Test
- public void testExistsForNonExistingData() throws Exception {
-
- DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
- assertNotNull(writeTx);
-
- CheckedFuture<Boolean, ReadFailedException> exists =
- writeTx.exists(TestModel.TEST_PATH);
-
- assertEquals(false, exists.checkedGet());
-
- DOMStoreReadTransaction readTx = domStore.newReadOnlyTransaction();
- assertNotNull(readTx);
-
- exists =
- readTx.exists(TestModel.TEST_PATH);
-
- assertEquals(false, exists.checkedGet());
- }
-
- @Test(expected = ReadFailedException.class)
- public void testExistsThrowsReadFailedException() throws Exception {
-
- DOMStoreReadTransaction readTx = domStore.newReadOnlyTransaction();
- assertNotNull(readTx);
-
- readTx.close();
-
- readTx.exists(TestModel.TEST_PATH).checkedGet();
- }
-
- @Test(expected = ReadFailedException.class)
- public void testReadWithReadOnlyTransactionClosed() throws Exception {
-
- DOMStoreReadTransaction readTx = domStore.newReadOnlyTransaction();
- assertNotNull(readTx);
-
- readTx.close();
-
- doReadAndThrowEx(readTx);
- }
-
- @Test(expected = ReadFailedException.class)
- public void testReadWithReadOnlyTransactionFailure() throws Exception {
-
- DataTreeSnapshot mockSnapshot = Mockito.mock(DataTreeSnapshot.class);
- Mockito.doThrow(new RuntimeException("mock ex")).when(mockSnapshot)
- .readNode(Mockito.any(YangInstanceIdentifier.class));
-
- DOMStoreReadTransaction readTx = SnapshotBackedTransactions.newReadTransaction("1", true, mockSnapshot);
-
- doReadAndThrowEx(readTx);
- }
-
- @Test(expected = ReadFailedException.class)
- public void testReadWithReadWriteTransactionClosed() throws Exception {
-
- DOMStoreReadTransaction readTx = domStore.newReadWriteTransaction();
- assertNotNull(readTx);
-
- readTx.close();
-
- doReadAndThrowEx(readTx);
- }
-
- @Test(expected = ReadFailedException.class)
- public void testReadWithReadWriteTransactionFailure() throws Exception {
-
- DataTreeSnapshot mockSnapshot = Mockito.mock(DataTreeSnapshot.class);
- DataTreeModification mockModification = Mockito.mock(DataTreeModification.class);
- Mockito.doThrow(new RuntimeException("mock ex")).when(mockModification)
- .readNode(Mockito.any(YangInstanceIdentifier.class));
- Mockito.doReturn(mockModification).when(mockSnapshot).newModification();
- @SuppressWarnings("unchecked")
- TransactionReadyPrototype<String> mockReady = Mockito.mock(TransactionReadyPrototype.class);
- DOMStoreReadTransaction readTx = SnapshotBackedTransactions.newReadWriteTransaction("1", false, mockSnapshot,
- mockReady);
-
- doReadAndThrowEx(readTx);
- }
-
- private static void doReadAndThrowEx(final DOMStoreReadTransaction readTx) throws ReadFailedException {
- readTx.read(TestModel.TEST_PATH).checkedGet();
- }
-
- @Test(expected = IllegalStateException.class)
- public void testWriteWithTransactionReady() {
-
- DOMStoreWriteTransaction writeTx = domStore.newWriteOnlyTransaction();
-
- writeTx.ready();
-
- // Should throw ex
- writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
- }
-
- @Test(expected = IllegalStateException.class)
- public void testReadyWithTransactionAlreadyReady() {
-
- DOMStoreWriteTransaction writeTx = domStore.newWriteOnlyTransaction();
-
- writeTx.ready();
-
- // Should throw ex
- writeTx.ready();
- }
-
- @Test
- public void testReadyWithMissingMandatoryData() throws InterruptedException {
- DOMStoreWriteTransaction writeTx = domStore.newWriteOnlyTransaction();
- NormalizedNode<?, ?> testNode = ImmutableContainerNodeBuilder.create()
- .withNodeIdentifier(new NodeIdentifier(TestModel.MANDATORY_DATA_TEST_QNAME))
- .addChild(ImmutableNodes.leafNode(TestModel.OPTIONAL_QNAME, "data"))
- .build();
- writeTx.write(TestModel.MANDATORY_DATA_TEST_PATH, testNode);
- DOMStoreThreePhaseCommitCohort ready = writeTx.ready();
- try {
- ready.canCommit().get();
- Assert.fail("Expected exception on canCommit");
- } catch (ExecutionException e) {
- // nop
- }
- }
-
- @Test
- public void testTransactionAbort() throws InterruptedException, ExecutionException {
-
- DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
- assertNotNull(writeTx);
-
- assertTestContainerWrite(writeTx);
-
- DOMStoreThreePhaseCommitCohort cohort = writeTx.ready();
-
- assertTrue(cohort.canCommit().get().booleanValue());
- cohort.preCommit().get();
- cohort.abort().get();
-
- Optional<NormalizedNode<?, ?>> afterCommitRead = domStore.newReadOnlyTransaction().read(TestModel.TEST_PATH)
- .get();
- assertFalse(afterCommitRead.isPresent());
- }
-
- @Test
- public void testTransactionChain() throws InterruptedException, ExecutionException {
- DOMStoreTransactionChain txChain = domStore.createTransactionChain();
- assertNotNull(txChain);
-
- /*
- * We alocate new read-write transaction and write /test
- */
- DOMStoreReadWriteTransaction firstTx = txChain.newReadWriteTransaction();
- assertTestContainerWrite(firstTx);
-
- /*
- * First transaction is marked as ready, we are able to allocate chained
- * transactions
- */
- final DOMStoreThreePhaseCommitCohort firstWriteTxCohort = firstTx.ready();
-
- /*
- * We alocate chained transaction - read transaction, note first one is
- * still not commited to datastore.
- */
- DOMStoreReadTransaction secondReadTx = txChain.newReadOnlyTransaction();
-
- /*
- * We test if we are able to read data from tx, read should not fail
- * since we are using chained transaction.
- */
- assertTestContainerExists(secondReadTx);
-
- /*
- * We alocate next transaction, which is still based on first one, but
- * is read-write.
- */
- DOMStoreReadWriteTransaction thirdDeleteTx = txChain.newReadWriteTransaction();
-
- /*
- * We test existence of /test in third transaction container should
- * still be visible from first one (which is still uncommmited).
- */
- assertTestContainerExists(thirdDeleteTx);
-
- /*
- * We delete node in third transaction
- */
- thirdDeleteTx.delete(TestModel.TEST_PATH);
-
- /*
- * third transaction is sealed.
- */
- DOMStoreThreePhaseCommitCohort thirdDeleteTxCohort = thirdDeleteTx.ready();
-
- /*
- * We commit first transaction
- */
- assertThreePhaseCommit(firstWriteTxCohort);
-
- // Alocates store transacion
- DOMStoreReadTransaction storeReadTx = domStore.newReadOnlyTransaction();
-
- /*
- * We verify transaction is commited to store, container should exists
- * in datastore.
- */
- assertTestContainerExists(storeReadTx);
-
- /*
- * We commit third transaction
- */
- assertThreePhaseCommit(thirdDeleteTxCohort);
- }
-
- @Test
- @Ignore
- public void testTransactionConflict() throws InterruptedException, ExecutionException {
- DOMStoreReadWriteTransaction txOne = domStore.newReadWriteTransaction();
- DOMStoreReadWriteTransaction txTwo = domStore.newReadWriteTransaction();
- assertTestContainerWrite(txOne);
- assertTestContainerWrite(txTwo);
-
- /*
- * Commits transaction
- */
- assertThreePhaseCommit(txOne.ready());
-
- /*
- * Asserts that txTwo could not be commited
- */
- assertFalse(txTwo.ready().canCommit().get());
- }
-
- private static void assertThreePhaseCommit(final DOMStoreThreePhaseCommitCohort cohort)
- throws InterruptedException, ExecutionException {
- assertTrue(cohort.canCommit().get().booleanValue());
- cohort.preCommit().get();
- cohort.commit().get();
- }
-
- private static Optional<NormalizedNode<?, ?>> assertTestContainerWrite(final DOMStoreReadWriteTransaction writeTx)
- throws InterruptedException, ExecutionException {
- /*
- * Writes /test in writeTx
- */
- writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
-
- return assertTestContainerExists(writeTx);
- }
-
- /**
- * Reads /test from readTx Read should return container.
- */
- private static Optional<NormalizedNode<?, ?>> assertTestContainerExists(final DOMStoreReadTransaction readTx)
- throws InterruptedException, ExecutionException {
-
- ListenableFuture<Optional<NormalizedNode<?, ?>>> writeTxContainer = readTx.read(TestModel.TEST_PATH);
- assertTrue(writeTxContainer.get().isPresent());
- return writeTxContainer.get();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.store.impl;
-
-import static org.opendaylight.controller.md.sal.dom.store.impl.DatastoreTestTask.added;
-import static org.opendaylight.controller.md.sal.dom.store.impl.DatastoreTestTask.deleted;
-import static org.opendaylight.controller.md.sal.dom.store.impl.DatastoreTestTask.replaced;
-import static org.opendaylight.controller.md.sal.dom.store.impl.DatastoreTestTask.subtreeModified;
-
-public class RootScopeSubtreeTest extends DefaultDataTreeChangeListenerTestSuite {
-
- @Override
- protected void putTopLevelOneNestedSetup(final DatastoreTestTask task) {
- task.changeListener(TOP_LEVEL, added(TOP_LEVEL));
- }
-
- @Override
- protected void putTopLevelOneNestedVerify(final DatastoreTestTask task) {
- task.verifyChangeEvents();
- }
-
- @Override
- protected void replaceTopLevelNestedSetup(DatastoreTestTask task) {
- task.changeListener(TOP_LEVEL, added(TOP_LEVEL), replaced(TOP_LEVEL));
- }
-
- @Override
- protected void replaceTopLevelNestedVerify(final DatastoreTestTask task) {
- task.verifyChangeEvents();
- }
-
- @Override
- protected void putTopLevelWithTwoNestedSetup(final DatastoreTestTask task) {
- task.changeListener(TOP_LEVEL, added(TOP_LEVEL));
- }
-
- @Override
- protected void putTopLevelWithTwoNestedVerify(final DatastoreTestTask task) {
- task.verifyChangeEvents();
- }
-
- @Override
- protected void twoNestedExistsOneIsDeletedSetup(DatastoreTestTask task) {
- task.changeListener(TOP_LEVEL, added(TOP_LEVEL), subtreeModified(TOP_LEVEL));
- }
-
- @Override
- protected void twoNestedExistsOneIsDeletedVerify(final DatastoreTestTask task) {
- task.verifyChangeEvents();
- }
-
- @Override
- protected void nestedListExistsRootDeletedSetup(DatastoreTestTask task) {
- task.changeListener(TOP_LEVEL, added(TOP_LEVEL), deleted(TOP_LEVEL));
- }
-
- @Override
- protected void nestedListExistsRootDeletedVerify(final DatastoreTestTask task) {
- task.verifyChangeEvents();
- }
-
- @Override
- protected void existingOneNestedWriteAdditionalNestedSetup(DatastoreTestTask task) {
- task.changeListener(TOP_LEVEL, added(TOP_LEVEL), subtreeModified(TOP_LEVEL));
- }
-
- @Override
- protected void existingOneNestedWriteAdditionalNestedVerify(final DatastoreTestTask task) {
- task.verifyChangeEvents();
- }
-
- @Override
- protected void existingTopWriteTwoNestedSetup(DatastoreTestTask task) {
- task.changeListener(TOP_LEVEL, added(TOP_LEVEL), subtreeModified(TOP_LEVEL));
- }
-
- @Override
- protected void existingTopWriteTwoNestedVerify(final DatastoreTestTask task) {
- task.verifyChangeEvents();
- }
-
- @Override
- protected void existingTopWriteSiblingSetup(DatastoreTestTask task) {
- task.changeListener(TOP_LEVEL, added(TOP_LEVEL), subtreeModified(TOP_LEVEL));
- }
-
- @Override
- protected void existingTopWriteSiblingVerify(final DatastoreTestTask task) {
- task.verifyChangeEvents();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.store.impl;
-
-import static org.junit.Assert.assertNotNull;
-
-import com.google.common.util.concurrent.MoreExecutors;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
-import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.rpcservice.rev140701.RockTheHouseInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
-import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
-public class SchemaUpdateForTransactionTest {
-
- private static final YangInstanceIdentifier TOP_PATH = YangInstanceIdentifier.of(Top.QNAME);
- private SchemaContext schemaContext;
- private InMemoryDOMDataStore domStore;
-
- @Before
- public void setupStore() throws Exception {
- this.domStore = new InMemoryDOMDataStore("TEST", MoreExecutors.newDirectExecutorService());
- loadSchemas(RockTheHouseInput.class);
- }
-
- public void loadSchemas(final Class<?>... classes) throws Exception {
- final ModuleInfoBackedContext context = ModuleInfoBackedContext.create();
- for (final Class<?> clz : classes) {
- YangModuleInfo moduleInfo = BindingReflections.getModuleInfo(clz);
-
- context.registerModuleInfo(moduleInfo);
- }
- this.schemaContext = context.tryToCreateSchemaContext().get();
- this.domStore.onGlobalContextUpdated(this.schemaContext);
- }
-
- /**
- * Test suite tests allocating transaction when schema context
- * does not contain module necessary for client write,
- * then triggering update of global schema context
- * and then performing write (according to new module).
- *
- * <p>
- * If transaction between allocation and schema context was
- * unmodified, it is safe to change its schema context
- * to new one (e.g. it will be same as if allocated after
- * schema context update.)
- */
- @Test
- public void testTransactionSchemaUpdate() throws Exception {
-
- assertNotNull(this.domStore);
-
- // We allocate transaction, initial schema context does not
- // contain Lists model
- final DOMStoreReadWriteTransaction writeTx = this.domStore.newReadWriteTransaction();
- assertNotNull(writeTx);
-
- // we trigger schema context update to contain Lists model
- loadSchemas(RockTheHouseInput.class, Top.class);
-
- /*
- * Writes /test in writeTx, this write should not fail
- * with IllegalArgumentException since /test is in
- * schema context.
- */
- writeTx.write(TOP_PATH, ImmutableNodes.containerNode(Top.QNAME));
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Brocade Communications Systems, Inc. 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.md.sal.dom.store.impl;
-
-import com.google.common.util.concurrent.ForwardingExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
-import java.util.concurrent.ExecutorService;
-
-/**
- * A forwarding Executor used by unit tests for DataChangeListener notifications.
- *
- * @author Thomas Pantelis
- */
-public class TestDCLExecutorService extends ForwardingExecutorService {
-
- // Start with a same thread executor to avoid timing issues during test setup.
- private volatile ExecutorService currentExecutor = MoreExecutors.newDirectExecutorService();
-
- // The real executor to use when test setup is complete.
- private final ExecutorService postSetupExecutor;
-
-
- public TestDCLExecutorService(final ExecutorService postSetupExecutor) {
- this.postSetupExecutor = postSetupExecutor;
- }
-
- @Override
- protected ExecutorService delegate() {
- return currentExecutor;
- }
-
- public void afterTestSetup() {
- // Test setup complete - switch to the real executor.
- currentExecutor = postSetupExecutor;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.store.impl;
-
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-
-public final class TestModel {
-
- public static final QName TEST_QNAME =
- QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13", "test");
- public static final QName OUTER_LIST_QNAME = QName.create(TEST_QNAME, "outer-list");
- public static final QName INNER_LIST_QNAME = QName.create(TEST_QNAME, "inner-list");
- public static final QName OUTER_CHOICE_QNAME = QName.create(TEST_QNAME, "outer-choice");
- public static final QName ID_QNAME = QName.create(TEST_QNAME, "id");
- public static final QName NAME_QNAME = QName.create(TEST_QNAME, "name");
- public static final QName VALUE_QNAME = QName.create(TEST_QNAME, "value");
- public static final QName TWO_QNAME = QName.create(TEST_QNAME, "two");
- public static final QName THREE_QNAME = QName.create(TEST_QNAME, "three");
- public static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier.of(TEST_QNAME);
- public static final YangInstanceIdentifier OUTER_LIST_PATH =
- YangInstanceIdentifier.builder(TEST_PATH).node(OUTER_LIST_QNAME).build();
-
- public static final QName MANDATORY_DATA_TEST_QNAME =
- QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test",
- "2014-03-13",
- "mandatory-data-test");
- public static final QName OPTIONAL_QNAME = QName.create(MANDATORY_DATA_TEST_QNAME, "optional-data");
- public static final QName MANDATORY_QNAME = QName.create(MANDATORY_DATA_TEST_QNAME, "mandatory-data");
- public static final YangInstanceIdentifier MANDATORY_DATA_TEST_PATH =
- YangInstanceIdentifier.of(MANDATORY_DATA_TEST_QNAME);
-
- private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang";
-
- private TestModel() {
- }
-
- public static SchemaContext createTestContext() {
- return YangParserTestUtils.parseYangResource(DATASTORE_TEST_YANG);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.dom.store.impl;
-
-import static org.opendaylight.controller.md.sal.dom.store.impl.DatastoreTestTask.added;
-import static org.opendaylight.controller.md.sal.dom.store.impl.DatastoreTestTask.deleted;
-import static org.opendaylight.controller.md.sal.dom.store.impl.DatastoreTestTask.replaced;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-
-public class WildcardedScopeBaseTest extends DefaultDataTreeChangeListenerTestSuite {
-
- private static final YangInstanceIdentifier TOP_LEVEL_LIST_ALL = TOP_LEVEL.node(TopLevelList.QNAME).node(
- TopLevelList.QNAME);
-
- @Override
- protected void putTopLevelOneNestedSetup(final DatastoreTestTask task) {
- task.changeListener(TOP_LEVEL_LIST_ALL, added(path(FOO)));
- }
-
- @Override
- protected void putTopLevelOneNestedVerify(final DatastoreTestTask task) {
- task.verifyChangeEvents();
- }
-
- @Override
- protected void replaceTopLevelNestedSetup(DatastoreTestTask task) {
- task.changeListener(TOP_LEVEL_LIST_ALL, added(path(FOO)), replaced(path(FOO)));
- }
-
- @Override
- protected void replaceTopLevelNestedVerify(final DatastoreTestTask task) {
- task.verifyChangeEvents();
- }
-
- @Override
- protected void putTopLevelWithTwoNestedSetup(final DatastoreTestTask task) {
- task.changeListener(TOP_LEVEL_LIST_ALL, added(path(FOO)));
- }
-
- @Override
- protected void putTopLevelWithTwoNestedVerify(final DatastoreTestTask task) {
- task.verifyChangeEvents();
- }
-
- @Override
- protected void twoNestedExistsOneIsDeletedSetup(DatastoreTestTask task) {
- task.changeListener(TOP_LEVEL_LIST_ALL, added(path(FOO)));
- }
-
- @Override
- protected void twoNestedExistsOneIsDeletedVerify(final DatastoreTestTask task) {
- task.verifyChangeEvents();
- }
-
- @Override
- protected void nestedListExistsRootDeletedSetup(DatastoreTestTask task) {
- task.changeListener(TOP_LEVEL_LIST_ALL, added(path(FOO)), deleted(path(FOO)));
- }
-
- @Override
- protected void nestedListExistsRootDeletedVerify(final DatastoreTestTask task) {
- task.verifyChangeEvents();
- }
-
- @Override
- protected void existingOneNestedWriteAdditionalNestedSetup(DatastoreTestTask task) {
- task.changeListener(TOP_LEVEL_LIST_ALL, added(path(FOO)));
- }
-
- @Override
- protected void existingOneNestedWriteAdditionalNestedVerify(final DatastoreTestTask task) {
- task.verifyChangeEvents();
- }
-
- @Override
- protected void existingTopWriteTwoNestedSetup(DatastoreTestTask task) {
- task.changeListener(TOP_LEVEL_LIST_ALL, added(path(FOO)));
- }
-
- @Override
- protected void existingTopWriteTwoNestedVerify(final DatastoreTestTask task) {
- task.verifyChangeEvents();
- }
-
- @Override
- protected void existingTopWriteSiblingSetup(DatastoreTestTask task) {
- task.changeListener(TOP_LEVEL_LIST_ALL, added(path(FOO)), added(path(FOO_SIBLING)));
- }
-
- @Override
- protected void existingTopWriteSiblingVerify(final DatastoreTestTask task) {
- task.verifyChangeEvents();
- }
-}
+++ /dev/null
-module odl-datastore-test {
- yang-version 1;
- namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test";
- prefix "store-test";
-
- revision "2014-03-13" {
- description "Initial revision.";
- }
-
- container test {
- presence "needs to be present when empty";
-
- list outer-list {
- key id;
- leaf id {
- type uint16;
- }
- choice outer-choice {
- case one {
- leaf one {
- type string;
- }
- }
- case two-three {
- leaf two {
- type string;
- }
- leaf three {
- type string;
- }
- }
- }
- list inner-list {
- key name;
- leaf name {
- type string;
- }
- leaf value {
- type string;
- }
- }
- }
- }
-
- container mandatory-data-test {
- presence "needs to be present when empty";
-
- leaf optional-data {
- type string;
- }
- leaf mandatory-data {
- type string;
- mandatory true;
- }
- }
-}
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-dom-spi</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-common-impl</artifactId>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-clustering-commons</artifactId>
<artifactId>clustering-it-model</artifactId>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-api</artifactId>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-binding-api</artifactId>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-common-api</artifactId>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-common-api</artifactId>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
package org.opendaylight.controller.clustering.it.listener;
import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.MoreExecutors;
-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.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.WriteTransaction;
+import org.opendaylight.mdsal.common.api.CommitInfo;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.people.rev140818.CarPeople;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.people.rev140818.car.people.CarPerson;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.people.rev140818.car.people.CarPersonBuilder;
import org.slf4j.LoggerFactory;
public class PeopleCarListener implements CarPurchaseListener {
-
private static final Logger LOG = LoggerFactory.getLogger(PeopleCarListener.class);
private DataBroker dataProvider;
WriteTransaction tx = dataProvider.newWriteOnlyTransaction();
tx.put(LogicalDatastoreType.CONFIGURATION, carPersonIId, carPerson, true);
- Futures.addCallback(tx.submit(), new FutureCallback<Void>() {
+ tx.commit().addCallback(new FutureCallback<CommitInfo>() {
@Override
- public void onSuccess(final Void result) {
+ public void onSuccess(final CommitInfo result) {
LOG.info("Successfully added car-person entry: [{}]", carPerson);
}
* 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.clustering.it.provider;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
import org.opendaylight.yang.gen.v1.urn.opendaylight.controller.basic.rpc.test.rev160120.BasicGlobalOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.controller.basic.rpc.test.rev160120.BasicGlobalOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.controller.basic.rpc.test.rev160120.BasicRpcTestService;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.slf4j.Logger;
private static final Logger LOG = LoggerFactory.getLogger(BasicRpcTestProvider.class);
private static final ServiceGroupIdentifier IDENTIFIER = ServiceGroupIdentifier.create("Basic-rpc-test");
- private final RpcProviderRegistry rpcProviderRegistry;
+ private final RpcProviderService rpcProviderRegistry;
private final ClusterSingletonServiceProvider singletonService;
- private BindingAwareBroker.RpcRegistration<BasicRpcTestService> rpcRegistration;
- public BasicRpcTestProvider(final RpcProviderRegistry rpcProviderRegistry,
+ private ObjectRegistration<?> rpcRegistration;
+
+ public BasicRpcTestProvider(final RpcProviderService rpcProviderRegistry,
final ClusterSingletonServiceProvider singletonService) {
this.rpcProviderRegistry = rpcProviderRegistry;
this.singletonService = singletonService;
@Override
public void instantiateServiceInstance() {
LOG.info("Basic testing rpc registered as global");
- rpcRegistration = rpcProviderRegistry.addRpcImplementation(BasicRpcTestService.class, this);
+ rpcRegistration = rpcProviderRegistry.registerRpcImplementation(BasicRpcTestService.class, this);
}
@Override
*/
package org.opendaylight.controller.clustering.it.provider;
-import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
-import org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
+import org.opendaylight.mdsal.binding.api.DataObjectModification;
+import org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType;
+import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
+import org.opendaylight.mdsal.binding.api.DataTreeModification;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.rev140818.Cars;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
public void onDataTreeChanged(final java.util.Collection<DataTreeModification<Cars>> changes) {
if (LOG.isTraceEnabled()) {
for (DataTreeModification<Cars> change : changes) {
- ouputChanges(change);
+ outputChanges(change);
}
}
}
- private static void ouputChanges(final DataTreeModification<Cars> change) {
+ private static void outputChanges(final DataTreeModification<Cars> change) {
final DataObjectModification<Cars> rootNode = change.getRootNode();
final ModificationType modificationType = rootNode.getModificationType();
final InstanceIdentifier<Cars> rootIdentifier = change.getRootPath().getRootIdentifier();
switch (modificationType) {
case WRITE:
case SUBTREE_MODIFIED: {
- final Cars dataBefore = rootNode.getDataBefore();
- final Cars dataAfter = rootNode.getDataAfter();
LOG.trace("onDataTreeChanged - Cars config with path {} was added or changed from {} to {}",
- rootIdentifier, dataBefore, dataAfter);
+ rootIdentifier, rootNode.getDataBefore(), rootNode.getDataAfter());
break;
}
case DELETE: {
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
-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.md.sal.dom.api.DOMDataTreeCommitCohortRegistry;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
+import org.opendaylight.mdsal.binding.api.WriteTransaction;
+import org.opendaylight.mdsal.common.api.CommitInfo;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.dom.api.DOMDataBroker;
import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistration;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry;
import org.opendaylight.mdsal.eos.binding.api.Entity;
import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipChange;
import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipListener;
private static final String ENTITY_TYPE = "cars";
private static final InstanceIdentifier<Cars> CARS_IID = InstanceIdentifier.builder(Cars.class).build();
- private static final DataTreeIdentifier<Cars> CARS_DTID = new DataTreeIdentifier<>(
+ private static final DataTreeIdentifier<Cars> CARS_DTID = DataTreeIdentifier.create(
LogicalDatastoreType.CONFIGURATION, CARS_IID);
private final DataBroker dataProvider;
InstanceIdentifier<Cars> carsId = InstanceIdentifier.create(Cars.class);
tx.merge(LogicalDatastoreType.CONFIGURATION, carsId, new CarsBuilder().build());
try {
- tx.submit().checkedGet(5, TimeUnit.SECONDS);
- } catch (TransactionCommitFailedException | TimeoutException e) {
+ tx.commit().get(5, TimeUnit.SECONDS);
+ } catch (TimeoutException | InterruptedException | ExecutionException e) {
LOG_PURCHASE_CAR.error("Put Cars failed",e);
return Futures.immediateFuture(RpcResultBuilder.success(new StressTestOutputBuilder().build()).build());
}
CarEntry car = new CarEntryBuilder().setId(new CarId("car" + id)).build();
tx1.put(LogicalDatastoreType.CONFIGURATION,
InstanceIdentifier.<Cars>builder(Cars.class).child(CarEntry.class, car.key()).build(), car);
- Futures.addCallback(tx1.submit(), new FutureCallback<Void>() {
+ tx1.commit().addCallback(new FutureCallback<CommitInfo>() {
@Override
- public void onSuccess(final Void result) {
+ public void onSuccess(final CommitInfo result) {
// Transaction succeeded
succcessCounter.getAndIncrement();
}
return RpcResultBuilder.success(new RegisterCommitCohortOutputBuilder().build()).buildFuture();
}
- final DOMDataTreeCommitCohortRegistry commitCohortRegistry = (DOMDataTreeCommitCohortRegistry)
- domDataBroker.getSupportedExtensions().get(DOMDataTreeCommitCohortRegistry.class);
+ final DOMDataTreeCommitCohortRegistry commitCohortRegistry = domDataBroker.getExtensions().getInstance(
+ DOMDataTreeCommitCohortRegistry.class);
if (commitCohortRegistry == null) {
// Shouldn't happen
import akka.actor.Props;
import akka.dispatch.OnComplete;
import akka.pattern.Patterns;
-import com.google.common.base.Optional;
import com.google.common.base.Strings;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import java.util.Optional;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.opendaylight.controller.clustering.it.provider.impl.SingletonGetConstantService;
import org.opendaylight.controller.clustering.it.provider.impl.WriteTransactionsHandler;
import org.opendaylight.controller.clustering.it.provider.impl.YnlListener;
-import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
-import org.opendaylight.controller.md.sal.binding.api.NotificationService;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
-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.DOMRpcImplementationRegistration;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.mdsal.binding.api.NotificationPublishService;
+import org.opendaylight.mdsal.binding.api.NotificationService;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.dom.api.DOMDataBroker;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService;
import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
import org.opendaylight.mdsal.dom.api.DOMDataTreeLoopException;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
import org.opendaylight.mdsal.dom.api.DOMDataTreeService;
+import org.opendaylight.mdsal.dom.api.DOMRpcImplementationRegistration;
+import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
import org.opendaylight.mdsal.dom.api.DOMSchemaService;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.WriteTransactionsInput;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.WriteTransactionsOutput;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
import org.opendaylight.yangtools.yang.common.RpcResult;
import scala.concurrent.duration.FiniteDuration;
public class MdsalLowLevelTestProvider implements OdlMdsalLowlevelControlService {
-
private static final Logger LOG = LoggerFactory.getLogger(MdsalLowLevelTestProvider.class);
- private static final org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType CONTROLLER_CONFIG =
- org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION;
- private final RpcProviderRegistry rpcRegistry;
- private final BindingAwareBroker.RpcRegistration<OdlMdsalLowlevelControlService> registration;
+ private final RpcProviderService rpcRegistry;
+ private final ObjectRegistration<OdlMdsalLowlevelControlService> registration;
private final DistributedShardFactory distributedShardFactory;
private final DistributedDataStoreInterface configDataStore;
private final DOMDataTreeService domDataTreeService;
- public MdsalLowLevelTestProvider(final RpcProviderRegistry rpcRegistry,
+ public MdsalLowLevelTestProvider(final RpcProviderService rpcRegistry,
final DOMRpcProviderService domRpcService,
final ClusterSingletonServiceProvider singletonService,
final DOMSchemaService schemaService,
this.actorSystem = actorSystemProvider.getActorSystem();
this.prefixLeaderHandler = new PrefixLeaderHandler(domDataTreeService, bindingNormalizedNodeSerializer);
+ domDataTreeChangeService = domDataBroker.getExtensions().getInstance(DOMDataTreeChangeService.class);
- domDataTreeChangeService =
- (DOMDataTreeChangeService) domDataBroker.getSupportedExtensions().get(DOMDataTreeChangeService.class);
-
- registration = rpcRegistry.addRpcImplementation(OdlMdsalLowlevelControlService.class, this);
+ registration = rpcRegistry.registerRpcImplementation(OdlMdsalLowlevelControlService.class, this);
prefixShardHandler = new PrefixShardHandler(distributedShardFactory, domDataTreeService,
bindingNormalizedNodeSerializer);
idIntsListener = new IdIntsListener();
- dtclReg = domDataTreeChangeService
- .registerDataTreeChangeListener(
- new org.opendaylight.controller.md.sal.dom.api.DOMDataTreeIdentifier(
- CONTROLLER_CONFIG, WriteTransactionsHandler.ID_INT_YID),
- idIntsListener);
+ dtclReg = domDataTreeChangeService.registerDataTreeChangeListener(
+ new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, WriteTransactionsHandler.ID_INT_YID),
+ idIntsListener);
return RpcResultBuilder.success(new SubscribeDtclOutputBuilder().build()).buildFuture();
}
"id-ints listener has not received any notifications.").buildFuture();
}
- final DOMDataReadOnlyTransaction rTx = domDataBroker.newReadOnlyTransaction();
- try {
- final Optional<NormalizedNode<?, ?>> readResult =
- rTx.read(CONTROLLER_CONFIG, WriteTransactionsHandler.ID_INT_YID).get();
+ try (DOMDataTreeReadTransaction rTx = domDataBroker.newReadOnlyTransaction()) {
+ final Optional<NormalizedNode<?, ?>> readResult = rTx.read(LogicalDatastoreType.CONFIGURATION,
+ WriteTransactionsHandler.ID_INT_YID).get();
if (!readResult.isPresent()) {
return RpcResultBuilder.<UnsubscribeDtclOutput>failed().withError(ErrorType.APPLICATION, "data-missing",
*/
package org.opendaylight.controller.clustering.it.provider;
+import com.google.common.collect.ImmutableSet;
import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.SettableFuture;
-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.sal.binding.api.BindingAwareBroker;
+import java.util.HashSet;
+import java.util.Set;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
+import org.opendaylight.mdsal.binding.api.WriteTransaction;
+import org.opendaylight.mdsal.common.api.CommitInfo;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.purchase.rev140818.CarPurchaseService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.people.rev140818.AddPersonInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.people.rev140818.AddPersonOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.people.rev140818.AddPersonOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.people.rev140818.People;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.people.rev140818.PeopleService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.people.rev140818.PersonContext;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.people.rev140818.people.Person;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.people.rev140818.people.PersonBuilder;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcResult;
private static final Logger LOG = LoggerFactory.getLogger(PeopleProvider.class);
+ private final Set<ObjectRegistration<?>> regs = new HashSet<>();
private DataBroker dataProvider;
-
- private BindingAwareBroker.RoutedRpcRegistration<CarPurchaseService> rpcRegistration;
+ private RpcProviderService rpcProviderService;
+ private CarPurchaseService rpcImplementation;
public void setDataProvider(final DataBroker salDataProvider) {
this.dataProvider = salDataProvider;
}
-
- public void setRpcRegistration(final BindingAwareBroker.RoutedRpcRegistration<CarPurchaseService> rpcRegistration) {
- this.rpcRegistration = rpcRegistration;
+ public void setRpcImplementation(final CarPurchaseService rpcImplementation) {
+ this.rpcImplementation = rpcImplementation;
}
@Override
WriteTransaction tx = dataProvider.newWriteOnlyTransaction();
tx.put(LogicalDatastoreType.CONFIGURATION, personId, person, true);
- Futures.addCallback(tx.submit(), new FutureCallback<Void>() {
+ tx.commit().addCallback(new FutureCallback<CommitInfo>() {
@Override
- public void onSuccess(final Void result) {
+ public void onSuccess(final CommitInfo result) {
LOG.info("RPC addPerson : person added successfully [{}]", person);
- rpcRegistration.registerPath(PersonContext.class, personId);
+ regs.add(rpcProviderService.registerRpcImplementation(CarPurchaseService.class, rpcImplementation,
+ ImmutableSet.of(personId)));
LOG.info("RPC addPerson : routed rpc registered for instance ID [{}]", personId);
futureResult.set(RpcResultBuilder.success(new AddPersonOutputBuilder().build()).build());
}
@Override
public void close() {
+ regs.forEach(ObjectRegistration::close);
+ regs.clear();
}
}
* 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.clustering.it.provider;
+import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.SettableFuture;
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import com.google.common.util.concurrent.MoreExecutors;
+import org.opendaylight.mdsal.binding.api.NotificationPublishService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.purchase.rev140818.BuyCarInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.purchase.rev140818.BuyCarOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.purchase.rev140818.BuyCarOutputBuilder;
private static final Logger LOG = LoggerFactory.getLogger(PurchaseCarProvider.class);
- private NotificationProviderService notificationProvider;
+ private NotificationPublishService notificationProvider;
- public void setNotificationProvider(final NotificationProviderService salService) {
+ public void setNotificationProvider(final NotificationPublishService salService) {
this.notificationProvider = salService;
}
@Override
public ListenableFuture<RpcResult<BuyCarOutput>> buyCar(final BuyCarInput input) {
LOG.info("Routed RPC buyCar : generating notification for buying car [{}]", input);
- final SettableFuture<RpcResult<BuyCarOutput>> futureResult = SettableFuture.create();
- CarBoughtBuilder carBoughtBuilder = new CarBoughtBuilder();
- carBoughtBuilder.setCarId(input.getCarId());
- carBoughtBuilder.setPersonId(input.getPersonId());
- notificationProvider.publish(carBoughtBuilder.build());
- futureResult.set(RpcResultBuilder.success(new BuyCarOutputBuilder().build()).build());
- return futureResult;
+
+ return Futures.transform(notificationProvider.offerNotification(new CarBoughtBuilder()
+ .setCarId(input.getCarId())
+ .setPersonId(input.getPersonId())
+ .build()),
+ result -> RpcResultBuilder.success(new BuyCarOutputBuilder().build()).build(),
+ MoreExecutors.directExecutor());
}
@Override
package org.opendaylight.controller.clustering.it.provider.impl;
import com.google.common.base.Stopwatch;
+import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.Collection;
import java.util.Collections;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicLong;
+import org.opendaylight.mdsal.common.api.CommitInfo;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.TransactionsParams;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
// Not completed yet: create a transaction and hook it up
final long txId = txCounter.incrementAndGet();
- final ListenableFuture<?> execFuture = execWrite(txId);
+ final FluentFuture<? extends CommitInfo> execFuture = execWrite(txId);
LOG.debug("New future #{} allocated", txId);
// Ordering is important: we need to add the future before hooking the callback
futures.add(execFuture);
- Futures.addCallback(execFuture, new FutureCallback<Object>() {
+ execFuture.addCallback(new FutureCallback<CommitInfo>() {
@Override
- public void onSuccess(final Object result) {
+ public void onSuccess(final CommitInfo result) {
txSuccess(execFuture, txId);
}
runTimedOut("Transactions did not finish in " + DEAD_TIMEOUT_SECONDS + " seconds");
}
- abstract ListenableFuture<?> execWrite(long txId);
+ abstract FluentFuture<? extends CommitInfo> execWrite(long txId);
abstract void runFailed(Throwable cause, long txId);
*/
package org.opendaylight.controller.clustering.it.provider.impl;
-import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationRegistration;
-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.spi.DefaultDOMRpcResult;
+import com.google.common.util.concurrent.ListenableFuture;
+import java.net.URI;
+import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier;
+import org.opendaylight.mdsal.dom.api.DOMRpcImplementation;
+import org.opendaylight.mdsal.dom.api.DOMRpcImplementationRegistration;
+import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
+import org.opendaylight.mdsal.dom.api.DOMRpcResult;
+import org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.QNameModule;
+import org.opendaylight.yangtools.yang.common.Revision;
+import org.opendaylight.yangtools.yang.common.YangConstants;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder;
import org.slf4j.LoggerFactory;
public final class GetConstantService implements DOMRpcImplementation {
-
private static final Logger LOG = LoggerFactory.getLogger(GetConstantService.class);
- private static final QName OUTPUT =
- QName.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target","2017-02-15", "output");
- private static final QName CONSTANT =
- QName.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target","2017-02-15", "constant");
- private static final QName GET_CONSTANT =
- QName.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target","2017-02-15", "get-constant");
+ private static final QNameModule MODULE = QNameModule.create(
+ URI.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target"), Revision.of("2017-02-15")).intern();
+
+ private static final QName OUTPUT = YangConstants.operationOutputQName(MODULE).intern();
+ private static final QName CONSTANT = QName.create(MODULE, "constant").intern();
+ private static final QName GET_CONSTANT = QName.create(MODULE, "get-constant").intern();
private final String constant;
public static DOMRpcImplementationRegistration<GetConstantService> registerNew(
final DOMRpcProviderService rpcProviderService, final String constant) {
-
LOG.debug("Registering get-constant service, constant value: {}", constant);
- final DOMRpcIdentifier id = DOMRpcIdentifier.create(SchemaPath.create(true, GET_CONSTANT));
-
- return rpcProviderService.registerRpcImplementation(new GetConstantService(constant), id);
+ return rpcProviderService.registerRpcImplementation(new GetConstantService(constant),
+ DOMRpcIdentifier.create(SchemaPath.create(true, GET_CONSTANT)));
}
@Override
- public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final DOMRpcIdentifier rpc,
- final NormalizedNode<?, ?> input) {
+ public ListenableFuture<DOMRpcResult> invokeRpc(final DOMRpcIdentifier rpc, final NormalizedNode<?, ?> input) {
LOG.debug("get-constant invoked, current value: {}", constant);
- final LeafNode<Object> value = ImmutableLeafNodeBuilder.create()
+ return Futures.immediateFuture(new DefaultDOMRpcResult(ImmutableContainerNodeBuilder.create()
+ .withNodeIdentifier(new NodeIdentifier(OUTPUT))
+ .withChild(ImmutableLeafNodeBuilder.create()
.withNodeIdentifier(new NodeIdentifier(CONSTANT))
.withValue(constant)
- .build();
-
- final ContainerNode result = ImmutableContainerNodeBuilder.create()
- .withNodeIdentifier(new NodeIdentifier(OUTPUT))
- .withChild(value)
- .build();
-
- return Futures.immediateCheckedFuture(new DefaultDOMRpcResult(result));
+ .build())
+ .build()));
}
}
*/
package org.opendaylight.controller.clustering.it.provider.impl;
+import static com.google.common.base.Preconditions.checkState;
import static org.opendaylight.controller.clustering.it.provider.impl.AbstractTransactionHandler.ITEM;
-import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.SettableFuture;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Collection;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
-import org.opendaylight.controller.md.sal.dom.api.ClusteredDOMDataTreeChangeListener;
+import org.opendaylight.mdsal.dom.api.ClusteredDOMDataTreeChangeListener;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
public void onDataTreeChanged(final Collection<DataTreeCandidate> changes) {
// There should only be one candidate reported
- Preconditions.checkState(changes.size() == 1);
+ checkState(changes.size() == 1);
lastNotifTimestamp.set(System.nanoTime());
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
-import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
+import org.opendaylight.mdsal.binding.api.NotificationPublishService;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.target.rev170215.IdSequence;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.target.rev170215.IdSequenceBuilder;
import org.slf4j.Logger;
*/
package org.opendaylight.controller.clustering.it.provider.impl;
-import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationRegistration;
-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.spi.DefaultDOMRpcResult;
+import com.google.common.util.concurrent.ListenableFuture;
+import java.net.URI;
import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
+import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier;
+import org.opendaylight.mdsal.dom.api.DOMRpcImplementation;
+import org.opendaylight.mdsal.dom.api.DOMRpcImplementationRegistration;
+import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
+import org.opendaylight.mdsal.dom.api.DOMRpcResult;
+import org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.QNameModule;
+import org.opendaylight.yangtools.yang.common.Revision;
+import org.opendaylight.yangtools.yang.common.YangConstants;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder;
import org.slf4j.LoggerFactory;
public final class RoutedGetConstantService implements DOMRpcImplementation {
-
private static final Logger LOG = LoggerFactory.getLogger(RoutedGetConstantService.class);
- private static final QName OUTPUT =
- QName.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target","2017-02-15", "output");
- private static final QName CONSTANT =
- QName.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target","2017-02-15", "constant");
- private static final QName CONTEXT =
- QName.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target","2017-02-15", "context");
- private static final QName GET_CONTEXTED_CONSTANT =
- QName.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target","2017-02-15",
- "get-contexted-constant");
+ private static final QNameModule MODULE = QNameModule.create(
+ URI.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target"), Revision.of("2017-02-15")).intern();
+ private static final QName OUTPUT = YangConstants.operationOutputQName(MODULE).intern();
+ private static final QName CONSTANT = QName.create(MODULE, "constant").intern();
+ private static final QName GET_CONTEXTED_CONSTANT = QName.create(MODULE, "get-contexted-constant").intern();
private final String constant;
}
@Override
- public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final DOMRpcIdentifier rpc,
- final NormalizedNode<?, ?> input) {
+ public ListenableFuture<DOMRpcResult> invokeRpc(final DOMRpcIdentifier rpc, final NormalizedNode<?, ?> input) {
LOG.debug("get-contexted-constant invoked, current value: {}", constant);
- final LeafNode<Object> value = ImmutableLeafNodeBuilder.create()
- .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(CONSTANT))
+ return Futures.immediateFuture(new DefaultDOMRpcResult(ImmutableContainerNodeBuilder.create()
+ .withNodeIdentifier(new NodeIdentifier(OUTPUT))
+ .withChild(ImmutableLeafNodeBuilder.create()
+ .withNodeIdentifier(new NodeIdentifier(CONSTANT))
.withValue(constant)
- .build();
-
- final ContainerNode result = ImmutableContainerNodeBuilder.create()
- .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(OUTPUT))
- .withChild(value)
- .build();
-
- return Futures.immediateCheckedFuture(new DefaultDOMRpcResult(result));
+ .build())
+ .build()));
}
}
*/
package org.opendaylight.controller.clustering.it.provider.impl;
-import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationRegistration;
-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.spi.DefaultDOMRpcResult;
+import java.net.URI;
+import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier;
+import org.opendaylight.mdsal.dom.api.DOMRpcImplementation;
+import org.opendaylight.mdsal.dom.api.DOMRpcImplementationRegistration;
+import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
+import org.opendaylight.mdsal.dom.api.DOMRpcResult;
+import org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.QNameModule;
+import org.opendaylight.yangtools.yang.common.Revision;
+import org.opendaylight.yangtools.yang.common.YangConstants;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder;
private static final Logger LOG = LoggerFactory.getLogger(SingletonGetConstantService.class);
- private static final QName OUTPUT =
- QName.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target","2017-02-15", "output");
- private static final QName CONSTANT =
- QName.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target","2017-02-15", "constant");
- private static final QName CONTEXT =
- QName.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target","2017-02-15", "context");
- private static final QName GET_SINGLETON_CONSTANT =
- QName.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target","2017-02-15",
- "get-singleton-constant");
+ private static final QNameModule MODULE = QNameModule.create(
+ URI.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target"), Revision.of("2017-02-15")).intern();
+ private static final QName OUTPUT = YangConstants.operationOutputQName(MODULE).intern();
+ private static final QName CONSTANT = QName.create(MODULE, "constant").intern();
+ private static final QName CONTEXT = QName.create(MODULE, "context").intern();
+ private static final QName GET_SINGLETON_CONSTANT = QName.create(MODULE, "get-singleton-constant").intern();
private static final ServiceGroupIdentifier SERVICE_GROUP_IDENTIFIER =
ServiceGroupIdentifier.create("get-singleton-constant-service");
private final String constant;
private DOMRpcImplementationRegistration<SingletonGetConstantService> rpcRegistration;
- private SingletonGetConstantService(final DOMRpcProviderService rpcProviderService,
- final String constant) {
-
-
+ private SingletonGetConstantService(final DOMRpcProviderService rpcProviderService, final String constant) {
this.rpcProviderService = rpcProviderService;
this.constant = constant;
}
final String constant) {
LOG.debug("Registering get-singleton-constant into ClusterSingletonService, value {}", constant);
- return singletonService
- .registerClusterSingletonService(new SingletonGetConstantService(rpcProviderService, constant));
+ return singletonService.registerClusterSingletonService(
+ new SingletonGetConstantService(rpcProviderService, constant));
}
@Override
- public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(DOMRpcIdentifier rpc,
- NormalizedNode<?, ?> input) {
+ public ListenableFuture<DOMRpcResult> invokeRpc(final DOMRpcIdentifier rpc, final NormalizedNode<?, ?> input) {
LOG.debug("get-singleton-constant invoked, current value: {}", constant);
- final LeafNode<Object> value = ImmutableLeafNodeBuilder.create()
+ return Futures.immediateFuture(new DefaultDOMRpcResult(ImmutableContainerNodeBuilder.create()
+ .withNodeIdentifier(new NodeIdentifier(OUTPUT))
+ .withChild(ImmutableLeafNodeBuilder.create()
.withNodeIdentifier(new NodeIdentifier(CONSTANT))
.withValue(constant)
- .build();
-
- final ContainerNode result = ImmutableContainerNodeBuilder.create()
- .withNodeIdentifier(new NodeIdentifier(OUTPUT))
- .withChild(value)
- .build();
-
- return Futures.immediateCheckedFuture(new DefaultDOMRpcResult(result));
+ .build())
+ .build()));
}
@Override
import static java.util.Objects.requireNonNull;
+import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
import java.util.LinkedHashSet;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicLong;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.OptimisticLockFailedException;
-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.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.mdsal.common.api.CommitInfo;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.OptimisticLockFailedException;
+import org.opendaylight.mdsal.dom.api.DOMDataBroker;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeTransaction;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
+import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
+import org.opendaylight.mdsal.dom.api.DOMTransactionChainListener;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.WriteTransactionsInput;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.WriteTransactionsOutput;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.WriteTransactionsOutputBuilder;
import org.slf4j.LoggerFactory;
public abstract class WriteTransactionsHandler extends AbstractTransactionHandler {
- private static final class Chained extends WriteTransactionsHandler implements TransactionChainListener {
+ private static final class Chained extends WriteTransactionsHandler implements DOMTransactionChainListener {
private final SplittableRandom random = new SplittableRandom();
private final DOMTransactionChain transactionChain;
}
@Override
- DOMDataWriteTransaction createTransaction() {
+ DOMDataTreeWriteTransaction createTransaction() {
return transactionChain.newWriteOnlyTransaction();
}
}
@Override
- public void onTransactionChainFailed(final TransactionChain<?, ?> chain,
- final AsyncTransaction<?, ?> transaction, final Throwable cause) {
+ public void onTransactionChainFailed(final DOMTransactionChain chain, final DOMDataTreeTransaction transaction,
+ final Throwable cause) {
// This is expected to happen frequently in isolation testing.
LOG.debug("Transaction chain failed.", cause);
// Do not return RPC here, rely on transaction failure to call runFailed.
}
@Override
- public void onTransactionChainSuccessful(final TransactionChain<?, ?> chain) {
+ public void onTransactionChainSuccessful(final DOMTransactionChain chain) {
LOG.debug("Transaction chain closed successfully.");
}
}
}
@Override
- DOMDataWriteTransaction createTransaction() {
+ DOMDataTreeWriteTransaction createTransaction() {
return dataBroker.newWriteOnlyTransaction();
}
.withChild(ImmutableNodes.mapNodeBuilder(ID_INT).build())
.build();
- DOMDataWriteTransaction tx = domDataBroker.newWriteOnlyTransaction();
+ DOMDataTreeWriteTransaction tx = domDataBroker.newWriteOnlyTransaction();
// write only the top list
tx.merge(LogicalDatastoreType.CONFIGURATION, ID_INTS_YID, containerNode);
try {
- tx.submit().checkedGet(INIT_TX_TIMEOUT_SECONDS, TimeUnit.SECONDS);
- } catch (final OptimisticLockFailedException e) {
- // when multiple write-transactions are executed concurrently we need to ignore this.
- // If we get optimistic lock here it means id-ints already exists and we can continue.
- LOG.debug("Got an optimistic lock when writing initial top level list element.", e);
- } catch (final TransactionCommitFailedException | TimeoutException e) {
+ tx.commit().get(INIT_TX_TIMEOUT_SECONDS, TimeUnit.SECONDS);
+ } catch (InterruptedException | TimeoutException e) {
LOG.error("Error writing top-level path {}: {}", ID_INTS_YID, containerNode, e);
return RpcResultBuilder.<WriteTransactionsOutput>failed().withError(RpcError.ErrorType.APPLICATION,
String.format("Could not start write transactions - error writing top-level path %s: %s",
ID_INTS_YID, containerNode), e).buildFuture();
+ } catch (ExecutionException e) {
+ final Throwable cause = e.getCause();
+ if (cause instanceof OptimisticLockFailedException) {
+ // when multiple write-transactions are executed concurrently we need to ignore this.
+ // If we get optimistic lock here it means id-ints already exists and we can continue.
+ LOG.debug("Got an optimistic lock when writing initial top level list element.", e);
+ } else {
+ LOG.error("Error writing top-level path {}: {}", ID_INTS_YID, containerNode, e);
+ return RpcResultBuilder.<WriteTransactionsOutput>failed().withError(RpcError.ErrorType.APPLICATION,
+ String.format("Could not start write transactions - error writing top-level path %s: %s",
+ ID_INTS_YID, containerNode), e).buildFuture();
+ }
}
tx = domDataBroker.newWriteOnlyTransaction();
tx.merge(LogicalDatastoreType.CONFIGURATION, idListItem, entry);
try {
- tx.submit().get(INIT_TX_TIMEOUT_SECONDS, TimeUnit.SECONDS);
+ tx.commit().get(INIT_TX_TIMEOUT_SECONDS, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
LOG.error("Error writing top-level path {}: {}", idListItem, entry, e);
return RpcResultBuilder.<WriteTransactionsOutput>failed().withError(RpcError.ErrorType.APPLICATION,
tx.put(LogicalDatastoreType.CONFIGURATION, itemListId, itemListNode);
try {
- tx.submit().get(INIT_TX_TIMEOUT_SECONDS, TimeUnit.SECONDS);
+ tx.commit().get(INIT_TX_TIMEOUT_SECONDS, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
LOG.error("Error filling initial item list path {}: {}", itemListId, itemListNode, e);
return RpcResultBuilder.<WriteTransactionsOutput>failed().withError(RpcError.ErrorType.APPLICATION,
}
@Override
- ListenableFuture<Void> execWrite(final long txId) {
+ FluentFuture<? extends @NonNull CommitInfo> execWrite(final long txId) {
final int i = nextInt(MAX_ITEM + 1);
final YangInstanceIdentifier entryId =
idListItem.node(ITEM).node(YangInstanceIdentifier.NodeIdentifierWithPredicates.of(ITEM, NUMBER, i));
- final DOMDataWriteTransaction tx = createTransaction();
+ final DOMDataTreeWriteTransaction tx = createTransaction();
if (usedValues.contains(i)) {
LOG.debug("Deleting item: {}", i);
usedValues.add(i);
}
- return tx.submit();
+ return tx.commit();
}
@Override
.withError(RpcError.ErrorType.APPLICATION, cause).build());
}
- abstract DOMDataWriteTransaction createTransaction();
+ abstract DOMDataTreeWriteTransaction createTransaction();
abstract int nextInt(int bound);
}
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
odl:use-default-for-reference-types="true">
- <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"/>
- <reference id="notificationService" interface="org.opendaylight.controller.sal.binding.api.NotificationProviderService"/>
+ <reference id="dataBroker" interface="org.opendaylight.mdsal.binding.api.DataBroker"/>
<reference id="entityOwnershipService" interface="org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService"/>
- <reference id="bindingRpcRegistry" interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry"/>
- <reference id="domRpcProviderService" interface="org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService"/>
+ <reference id="bindingRpcRegistry" interface="org.opendaylight.mdsal.binding.api.RpcProviderService"/>
+ <reference id="domRpcProviderService" interface="org.opendaylight.mdsal.dom.api.DOMRpcProviderService"/>
<reference id="clusterSingletonService" interface="org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider"/>
- <reference id="domDataBroker" interface="org.opendaylight.controller.md.sal.dom.api.DOMDataBroker"/>
+ <reference id="domDataBroker" interface="org.opendaylight.mdsal.dom.api.DOMDataBroker"/>
<reference id="schemaService" interface="org.opendaylight.mdsal.dom.api.DOMSchemaService"/>
<reference id="normalizedNodeSerializer" interface="org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer"/>
- <reference id="notificationPublishService" interface="org.opendaylight.controller.md.sal.binding.api.NotificationPublishService" />
- <reference id="notificationListenerService" interface="org.opendaylight.controller.md.sal.binding.api.NotificationService" />
+ <reference id="notificationPublishService" interface="org.opendaylight.mdsal.binding.api.NotificationPublishService" />
+ <reference id="notificationListenerService" interface="org.opendaylight.mdsal.binding.api.NotificationService" />
<reference id="domDataTreeService" interface="org.opendaylight.mdsal.dom.api.DOMDataTreeService"/>
<reference id="distributedShardFactory" interface="org.opendaylight.controller.cluster.sharding.DistributedShardFactory"/>
<reference id="configDatastore" interface="org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface"
<bean id="purchaseCarProvider" class="org.opendaylight.controller.clustering.it.provider.PurchaseCarProvider" >
- <property name="notificationProvider" ref="notificationService"/>
+ <property name="notificationProvider" ref="notificationPublishService"/>
</bean>
- <odl:routed-rpc-implementation id="carPurchaseRpcReg" ref="purchaseCarProvider"/>
+ <!-- odl:routed-rpc-implementation id="carPurchaseRpcReg" ref="purchaseCarProvider"/ -->
<bean id="peopleProvider" class="org.opendaylight.controller.clustering.it.provider.PeopleProvider" >
<property name="dataProvider" ref="dataBroker"/>
- <property name="rpcRegistration" ref="carPurchaseRpcReg"/>
+ <property name="rpcImplementation" ref="purchaseCarProvider"/>
</bean>
<bean id="carProvider" class="org.opendaylight.controller.clustering.it.provider.CarProvider"
<artifactId>sal-common-util</artifactId>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-api</artifactId>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-binding-api</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>