import java.util.Collections;
import java.util.Iterator;
import java.util.Map.Entry;
+import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
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.impl.BindingToNormalizedNodeCodec;
import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest;
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.dom.broker.impl.mount.DOMMountPointServiceImpl;
import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.controller.sal.core.api.mount.MountProvisionListener;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
+import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
+import org.opendaylight.mdsal.dom.api.DOMMountPointListener;
import org.opendaylight.mdsal.eos.dom.simple.SimpleDOMEntityOwnershipService;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
-import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
@Mock private ScheduledThreadPool mockKeepaliveExecutor;
@Mock private ActorSystemProvider mockMasterActorSystemProvider;
- @Mock private MountProvisionListener masterMountPointListener;
+ @Mock private DOMMountPointListener masterMountPointListener;
private final DOMMountPointService masterMountPointService = new DOMMountPointServiceImpl();
private final DOMRpcRouter deviceRpcService = new DOMRpcRouter();
private DOMClusterSingletonServiceProviderImpl masterClusterSingletonServiceProvider;
@Mock private ActorSystemProvider mockSlaveActorSystemProvider;
@Mock private ClusterSingletonServiceProvider mockSlaveClusterSingletonServiceProvider;
@Mock private ClusterSingletonServiceRegistration mockSlaveClusterSingletonServiceReg;
- @Mock private MountProvisionListener slaveMountPointListener;
+ @Mock private DOMMountPointListener slaveMountPointListener;
private final DOMMountPointService slaveMountPointService = new DOMMountPointServiceImpl();
private DataBroker slaveDataBroker;
private ActorSystem slaveSystem;
private YangModuleInfo topModuleInfo;
private SchemaPath putTopRpcSchemaPath;
private SchemaPath getTopRpcSchemaPath;
- private BindingToNormalizedNodeCodec bindingToNormalized;
+ private BindingNormalizedNodeSerializer bindingToNormalized;
private YangInstanceIdentifier yangNodeInstanceId;
private final TopDOMRpcImplementation topRpcImplementation = new TopDOMRpcImplementation();
LOG.info("****** Setup complete");
}
- private void deleteCacheDir() {
+ private static void deleteCacheDir() {
FileUtils.deleteQuietly(new File(NetconfTopologyUtils.CACHE_DIRECTORY));
}
@After
public void tearDown() throws Exception {
deleteCacheDir();
- TestKit.shutdownActorSystem(slaveSystem, Boolean.TRUE);
- TestKit.shutdownActorSystem(masterSystem, Boolean.TRUE);
+ TestKit.shutdownActorSystem(slaveSystem, true);
+ TestKit.shutdownActorSystem(masterSystem, true);
}
private void setupMaster() throws Exception {
mockMasterActorSystemProvider, eventExecutor, mockClientDispatcher, TOPOLOGY_ID, config,
masterMountPointService, mockEncryptionService) {
@Override
- protected NetconfTopologyContext newNetconfTopologyContext(NetconfTopologySetup setup,
- ServiceGroupIdentifier serviceGroupIdent, Timeout actorResponseWaitTime) {
+ protected NetconfTopologyContext newNetconfTopologyContext(final NetconfTopologySetup setup,
+ final ServiceGroupIdentifier serviceGroupIdent, final Timeout actorResponseWaitTime) {
NetconfTopologyContext context =
super.newNetconfTopologyContext(setup, serviceGroupIdent, actorResponseWaitTime);
NetconfTopologyContext spiedContext = spy(context);
slaveNetconfTopologyManager = new NetconfTopologyManager(slaveDataBroker, mockRpcProviderRegistry,
mockSlaveClusterSingletonServiceProvider, mockKeepaliveExecutor, mockThreadPool,
mockSlaveActorSystemProvider, eventExecutor, mockClientDispatcher, TOPOLOGY_ID, config,
- slaveMountPointService, mockEncryptionService) {
+ slaveMountPointService, mockEncryptionService) {
@Override
- protected NetconfTopologyContext newNetconfTopologyContext(NetconfTopologySetup setup,
- ServiceGroupIdentifier serviceGroupIdent, Timeout actorResponseWaitTime) {
+ protected NetconfTopologyContext newNetconfTopologyContext(final NetconfTopologySetup setup,
+ final ServiceGroupIdentifier serviceGroupIdent, final Timeout actorResponseWaitTime) {
NetconfTopologyContext spiedContext =
spy(super.newNetconfTopologyContext(setup, serviceGroupIdent, actorResponseWaitTime));
slaveNetconfTopologyContextFuture.set(spiedContext);
slaveTxChain = slaveDataBroker.createTransactionChain(new TransactionChainListener() {
@Override
- public void onTransactionChainSuccessful(TransactionChain<?, ?> chain) {
+ public void onTransactionChainSuccessful(final TransactionChain<?, ?> chain) {
}
@Override
- public void onTransactionChainFailed(TransactionChain<?, ?> chain, AsyncTransaction<?, ?> transaction,
- Throwable cause) {
+ public void onTransactionChainFailed(final TransactionChain<?, ?> chain,
+ final AsyncTransaction<?, ?> transaction, final Throwable cause) {
LOG.error("Slave transaction chain failed", cause);
}
});
Optional<Node> node = readTx.read(LogicalDatastoreType.OPERATIONAL,
NODE_INSTANCE_ID).get(5, TimeUnit.SECONDS);
assertTrue(node.isPresent());
- final NetconfNode netconfNode = node.get().getAugmentation(NetconfNode.class);
+ final NetconfNode netconfNode = node.get().augmentation(NetconfNode.class);
return netconfNode.getConnectionStatus() != NetconfNodeConnectionStatus.ConnectionStatus.Connected;
}
});
verify(mockSlaveClusterSingletonServiceReg).close();
}
- private void testDOMRpcService(DOMRpcService domRpcService)
+ private void testDOMRpcService(final DOMRpcService domRpcService)
throws InterruptedException, ExecutionException, TimeoutException {
testPutTopRpc(domRpcService, new DefaultDOMRpcResult((NormalizedNode<?, ?>)null));
testPutTopRpc(domRpcService, null);
testFailedRpc(domRpcService, getTopRpcSchemaPath, null);
}
- private void testPutTopRpc(DOMRpcService domRpcService, DOMRpcResult result)
+ private void testPutTopRpc(final DOMRpcService domRpcService, final DOMRpcResult result)
throws InterruptedException, ExecutionException, TimeoutException {
ContainerNode putTopInput = bindingToNormalized.toNormalizedNodeRpcData(
new PutTopInputBuilder().setTopLevelList(Arrays.asList(new TopLevelListBuilder().setName("one")
testRpc(domRpcService, putTopRpcSchemaPath, putTopInput, result);
}
- private void testGetTopRpc(DOMRpcService domRpcService, DOMRpcResult result)
+ private void testGetTopRpc(final DOMRpcService domRpcService, final DOMRpcResult result)
throws InterruptedException, ExecutionException, TimeoutException {
testRpc(domRpcService, getTopRpcSchemaPath, null, result);
}
- private void testRpc(DOMRpcService domRpcService, SchemaPath schemaPath, NormalizedNode<?, ?> input,
- DOMRpcResult result) throws InterruptedException, ExecutionException, TimeoutException {
+ private void testRpc(final DOMRpcService domRpcService, final SchemaPath schemaPath,
+ final NormalizedNode<?, ?> input, final DOMRpcResult result) throws InterruptedException,
+ ExecutionException, TimeoutException {
final DOMRpcResult actual = invokeRpc(domRpcService, schemaPath, input, Futures.immediateCheckedFuture(result));
if (result == null) {
assertNull(actual);
}
}
- private void testFailedRpc(DOMRpcService domRpcService, SchemaPath schemaPath, NormalizedNode<?, ?> input)
- throws InterruptedException, TimeoutException {
+ private void testFailedRpc(final DOMRpcService domRpcService, final SchemaPath schemaPath,
+ final NormalizedNode<?, ?> input) throws InterruptedException, TimeoutException {
try {
invokeRpc(domRpcService, schemaPath, input, Futures.immediateFailedCheckedFuture(
new ClusteringRpcException("mock")));
}
}
- private DOMRpcResult invokeRpc(DOMRpcService domRpcService, SchemaPath schemaPath, NormalizedNode<?, ?> input,
- CheckedFuture<DOMRpcResult, DOMRpcException> returnFuture)
+ private DOMRpcResult invokeRpc(final DOMRpcService domRpcService, final SchemaPath schemaPath,
+ final NormalizedNode<?, ?> input, final CheckedFuture<DOMRpcResult, DOMRpcException> returnFuture)
throws InterruptedException, ExecutionException, TimeoutException {
topRpcImplementation.init(returnFuture);
final ListenableFuture<DOMRpcResult> resultFuture = domRpcService.invokeRpc(schemaPath, input);
return resultFuture.get(5, TimeUnit.SECONDS);
}
- private static void testDOMDataBrokerOperations(DOMDataBroker dataBroker)
+ private static void testDOMDataBrokerOperations(final DOMDataBroker dataBroker)
throws InterruptedException, ExecutionException, TimeoutException {
DOMDataWriteTransaction writeTx = dataBroker.newWriteOnlyTransaction();
assertTrue(readTx.cancel());
}
- private static void writeNetconfNode(String cacheDir, DataBroker databroker)
+ private static void writeNetconfNode(final String cacheDir, final DataBroker databroker)
throws InterruptedException, ExecutionException, TimeoutException {
final NetconfNode netconfNode = new NetconfNodeBuilder()
.setHost(new Host(new IpAddress(new Ipv4Address("127.0.0.1"))))
writeTx.commit().get(5, TimeUnit.SECONDS);
}
- private static void verifyDataInStore(DOMDataReadTransaction readTx, YangInstanceIdentifier path,
- NormalizedNode<?, ?> expNode) throws InterruptedException, ExecutionException, TimeoutException {
+ private static void verifyDataInStore(final DOMDataReadTransaction readTx, final YangInstanceIdentifier path,
+ final NormalizedNode<?, ?> expNode) throws InterruptedException, ExecutionException, TimeoutException {
final Optional<NormalizedNode<?, ?>> read = readTx.read(LogicalDatastoreType.CONFIGURATION, path)
.get(5, TimeUnit.SECONDS);
assertTrue(read.isPresent());
assertTrue(exists);
}
- private static void verifyTopologyNodesCreated(DataBroker dataBroker) {
+ private static void verifyTopologyNodesCreated(final DataBroker dataBroker) {
await().atMost(5, TimeUnit.SECONDS).until(() -> {
try (ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction()) {
Optional<Topology> configTopology = readTx.read(LogicalDatastoreType.CONFIGURATION,
private AbstractConcurrentDataBrokerTest newDataBrokerTest() throws Exception {
AbstractConcurrentDataBrokerTest dataBrokerTest = new AbstractConcurrentDataBrokerTest(true) {
@Override
- protected Iterable<YangModuleInfo> getModuleInfos() throws Exception {
+ protected Set<YangModuleInfo> getModuleInfos() throws Exception {
return ImmutableSet.of(BindingReflections.getModuleInfo(NetconfNode.class),
BindingReflections.getModuleInfo(NetworkTopology.class),
BindingReflections.getModuleInfo(Topology.class),
return dataBrokerTest;
}
- private void awaitMountPointNotPresent(DOMMountPointService mountPointService) {
+ private void awaitMountPointNotPresent(final DOMMountPointService mountPointService) {
await().atMost(5, TimeUnit.SECONDS).until(
() -> !mountPointService.getMountPoint(yangNodeInstanceId).isPresent());
}
- private static DOMDataBroker getDOMDataBroker(DOMMountPoint mountPoint) {
+ private static DOMDataBroker getDOMDataBroker(final DOMMountPoint mountPoint) {
return getMountPointService(mountPoint, DOMDataBroker.class);
}
- private static DOMRpcService getDOMRpcService(DOMMountPoint mountPoint) {
+ private static DOMRpcService getDOMRpcService(final DOMMountPoint mountPoint) {
return getMountPointService(mountPoint, DOMRpcService.class);
}
- private static <T extends DOMService> T getMountPointService(DOMMountPoint mountPoint, Class<T> serviceClass) {
+ private static <T extends DOMService> T getMountPointService(final DOMMountPoint mountPoint,
+ final Class<T> serviceClass) {
final Optional<T> maybeService = mountPoint.getService(serviceClass);
assertTrue(maybeService.isPresent());
return maybeService.get();
}
- private DOMMountPoint awaitMountPoint(DOMMountPointService mountPointService) {
+ private DOMMountPoint awaitMountPoint(final DOMMountPointService mountPointService) {
await().atMost(5, TimeUnit.SECONDS).until(() -> {
return mountPointService.getMountPoint(yangNodeInstanceId).isPresent();
});
return mountPointService.getMountPoint(yangNodeInstanceId).get();
}
- private RpcDefinition findRpcDefinition(String rpc) {
+ private RpcDefinition findRpcDefinition(final String rpc) {
Module topModule = deviceSchemaContext.findModule(TOP_MODULE_NAME, topModuleInfo.getName().getRevision()).get();
RpcDefinition rpcDefinition = null;
for (RpcDefinition def: topModule.getRpcs()) {
private volatile CheckedFuture<DOMRpcResult, DOMRpcException> returnFuture;
@Override
- public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(DOMRpcIdentifier rpc,
- NormalizedNode<?, ?> input) {
+ public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final DOMRpcIdentifier rpc,
+ final NormalizedNode<?, ?> input) {
rpcInvokedFuture.set(new SimpleEntry<>(rpc, input));
return returnFuture;
}
- void init(CheckedFuture<DOMRpcResult, DOMRpcException> retFuture) {
+ void init(final CheckedFuture<DOMRpcResult, DOMRpcException> retFuture) {
this.returnFuture = retFuture;
rpcInvokedFuture = SettableFuture.create();
}
- void verify(DOMRpcIdentifier expRpc, NormalizedNode<?, ?> expInput)
+ void verify(final DOMRpcIdentifier expRpc, final NormalizedNode<?, ?> expInput)
throws InterruptedException, ExecutionException, TimeoutException {
final Entry<DOMRpcIdentifier, NormalizedNode<?, ?>> actual = rpcInvokedFuture.get(5, TimeUnit.SECONDS);
assertEquals(expRpc, actual.getKey());