*/
package org.opendaylight.dsbenchmark.listener;
-import java.util.Collection;
+import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
-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.dsbenchmark.rev150105.TestExec;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private final AtomicInteger numDataChanges = new AtomicInteger(0);
@Override
- public void onDataTreeChanged(
- final Collection<DataTreeModification<TestExec>> changes) {
+ public void onDataTreeChanged(final List<DataTreeModification<TestExec>> changes) {
// Since we're registering the same DsbenchmarkListener object for both
// OPERATIONAL and CONFIG, the onDataTreeChanged() method can be called
// from different threads, and we need to use atomic counters.
}
private static synchronized void logDataTreeChangeEvent(final int eventNum,
- final Collection<DataTreeModification<TestExec>> changes) {
+ final List<DataTreeModification<TestExec>> changes) {
LOG.debug("DsbenchmarkListener-onDataTreeChanged: Event {}", eventNum);
- for (DataTreeModification<TestExec> change : changes) {
- final DataObjectModification<TestExec> rootNode = change.getRootNode();
- final ModificationType modType = rootNode.getModificationType();
- final PathArgument changeId = rootNode.getIdentifier();
- final Collection<? extends DataObjectModification<? extends DataObject>> modifications =
- rootNode.getModifiedChildren();
+ for (var change : changes) {
+ final var rootNode = change.getRootNode();
+ final var modType = rootNode.modificationType();
+ final var changeId = rootNode.step();
+ final var modifications = rootNode.modifiedChildren();
LOG.debug(" changeId {}, modType {}, mods: {}", changeId, modType, modifications.size());
- for (DataObjectModification<? extends DataObject> mod : modifications) {
- LOG.debug(" mod-getDataAfter: {}", mod.getDataAfter());
+ for (var mod : modifications) {
+ LOG.debug(" mod-getDataAfter: {}", mod.dataAfter());
}
}
}
import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestExec;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final Logger LOG = LoggerFactory.getLogger(DsbenchmarkListenerProvider.class);
private static final InstanceIdentifier<TestExec> TEST_EXEC_IID =
InstanceIdentifier.builder(TestExec.class).build();
- private final List<ListenerRegistration<DsbenchmarkListener>> listeners = new ArrayList<>();
+ private final List<DsbenchmarkListener> listeners = new ArrayList<>();
+ private final List<Registration> registrations = new ArrayList<>();
private final DataBroker dataBroker;
public DsbenchmarkListenerProvider(final DataBroker dataBroker) {
public void createAndRegisterListeners(final int numListeners) {
for (int i = 0; i < numListeners; i++) {
- DsbenchmarkListener listener = new DsbenchmarkListener();
- listeners.add(dataBroker.registerDataTreeChangeListener(
- DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION, TEST_EXEC_IID), listener));
- listeners.add(dataBroker.registerDataTreeChangeListener(
- DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, TEST_EXEC_IID), listener));
+ var listener = new DsbenchmarkListener();
+ listeners.add(listener);
+ registrations.add(dataBroker.registerDataTreeChangeListener(
+ DataTreeIdentifier.of(LogicalDatastoreType.CONFIGURATION, TEST_EXEC_IID), listener));
+ registrations.add(dataBroker.registerDataTreeChangeListener(
+ DataTreeIdentifier.of(LogicalDatastoreType.OPERATIONAL, TEST_EXEC_IID), listener));
}
LOG.debug("DsbenchmarkListenerProvider created {} listeneres", numListeners);
public long getDataChangeCount() {
long dataChanges = 0;
- for (ListenerRegistration<DsbenchmarkListener> listenerRegistration : listeners) {
- dataChanges += listenerRegistration.getInstance().getNumDataChanges();
+ for (var listener : listeners) {
+ dataChanges += listener.getNumDataChanges();
}
LOG.debug("DsbenchmarkListenerProvider , total data changes {}", dataChanges);
return dataChanges;
public long getEventCountAndDestroyListeners() {
long totalEvents = 0;
- for (ListenerRegistration<DsbenchmarkListener> listenerRegistration : listeners) {
- totalEvents += listenerRegistration.getInstance().getNumEvents();
- listenerRegistration.close();
+ registrations.forEach(Registration::close);
+ registrations.clear();
+
+ for (var listener : listeners) {
+ totalEvents += listener.getNumEvents();
}
listeners.clear();
+
LOG.debug("DsbenchmarkListenerProvider destroyed listeneres, total events {}", totalEvents);
return totalEvents;
}
import java.util.concurrent.ExecutionException;
import org.opendaylight.dsbenchmark.DatastoreAbstractWriter;
import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.Transaction;
import org.opendaylight.mdsal.binding.api.TransactionChain;
-import org.opendaylight.mdsal.binding.api.TransactionChainListener;
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.dsbenchmark.rev150105.test.exec.OuterList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterListKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.Empty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class TxchainBaDelete extends DatastoreAbstractWriter implements TransactionChainListener {
+public class TxchainBaDelete extends DatastoreAbstractWriter implements FutureCallback<Empty> {
private static final Logger LOG = LoggerFactory.getLogger(TxchainBaDelete.class);
private final DataBroker bindingDataBroker;
@Override
public void executeList() {
final LogicalDatastoreType dsType = getDataStoreType();
- final TransactionChain chain = bindingDataBroker.createMergingTransactionChain(this);
+ final TransactionChain chain = bindingDataBroker.createMergingTransactionChain();
+ chain.addCallback(this);
WriteTransaction tx = chain.newWriteOnlyTransaction();
int txSubmitted = 0;
}
@Override
- public void onTransactionChainFailed(final TransactionChain chain, final Transaction transaction,
- final Throwable cause) {
- LOG.error("Broken chain {} in TxchainBaDelete, transaction {}", chain, transaction.getIdentifier(), cause);
+ public void onFailure(final Throwable cause) {
+ LOG.error("Broken chain in TxchainBaDelete", cause);
}
@Override
- public void onTransactionChainSuccessful(final TransactionChain chain) {
- LOG.debug("TxchainBaDelete closed successfully, chain {}", chain);
+ public void onSuccess(final Empty chain) {
+ LOG.debug("TxchainBaDelete closed successfully");
}
}
import org.opendaylight.dsbenchmark.DatastoreAbstractWriter;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.ReadTransaction;
-import org.opendaylight.mdsal.binding.api.Transaction;
-import org.opendaylight.mdsal.binding.api.TransactionChain;
-import org.opendaylight.mdsal.binding.api.TransactionChainListener;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput.DataStore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class TxchainBaRead extends DatastoreAbstractWriter implements TransactionChainListener {
+public class TxchainBaRead extends DatastoreAbstractWriter {
private static final Logger LOG = LoggerFactory.getLogger(TxchainBaRead.class);
private final DataBroker bindingDataBroker;
}
}
}
-
- @Override
- public void onTransactionChainFailed(final TransactionChain chain, final Transaction transaction,
- final Throwable cause) {
- LOG.error("Broken chain {} in TxchainBaDelete, transaction {}", chain, transaction.getIdentifier(), cause);
- }
-
- @Override
- public void onTransactionChainSuccessful(final TransactionChain chain) {
- LOG.debug("TxchainBaDelete closed successfully, chain {}", chain);
- }
}
import org.opendaylight.dsbenchmark.BaListBuilder;
import org.opendaylight.dsbenchmark.DatastoreAbstractWriter;
import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.Transaction;
-import org.opendaylight.mdsal.binding.api.TransactionChain;
-import org.opendaylight.mdsal.binding.api.TransactionChainListener;
import org.opendaylight.mdsal.common.api.CommitInfo;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput.DataStore;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestExec;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterList;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.Empty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class TxchainBaWrite extends DatastoreAbstractWriter implements TransactionChainListener {
+public class TxchainBaWrite extends DatastoreAbstractWriter implements FutureCallback<Empty> {
private static final Logger LOG = LoggerFactory.getLogger(TxchainBaWrite.class);
private final DataBroker dataBroker;
@Override
public void executeList() {
- final var chain = dataBroker.createMergingTransactionChain(this);
+ final var chain = dataBroker.createMergingTransactionChain();
+ chain.addCallback(this);
final var dsType = getDataStoreType();
var tx = chain.newWriteOnlyTransaction();
}
@Override
- public void onTransactionChainFailed(final TransactionChain chain, final Transaction transaction,
- final Throwable cause) {
- LOG.error("Broken chain {} in DatastoreBaAbstractWrite, transaction {}", chain, transaction.getIdentifier(),
- cause);
+ public void onFailure(final Throwable cause) {
+ LOG.error("Broken chain in DatastoreBaAbstractWrite", cause);
}
@Override
- public void onTransactionChainSuccessful(final TransactionChain chain) {
- LOG.debug("DatastoreBaAbstractWrite closed successfully, chain {}", chain);
+ public void onSuccess(final Empty result) {
+ LOG.debug("DatastoreBaAbstractWrite closed successfully");
}
}
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.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.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput.DataStore;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestExec;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterList;
+import org.opendaylight.yangtools.yang.common.Empty;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class TxchainDomDelete extends DatastoreAbstractWriter implements DOMTransactionChainListener {
+public class TxchainDomDelete extends DatastoreAbstractWriter implements FutureCallback<Empty> {
private static final Logger LOG = LoggerFactory.getLogger(TxchainDomDelete.class);
private final DOMDataBroker domDataBroker;
final org.opendaylight.yangtools.yang.common.QName olId = QName.create(OuterList.QNAME, "id");
final YangInstanceIdentifier pid =
YangInstanceIdentifier.builder().node(TestExec.QNAME).node(OuterList.QNAME).build();
- final DOMTransactionChain chain = domDataBroker.createMergingTransactionChain(this);
+ final DOMTransactionChain chain = domDataBroker.createMergingTransactionChain();
+ chain.addCallback(this);
DOMDataTreeWriteTransaction tx = chain.newWriteOnlyTransaction();
int txSubmitted = 0;
}
@Override
- public void onTransactionChainFailed(final DOMTransactionChain chain, final DOMDataTreeTransaction transaction,
- final Throwable cause) {
- LOG.error("Broken chain {} in TxchainDomDelete, transaction {}", chain, transaction.getIdentifier(), cause);
+ public void onFailure(final Throwable cause) {
+ LOG.error("Broken chain in TxchainDomDelete", cause);
}
@Override
- public void onTransactionChainSuccessful(final DOMTransactionChain chain) {
- LOG.debug("TxchainDomDelete closed successfully, chain {}", chain);
+ public void onSuccess(final Empty result) {
+ LOG.debug("TxchainDomDelete closed successfully");
}
}
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.mdsal.dom.api.DOMDataBroker;
import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeTransaction;
-import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
-import org.opendaylight.mdsal.dom.api.DOMTransactionChainListener;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput.DataStore;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestExec;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class TxchainDomRead extends DatastoreAbstractWriter implements DOMTransactionChainListener {
+public class TxchainDomRead extends DatastoreAbstractWriter {
private static final Logger LOG = LoggerFactory.getLogger(TxchainDomRead.class);
private final DOMDataBroker domDataBroker;
@Override
public void executeList() {
final LogicalDatastoreType dsType = getDataStoreType();
- final org.opendaylight.yangtools.yang.common.QName olId = QName.create(OuterList.QNAME, "id");
+ final QName olId = QName.create(OuterList.QNAME, "id");
final YangInstanceIdentifier pid =
YangInstanceIdentifier.builder().node(TestExec.QNAME).node(OuterList.QNAME).build();
}
}
}
-
- @Override
- public void onTransactionChainFailed(final DOMTransactionChain chain, final DOMDataTreeTransaction transaction,
- final Throwable cause) {
- LOG.error("Broken chain {} in TxchainDomDelete, transaction {}", chain, transaction.getIdentifier(), cause);
- }
-
- @Override
- public void onTransactionChainSuccessful(final DOMTransactionChain chain) {
- LOG.debug("TxchainDomDelete closed successfully, chain {}", chain);
- }
}
import org.opendaylight.dsbenchmark.DomListBuilder;
import org.opendaylight.mdsal.common.api.CommitInfo;
import org.opendaylight.mdsal.dom.api.DOMDataBroker;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeTransaction;
-import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
-import org.opendaylight.mdsal.dom.api.DOMTransactionChainListener;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput.DataStore;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestExec;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterList;
+import org.opendaylight.yangtools.yang.common.Empty;
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;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class TxchainDomWrite extends DatastoreAbstractWriter implements DOMTransactionChainListener {
+public class TxchainDomWrite extends DatastoreAbstractWriter implements FutureCallback<Empty> {
private static final Logger LOG = LoggerFactory.getLogger(TxchainDomWrite.class);
private final DOMDataBroker dataBroker;
public void executeList() {
final var dsType = getDataStoreType();
final var pid = YangInstanceIdentifier.of(TestExec.QNAME, OuterList.QNAME);
- final var chain = dataBroker.createMergingTransactionChain(this);
+ final var chain = dataBroker.createMergingTransactionChain();
+ chain.addCallback(this);
var tx = chain.newWriteOnlyTransaction();
int txSubmitted = 0;
}
@Override
- public void onTransactionChainFailed(final DOMTransactionChain chain, final DOMDataTreeTransaction transaction,
- final Throwable cause) {
- LOG.error("Broken chain {} in TxchainDomWrite, transaction {}", chain, transaction.getIdentifier(), cause);
+ public void onFailure(final Throwable cause) {
+ LOG.error("Broken chain in TxchainDomWrite", cause);
}
@Override
- public void onTransactionChainSuccessful(final DOMTransactionChain chain) {
- LOG.debug("Chain {} closed successfully", chain);
+ public void onSuccess(final Empty result) {
+ LOG.debug("Chain closed successfully");
}
}
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
-import java.util.Map;
import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicLong;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.GlobalRpcBench;
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;
import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.payload.Payload;
import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.payload.PayloadBuilder;
import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.payload.PayloadKey;
-import org.opendaylight.yangtools.yang.common.RpcResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
return rpcError.get();
}
- public GlobalBindingRTCClient(final RpcConsumerRegistry registry, final int inSize) {
- this.globalRpcBench = registry.getRpc(GlobalRpcBench.class);
+ public GlobalBindingRTCClient(final RpcService rpcService, final int inSize) {
+ globalRpcBench = rpcService.getRpc(GlobalRpcBench.class);
this.inSize = inSize;
Builder<PayloadKey, Payload> listVals = ImmutableMap.builderWithExpectedSize(inSize);
int error = 0;
for (int i = 0; i < iterations; i++) {
- Future<RpcResult<GlobalRpcBenchOutput>> output = globalRpcBench.invoke(inVal);
+ final var output = globalRpcBench.invoke(inVal);
try {
- RpcResult<GlobalRpcBenchOutput> rpcResult = output.get();
+ final var rpcResult = output.get();
if (rpcResult.isSuccessful()) {
- Map<PayloadKey, Payload> retVal = rpcResult.getResult().getPayload();
+ final var retVal = rpcResult.getResult().getPayload();
if (retVal.size() == inSize) {
ok++;
}
// TODO Auto-generated method stub
}
-
}
import java.util.concurrent.Future;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicLong;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.RoutedRpcBench;
import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.RoutedRpcBenchInput;
import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.RoutedRpcBenchInputBuilder;
private final List<RoutedRpcBenchInput> inVal = new ArrayList<>();
private final int inSize;
- public RoutedBindingRTClient(final RpcConsumerRegistry registry, final int inSize,
+ public RoutedBindingRTClient(final RpcService rpcService, final int inSize,
final List<InstanceIdentifier<?>> routeIid) {
- this.routedRpcBench = registry.getRpc(RoutedRpcBench.class);
+ routedRpcBench = rpcService.getRpc(RoutedRpcBench.class);
this.inSize = inSize;
Builder<PayloadKey, Payload> listVals = ImmutableMap.builderWithExpectedSize(inSize);
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.inject.Singleton;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
+import org.opendaylight.mdsal.binding.api.RpcService;
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.rpcbench.payload.rev150702.rpcbench.rpc.routes.RpcRouteKey;
private final AtomicReference<ExecStatus> execStatus = new AtomicReference<>(ExecStatus.Idle);
private final RpcProviderService providerRegistry;
- private final RpcConsumerRegistry consumerRegistry;
+ private final RpcService consumerRegistry;
private final GlobalBindingRTCServer globalServer;
private final Registration reg;
@Inject
@Activate
public RpcbenchmarkProvider(@Reference final RpcProviderService providerRegistry,
- @Reference final RpcConsumerRegistry consumerRegistry) {
+ @Reference final RpcService consumerRegistry) {
this.providerRegistry = requireNonNull(providerRegistry);
this.consumerRegistry = requireNonNull(consumerRegistry);
globalServer = new GlobalBindingRTCServer(providerRegistry);
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.opendaylight.mdsal</groupId>
- <artifactId>dom-parent</artifactId>
- <version>12.0.4</version>
+ <artifactId>bundle-parent</artifactId>
+ <version>13.0.0</version>
<relativePath/>
</parent>
<link>https://commons.apache.org/proper/commons-lang/javadocs/api-release/</link>
<link>https://www.javadoc.io/doc/org.opendaylight.odlparent/odlparent-docs/13.0.10/</link>
- <link>https://www.javadoc.io/doc/org.opendaylight.yangtools/yangtools-docs/11.0.5/</link>
- <link>https://www.javadoc.io/doc/org.opendaylight.mdsal/mdsal-docs/12.0.4/</link>
+ <link>https://www.javadoc.io/doc/org.opendaylight.yangtools/yangtools-docs/13.0.1/</link>
+ <link>https://www.javadoc.io/doc/org.opendaylight.mdsal/mdsal-docs/13.0.0/</link>
</links>
<groups>
<group>
-->
<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="odl-clustering-test-app-${project.version}">
<feature name="odl-clustering-test-app" version="${project.version}">
- <feature version="[12,13)">odl-mdsal-model-rfc6991</feature>
+ <feature version="[13,14)">odl-mdsal-model-rfc6991</feature>
</feature>
</features>
-->
<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="[11,12)">odl-yangtools-codec</feature>
- <feature version="[12,13)">odl-mdsal-binding-api</feature>
- <feature version="[12,13)">odl-mdsal-binding-runtime</feature>
- <feature version="[12,13)">odl-mdsal-dom-api</feature>
+ <feature version="[13,14)">odl-yangtools-codec</feature>
+ <feature version="[13,14)">odl-mdsal-binding-api</feature>
+ <feature version="[13,14)">odl-mdsal-binding-runtime</feature>
+ <feature version="[13,14)">odl-mdsal-dom-api</feature>
<bundle start-level="40">mvn:org.opendaylight.controller/blueprint/${project.version}</bundle>
</feature>
</features>
-->
<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="odl-mdsal-${project.version}">
<feature name="odl-controller-broker-local" version="${project.version}">
- <feature version="[12,13)">odl-mdsal-dom</feature>
- <feature version="[12,13)">odl-mdsal-eos-binding</feature>
- <feature version="[12,13)">odl-mdsal-eos-dom</feature>
- <feature version="[12,13)">odl-mdsal-singleton-dom</feature>
+ <feature version="[13,14)">odl-mdsal-dom</feature>
+ <feature version="[13,14)">odl-mdsal-eos-binding</feature>
+ <feature version="[13,14)">odl-mdsal-eos-dom</feature>
+ <feature version="[13,14)">odl-mdsal-singleton-dom</feature>
</feature>
</features>
-->
<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="odl-controller-mdsal-common-${project.version}">
<feature name="odl-controller-mdsal-common" version="${project.version}">
- <feature version="[12,13)">odl-mdsal-common</feature>
- <feature version="[12,13)">odl-mdsal-binding-runtime</feature>
+ <feature version="[13,14)">odl-mdsal-common</feature>
+ <feature version="[13,14)">odl-mdsal-binding-runtime</feature>
</feature>
</features>
-->
<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="odl-mdsal-${project.version}">
<feature name="odl-mdsal-broker" version="${project.version}">
- <feature version="[12,13)">odl-mdsal-singleton-dom</feature>
- <feature version="[12,13)">odl-mdsal-eos-binding</feature>
+ <feature version="[13,14)">odl-mdsal-singleton-dom</feature>
+ <feature version="[13,14)">odl-mdsal-eos-binding</feature>
</feature>
</features>
<feature version="[13,14)">odl-apache-commons-lang3</feature>
<feature version="[13,14)">odl-dropwizard-metrics</feature>
<feature version="[13,14)">odl-servlet-api</feature>
- <feature version="[11,12)">odl-yangtools-data</feature>
- <feature version="[11,12)">odl-yangtools-codec</feature>
+ <feature version="[13,14)">odl-yangtools-data</feature>
+ <feature version="[13,14)">odl-yangtools-codec</feature>
</feature>
</features>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-controller-${project.version}">
<feature name="odl-mdsal-distributed-datastore" version="${project.version}">
<feature version="[13,14)">odl-apache-commons-text</feature>
- <feature version="[11,12)">odl-yangtools-codec</feature>
- <feature version="[12,13)">odl-mdsal-eos-dom</feature>
- <feature version="[12,13)">odl-mdsal-dom-broker</feature>
- <feature version="[12,13)">odl-mdsal-binding-dom-adapter</feature>
+ <feature version="[13,14)">odl-yangtools-codec</feature>
+ <feature version="[13,14)">odl-mdsal-eos-dom</feature>
+ <feature version="[13,14)">odl-mdsal-dom-broker</feature>
+ <feature version="[13,14)">odl-mdsal-binding-dom-adapter</feature>
<configfile finalname="configuration/initial/akka.conf">
mvn:org.opendaylight.controller/sal-clustering-config/${project.version}/xml/akkaconf
</configfile>
-->
<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="odl-toaster-${project.version}">
<feature name="odl-toaster" version="${project.version}">
- <feature version="[12,13)">odl-mdsal-binding-runtime</feature>
+ <feature version="[13,14)">odl-mdsal-binding-runtime</feature>
</feature>
</features>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-artifacts</artifactId>
- <version>11.0.5</version>
+ <version>13.0.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-artifacts</artifactId>
- <version>12.0.4</version>
+ <version>13.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
import org.opendaylight.yangtools.yang.binding.KeyAware;
import org.opendaylight.yangtools.yang.binding.contract.Naming;
import org.opendaylight.yangtools.yang.common.QName;
+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.MapNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
import org.opendaylight.yangtools.yang.data.codec.xml.XmlParserStream;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter;
import org.opendaylight.yangtools.yang.data.impl.schema.NormalizationResultHolder;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
}
@Override
- public NormalizedNode newDefaultNode(final SchemaTreeInference dataSchema) {
- return ImmutableNodes.containerNode(bindingQName);
+ public ContainerNode newDefaultNode(final SchemaTreeInference dataSchema) {
+ return ImmutableNodes.newContainerBuilder().withNodeIdentifier(new NodeIdentifier(bindingQName)).build();
}
}
checkArgument(keys.size() == 1, "Expected only 1 key for list %s", appConfigBindingClass);
QName listKeyQName = keys.iterator().next();
- return ImmutableNodes.mapEntryBuilder(bindingQName, listKeyQName, appConfigListKeyValue).build();
+ return ImmutableNodes.newMapEntryBuilder()
+ .withNodeIdentifier(NodeIdentifierWithPredicates.of(bindingQName, listKeyQName, appConfigListKeyValue))
+ .withChild(ImmutableNodes.leafNode(listKeyQName, appConfigListKeyValue))
+ .build();
}
}
}
import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.mdsal.dom.api.DOMSchemaService;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.ChildOf;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
private final AtomicBoolean readingInitialAppConfig = new AtomicBoolean(true);
private volatile BindingContext bindingContext;
- private volatile ListenerRegistration<?> appConfigChangeListenerReg;
+ private volatile Registration appConfigChangeListenerReg;
private volatile DataObject currentAppConfig;
// Note: the BindingNormalizedNodeSerializer interface is annotated as deprecated because there's an
// the data isn't present, we won't get an initial DTCN update so the read will indicate the data
// isn't present.
- DataTreeIdentifier<DataObject> dataTreeId = DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION,
+ DataTreeIdentifier<DataObject> dataTreeId = DataTreeIdentifier.of(LogicalDatastoreType.CONFIGURATION,
bindingContext.appConfigPath);
appConfigChangeListenerReg = dataBroker.registerDataTreeChangeListener(dataTreeId,
(ClusteredDataTreeChangeListener<DataObject>) this::onAppConfigChanged);
<packaging>bundle</packaging>
<dependencies>
+ <dependency>
+ <groupId>com.github.spotbugs</groupId>
+ <artifactId>spotbugs-annotations</artifactId>
+ <optional>true</optional>
+ </dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<packaging>bundle</packaging>
<dependencies>
+ <dependency>
+ <groupId>com.github.spotbugs</groupId>
+ <artifactId>spotbugs-annotations</artifactId>
+ <optional>true</optional>
+ </dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-singleton-common-api</artifactId>
+ <artifactId>mdsal-singleton-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-singleton-dom-impl</artifactId>
+ <artifactId>mdsal-singleton-impl</artifactId>
<scope>test</scope>
</dependency>
import org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException;
import org.opendaylight.mdsal.eos.common.api.EntityOwnershipState;
import org.opendaylight.mdsal.eos.dom.api.DOMEntity;
-import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipCandidateRegistration;
import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListener;
-import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListenerRegistration;
import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.GetEntities;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.GetEntitiesInput;
}
@Override
- public DOMEntityOwnershipCandidateRegistration registerCandidate(final DOMEntity entity)
+ public Registration registerCandidate(final DOMEntity entity)
throws CandidateAlreadyRegisteredException {
if (!registeredEntities.add(entity)) {
throw new CandidateAlreadyRegisteredException(entity);
}
@Override
- public DOMEntityOwnershipListenerRegistration registerListener(final String entityType,
- final DOMEntityOwnershipListener listener) {
+ public Registration registerListener(final String entityType, final DOMEntityOwnershipListener listener) {
LOG.debug("Registering listener {} for type {}", listener, entityType);
listenerRegistry.tell(new RegisterListener(entityType, listener));
import static java.util.Objects.requireNonNull;
import org.opendaylight.mdsal.eos.dom.api.DOMEntity;
-import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipCandidateRegistration;
import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
-final class CandidateRegistration extends AbstractObjectRegistration<DOMEntity>
- implements DOMEntityOwnershipCandidateRegistration {
+final class CandidateRegistration extends AbstractObjectRegistration<DOMEntity> {
private final AkkaEntityOwnershipService service;
CandidateRegistration(final DOMEntity instance, final AkkaEntityOwnershipService service) {
import com.google.common.base.MoreObjects;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListener;
-import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListenerRegistration;
import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
-final class ListenerRegistration extends AbstractObjectRegistration<DOMEntityOwnershipListener>
- implements DOMEntityOwnershipListenerRegistration {
+final class ListenerRegistration extends AbstractObjectRegistration<DOMEntityOwnershipListener> {
private final AkkaEntityOwnershipService service;
private final @NonNull String entityType;
this.service = requireNonNull(service);
}
- @Override
- public String getEntityType() {
+ public String entityType() {
return entityType;
}
import org.opendaylight.controller.eos.akka.registry.listener.owner.command.OwnerChanged;
import org.opendaylight.controller.eos.akka.registry.listener.type.command.EntityOwnerChanged;
import org.opendaylight.controller.eos.akka.registry.listener.type.command.TypeListenerCommand;
-import org.opendaylight.mdsal.eos.common.api.EntityOwnershipChangeState;
+import org.opendaylight.mdsal.eos.common.api.EntityOwnershipStateChange;
import org.opendaylight.mdsal.eos.dom.api.DOMEntity;
-import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipChange;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private void triggerNoOwnerNotification() {
LOG.debug("Triggering initial notification without an owner for: {}", entity);
-
- toNotify.tell(new EntityOwnerChanged(new DOMEntityOwnershipChange(
- entity, EntityOwnershipChangeState.REMOTE_OWNERSHIP_LOST_NO_OWNER)));
+ toNotify.tell(new EntityOwnerChanged(entity, EntityOwnershipStateChange.REMOTE_OWNERSHIP_LOST_NO_OWNER, false));
}
private Behavior<ListenerCommand> onOwnerChanged(final OwnerChanged ownerChanged) {
currentOwner = newOwner;
- toNotify.tell(new EntityOwnerChanged(new DOMEntityOwnershipChange(
- entity, EntityOwnershipChangeState.from(wasOwner, isOwner, hasOwner))));
+ toNotify.tell(new EntityOwnerChanged(entity, EntityOwnershipStateChange.from(wasOwner, isOwner, hasOwner),
+ false));
}
private void handleOwnerLost(final Replicator.Deleted<LWWRegister<String>> changed) {
LOG.debug("Owner lost for entity:{}, currentOwner: {}, wasOwner: {}", entity, currentOwner, wasOwner);
currentOwner = "";
- toNotify.tell(new EntityOwnerChanged(new DOMEntityOwnershipChange(
- entity, EntityOwnershipChangeState.from(wasOwner, false, false))));
+ toNotify.tell(new EntityOwnerChanged(entity, EntityOwnershipStateChange.from(wasOwner, false, false), false));
}
}
private Behavior<TypeListenerCommand> onOwnerChanged(final EntityOwnerChanged rsp) {
LOG.debug("{} : Entity-type: {} listener, owner change: {}", localMember, entityType, rsp);
-
- listener.ownershipChanged(rsp.getOwnershipChange());
+ listener.ownershipChanged(rsp.entity(), rsp.change(), false);
return this;
}
import static java.util.Objects.requireNonNull;
import com.google.common.base.MoreObjects;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipChange;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.opendaylight.controller.eos.akka.registry.listener.type.EntityTypeListenerActor;
+import org.opendaylight.mdsal.eos.common.api.EntityOwnershipStateChange;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntity;
/**
- * Notification sent to EntityTypeListenerActor when there is an owner change for an Entity of a given type.
+ * Notification sent to {@link EntityTypeListenerActor} when there is an owner change for an Entity of a given type.
*/
+@NonNullByDefault
public final class EntityOwnerChanged extends TypeListenerCommand {
- private final @NonNull DOMEntityOwnershipChange ownershipChange;
+ private final DOMEntity entity;
+ private final EntityOwnershipStateChange change;
+ private final boolean inJeopardy;
- public EntityOwnerChanged(final DOMEntityOwnershipChange ownershipChange) {
- this.ownershipChange = requireNonNull(ownershipChange);
+ public EntityOwnerChanged(final DOMEntity entity, final EntityOwnershipStateChange change,
+ final boolean inJeopardy) {
+ this.entity = requireNonNull(entity);
+ this.change = requireNonNull(change);
+ this.inJeopardy = requireNonNull(inJeopardy);
}
- public @NonNull DOMEntityOwnershipChange getOwnershipChange() {
- return ownershipChange;
+ public DOMEntity entity() {
+ return entity;
+ }
+
+ public EntityOwnershipStateChange change() {
+ return change;
+ }
+
+ public boolean inJeopardy() {
+ return inJeopardy;
}
@Override
public String toString() {
- return MoreObjects.toStringHelper(this).add("ownershipChange", ownershipChange).toString();
+ return MoreObjects.toStringHelper(this)
+ .add("entity", entity)
+ .add("change", change)
+ .add("inJeopardy", inJeopardy)
+ .toString();
}
}
import org.opendaylight.controller.eos.akka.registry.candidate.command.CandidateRegistryCommand;
import org.opendaylight.controller.eos.akka.registry.candidate.command.RegisterCandidate;
import org.opendaylight.controller.eos.akka.registry.candidate.command.UnregisterCandidate;
+import org.opendaylight.controller.eos.akka.registry.listener.type.command.EntityOwnerChanged;
import org.opendaylight.controller.eos.akka.registry.listener.type.command.RegisterListener;
import org.opendaylight.controller.eos.akka.registry.listener.type.command.TypeListenerRegistryCommand;
import org.opendaylight.mdsal.binding.dom.codec.impl.BindingCodecContext;
import org.opendaylight.mdsal.binding.generator.impl.DefaultBindingRuntimeGenerator;
import org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeGenerator;
import org.opendaylight.mdsal.binding.runtime.spi.BindingRuntimeHelpers;
+import org.opendaylight.mdsal.eos.common.api.EntityOwnershipStateChange;
import org.opendaylight.mdsal.eos.dom.api.DOMEntity;
-import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipChange;
import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
await().until(() -> !listener.getChanges().isEmpty());
await().atMost(Duration.ofSeconds(10)).untilAsserted(() -> {
- final List<DOMEntityOwnershipChange> changes = listener.getChanges();
- final DOMEntityOwnershipChange domEntityOwnershipChange = listener.getChanges().get(changes.size() - 1);
- assertEquals(entity, domEntityOwnershipChange.getEntity());
+ final var changes = listener.getChanges();
+ final var domEntityOwnershipChange = listener.getChanges().get(changes.size() - 1);
+ assertEquals(entity, domEntityOwnershipChange.entity());
- assertEquals(hasOwner, domEntityOwnershipChange.getState().hasOwner());
- assertEquals(isOwner, domEntityOwnershipChange.getState().isOwner());
- assertEquals(wasOwner, domEntityOwnershipChange.getState().wasOwner());
+ assertEquals(hasOwner, domEntityOwnershipChange.change().hasOwner());
+ assertEquals(isOwner, domEntityOwnershipChange.change().isOwner());
+ assertEquals(wasOwner, domEntityOwnershipChange.change().wasOwner());
});
}
}
protected static final class MockEntityOwnershipListener implements DOMEntityOwnershipListener {
-
- private final Logger log;
-
- private final List<DOMEntityOwnershipChange> changes = new ArrayList<>();
+ private final List<EntityOwnerChanged> changes = new ArrayList<>();
private final String member;
+ private final Logger log;
public MockEntityOwnershipListener(final String member) {
log = LoggerFactory.getLogger("EOS-listener-" + member);
}
@Override
- public void ownershipChanged(final DOMEntityOwnershipChange ownershipChange) {
- log.info("{} Received ownershipCHanged: {}", member, ownershipChange);
+ public void ownershipChanged(final DOMEntity entity, final EntityOwnershipStateChange change,
+ final boolean inJeopardy) {
+ final var changed = new EntityOwnerChanged(entity, change, inJeopardy);
+ log.info("{} Received ownershipCHanged: {}", member, changed);
log.info("{} changes: {}", member, changes.size());
- changes.add(ownershipChange);
+ changes.add(changed);
}
- public List<DOMEntityOwnershipChange> getChanges() {
+ public List<EntityOwnerChanged> getChanges() {
return changes;
}
import akka.cluster.ddata.typed.javadsl.Replicator;
import com.typesafe.config.ConfigFactory;
import java.time.Duration;
+import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.CompletionStage;
import org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException;
import org.opendaylight.mdsal.eos.common.api.EntityOwnershipState;
import org.opendaylight.mdsal.eos.dom.api.DOMEntity;
-import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipCandidateRegistration;
-import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListenerRegistration;
import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.EntityName;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.EntityType;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
final YangInstanceIdentifier entityId = YangInstanceIdentifier.of(QNAME);
final DOMEntity entity = new DOMEntity(ENTITY_TYPE, entityId);
- final DOMEntityOwnershipCandidateRegistration reg = service.registerCandidate(entity);
+ final Registration reg = service.registerCandidate(entity);
+ assertNotNull(reg);
- verifyEntityOwnershipCandidateRegistration(entity, reg);
verifyEntityCandidateRegistered(ENTITY_TYPE, entityId, "member-1");
try {
}
final DOMEntity entity2 = new DOMEntity(ENTITY_TYPE2, entityId);
- final DOMEntityOwnershipCandidateRegistration reg2 = service.registerCandidate(entity2);
+ final Registration reg2 = service.registerCandidate(entity2);
- verifyEntityOwnershipCandidateRegistration(entity2, reg2);
+ assertNotNull(reg2);
verifyEntityCandidateRegistered(ENTITY_TYPE2, entityId, "member-1");
}
final YangInstanceIdentifier entityId = YangInstanceIdentifier.of(QNAME);
final DOMEntity entity = new DOMEntity(ENTITY_TYPE, entityId);
- final DOMEntityOwnershipCandidateRegistration reg = service.registerCandidate(entity);
+ final Registration reg = service.registerCandidate(entity);
+ assertNotNull(reg);
- verifyEntityOwnershipCandidateRegistration(entity, reg);
verifyEntityCandidateRegistered(ENTITY_TYPE, entityId, "member-1");
reg.close();
final DOMEntity entity = new DOMEntity(ENTITY_TYPE, entityId);
final MockEntityOwnershipListener listener = new MockEntityOwnershipListener("member-1");
- final DOMEntityOwnershipListenerRegistration reg = service.registerListener(entity.getType(), listener);
+ final Registration reg = service.registerListener(entity.getType(), listener);
assertNotNull("EntityOwnershipListenerRegistration null", reg);
- assertEquals("getEntityType", entity.getType(), reg.getEntityType());
- assertEquals("getInstance", listener, reg.getInstance());
- final DOMEntityOwnershipCandidateRegistration candidate = service.registerCandidate(entity);
+ final Registration candidate = service.registerCandidate(entity);
verifyListenerState(listener, entity, true, true, false);
final int changes = listener.getChanges().size();
public void testGetOwnershipState() throws Exception {
final DOMEntity entity = new DOMEntity(ENTITY_TYPE, "one");
- final DOMEntityOwnershipCandidateRegistration registration = service.registerCandidate(entity);
+ final Registration registration = service.registerCandidate(entity);
verifyGetOwnershipState(service, entity, EntityOwnershipState.IS_OWNER);
final RunningContext runningContext = service.getRunningContext();
final DOMEntity entity = new DOMEntity(ENTITY_TYPE, entityId);
- final DOMEntityOwnershipCandidateRegistration reg = service.registerCandidate(entity);
+ final Registration reg = service.registerCandidate(entity);
- verifyEntityOwnershipCandidateRegistration(entity, reg);
+ assertNotNull(reg);
verifyEntityCandidateRegistered(ENTITY_TYPE, entityId, "member-1");
- var getEntityResult = service.getEntity(new GetEntityInputBuilder()
+ var result = service.getEntity(new GetEntityInputBuilder()
.setName(new EntityName(CODEC_CONTEXT.fromYangInstanceIdentifier(entityId)))
.setType(new EntityType(ENTITY_TYPE))
.build())
- .get();
+ .get()
+ .getResult();
- assertEquals(getEntityResult.getResult().getOwnerNode().getValue(), "member-1");
- assertEquals(getEntityResult.getResult().getCandidateNodes().get(0).getValue(), "member-1");
+ assertEquals(result.getOwnerNode().getValue(), "member-1");
+ assertEquals(result.getCandidateNodes().get(0).getValue(), "member-1");
// we should not be able to retrieve the entity when using string
final String entityPathEncoded =
"/network-topology:network-topology/topology[topology-id='test']/node[node-id='test://test-node']";
- getEntityResult = service.getEntity(new GetEntityInputBuilder()
- .setName(new EntityName(entityPathEncoded))
- .setType(new EntityType(ENTITY_TYPE))
- .build())
- .get();
+ result = service.getEntity(new GetEntityInputBuilder()
+ .setName(new EntityName(entityPathEncoded))
+ .setType(new EntityType(ENTITY_TYPE))
+ .build())
+ .get()
+ .getResult();
- assertNull(getEntityResult.getResult().getOwnerNode());
- assertTrue(getEntityResult.getResult().getCandidateNodes().isEmpty());
+ assertNull(result.getOwnerNode());
+ assertEquals(List.of(), result.getCandidateNodes());
final var getEntitiesResult = service.getEntities(new GetEntitiesInputBuilder().build()).get().getResult();
-
- assertEquals(getEntitiesResult.getEntities().size(), 1);
- assertTrue(getEntitiesResult.getEntities().get(new EntitiesKey(
- new EntityName(CODEC_CONTEXT.fromYangInstanceIdentifier(entityId)), new EntityType(ENTITY_TYPE)))
- .getCandidateNodes().contains(new NodeName("member-1")));
- assertTrue(getEntitiesResult.getEntities().get(new EntitiesKey(
+ final var entities = getEntitiesResult.nonnullEntities();
+ assertEquals(1, entities.size());
+ assertTrue(entities.get(new EntitiesKey(new EntityName(CODEC_CONTEXT.fromYangInstanceIdentifier(entityId)),
+ new EntityType(ENTITY_TYPE))).getCandidateNodes().contains(new NodeName("member-1")));
+ assertTrue(entities.get(new EntitiesKey(
new EntityName(CODEC_CONTEXT.fromYangInstanceIdentifier(entityId)),
new EntityType(ENTITY_TYPE)))
.getOwnerNode().getValue().equals("member-1"));
return success.get(CandidateRegistry.KEY).getEntries();
}
-
- private static void verifyEntityOwnershipCandidateRegistration(final DOMEntity entity,
- final DOMEntityOwnershipCandidateRegistration reg) {
- assertNotNull("EntityOwnershipCandidateRegistration null", reg);
- assertEquals("getInstance", entity, reg.getInstance());
- }
}
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.mdsal.eos.dom.api.DOMEntity;
-import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipCandidateRegistration;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.EntityName;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.EntityType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.GetEntitiesInputBuilder;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
final DOMEntity entity = new DOMEntity(ENTITY_TYPE, entityId);
- final DOMEntityOwnershipCandidateRegistration reg = service1.registerCandidate(entity);
+ final Registration reg = service1.registerCandidate(entity);
await().untilAsserted(() -> {
final var getEntityResult = service1.getEntity(new GetEntityInputBuilder()
// immediately, so that the rpc actor retries with distributed-data asap
await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> {
final var getEntitiesResult = service2.getEntities(new GetEntitiesInputBuilder().build()).get().getResult();
-
- assertEquals(getEntitiesResult.getEntities().size(), 1);
- assertTrue(getEntitiesResult.getEntities().get(new EntitiesKey(
- new EntityName(CODEC_CONTEXT.fromYangInstanceIdentifier(entityId)),
- new EntityType(ENTITY_TYPE)))
- .getCandidateNodes().contains(new NodeName("member-1")));
- assertTrue(getEntitiesResult.getEntities().get(new EntitiesKey(
- new EntityName(CODEC_CONTEXT.fromYangInstanceIdentifier(entityId)),
- new EntityType(ENTITY_TYPE)))
- .getOwnerNode().getValue().equals("member-1"));
+ final var entities = getEntitiesResult.nonnullEntities();
+ assertEquals(1, entities.size());
+ assertTrue(entities.get(new EntitiesKey(
+ new EntityName(CODEC_CONTEXT.fromYangInstanceIdentifier(entityId)),
+ new EntityType(ENTITY_TYPE)))
+ .getCandidateNodes().contains(new NodeName("member-1")));
+ assertTrue(entities.get(new EntitiesKey(
+ new EntityName(CODEC_CONTEXT.fromYangInstanceIdentifier(entityId)),
+ new EntityType(ENTITY_TYPE)))
+ .getOwnerNode().getValue().equals("member-1"));
});
await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> {
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.eos.akka.AbstractNativeEosTest;
-import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipService;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
-import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
-import org.opendaylight.mdsal.singleton.dom.impl.DOMClusterSingletonServiceProviderImpl;
+import org.opendaylight.mdsal.singleton.api.ClusterSingletonService;
+import org.opendaylight.mdsal.singleton.api.ServiceGroupIdentifier;
+import org.opendaylight.mdsal.singleton.impl.EOSClusterSingletonServiceProvider;
+import org.opendaylight.yangtools.concepts.Registration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private MockNativeEntityOwnershipService node2;
private MockNativeEntityOwnershipService node3;
- private MockSingletonService singletonNode1;
- private MockSingletonService singletonNode2;
- private MockSingletonService singletonNode3;
+ private EOSClusterSingletonServiceProvider singletonNode1;
+ private EOSClusterSingletonServiceProvider singletonNode2;
+ private EOSClusterSingletonServiceProvider singletonNode3;
@Before
node2 = startupNativeService(2551, List.of("member-2"), THREE_NODE_SEED_NODES);
node3 = startupNativeService(2552, List.of("member-3"), THREE_NODE_SEED_NODES);
- singletonNode1 = new MockSingletonService(node1);
- singletonNode1.initializeProvider();
-
- singletonNode2 = new MockSingletonService(node2);
- singletonNode2.initializeProvider();
-
- singletonNode3 = new MockSingletonService(node3);
- singletonNode3.initializeProvider();
+ singletonNode1 = new EOSClusterSingletonServiceProvider(node1);
+ singletonNode2 = new EOSClusterSingletonServiceProvider(node2);
+ singletonNode3 = new EOSClusterSingletonServiceProvider(node3);
waitUntillNodeReady(node3);
}
@Test
public void testSingletonOwnershipHandoff() {
final MockClusterSingletonService service = new MockClusterSingletonService("member-1", "service-1");
- final ClusterSingletonServiceRegistration registration =
- singletonNode1.registerClusterSingletonService(service);
+ final Registration registration = singletonNode1.registerClusterSingletonService(service);
verifyServiceActive(service);
@Test
public void testSingletonOwnershipHandoffOnNodeShutdown() throws Exception {
MockClusterSingletonService service2 = new MockClusterSingletonService("member-2", "service-1");
- ClusterSingletonServiceRegistration registration2 =
- singletonNode2.registerClusterSingletonService(service2);
+ Registration registration2 = singletonNode2.registerClusterSingletonService(service2);
verifyServiceActive(service2);
final MockClusterSingletonService service3 = new MockClusterSingletonService("member-3", "service-1");
- final ClusterSingletonServiceRegistration registration3 =
- singletonNode3.registerClusterSingletonService(service3);
+ final Registration registration3 = singletonNode3.registerClusterSingletonService(service3);
verifyServiceInactive(service3, 2);
verifyServiceActive(service3);
node2 = startupNativeService(2551, List.of("member-1"), THREE_NODE_SEED_NODES);
- singletonNode2 = new MockSingletonService(node2);
- singletonNode2.initializeProvider();
+ singletonNode2 = new EOSClusterSingletonServiceProvider(node2);
waitUntillNodeReady(node2);
service2 = new MockClusterSingletonService("member-2", "service-1");
verifyServiceInactive(service2, 5);
}
- private void waitUntillNodeReady(MockNativeEntityOwnershipService node) {
+ private static void waitUntillNodeReady(final MockNativeEntityOwnershipService node) {
// need to wait until all nodes are ready
final Cluster cluster = Cluster.get(Adapter.toTyped(node.getActorSystem()));
Awaitility.await().atMost(Duration.ofSeconds(20)).until(() -> {
});
}
- private static void verifyServiceActive(MockClusterSingletonService service) {
+ private static void verifyServiceActive(final MockClusterSingletonService service) {
await().untilAsserted(() -> assertTrue(service.isActivated()));
}
- private static void verifyServiceActive(MockClusterSingletonService service, long delay) {
+ private static void verifyServiceActive(final MockClusterSingletonService service, final long delay) {
await().pollDelay(delay, TimeUnit.SECONDS).untilAsserted(() -> assertTrue(service.isActivated()));
}
- private static void verifyServiceInactive(MockClusterSingletonService service) {
+ private static void verifyServiceInactive(final MockClusterSingletonService service) {
await().untilAsserted(() -> assertFalse(service.isActivated()));
}
- private static void verifyServiceInactive(MockClusterSingletonService service, long delay) {
+ private static void verifyServiceInactive(final MockClusterSingletonService service, final long delay) {
await().pollDelay(delay, TimeUnit.SECONDS).untilAsserted(() -> assertFalse(service.isActivated()));
}
private final ServiceGroupIdentifier identifier;
private boolean activated = false;
- MockClusterSingletonService(String member, String identifier) {
+ MockClusterSingletonService(final String member, final String identifier) {
this.member = member;
- this.identifier = ServiceGroupIdentifier.create(identifier);
+ this.identifier = new ServiceGroupIdentifier(identifier);
}
@Override
return activated;
}
}
-
- private static class MockSingletonService extends DOMClusterSingletonServiceProviderImpl {
- MockSingletonService(DOMEntityOwnershipService entityOwnershipService) {
- super(entityOwnershipService);
- }
- }
}
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-artifacts</artifactId>
- <version>12.0.4</version>
+ <version>13.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<parent>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>binding-parent</artifactId>
- <version>12.0.4</version>
+ <version>13.0.0</version>
<relativePath/>
</parent>
import javax.inject.Inject;
import org.junit.Before;
import org.junit.Test;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.RoutedSimpleRoute;
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;
@Inject
@Filter(timeout = 120 * 1000)
- RpcConsumerRegistry rpcConsumerRegistry;
+ RpcService rpcService;
/**
* Prepare mocks.
assertNotNull("Registration should not be null", firstReg);
assertNotSame(secondReg, firstReg);
- RoutedSimpleRoute consumerService = rpcConsumerRegistry.getRpc(RoutedSimpleRoute.class);
+ RoutedSimpleRoute consumerService = rpcService.getRpc(RoutedSimpleRoute.class);
assertNotNull("MD-SAL instance of test Service should be returned", consumerService);
assertNotSame("Provider instance and consumer instance should not be same.", routedSimpleRouteRpc1,
consumerService);
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.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.ActivateEosDatacenter;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.ActivateEosDatacenterInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
@Command(scope = "cluster-admin", name = "activate-eos-datacenter", description = "Run an activate-eos-datacenter test")
public class ActivateEosDatacenterCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcConsumerRegistry;
+ private RpcService rpcService;
@Override
protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
- return rpcConsumerRegistry.getRpc(ActivateEosDatacenter.class)
+ return rpcService.getRpc(ActivateEosDatacenter.class)
.invoke(new ActivateEosDatacenterInputBuilder().build());
}
}
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.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.AddReplicasForAllShards;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.AddReplicasForAllShardsInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
description = "Run an add-replicas-for-all-shards test")
public class AddReplicasForAllShardsCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcConsumerRegistry;
+ private RpcService rpcService;
@Override
protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
- return rpcConsumerRegistry.getRpc(AddReplicasForAllShards.class)
+ return rpcService.getRpc(AddReplicasForAllShards.class)
.invoke(new AddReplicasForAllShardsInputBuilder().build());
}
}
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.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.AddShardReplica;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.AddShardReplicaInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.DataStoreType;
@Command(scope = "cluster-admin", name = "add-shard-replica", description = "Run an add-shard-replica test")
public class AddShardReplicaCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcConsumerRegistry;
+ private RpcService rpcService;
@Argument(index = 0, name = "shard-name", required = true)
private String shardName;
@Argument(index = 1, name = "data-store-type", required = true, description = "config / operational")
@Override
protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
- return rpcConsumerRegistry.getRpc(AddShardReplica.class)
+ return rpcService.getRpc(AddShardReplica.class)
.invoke(new AddShardReplicaInputBuilder()
.setShardName(shardName)
.setDataStoreType(DataStoreType.forName(dataStoreType))
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.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.BackupDatastore;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.BackupDatastoreInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
@Command(scope = "cluster-admin", name = "backup-datastore", description = "Run a backup-datastore test")
public class BackupDatastoreCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcConsumerRegistry;
+ private RpcService rpcService;
@Argument(index = 0, name = "file-path", required = true)
private String filePath;
@Argument(index = 1, name = "timeout", required = true)
@Override
protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
- return rpcConsumerRegistry.getRpc(BackupDatastore.class)
+ return rpcService.getRpc(BackupDatastore.class)
.invoke(new BackupDatastoreInputBuilder()
.setFilePath(filePath)
.setTimeout(Uint32.valueOf(timeout))
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.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.ChangeMemberVotingStatesForAllShards;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.ChangeMemberVotingStatesForAllShardsInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.member.voting.states.input.MemberVotingState;
description = "Run a change-member-voting-states-for-all-shards test")
public class ChangeMemberVotingStatesForAllShardsCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcConsumerRegistry;
+ private RpcService rpcService;
@Argument(index = 0, name = "member-name", required = true)
private String memberName;
@Argument(index = 1, name = "voting", required = true)
.setVoting(voting)
.build();
- return rpcConsumerRegistry.getRpc(ChangeMemberVotingStatesForAllShards.class)
+ return rpcService.getRpc(ChangeMemberVotingStatesForAllShards.class)
.invoke(new ChangeMemberVotingStatesForAllShardsInputBuilder()
.setMemberVotingState(List.of(memberVotingState))
.build());
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.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.ChangeMemberVotingStatesForShard;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.ChangeMemberVotingStatesForShardInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.DataStoreType;
description = "Run a change-member-voting-states-for-shard test")
public class ChangeMemberVotingStatesForShardCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcConsumerRegistry;
+ private RpcService rpcService;
@Argument(index = 0, name = "shard-name", required = true)
private String shardName;
@Argument(index = 1, name = "data-store-type", required = true, description = "config / operational")
.setVoting(voting)
.build();
- return rpcConsumerRegistry.getRpc(ChangeMemberVotingStatesForShard.class)
+ return rpcService.getRpc(ChangeMemberVotingStatesForShard.class)
.invoke(new ChangeMemberVotingStatesForShardInputBuilder()
.setShardName(shardName)
.setDataStoreType(DataStoreType.forName(dataStoreType))
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.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.DeactivateEosDatacenter;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.DeactivateEosDatacenterInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
description = "Run a deactivate-eos-datacenter test")
public class DeactivateEosDatacenterCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcConsumerRegistry;
+ private RpcService rpcService;
@Override
protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
- return rpcConsumerRegistry.getRpc(DeactivateEosDatacenter.class)
+ return rpcService.getRpc(DeactivateEosDatacenter.class)
.invoke(new DeactivateEosDatacenterInputBuilder().build());
}
}
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.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.FlipMemberVotingStatesForAllShards;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.FlipMemberVotingStatesForAllShardsInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
description = "Run a flip-member-voting-states-for-all-shards test")
public class FlipMemberVotingStatesForAllShardsCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcConsumerRegistry;
+ private RpcService rpcService;
@Override
protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
- return rpcConsumerRegistry.getRpc(FlipMemberVotingStatesForAllShards.class)
+ return rpcService.getRpc(FlipMemberVotingStatesForAllShards.class)
.invoke(new FlipMemberVotingStatesForAllShardsInputBuilder().build());
}
}
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.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.GetKnownClientsForAllShards;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.GetKnownClientsForAllShardsInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
description = "Run a get-known-clients-for-all-shards test")
public class GetKnownClientsForAllShardsCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcConsumerRegistry;
+ private RpcService rpcService;
@Override
protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
- return rpcConsumerRegistry.getRpc(GetKnownClientsForAllShards.class)
+ return rpcService.getRpc(GetKnownClientsForAllShards.class)
.invoke(new GetKnownClientsForAllShardsInputBuilder().build());
}
}
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.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.DataStoreType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.GetShardRole;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.GetShardRoleInputBuilder;
@Command(scope = "cluster-admin", name = "get-shard-role", description = "Run a get-shard-role test")
public class GetShardRoleCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcConsumerRegistry;
+ private RpcService rpcService;
@Argument(index = 0, name = "shard-name", required = true)
private String shardName;
@Argument(index = 1, name = "data-store-type", required = true, description = "config / operational")
@Override
protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
- return rpcConsumerRegistry.getRpc(GetShardRole.class)
+ return rpcService.getRpc(GetShardRole.class)
.invoke(new GetShardRoleInputBuilder()
.setShardName(shardName)
.setDataStoreType(DataStoreType.forName(dataStoreType))
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.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.DataStoreType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.LocateShard;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.LocateShardInputBuilder;
@Command(scope = "cluster-admin", name = "locate-shard", description = "Run a locate-shard test")
public class LocateShardCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcConsumerRegistry;
+ private RpcService rpcService;
@Argument(index = 0, name = "shard-name", required = true)
private String shardName;
@Argument(index = 1, name = "data-store-type", required = true, description = "config / operational")
@Override
protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
- return rpcConsumerRegistry.getRpc(LocateShard.class)
+ return rpcService.getRpc(LocateShard.class)
.invoke(new LocateShardInputBuilder()
.setShardName(shardName)
.setDataStoreType(DataStoreType.forName(dataStoreType))
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.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.DataStoreType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.MakeLeaderLocal;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.MakeLeaderLocalInputBuilder;
@Command(scope = "cluster-admin", name = "make-leader-local", description = "Run a make-leader-local test")
public class MakeLeaderLocalCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcConsumerRegistry;
+ private RpcService rpcService;
@Argument(index = 0, name = "shard-name", required = true)
private String shardName;
@Argument(index = 1, name = "data-store-type", required = true, description = "config / operational")
@Override
protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
- return rpcConsumerRegistry.getRpc(MakeLeaderLocal.class)
+ return rpcService.getRpc(MakeLeaderLocal.class)
.invoke(new MakeLeaderLocalInputBuilder()
.setShardName(shardName)
.setDataStoreType(DataStoreType.forName(dataStoreType))
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.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.RemoveAllShardReplicas;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.RemoveAllShardReplicasInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
description = "Run a remove-all-shard-replicas test")
public class RemoveAllShardReplicasCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcConsumerRegistry;
+ private RpcService rpcService;
@Argument(index = 0, name = "member-name",required = true)
private String memberName;
@Override
protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
- return rpcConsumerRegistry.getRpc(RemoveAllShardReplicas.class)
+ return rpcService.getRpc(RemoveAllShardReplicas.class)
.invoke(new RemoveAllShardReplicasInputBuilder()
.setMemberName(memberName)
.build());
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.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.DataStoreType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.RemoveShardReplica;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.RemoveShardReplicaInputBuilder;
@Command(scope = "cluster-admin", name = "remove-shard-replica", description = "Run a remove-shard-replica")
public class RemoveShardReplicaCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcConsumerRegistry;
+ private RpcService rpcService;
@Argument(index = 0, name = "shard-name", required = true)
private String shardName;
@Argument(index = 1, name = "data-store-type", required = true, description = "config / operational")
@Override
protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
- return rpcConsumerRegistry.getRpc(RemoveShardReplica.class)
+ return rpcService.getRpc(RemoveShardReplica.class)
.invoke(new RemoveShardReplicaInputBuilder()
.setShardName(shardName)
.setDataStoreType(DataStoreType.forName(dataStoreType))
import java.util.Set;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.controller.cluster.schema.provider.impl.YangTextSchemaSourceSerializationProxy;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
import scala.concurrent.Future;
/**
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
import org.opendaylight.controller.cluster.schema.provider.RemoteYangTextSourceProvider;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.YangTextSource;
import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import scala.concurrent.ExecutionContext;
-import scala.concurrent.Future;
/**
* Provides schema sources from {@link RemoteYangTextSourceProvider}.
*/
@Beta
-public class RemoteSchemaProvider implements SchemaSourceProvider<YangTextSchemaSource> {
+public class RemoteSchemaProvider implements SchemaSourceProvider<YangTextSource> {
private static final Logger LOG = LoggerFactory.getLogger(RemoteSchemaProvider.class);
private final RemoteYangTextSourceProvider remoteRepo;
}
@Override
- public ListenableFuture<YangTextSchemaSource> getSource(final SourceIdentifier sourceIdentifier) {
+ public ListenableFuture<YangTextSource> getSource(final SourceIdentifier sourceIdentifier) {
LOG.trace("Getting yang schema source for {}", sourceIdentifier.name().getLocalName());
- Future<YangTextSchemaSourceSerializationProxy> result = remoteRepo.getYangTextSchemaSource(sourceIdentifier);
-
- final SettableFuture<YangTextSchemaSource> res = SettableFuture.create();
- result.onComplete(new OnComplete<YangTextSchemaSourceSerializationProxy>() {
+ final var res = SettableFuture.<YangTextSource>create();
+ remoteRepo.getYangTextSchemaSource(sourceIdentifier).onComplete(new OnComplete<>() {
@Override
- public void onComplete(final Throwable throwable,
- final YangTextSchemaSourceSerializationProxy yangTextSchemaSourceSerializationProxy) {
- if (yangTextSchemaSourceSerializationProxy != null) {
- res.set(yangTextSchemaSourceSerializationProxy.getRepresentation());
+ public void onComplete(final Throwable failure, final YangTextSchemaSourceSerializationProxy success) {
+ if (success != null) {
+ res.set(success.getRepresentation());
}
- if (throwable != null) {
- res.setException(throwable);
+ if (failure != null) {
+ res.setException(failure);
}
}
}, executionContext);
import java.io.IOException;
import java.util.Set;
import org.opendaylight.controller.cluster.schema.provider.RemoteYangTextSourceProvider;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.YangTextSource;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import scala.concurrent.Future;
LOG.trace("Sending yang schema source for {}", identifier);
final Promise<YangTextSchemaSourceSerializationProxy> promise = akka.dispatch.Futures.promise();
- ListenableFuture<YangTextSchemaSource> future =
- repository.getSchemaSource(identifier, YangTextSchemaSource.class);
+ ListenableFuture<YangTextSource> future =
+ repository.getSchemaSource(identifier, YangTextSource.class);
- Futures.addCallback(future, new FutureCallback<YangTextSchemaSource>() {
+ Futures.addCallback(future, new FutureCallback<YangTextSource>() {
@Override
- public void onSuccess(final YangTextSchemaSource result) {
+ public void onSuccess(final YangTextSource result) {
try {
promise.success(new YangTextSchemaSourceSerializationProxy(result));
} catch (IOException e) {
- LOG.warn("Unable to read schema source for {}", result.getIdentifier(), e);
+ LOG.warn("Unable to read schema source for {}", result.sourceId(), e);
promise.failure(e);
}
}
import java.io.Serializable;
import org.opendaylight.yangtools.yang.common.Revision;
import org.opendaylight.yangtools.yang.common.UnresolvedQName.Unqualified;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.YangTextSource;
+import org.opendaylight.yangtools.yang.model.spi.source.DelegatedYangTextSource;
/**
- * {@link org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource} serialization proxy.
+ * {@link YangTextSource} serialization proxy.
*/
@Beta
public class YangTextSchemaSourceSerializationProxy implements Serializable {
private final Revision revision;
private final String name;
- public YangTextSchemaSourceSerializationProxy(final YangTextSchemaSource source) throws IOException {
- final var id = source.getIdentifier();
- revision = id.revision();
- name = id.name().getLocalName();
+ public YangTextSchemaSourceSerializationProxy(final YangTextSource source) throws IOException {
+ final var sourceId = source.sourceId();
+ revision = sourceId.revision();
+ name = sourceId.name().getLocalName();
schemaSource = source.read();
}
- public YangTextSchemaSource getRepresentation() {
- return YangTextSchemaSource.delegateForCharSource(new SourceIdentifier(Unqualified.of(name), revision),
+ public YangTextSource getRepresentation() {
+ return new DelegatedYangTextSource(new SourceIdentifier(Unqualified.of(name), revision),
CharSource.wrap(schemaSource));
}
}
public void testSerializeDeserializeNodes() throws Exception {
final var normalizedNode = createNormalizedNode();
final var bytes = serialize(normalizedNode);
- assertEquals(10556, bytes.length);
+ assertEquals(10567, bytes.length);
assertEquals(normalizedNode, deserialize(bytes));
}
}
final byte[] bytes = bos.toByteArray();
- assertEquals(10558, bytes.length);
+ assertEquals(10569, bytes.length);
final var applierCalled = new AtomicBoolean(false);
try (var in = new DataInputStream(new ByteArrayInputStream(bytes))) {
.withChild(stringLeaf)
.withChild(createLeaf("longStringLeaf", "0123456789".repeat(1000)))
.withChild(createLeaf("stringLeaf", QName.create("base", "qName")))
- .withChild(createLeaf("stringLeaf", YangInstanceIdentifier.of()))
+ .withChild(createLeaf("stringLeaf", YangInstanceIdentifier.of(QName.create("test", "test"))))
.withChild(Builders.mapBuilder()
.withNodeIdentifier(id("mapNode"))
.withChild(entry1)
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.api.schema.DOMSourceAnyxmlNode;
import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
@Test
public void testAnyXMLNodeNotPrunedWhenHasParent() throws IOException {
- AbstractNormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH);
- DOMSourceAnyxmlNode child = Builders.anyXmlBuilder().withNodeIdentifier(
+ final var pruner = prunerFullSchema(TestModel.TEST_PATH);
+ final var child = Builders.anyXmlBuilder().withNodeIdentifier(
new NodeIdentifier(TestModel.ANY_XML_QNAME)).withValue(mock(DOMSource.class)).build();
- NormalizedNode input = Builders.containerBuilder().withNodeIdentifier(
+ final var input = Builders.containerBuilder().withNodeIdentifier(
new NodeIdentifier(TestModel.TEST_QNAME)).withChild(child).build();
NormalizedNodeWriter.forStreamWriter(pruner).write(input);
- NormalizedNode actual = pruner.getResult().orElseThrow();
- assertEquals("normalizedNode", input, actual);
+ assertEquals("normalizedNode", input, pruner.getResult().orElseThrow());
}
@Test
import akka.dispatch.ExecutionContexts;
import akka.dispatch.Futures;
import com.google.common.io.CharSource;
-import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.cluster.schema.provider.RemoteYangTextSourceProvider;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.DelegatedYangTextSource;
public class RemoteSchemaProviderTest {
private static final SourceIdentifier ID = new SourceIdentifier("Test", "2015-10-30");
@Test
public void getExistingYangTextSchemaSource() throws IOException, InterruptedException, ExecutionException {
- YangTextSchemaSource schemaSource = YangTextSchemaSource.delegateForCharSource(ID, CharSource.wrap("Test"));
+ final var schemaSource = new DelegatedYangTextSource(ID, CharSource.wrap("Test"));
doReturn(Futures.successful(new YangTextSchemaSourceSerializationProxy(schemaSource)))
.when(mockedRemoteSchemaRepository).getYangTextSchemaSource(ID);
- YangTextSchemaSource providedSource = remoteSchemaProvider.getSource(ID).get();
- assertEquals(ID, providedSource.getIdentifier());
+ final var providedSource = remoteSchemaProvider.getSource(ID).get();
+ assertEquals(ID, providedSource.sourceId());
assertEquals(schemaSource.read(), providedSource.read());
}
@Test
public void getNonExistingSchemaSource() throws InterruptedException {
- final var exception = new SchemaSourceException("Source not provided");
+ final var exception = new SchemaSourceException(ID, "Source not provided");
doReturn(Futures.failed(exception)).when(mockedRemoteSchemaRepository).getYangTextSchemaSource(ID);
- ListenableFuture<YangTextSchemaSource> sourceFuture = remoteSchemaProvider.getSource(ID);
+ final var sourceFuture = remoteSchemaProvider.getSource(ID);
assertTrue(sourceFuture.isDone());
final var cause = assertThrows(ExecutionException.class, sourceFuture::get).getCause();
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.YangTextSource;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.DelegatedYangTextSource;
import scala.concurrent.Await;
import scala.concurrent.duration.FiniteDuration;
@Test
public void testGetExistingYangTextSchemaSource() throws Exception {
- var schemaSource = YangTextSchemaSource.delegateForCharSource(ID, CharSource.wrap("Test source."));
+ var schemaSource = new DelegatedYangTextSource(ID, CharSource.wrap("Test source."));
doReturn(Futures.immediateFuture(schemaSource)).when(mockedLocalRepository)
- .getSchemaSource(ID, YangTextSchemaSource.class);
+ .getSchemaSource(ID, YangTextSource.class);
var retrievedSourceFuture = remoteRepository.getYangTextSchemaSource(ID);
assertTrue(retrievedSourceFuture.isCompleted());
var resultSchemaSource = Await.result(retrievedSourceFuture, FiniteDuration.Zero()).getRepresentation();
- assertEquals(resultSchemaSource.getIdentifier(), schemaSource.getIdentifier());
+ assertEquals(resultSchemaSource.sourceId(), schemaSource.sourceId());
assertEquals(resultSchemaSource.read(), schemaSource.read());
}
@Test
public void testGetNonExistentYangTextSchemaSource() throws Exception {
- final var exception = new SchemaSourceException("Source is not provided");
+ final var exception = new SchemaSourceException(ID, "Source is not provided");
doReturn(Futures.immediateFailedFuture(exception)).when(mockedLocalRepository)
- .getSchemaSource(ID, YangTextSchemaSource.class);
+ .getSchemaSource(ID, YangTextSource.class);
var retrievedSourceFuture = remoteRepository.getYangTextSchemaSource(ID);
assertTrue(retrievedSourceFuture.isCompleted());
import java.io.ObjectOutputStream;
import org.junit.Before;
import org.junit.Test;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.YangTextSource;
+import org.opendaylight.yangtools.yang.model.spi.source.DelegatedYangTextSource;
public class YangTextSourceSerializationProxyTest {
- private YangTextSchemaSource schemaSource;
+ private YangTextSource schemaSource;
@Before
public void setUp() {
- schemaSource = YangTextSchemaSource.delegateForCharSource(new SourceIdentifier("test", "2015-10-30"),
+ schemaSource = new DelegatedYangTextSource(new SourceIdentifier("test", "2015-10-30"),
CharSource.wrap("Test source."));
}
@Test
public void serializeAndDeserializeProxy() throws ClassNotFoundException, IOException {
- YangTextSchemaSourceSerializationProxy proxy = new YangTextSchemaSourceSerializationProxy(schemaSource);
+ final var proxy = new YangTextSchemaSourceSerializationProxy(schemaSource);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(proxy);
final byte[] bytes = bos.toByteArray();
- assertEquals(333, bytes.length);
+ assertEquals(323, bytes.length);
ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bytes));
- YangTextSchemaSourceSerializationProxy deserializedProxy =
- (YangTextSchemaSourceSerializationProxy) ois.readObject();
+ final var deserializedProxy = (YangTextSchemaSourceSerializationProxy) ois.readObject();
- assertEquals(deserializedProxy.getRepresentation().getIdentifier(), proxy.getRepresentation().getIdentifier());
+ assertEquals(deserializedProxy.getRepresentation().sourceId(), proxy.getRepresentation().sourceId());
assertEquals(deserializedProxy.getRepresentation().read(), proxy.getRepresentation().read());
}
@Test
public void testProxyEqualsBackingYangTextSource() throws IOException {
- YangTextSchemaSourceSerializationProxy serializationProxy =
- new YangTextSchemaSourceSerializationProxy(schemaSource);
+ final var serializationProxy = new YangTextSchemaSourceSerializationProxy(schemaSource);
- assertEquals(serializationProxy.getRepresentation().getIdentifier(), schemaSource.getIdentifier());
+ assertEquals(serializationProxy.getRepresentation().sourceId(), schemaSource.sourceId());
assertEquals(serializationProxy.getRepresentation().read(), schemaSource.read());
}
}
<packaging>bundle</packaging>
<dependencies>
+ <dependency>
+ <groupId>com.github.spotbugs</groupId>
+ <artifactId>spotbugs-annotations</artifactId>
+ <optional>true</optional>
+ </dependency>
+
<!-- Java -->
<dependency>
<groupId>org.slf4j</groupId>
+++ /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.cluster.databroker;
-
-import static com.google.common.base.Preconditions.checkState;
-
-import com.google.common.collect.ClassToInstanceMap;
-import com.google.common.collect.ImmutableClassToInstanceMap;
-import com.google.common.collect.ImmutableClassToInstanceMap.Builder;
-import java.util.EnumMap;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicLong;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.mdsal.dom.api.DOMDataBrokerExtension;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService;
-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.api.DOMDataTreeIdentifier;
-import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
-import org.opendaylight.mdsal.dom.api.DOMTransactionChainListener;
-import org.opendaylight.mdsal.dom.spi.PingPongMergingDOMDataBroker;
-import org.opendaylight.mdsal.dom.spi.store.DOMStore;
-import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain;
-import org.opendaylight.mdsal.dom.spi.store.DOMStoreTreeChangePublisher;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public abstract class AbstractDOMBroker extends AbstractDOMTransactionFactory<DOMStore>
- implements PingPongMergingDOMDataBroker {
-
- private static final Logger LOG = LoggerFactory.getLogger(AbstractDOMBroker.class);
-
- private final AtomicLong txNum = new AtomicLong();
- private final AtomicLong chainNum = new AtomicLong();
- private final ClassToInstanceMap<DOMDataBrokerExtension> extensions;
-
- private volatile AutoCloseable closeable;
-
- protected AbstractDOMBroker(final Map<LogicalDatastoreType, DOMStore> datastores) {
- super(datastores);
-
- Builder<DOMDataBrokerExtension> extBuilder = ImmutableClassToInstanceMap.builder();
- if (isSupported(datastores, DOMStoreTreeChangePublisher.class)) {
- extBuilder.put(DOMDataTreeChangeService.class, new DOMDataTreeChangeService() {
- @Override
- public <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerDataTreeChangeListener(
- final DOMDataTreeIdentifier treeId, final L listener) {
- DOMStore store = getDOMStore(treeId.getDatastoreType());
- return ((DOMStoreTreeChangePublisher) store).registerTreeChangeListener(
- treeId.getRootIdentifier(), listener);
- }
- });
- }
-
- if (isSupported(datastores, DOMDataTreeCommitCohortRegistry.class)) {
- extBuilder.put(DOMDataTreeCommitCohortRegistry.class, new DOMDataTreeCommitCohortRegistry() {
- @Override
- public <T extends DOMDataTreeCommitCohort> DOMDataTreeCommitCohortRegistration<T> registerCommitCohort(
- final DOMDataTreeIdentifier path, final T cohort) {
- DOMStore store = getDOMStore(path.getDatastoreType());
- return ((DOMDataTreeCommitCohortRegistry) store).registerCommitCohort(path, cohort);
- }
- });
- }
-
- extensions = extBuilder.build();
- }
-
- private static boolean isSupported(final Map<LogicalDatastoreType, DOMStore> datastores,
- final Class<?> expDOMStoreInterface) {
- return datastores.values().stream().allMatch(expDOMStoreInterface::isInstance);
- }
-
- 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 ClassToInstanceMap<DOMDataBrokerExtension> getExtensions() {
- return extensions;
- }
-
- @Override
- public DOMTransactionChain createTransactionChain(final DOMTransactionChainListener listener) {
- checkNotClosed();
-
- final Map<LogicalDatastoreType, DOMStoreTransactionChain> backingChains =
- new EnumMap<>(LogicalDatastoreType.class);
- for (Map.Entry<LogicalDatastoreType, DOMStore> entry : getTxFactories().entrySet()) {
- backingChains.put(entry.getKey(), entry.getValue().createTransactionChain());
- }
-
- final long chainId = chainNum.getAndIncrement();
- LOG.debug("Transaction chain {} created with listener {}, backing store chains {}", chainId, listener,
- backingChains);
- return new DOMBrokerTransactionChain(chainId, backingChains, this, listener);
- }
-
- private DOMStore getDOMStore(final LogicalDatastoreType type) {
- DOMStore store = getTxFactories().get(type);
- checkState(store != null, "Requested logical data store is not available.");
- return 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.cluster.databroker;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.MoreObjects;
-import com.google.common.base.MoreObjects.ToStringHelper;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import java.lang.invoke.MethodHandles;
-import java.lang.invoke.VarHandle;
-import java.util.Map;
-import java.util.Map.Entry;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.mdsal.common.api.TransactionDatastoreMismatchException;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeTransaction;
-import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransaction;
-import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionFactory;
-
-public abstract class AbstractDOMBrokerTransaction<T extends DOMStoreTransaction> implements DOMDataTreeTransaction {
-
- private static final VarHandle BACKING_TX;
-
- static {
- try {
- BACKING_TX = MethodHandles.lookup()
- .findVarHandle(AbstractDOMBrokerTransaction.class, "backingTx", Entry.class);
- } catch (NoSuchFieldException | IllegalAccessException e) {
- throw new ExceptionInInitializerError(e);
- }
- }
-
- private final @NonNull Object identifier;
- private final Map<LogicalDatastoreType, ? extends DOMStoreTransactionFactory> storeTxFactories;
-
- @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD",
- justification = "https://github.com/spotbugs/spotbugs/issues/2749")
- private volatile Entry<LogicalDatastoreType, T> backingTx;
-
- /**
- * Creates new transaction.
- *
- * @param identifier Identifier of transaction.
- */
- protected AbstractDOMBrokerTransaction(final Object identifier,
- final Map<LogicalDatastoreType, ? extends DOMStoreTransactionFactory> storeTxFactories) {
- this.identifier = requireNonNull(identifier, "Identifier should not be null");
- this.storeTxFactories = requireNonNull(storeTxFactories, "Store Transaction Factories should not be null");
- checkArgument(!storeTxFactories.isEmpty(), "Store Transaction Factories should not be empty");
- }
-
- /**
- * Returns sub-transaction associated with supplied key.
- *
- * @param datastoreType the data store type
- * @return the sub-transaction
- * @throws NullPointerException if datastoreType is null
- * @throws IllegalArgumentException if no sub-transaction is associated with datastoreType.
- * @throws TransactionDatastoreMismatchException if datastoreType mismatches the one used at first access
- */
- protected final T getSubtransaction(final LogicalDatastoreType datastoreType) {
- requireNonNull(datastoreType, "datastoreType must not be null.");
-
- var entry = backingTx;
- if (entry == null) {
- if (!storeTxFactories.containsKey(datastoreType)) {
- throw new IllegalArgumentException(datastoreType + " is not supported");
- }
- final var tx = createTransaction(datastoreType);
- final var newEntry = Map.entry(datastoreType, tx);
- final var witness = (Entry<LogicalDatastoreType, T>) BACKING_TX.compareAndExchange(this, null, newEntry);
- if (witness != null) {
- tx.close();
- entry = witness;
- } else {
- entry = newEntry;
- }
- }
-
- final var expected = entry.getKey();
- if (expected != datastoreType) {
- throw new TransactionDatastoreMismatchException(expected, datastoreType);
- }
- return entry.getValue();
- }
-
- /**
- * Returns sub-transaction if initialized.
- */
- @VisibleForTesting
- protected T getSubtransaction() {
- final Entry<LogicalDatastoreType, T> entry;
- return (entry = backingTx) == null ? null : entry.getValue();
- }
-
- protected abstract T createTransaction(LogicalDatastoreType datastoreType);
-
- @Override
- public Object getIdentifier() {
- return identifier;
- }
-
- @SuppressWarnings("checkstyle:IllegalCatch")
- protected void closeSubtransaction() {
- final var local = backingTx;
- if (local != null) {
- try {
- local.getValue().close();
- } catch (Exception e) {
- throw new IllegalStateException("Uncaught exception occurred during closing transaction", e);
- }
- }
- }
-
- protected DOMStoreTransactionFactory getTxFactory(final LogicalDatastoreType type) {
- return storeTxFactories.get(type);
- }
-
- @Override
- public final String toString() {
- return addToStringAttributes(MoreObjects.toStringHelper(this).omitNullValues()).toString();
- }
-
- protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
- return toStringHelper.add("identifier", 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.cluster.databroker;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkState;
-import static java.util.Objects.requireNonNull;
-import static org.opendaylight.yangtools.util.concurrent.FluentFutures.immediateFailedFluentFuture;
-
-import com.google.common.base.MoreObjects.ToStringHelper;
-import com.google.common.util.concurrent.FluentFuture;
-import com.google.common.util.concurrent.Futures;
-import java.util.Map;
-import java.util.concurrent.Future;
-import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
-import org.opendaylight.mdsal.common.api.CommitInfo;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
-import org.opendaylight.mdsal.dom.broker.TransactionCommitFailedExceptionMapper;
-import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionFactory;
-import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
-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.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public abstract class AbstractDOMBrokerWriteTransaction<T extends DOMStoreWriteTransaction>
- extends AbstractDOMBrokerTransaction<T> implements DOMDataTreeWriteTransaction {
-
- @SuppressWarnings("rawtypes")
- private static final AtomicReferenceFieldUpdater<AbstractDOMBrokerWriteTransaction, AbstractDOMTransactionFactory>
- IMPL_UPDATER = AtomicReferenceFieldUpdater.newUpdater(AbstractDOMBrokerWriteTransaction.class,
- AbstractDOMTransactionFactory.class, "commitImpl");
- @SuppressWarnings("rawtypes")
- private static final AtomicReferenceFieldUpdater<AbstractDOMBrokerWriteTransaction, Future> FUTURE_UPDATER =
- AtomicReferenceFieldUpdater.newUpdater(AbstractDOMBrokerWriteTransaction.class, Future.class,
- "commitFuture");
- private static final Logger LOG = LoggerFactory.getLogger(AbstractDOMBrokerWriteTransaction.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 AbstractDOMTransactionFactory<?> commitImpl;
-
- /**
- * Future task of transaction commit. It starts off as null, but is
- * set appropriately on {@link #submit()} 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 AbstractDOMBrokerWriteTransaction(final Object identifier,
- final Map<LogicalDatastoreType, ? extends DOMStoreTransactionFactory> storeTxFactories,
- final AbstractDOMTransactionFactory<?> commitImpl) {
- super(identifier, storeTxFactories);
- this.commitImpl = requireNonNull(commitImpl, "commitImpl must not be null.");
- }
-
- @Override
- public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode data) {
- checkRunning(commitImpl);
- checkInstanceIdentifierReferencesData(path,data);
- getSubtransaction(store).write(path, data);
- }
-
- private static void checkInstanceIdentifierReferencesData(final YangInstanceIdentifier path,
- final NormalizedNode data) {
- checkArgument(data != null, "Attempted to store null data at %s", path);
- final PathArgument lastArg = path.getLastPathArgument();
- if (lastArg != null) {
- checkArgument(lastArg.equals(data.name()),
- "Instance identifier references %s but data identifier is %s", lastArg, 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);
- checkInstanceIdentifierReferencesData(path, data);
- getSubtransaction(store).merge(path, data);
- }
-
- @Override
- public boolean cancel() {
- final AbstractDOMTransactionFactory<?> impl = IMPL_UPDATER.getAndSet(this, null);
- if (impl != null) {
- LOG.trace("Transaction {} cancelled before submit", getIdentifier());
- FUTURE_UPDATER.lazySet(this, CANCELLED_FUTURE);
- closeSubtransaction();
- 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
- @SuppressWarnings("checkstyle:IllegalCatch")
- public FluentFuture<? extends CommitInfo> commit() {
- final AbstractDOMTransactionFactory<?> impl = IMPL_UPDATER.getAndSet(this, null);
- checkRunning(impl);
-
- FluentFuture<? extends CommitInfo> ret;
- final var tx = getSubtransaction();
- if (tx == null) {
- ret = CommitInfo.emptyFluentFuture();
- } else {
- try {
- ret = impl.commit(this, tx.ready());
- } catch (RuntimeException e) {
- ret = immediateFailedFluentFuture(TransactionCommitFailedExceptionMapper.COMMIT_ERROR_MAPPER.apply(e));
- }
- }
-
- FUTURE_UPDATER.lazySet(this, ret);
- return ret;
- }
-
- private void checkRunning(final AbstractDOMTransactionFactory<?> impl) {
- checkState(impl != null, "Transaction %s is no longer running", getIdentifier());
- }
-
- @Override
- protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
- return super.addToStringAttributes(toStringHelper).add("running", commitImpl == 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.cluster.databroker;
-
-import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.FluentFuture;
-import java.lang.invoke.MethodHandles;
-import java.lang.invoke.VarHandle;
-import java.util.EnumMap;
-import java.util.Map;
-import org.opendaylight.mdsal.common.api.CommitInfo;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-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.spi.store.DOMStoreThreePhaseCommitCohort;
-import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public abstract class AbstractDOMTransactionFactory<T extends DOMStoreTransactionFactory> implements AutoCloseable {
- private static final Logger LOG = LoggerFactory.getLogger(AbstractDOMTransactionFactory.class);
- private static final VarHandle CLOSED;
-
- static {
- try {
- CLOSED = MethodHandles.lookup().findVarHandle(AbstractDOMTransactionFactory.class, "closed", boolean.class);
- } catch (NoSuchFieldException | IllegalAccessException e) {
- throw new ExceptionInInitializerError(e);
- }
- }
-
- private final Map<LogicalDatastoreType, T> storeTxFactories;
-
- private volatile boolean closed;
-
- protected AbstractDOMTransactionFactory(final Map<LogicalDatastoreType, 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();
-
- /**
- * Submits a transaction asynchronously for commit.
- *
- * @param transaction the transaction to submit
- * @param cohort the associated cohort
- * @return a resulting Future
- */
- protected abstract FluentFuture<? extends CommitInfo> commit(DOMDataTreeWriteTransaction transaction,
- DOMStoreThreePhaseCommitCohort cohort);
-
- /**
- * Creates a new read-only transaction.
- *
- * @return the transaction instance
- */
- public final DOMDataTreeReadTransaction newReadOnlyTransaction() {
- checkNotClosed();
-
- return new DOMBrokerReadOnlyTransaction(newTransactionIdentifier(), storeTxFactories);
- }
-
-
- /**
- * Creates a new write-only transaction.
- *
- * @return the transaction instance
- */
- public final DOMDataTreeWriteTransaction newWriteOnlyTransaction() {
- checkNotClosed();
-
- return new DOMBrokerWriteOnlyTransaction(newTransactionIdentifier(), storeTxFactories, this);
- }
-
-
- /**
- * Creates a new read-write transaction.
- *
- * @return the transaction instance
- */
- public final DOMDataTreeReadWriteTransaction newReadWriteTransaction() {
- checkNotClosed();
-
- return new DOMBrokerReadWriteTransaction(newTransactionIdentifier(), storeTxFactories, 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.
- */
- public 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, "Transaction factory was closed. No further operations allowed.");
- }
-
- @Override
- public void close() {
- if (!CLOSED.compareAndSet(this, false, true)) {
- LOG.warn("Transaction factory was already closed", new Throwable());
- }
- }
-}
import static com.google.common.base.Preconditions.checkArgument;
import static java.util.Objects.requireNonNull;
-import static org.opendaylight.mdsal.dom.broker.TransactionCommitFailedExceptionMapper.CAN_COMMIT_ERROR_MAPPER;
-import static org.opendaylight.mdsal.dom.broker.TransactionCommitFailedExceptionMapper.COMMIT_ERROR_MAPPER;
-import static org.opendaylight.mdsal.dom.broker.TransactionCommitFailedExceptionMapper.PRE_COMMIT_MAPPER;
+import static org.opendaylight.mdsal.dom.spi.TransactionCommitFailedExceptionMapper.CAN_COMMIT_ERROR_MAPPER;
+import static org.opendaylight.mdsal.dom.spi.TransactionCommitFailedExceptionMapper.COMMIT_ERROR_MAPPER;
+import static org.opendaylight.mdsal.dom.spi.TransactionCommitFailedExceptionMapper.PRE_COMMIT_MAPPER;
import com.google.common.annotations.Beta;
import com.google.common.util.concurrent.AbstractFuture;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
-import org.opendaylight.mdsal.dom.broker.TransactionCommitFailedExceptionMapper;
+import org.opendaylight.mdsal.dom.spi.AbstractDOMDataBroker;
+import org.opendaylight.mdsal.dom.spi.TransactionCommitFailedExceptionMapper;
import org.opendaylight.mdsal.dom.spi.store.DOMStore;
import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
import org.opendaylight.yangtools.util.DurationStatisticsTracker;
* @author Thomas Pantelis
*/
@Beta
-public class ConcurrentDOMDataBroker extends AbstractDOMBroker {
+public class ConcurrentDOMDataBroker extends AbstractDOMDataBroker {
private static final Logger LOG = LoggerFactory.getLogger(ConcurrentDOMDataBroker.class);
private static final String CAN_COMMIT = "CAN_COMMIT";
private static final String PRE_COMMIT = "PRE_COMMIT";
+++ /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.cluster.databroker;
-
-import com.google.common.util.concurrent.FluentFuture;
-import java.util.Map;
-import java.util.Optional;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
-import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction;
-import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionFactory;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-public class DOMBrokerReadOnlyTransaction
- extends AbstractDOMBrokerTransaction<DOMStoreReadTransaction> implements DOMDataTreeReadTransaction {
-
- /**
- * Creates new composite Transactions.
- *
- * @param identifier Identifier of transaction.
- */
- protected DOMBrokerReadOnlyTransaction(final Object identifier,
- final Map<LogicalDatastoreType, ? extends DOMStoreTransactionFactory> storeTxFactories) {
- super(identifier, storeTxFactories);
- }
-
- @Override
- public FluentFuture<Optional<NormalizedNode>> read(final LogicalDatastoreType store,
- final YangInstanceIdentifier path) {
- return getSubtransaction(store).read(path);
- }
-
- @Override
- public FluentFuture<Boolean> exists(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
- return getSubtransaction(store).exists(path);
- }
-
- @Override
- public void close() {
- closeSubtransaction();
- }
-
- @Override
- protected DOMStoreReadTransaction createTransaction(final LogicalDatastoreType key) {
- return getTxFactory(key).newReadOnlyTransaction();
- }
-}
+++ /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.cluster.databroker;
-
-import com.google.common.util.concurrent.FluentFuture;
-import java.util.Map;
-import java.util.Optional;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction;
-import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction;
-import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionFactory;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-
-public class DOMBrokerReadWriteTransaction extends AbstractDOMBrokerWriteTransaction<DOMStoreReadWriteTransaction>
- implements DOMDataTreeReadWriteTransaction {
-
- /**
- * Constructs an instance.
- *
- * @param identifier identifier of transaction.
- * @param storeTxFactories the backing transaction store factories
- */
- protected DOMBrokerReadWriteTransaction(final Object identifier,
- final Map<LogicalDatastoreType, ? extends DOMStoreTransactionFactory> storeTxFactories,
- final AbstractDOMTransactionFactory<?> commitImpl) {
- super(identifier, storeTxFactories, commitImpl);
- }
-
- @Override
- public FluentFuture<Optional<NormalizedNode>> read(final LogicalDatastoreType store,
- final YangInstanceIdentifier path) {
- return getSubtransaction(store).read(path);
- }
-
- @Override
- public FluentFuture<Boolean> exists(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
- return getSubtransaction(store).exists(path);
- }
-
- @Override
- protected DOMStoreReadWriteTransaction createTransaction(final LogicalDatastoreType key) {
- return getTxFactory(key).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.cluster.databroker;
-
-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 java.util.Map;
-import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
-import org.opendaylight.mdsal.common.api.CommitInfo;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-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.store.DOMStoreThreePhaseCommitCohort;
-import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-final class DOMBrokerTransactionChain extends AbstractDOMTransactionFactory<DOMStoreTransactionChain>
- implements DOMTransactionChain {
- private enum State {
- RUNNING,
- CLOSING,
- CLOSED,
- FAILED,
- }
-
- private static final AtomicIntegerFieldUpdater<DOMBrokerTransactionChain> COUNTER_UPDATER =
- AtomicIntegerFieldUpdater.newUpdater(DOMBrokerTransactionChain.class, "counter");
- private static final AtomicReferenceFieldUpdater<DOMBrokerTransactionChain, State> STATE_UPDATER =
- AtomicReferenceFieldUpdater.newUpdater(DOMBrokerTransactionChain.class, State.class, "state");
- private static final Logger LOG = LoggerFactory.getLogger(DOMBrokerTransactionChain.class);
- private final AtomicLong txNum = new AtomicLong();
- private final AbstractDOMBroker broker;
- private final DOMTransactionChainListener listener;
- private final long chainId;
-
- private volatile State state = State.RUNNING;
- private volatile int counter = 0;
-
- /**
- * Constructs an instance.
- *
- * @param chainId
- * ID of transaction chain
- * @param chains
- * Backing {@link DOMStoreTransactionChain}s.
- * @param listener
- * Listener, which listens on transaction chain events.
- * @throws NullPointerException
- * If any of arguments is null.
- */
- DOMBrokerTransactionChain(final long chainId, final Map<LogicalDatastoreType, DOMStoreTransactionChain> chains,
- final AbstractDOMBroker broker, final DOMTransactionChainListener 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 FluentFuture<? extends CommitInfo> commit(
- final DOMDataTreeWriteTransaction transaction, final DOMStoreThreePhaseCommitCohort cohort) {
- checkNotFailed();
- checkNotClosed();
-
- final FluentFuture<? extends CommitInfo> ret = broker.commit(transaction, cohort);
-
- COUNTER_UPDATER.incrementAndGet(this);
- ret.addCallback(new FutureCallback<CommitInfo>() {
- @Override
- public void onSuccess(final CommitInfo result) {
- transactionCompleted();
- }
-
- @Override
- public void onFailure(final Throwable failure) {
- transactionFailed(transaction, failure);
- }
- }, 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);
- }
-
- private void transactionCompleted() {
- if (COUNTER_UPDATER.decrementAndGet(this) == 0 && state == State.CLOSING) {
- finishClose();
- }
- }
-
- private void transactionFailed(final DOMDataTreeWriteTransaction tx, final Throwable cause) {
- state = State.FAILED;
- LOG.debug("Transaction chain {}Â failed.", this, cause);
- listener.onTransactionChainFailed(this, tx, cause);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Huawei Technologies Co. Ltd. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse 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.databroker;
-
-import java.util.Map;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionFactory;
-import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
-
-public class DOMBrokerWriteOnlyTransaction extends AbstractDOMBrokerWriteTransaction<DOMStoreWriteTransaction> {
-
- /**
- * Constructs an instance.
- *
- * @param identifier identifier of transaction.
- * @param storeTxFactories the backing transaction store factories
- */
- public DOMBrokerWriteOnlyTransaction(Object identifier,
- Map<LogicalDatastoreType, ? extends DOMStoreTransactionFactory> storeTxFactories,
- AbstractDOMTransactionFactory<?> commitImpl) {
- super(identifier, storeTxFactories, commitImpl);
- }
-
- @Override
- protected DOMStoreWriteTransaction createTransaction(LogicalDatastoreType key) {
- return getTxFactory(key).newWriteOnlyTransaction();
- }
-
-}
package org.opendaylight.controller.cluster.databroker;
import com.google.common.annotations.Beta;
-import com.google.common.collect.ClassToInstanceMap;
import com.google.common.collect.ImmutableMap;
+import java.util.Collection;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
import org.opendaylight.controller.md.sal.common.util.jmx.ThreadExecutorStatsMXBeanImpl;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.mdsal.dom.api.DOMDataBroker;
-import org.opendaylight.mdsal.dom.api.DOMDataBrokerExtension;
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.store.DOMStore;
import org.opendaylight.yangtools.util.DurationStatisticsTracker;
import org.opendaylight.yangtools.util.concurrent.SpecialExecutors;
}
@Override
- public ClassToInstanceMap<DOMDataBrokerExtension> getExtensions() {
- return delegate.getExtensions();
+ public Collection<Extension> supportedExtensions() {
+ return delegate.supportedExtensions();
}
@Override
- public DOMTransactionChain createTransactionChain(final DOMTransactionChainListener listener) {
- return delegate.createTransactionChain(listener);
+ public DOMTransactionChain createTransactionChain() {
+ return delegate.createTransactionChain();
}
@Override
- public DOMTransactionChain createMergingTransactionChain(final DOMTransactionChainListener listener) {
- return delegate.createMergingTransactionChain(listener);
+ public DOMTransactionChain createMergingTransactionChain() {
+ return delegate.createMergingTransactionChain();
}
@Activate
import org.opendaylight.yangtools.yang.data.tree.api.DataTreeModificationCursor;
import org.opendaylight.yangtools.yang.data.tree.api.DataTreeSnapshot;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-import org.opendaylight.yangtools.yang.model.spi.AbstractEffectiveModelContextProvider;
/**
* A {@link CursorAwareDataTreeModification} which does not really do anything and throws an
* {@link DataTreeSnapshot#newModification()} fails, see {@link LocalReadWriteProxyTransaction} for details. Surrounding
* code should guard against invocation of most of these methods.
*/
-final class FailedDataTreeModification extends AbstractEffectiveModelContextProvider
- implements CursorAwareDataTreeModification {
- private final @NonNull Exception cause;
+record FailedDataTreeModification(
+ @NonNull EffectiveModelContext modelContext,
+ @NonNull Exception cause) implements CursorAwareDataTreeModification {
- FailedDataTreeModification(final EffectiveModelContext context, final Exception cause) {
- super(context);
- this.cause = requireNonNull(cause);
- }
-
- @NonNull Exception cause() {
- return cause;
+ FailedDataTreeModification {
+ requireNonNull(modelContext);
+ requireNonNull(cause);
}
@Override
} catch (Exception e) {
LOG.debug("Failed to instantiate modification for {}", identifier, e);
recordedFailure = e;
- mod = new FailedDataTreeModification(snapshot.getEffectiveModelContext(), e);
+ mod = new FailedDataTreeModification(snapshot.modelContext(), e);
}
modification = mod;
}
*/
package org.opendaylight.controller.cluster.datastore;
-import static com.google.common.base.Preconditions.checkArgument;
import static java.util.Objects.requireNonNull;
import akka.actor.ActorRef;
import com.google.common.util.concurrent.Uninterruptibles;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.List;
-import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
import org.opendaylight.controller.cluster.common.actor.Dispatchers;
import org.opendaylight.controller.cluster.databroker.actors.dds.DataStoreClient;
import org.opendaylight.controller.cluster.datastore.shardmanager.ShardManagerCreator;
import org.opendaylight.controller.cluster.datastore.utils.ActorUtils;
import org.opendaylight.controller.cluster.datastore.utils.PrimaryShardInfoFutureCache;
-import org.opendaylight.mdsal.dom.api.ClusteredDOMDataTreeChangeListener;
+import org.opendaylight.mdsal.dom.api.DOMDataBroker.CommitCohortExtension;
import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
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.api.DOMDataTreeIdentifier;
import org.opendaylight.mdsal.dom.spi.store.DOMStoreTreeChangePublisher;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.common.Empty;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import scala.concurrent.duration.Duration;
/**
* Base implementation of a distributed DOMStore.
*/
-public abstract class AbstractDataStore implements DistributedDataStoreInterface, EffectiveModelContextListener,
- DatastoreContextPropertiesUpdater.Listener, DOMStoreTreeChangePublisher,
- DOMDataTreeCommitCohortRegistry, AutoCloseable {
-
+public abstract class AbstractDataStore implements DistributedDataStoreInterface,
+ DatastoreContextPropertiesUpdater.Listener, DOMStoreTreeChangePublisher, CommitCohortExtension,
+ AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(AbstractDataStore.class);
private final SettableFuture<Empty> readinessFuture = SettableFuture.create();
}
@Override
- public <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerTreeChangeListener(
- final YangInstanceIdentifier treeId, final L listener) {
+ public Registration registerTreeChangeListener(final YangInstanceIdentifier treeId,
+ final DOMDataTreeChangeListener listener) {
+ return registerTreeChangeListener(treeId, listener, true);
+ }
+
+ private @NonNull Registration registerTreeChangeListener(final YangInstanceIdentifier treeId,
+ final DOMDataTreeChangeListener listener, final boolean clustered) {
requireNonNull(treeId, "treeId should not be null");
requireNonNull(listener, "listener should not be null");
if (treeId.isEmpty()) {
// User is targeting root of the datastore. If there is more than one shard, we have to register with them
// all and perform data composition.
- final Set<String> shardNames = actorUtils.getConfiguration().getAllShardNames();
+ final var shardNames = actorUtils.getConfiguration().getAllShardNames();
if (shardNames.size() > 1) {
- checkArgument(listener instanceof ClusteredDOMDataTreeChangeListener,
- "Cannot listen on root without non-clustered listener %s", listener);
+ if (!clustered) {
+ throw new IllegalArgumentException(
+ "Cannot listen on root without non-clustered listener " + listener);
+ }
return new RootDataTreeChangeListenerProxy<>(actorUtils, listener, shardNames);
}
}
- final String shardName = actorUtils.getShardStrategyFactory().getStrategy(treeId).findShard(treeId);
+ final var shardName = actorUtils.getShardStrategyFactory().getStrategy(treeId).findShard(treeId);
LOG.debug("Registering tree listener: {} for tree: {} shard: {}", listener, treeId, shardName);
- final DataTreeChangeListenerProxy<L> listenerRegistrationProxy =
- new DataTreeChangeListenerProxy<>(actorUtils, listener, treeId);
- listenerRegistrationProxy.init(shardName);
+ return DataTreeChangeListenerProxy.of(actorUtils, listener, treeId, clustered, shardName);
+ }
- return listenerRegistrationProxy;
+ @Override
+ @Deprecated(since = "9.0.0", forRemoval = true)
+ public Registration registerLegacyTreeChangeListener(final YangInstanceIdentifier treeId,
+ final DOMDataTreeChangeListener listener) {
+ return registerTreeChangeListener(treeId, listener, false);
}
@Override
- public <C extends DOMDataTreeCommitCohort> DOMDataTreeCommitCohortRegistration<C> registerCommitCohort(
- final DOMDataTreeIdentifier subtree, final C cohort) {
- YangInstanceIdentifier treeId = requireNonNull(subtree, "subtree should not be null").getRootIdentifier();
+ public Registration registerCommitCohort(final DOMDataTreeIdentifier subtree,
+ final DOMDataTreeCommitCohort cohort) {
+ YangInstanceIdentifier treeId = requireNonNull(subtree, "subtree should not be null").path();
requireNonNull(cohort, "listener should not be null");
final String shardName = actorUtils.getShardStrategyFactory().getStrategy(treeId).findShard(treeId);
LOG.debug("Registering cohort: {} for tree: {} shard: {}", cohort, treeId, shardName);
- DataTreeCohortRegistrationProxy<C> cohortProxy =
- new DataTreeCohortRegistrationProxy<>(actorUtils, subtree, cohort);
+ final var cohortProxy = new DataTreeCohortRegistrationProxy<>(actorUtils, subtree, cohort);
cohortProxy.init(shardName);
return cohortProxy;
}
- @Override
public void onModelContextUpdated(final EffectiveModelContext newModelContext) {
actorUtils.setSchemaContext(newModelContext);
}
}
@Override
- @SuppressWarnings("unchecked")
- public <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerProxyListener(
- final YangInstanceIdentifier shardLookup, final YangInstanceIdentifier insideShard,
- final DOMDataTreeChangeListener delegate) {
-
+ public Registration registerProxyListener(final YangInstanceIdentifier shardLookup,
+ final YangInstanceIdentifier insideShard, final DOMDataTreeChangeListener delegate) {
requireNonNull(shardLookup, "shardLookup should not be null");
requireNonNull(insideShard, "insideShard should not be null");
requireNonNull(delegate, "delegate should not be null");
- final String shardName = actorUtils.getShardStrategyFactory().getStrategy(shardLookup).findShard(shardLookup);
- LOG.debug("Registering tree listener: {} for tree: {} shard: {}, path inside shard: {}",
- delegate,shardLookup, shardName, insideShard);
-
- // wrap this in the ClusteredDOMDataTreeChangeLister interface
- // since we always want clustered registration
- final DataTreeChangeListenerProxy<DOMDataTreeChangeListener> listenerRegistrationProxy =
- new DataTreeChangeListenerProxy<>(actorUtils, new ClusteredDOMDataTreeChangeListener() {
- @Override
- public void onDataTreeChanged(final List<DataTreeCandidate> changes) {
- delegate.onDataTreeChanged(changes);
- }
-
- @Override
- public void onInitialData() {
- delegate.onInitialData();
- }
- }, insideShard);
- listenerRegistrationProxy.init(shardName);
-
- return (ListenerRegistration<L>) listenerRegistrationProxy;
+ final var shardName = actorUtils.getShardStrategyFactory().getStrategy(shardLookup).findShard(shardLookup);
+ LOG.debug("Registering tree listener: {} for tree: {} shard: {}, path inside shard: {}", delegate, shardLookup,
+ shardName, insideShard);
+
+ return DataTreeChangeListenerProxy.of(actorUtils, new DOMDataTreeChangeListener() {
+ @Override
+ public void onDataTreeChanged(final List<DataTreeCandidate> changes) {
+ delegate.onDataTreeChanged(changes);
+ }
+
+ @Override
+ public void onInitialData() {
+ delegate.onInitialData();
+ }
+ }, insideShard, true, shardName);
}
private Duration initialSettleTime() {
import akka.actor.PoisonPill;
import akka.dispatch.OnComplete;
import com.google.common.annotations.VisibleForTesting;
+import com.google.common.util.concurrent.MoreExecutors;
+import java.util.concurrent.Executor;
import org.checkerframework.checker.lock.qual.GuardedBy;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.controller.cluster.datastore.exceptions.LocalShardNotFoundException;
import org.opendaylight.controller.cluster.datastore.messages.CloseDataTreeNotificationListenerRegistration;
import org.opendaylight.controller.cluster.datastore.messages.RegisterDataTreeChangeListener;
import org.opendaylight.controller.cluster.datastore.messages.RegisterDataTreeNotificationListenerReply;
import org.opendaylight.controller.cluster.datastore.utils.ActorUtils;
-import org.opendaylight.mdsal.dom.api.ClusteredDOMDataTreeChangeListener;
import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
-import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
+import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import scala.concurrent.Future;
/**
* Proxy class for holding required state to lazily instantiate a listener registration with an
*
* @param <T> listener type
*/
-final class DataTreeChangeListenerProxy<T extends DOMDataTreeChangeListener> extends AbstractListenerRegistration<T> {
+final class DataTreeChangeListenerProxy extends AbstractObjectRegistration<DOMDataTreeChangeListener> {
private static final Logger LOG = LoggerFactory.getLogger(DataTreeChangeListenerProxy.class);
private final ActorRef dataChangeListenerActor;
private final ActorUtils actorUtils;
private final YangInstanceIdentifier registeredPath;
+ private final boolean clustered;
@GuardedBy("this")
private ActorSelection listenerRegistrationActor;
- DataTreeChangeListenerProxy(final ActorUtils actorUtils, final T listener,
- final YangInstanceIdentifier registeredPath) {
+ @VisibleForTesting
+ private DataTreeChangeListenerProxy(final ActorUtils actorUtils, final DOMDataTreeChangeListener listener,
+ final YangInstanceIdentifier registeredPath, final boolean clustered, final String shardName) {
super(listener);
this.actorUtils = requireNonNull(actorUtils);
this.registeredPath = requireNonNull(registeredPath);
- this.dataChangeListenerActor = actorUtils.getActorSystem().actorOf(
+ this.clustered = clustered;
+ dataChangeListenerActor = actorUtils.getActorSystem().actorOf(
DataTreeChangeListenerActor.props(getInstance(), registeredPath)
.withDispatcher(actorUtils.getNotificationDispatcherPath()));
-
LOG.debug("{}: Created actor {} for DTCL {}", actorUtils.getDatastoreContext().getLogicalStoreType(),
dataChangeListenerActor, listener);
}
+ static @NonNull DataTreeChangeListenerProxy of(final ActorUtils actorUtils,
+ final DOMDataTreeChangeListener listener, final YangInstanceIdentifier registeredPath,
+ final boolean clustered, final String shardName) {
+ return ofTesting(actorUtils, listener, registeredPath, clustered, shardName, MoreExecutors.directExecutor());
+ }
+
+ @VisibleForTesting
+ static @NonNull DataTreeChangeListenerProxy ofTesting(final ActorUtils actorUtils,
+ final DOMDataTreeChangeListener listener, final YangInstanceIdentifier registeredPath,
+ final boolean clustered, final String shardName, final Executor executor) {
+ final var ret = new DataTreeChangeListenerProxy(actorUtils, listener, registeredPath, clustered, shardName);
+ executor.execute(() -> {
+ LOG.debug("{}: Starting discovery of shard {}", ret.logContext(), shardName);
+ actorUtils.findLocalShardAsync(shardName).onComplete(new OnComplete<>() {
+ @Override
+ public void onComplete(final Throwable failure, final ActorRef shard) {
+ if (failure instanceof LocalShardNotFoundException) {
+ LOG.debug("{}: No local shard found for {} - DataTreeChangeListener {} at path {} cannot be "
+ + "registered", ret.logContext(), shardName, listener, registeredPath);
+ } else if (failure != null) {
+ LOG.error("{}: Failed to find local shard {} - DataTreeChangeListener {} at path {} cannot be "
+ + "registered", ret.logContext(), shardName, listener, registeredPath, failure);
+ } else {
+ ret.doRegistration(shard);
+ }
+ }
+ }, actorUtils.getClientDispatcher());
+ });
+ return ret;
+ }
+
@Override
protected synchronized void removeRegistration() {
if (listenerRegistrationActor != null) {
dataChangeListenerActor.tell(PoisonPill.getInstance(), ActorRef.noSender());
}
- void init(final String shardName) {
- Future<ActorRef> findFuture = actorUtils.findLocalShardAsync(shardName);
- findFuture.onComplete(new OnComplete<ActorRef>() {
- @Override
- public void onComplete(final Throwable failure, final ActorRef shard) {
- if (failure instanceof LocalShardNotFoundException) {
- LOG.debug("{}: No local shard found for {} - DataTreeChangeListener {} at path {} "
- + "cannot be registered", logContext(), shardName, getInstance(), registeredPath);
- } else if (failure != null) {
- LOG.error("{}: Failed to find local shard {} - DataTreeChangeListener {} at path {} "
- + "cannot be registered", logContext(), shardName, getInstance(), registeredPath,
- failure);
- } else {
- doRegistration(shard);
- }
- }
- }, actorUtils.getClientDispatcher());
- }
-
private void setListenerRegistrationActor(final ActorSelection actor) {
if (actor == null) {
LOG.debug("{}: Ignoring null actor on {}", logContext(), this);
synchronized (this) {
if (!isClosed()) {
- this.listenerRegistrationActor = actor;
+ listenerRegistrationActor = actor;
return;
}
}
}
private void doRegistration(final ActorRef shard) {
-
- Future<Object> future = actorUtils.executeOperationAsync(shard,
- new RegisterDataTreeChangeListener(registeredPath, dataChangeListenerActor,
- getInstance() instanceof ClusteredDOMDataTreeChangeListener),
- actorUtils.getDatastoreContext().getShardInitializationTimeout());
-
- future.onComplete(new OnComplete<>() {
- @Override
- public void onComplete(final Throwable failure, final Object result) {
- if (failure != null) {
- LOG.error("{}: Failed to register DataTreeChangeListener {} at path {}", logContext(),
+ actorUtils.executeOperationAsync(shard,
+ new RegisterDataTreeChangeListener(registeredPath, dataChangeListenerActor, clustered),
+ actorUtils.getDatastoreContext().getShardInitializationTimeout()).onComplete(new OnComplete<>() {
+ @Override
+ public void onComplete(final Throwable failure, final Object result) {
+ if (failure != null) {
+ LOG.error("{}: Failed to register DataTreeChangeListener {} at path {}", logContext(),
getInstance(), registeredPath, failure);
- } else {
- RegisterDataTreeNotificationListenerReply reply = (RegisterDataTreeNotificationListenerReply)result;
- setListenerRegistrationActor(actorUtils.actorSelection(
- reply.getListenerRegistrationPath()));
+ } else {
+ setListenerRegistrationActor(actorUtils.actorSelection(
+ ((RegisterDataTreeNotificationListenerReply) result).getListenerRegistrationPath()));
+ }
}
- }
- }, actorUtils.getClientDispatcher());
+ }, actorUtils.getClientDispatcher());
}
@VisibleForTesting
final class DataTreeChangeListenerSupport extends LeaderLocalDelegateFactory<RegisterDataTreeChangeListener> {
private static final Logger LOG = LoggerFactory.getLogger(DataTreeChangeListenerSupport.class);
- private final Collection<DelayedDataTreeChangeListenerRegistration<DOMDataTreeChangeListener>>
+ private final Collection<DelayedDataTreeChangeListenerRegistration>
delayedDataTreeChangeListenerRegistrations = ConcurrentHashMap.newKeySet();
- private final Collection<DelayedDataTreeChangeListenerRegistration<DOMDataTreeChangeListener>>
+ private final Collection<DelayedDataTreeChangeListenerRegistration>
delayedListenerOnAllRegistrations = ConcurrentHashMap.newKeySet();
private final Collection<ActorSelection> leaderOnlyListenerActors = ConcurrentHashMap.newKeySet();
private final Collection<ActorSelection> allListenerActors = ConcurrentHashMap.newKeySet();
}
if (hasLeader) {
- for (DelayedDataTreeChangeListenerRegistration<DOMDataTreeChangeListener> reg :
- delayedListenerOnAllRegistrations) {
+ for (var reg : delayedListenerOnAllRegistrations) {
reg.doRegistration(this);
}
}
if (isLeader) {
- for (DelayedDataTreeChangeListenerRegistration<DOMDataTreeChangeListener> reg :
- delayedDataTreeChangeListenerRegistrations) {
+ for (var reg : delayedDataTreeChangeListenerRegistrations) {
reg.doRegistration(this);
}
} else {
LOG.debug("{}: Shard does not have a leader - delaying registration", persistenceId());
- final DelayedDataTreeChangeListenerRegistration<DOMDataTreeChangeListener> delayedReg =
- new DelayedDataTreeChangeListenerRegistration<>(message, registrationActor);
- final Collection<DelayedDataTreeChangeListenerRegistration<DOMDataTreeChangeListener>> delayedRegList;
+ final var delayedReg = new DelayedDataTreeChangeListenerRegistration(message, registrationActor);
+ final Collection<DelayedDataTreeChangeListenerRegistration> delayedRegList;
if (message.isRegisterOnAllInstances()) {
delayedRegList = delayedListenerOnAllRegistrations;
} else {
import org.opendaylight.mdsal.dom.api.DOMDataTreeCandidate;
import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
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.tree.api.DataTreeCandidate;
/**
* Registry of user commit cohorts, which is responsible for handling registration and calculation
* of affected cohorts based on {@link DataTreeCandidate}. This class is NOT thread-safe.
- *
*/
class DataTreeCohortActorRegistry extends AbstractRegistrationTree<ActorRef> {
private static final Logger LOG = LoggerFactory.getLogger(DataTreeCohortActorRegistry.class);
- private final Map<ActorRef, RegistrationTreeNode<ActorRef>> cohortToNode = new HashMap<>();
+ private final Map<ActorRef, Node<ActorRef>> cohortToNode = new HashMap<>();
Collection<ActorRef> getCohortActors() {
return new ArrayList<>(cohortToNode.keySet());
takeLock();
try {
final ActorRef cohortRef = cohort.getCohort();
- final RegistrationTreeNode<ActorRef> node =
- findNodeFor(cohort.getPath().getRootIdentifier().getPathArguments());
+ final Node<ActorRef> node = findNodeFor(cohort.getPath().path().getPathArguments());
addRegistration(node, cohort.getCohort());
cohortToNode.put(cohortRef, node);
} catch (final Exception e) {
void removeCommitCohort(final ActorRef sender, final RemoveCohort message) {
final ActorRef cohort = message.getCohort();
- final RegistrationTreeNode<ActorRef> node = cohortToNode.get(cohort);
+ final Node<ActorRef> node = cohortToNode.get(cohort);
if (node != null) {
removeRegistration(node, cohort);
cohortToNode.remove(cohort);
List<DataTreeCohortActor.CanCommit> createCanCommitMessages(final TransactionIdentifier txId,
final DataTreeCandidate candidate, final EffectiveModelContext schema) {
- try (RegistrationTreeSnapshot<ActorRef> cohorts = takeSnapshot()) {
+ try (var cohorts = takeSnapshot()) {
return new CanCommitMessageBuilder(txId, candidate, schema).perform(cohorts.getRootNode());
}
}
}
private void lookupAndCreateCanCommits(final List<PathArgument> args, final int offset,
- final RegistrationTreeNode<ActorRef> node) {
+ final Node<ActorRef> node) {
if (args.size() != offset) {
final PathArgument arg = args.get(offset);
- final RegistrationTreeNode<ActorRef> exactChild = node.getExactChild(arg);
+ final var exactChild = node.getExactChild(arg);
if (exactChild != null) {
lookupAndCreateCanCommits(args, offset + 1, exactChild);
}
- for (final RegistrationTreeNode<ActorRef> c : node.getInexactChildren(arg)) {
- lookupAndCreateCanCommits(args, offset + 1, c);
+ for (var inexact : node.getInexactChildren(arg)) {
+ lookupAndCreateCanCommits(args, offset + 1, inexact);
}
} else {
lookupAndCreateCanCommits(candidate.getRootPath(), node, candidate.getRootNode());
}
}
- private void lookupAndCreateCanCommits(final YangInstanceIdentifier path,
- final RegistrationTreeNode<ActorRef> regNode, final DataTreeCandidateNode candNode) {
+ private void lookupAndCreateCanCommits(final YangInstanceIdentifier path, final Node<ActorRef> regNode,
+ final DataTreeCandidateNode candNode) {
if (candNode.modificationType() == ModificationType.UNMODIFIED) {
LOG.debug("Skipping unmodified candidate {}", path);
return;
for (var candChild : candNode.childNodes()) {
if (candChild.modificationType() != ModificationType.UNMODIFIED) {
- final RegistrationTreeNode<ActorRef> regChild = regNode.getExactChild(candChild.name());
+ final var regChild = regNode.getExactChild(candChild.name());
if (regChild != null) {
lookupAndCreateCanCommits(path.node(candChild.name()), regChild, candChild);
}
}
private static DOMDataTreeIdentifier treeIdentifier(final YangInstanceIdentifier path) {
- return new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, path);
+ return DOMDataTreeIdentifier.of(LogicalDatastoreType.CONFIGURATION, path);
}
- List<DataTreeCohortActor.CanCommit> perform(final RegistrationTreeNode<ActorRef> rootNode) {
- final List<PathArgument> toLookup = candidate.getRootPath().getPathArguments();
+ List<DataTreeCohortActor.CanCommit> perform(final Node<ActorRef> rootNode) {
+ final var toLookup = candidate.getRootPath().getPathArguments();
lookupAndCreateCanCommits(toLookup, 0, rootNode);
final Map<ActorRef, Collection<DOMDataTreeCandidate>> mapView = actorToCandidates.asMap();
import org.opendaylight.controller.cluster.datastore.exceptions.LocalShardNotFoundException;
import org.opendaylight.controller.cluster.datastore.utils.ActorUtils;
import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohort;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistration;
import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
import org.slf4j.Logger;
import scala.concurrent.Future;
import scala.concurrent.duration.FiniteDuration;
-public class DataTreeCohortRegistrationProxy<C extends DOMDataTreeCommitCohort> extends AbstractObjectRegistration<C>
- implements DOMDataTreeCommitCohortRegistration<C> {
-
+public class DataTreeCohortRegistrationProxy<C extends DOMDataTreeCommitCohort> extends AbstractObjectRegistration<C> {
private static final Logger LOG = LoggerFactory.getLogger(DataTreeCohortRegistrationProxy.class);
private static final Timeout TIMEOUT = new Timeout(new FiniteDuration(5, TimeUnit.SECONDS));
+
private final DOMDataTreeIdentifier subtree;
private final ActorRef actor;
private final ActorUtils actorUtils;
super(cohort);
this.subtree = requireNonNull(subtree);
this.actorUtils = requireNonNull(actorUtils);
- this.actor = actorUtils.getActorSystem().actorOf(DataTreeCohortActor.props(getInstance(),
- subtree.getRootIdentifier()).withDispatcher(actorUtils.getNotificationDispatcherPath()));
+ actor = actorUtils.getActorSystem().actorOf(DataTreeCohortActor.props(getInstance(),
+ subtree.path()).withDispatcher(actorUtils.getNotificationDispatcherPath()));
}
public void init(final String shardName) {
import java.util.Optional;
import java.util.function.Consumer;
import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
-import org.opendaylight.mdsal.dom.spi.AbstractDOMDataTreeChangeListenerRegistration;
import org.opendaylight.mdsal.dom.spi.store.AbstractDOMStoreTreeChangePublisher;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate;
import org.slf4j.Logger;
}
@Override
- protected void notifyListener(final AbstractDOMDataTreeChangeListenerRegistration<?> registration,
- final List<DataTreeCandidate> changes) {
- LOG.debug("{}: notifyListener: listener: {}", logContext, registration.getInstance());
- registration.getInstance().onDataTreeChanged(changes);
+ protected void notifyListener(final Reg registration, final List<DataTreeCandidate> changes) {
+ final var listener = registration.listener();
+ LOG.debug("{}: notifyListener: listener: {}", logContext, listener);
+ listener.onDataTreeChanged(changes);
}
@Override
- protected void registrationRemoved(final AbstractDOMDataTreeChangeListenerRegistration<?> registration) {
+ protected void registrationRemoved(final Reg registration) {
LOG.debug("Registration {} removed", registration);
}
@Override
public void registerTreeChangeListener(final YangInstanceIdentifier treeId,
final DOMDataTreeChangeListener listener, final Optional<DataTreeCandidate> initialState,
- final Consumer<ListenerRegistration<DOMDataTreeChangeListener>> onRegistration) {
+ final Consumer<Registration> onRegistration) {
registerTreeChangeListener(treeId, listener, onRegistration);
if (initialState.isPresent()) {
}
void registerTreeChangeListener(final YangInstanceIdentifier treeId, final DOMDataTreeChangeListener listener,
- final Consumer<ListenerRegistration<DOMDataTreeChangeListener>> onRegistration) {
+ final Consumer<Registration> onRegistration) {
LOG.debug("{}: registerTreeChangeListener: path: {}, listener: {}", logContext, treeId, listener);
-
- AbstractDOMDataTreeChangeListenerRegistration<DOMDataTreeChangeListener> registration =
- super.registerTreeChangeListener(treeId, listener);
-
- onRegistration.accept(registration);
+ onRegistration.accept(super.registerTreeChangeListener(treeId, listener));
}
static void notifySingleListener(final YangInstanceIdentifier treeId, final DOMDataTreeChangeListener listener,
package org.opendaylight.controller.cluster.datastore;
import akka.actor.ActorRef;
-import java.util.EventListener;
import org.checkerframework.checker.lock.qual.GuardedBy;
import org.opendaylight.controller.cluster.datastore.messages.RegisterDataTreeChangeListener;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
-class DelayedDataTreeChangeListenerRegistration<L extends EventListener> implements ListenerRegistration<L> {
+class DelayedDataTreeChangeListenerRegistration implements Registration {
private final RegisterDataTreeChangeListener registrationMessage;
private final ActorRef registrationActor;
}
}
- @Override
- public L getInstance() {
- // ObjectRegistration annotates this method as @Nonnull but we could return null if the delegate is not set yet.
- // In reality, we do not and should not ever call this method on DelayedDataTreeChangeListenerRegistration
- // instances anyway but, since we have to provide an implementation to satisfy the interface, we throw
- // UnsupportedOperationException to honor the API contract of not returning null and to avoid a FindBugs error
- // for possibly returning null.
- throw new UnsupportedOperationException(
- "getInstance should not be called on this instance since it could be null");
- }
-
@Override
public synchronized void close() {
closed = true;
updater.setListener(dataStore);
- schemaService.registerSchemaContextListener(dataStore);
+ schemaService.registerSchemaContextListener(dataStore::onModelContextUpdated);
dataStore.setCloseable(updater);
dataStore.waitTillReady();
import org.opendaylight.controller.cluster.datastore.utils.ActorUtils;
import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
import org.opendaylight.mdsal.dom.spi.store.DOMStore;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
/**
ActorUtils getActorUtils();
@Beta
- <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerProxyListener(
- YangInstanceIdentifier shardLookup, YangInstanceIdentifier insideShard,
+ Registration registerProxyListener(YangInstanceIdentifier shardLookup, YangInstanceIdentifier insideShard,
DOMDataTreeChangeListener delegate);
}
import java.util.Map;
import org.opendaylight.controller.cluster.datastore.utils.ActorUtils;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.dom.api.DOMDataBroker.CommitCohortExtension;
import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
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.api.DOMDataTreeIdentifier;
import org.opendaylight.mdsal.dom.spi.store.DOMStore;
import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction;
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.concepts.Registration;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
@Beta
@Component(factory = OSGiDOMStore.FACTORY_NAME, service = { DOMStore.class, DistributedDataStoreInterface.class })
public final class OSGiDOMStore
- implements DistributedDataStoreInterface, DOMStoreTreeChangePublisher, DOMDataTreeCommitCohortRegistry {
+ implements DistributedDataStoreInterface, DOMStoreTreeChangePublisher, CommitCohortExtension {
// OSGi DS Component Factory name
static final String FACTORY_NAME = "org.opendaylight.controller.cluster.datastore.OSGiDOMStore";
static final String DATASTORE_INST_PROP = ".datastore.instance";
private static final Logger LOG = LoggerFactory.getLogger(OSGiDOMStore.class);
- private LogicalDatastoreType datastoreType;
+ private final LogicalDatastoreType datastoreType;
private AbstractDataStore datastore;
+ @Activate
+ public OSGiDOMStore(final Map<String, ?> properties) {
+ datastoreType = (LogicalDatastoreType) verifyNotNull(properties.get(DATASTORE_TYPE_PROP));
+ datastore = (AbstractDataStore) verifyNotNull(properties.get(DATASTORE_INST_PROP));
+ LOG.info("Datastore service type {} activated", datastoreType);
+ }
+
+ @Deactivate
+ void deactivate() {
+ datastore = null;
+ LOG.info("Datastore service type {} deactivated", datastoreType);
+ }
+
@Override
public ActorUtils getActorUtils() {
return datastore.getActorUtils();
}
@Override
- public <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerProxyListener(
- final YangInstanceIdentifier shardLookup, final YangInstanceIdentifier insideShard,
- final DOMDataTreeChangeListener delegate) {
+ public Registration registerProxyListener(final YangInstanceIdentifier shardLookup,
+ final YangInstanceIdentifier insideShard, final DOMDataTreeChangeListener delegate) {
return datastore.registerProxyListener(shardLookup, insideShard, delegate);
}
@Override
- public <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerTreeChangeListener(
- final YangInstanceIdentifier treeId, final L listener) {
+ public Registration registerTreeChangeListener(final YangInstanceIdentifier treeId,
+ final DOMDataTreeChangeListener listener) {
return datastore.registerTreeChangeListener(treeId, listener);
}
@Override
- public <T extends DOMDataTreeCommitCohort> DOMDataTreeCommitCohortRegistration<T> registerCommitCohort(
- final DOMDataTreeIdentifier path, final T cohort) {
+ public Registration registerCommitCohort(final DOMDataTreeIdentifier path, final DOMDataTreeCommitCohort cohort) {
return datastore.registerCommitCohort(path, cohort);
}
return datastore.newReadWriteTransaction();
}
- @Activate
- void activate(final Map<String, ?> properties) {
- datastoreType = (LogicalDatastoreType) verifyNotNull(properties.get(DATASTORE_TYPE_PROP));
- datastore = (AbstractDataStore) verifyNotNull(properties.get(DATASTORE_INST_PROP));
- LOG.info("Datastore service type {} activated", datastoreType);
- }
-
- @Deactivate
- void deactivate() {
- datastore = null;
- LOG.info("Datastore service type {} deactivated", datastoreType);
+ @Override
+ public Registration registerLegacyTreeChangeListener(final YangInstanceIdentifier treeId,
+ final DOMDataTreeChangeListener listener) {
+ return datastore.registerLegacyTreeChangeListener(treeId, listener);
}
}
final var introspector = introspectorFactory.newInstance(datastoreType, properties);
final var datastore = DistributedDataStoreFactory.createInstance(actorSystemProvider,
introspector.getContext(), introspector, snapshotRestore, config);
- datastore.setCloseable(schemaService.registerSchemaContextListener(datastore));
+ datastore.setCloseable(schemaService.registerSchemaContextListener(datastore::onModelContextUpdated));
final var state = new DatastoreState(introspector, datastoreType, datastore, serviceType);
Futures.addCallback(datastore.initialSettleFuture(), state,
import org.opendaylight.controller.cluster.datastore.messages.RegisterDataTreeNotificationListenerReply;
import org.opendaylight.controller.cluster.datastore.utils.ActorUtils;
import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
-import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
+import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-final class RootDataTreeChangeListenerProxy<L extends DOMDataTreeChangeListener>
- extends AbstractListenerRegistration<L> {
+final class RootDataTreeChangeListenerProxy<L extends DOMDataTreeChangeListener> extends AbstractObjectRegistration<L> {
private abstract static class State {
}
final Set<String> shardNames) {
super(listener);
this.actorUtils = requireNonNull(actorUtils);
- this.state = new ResolveShards(shardNames.size());
+ state = new ResolveShards(shardNames.size());
for (String shardName : shardNames) {
actorUtils.findLocalShardAsync(shardName).onComplete(new OnComplete<ActorRef>() {
} else if (state instanceof ResolveShards) {
// Simple case: just mark the fact we were closed, terminating when resolution finishes
state = new Terminated();
- } else if (state instanceof Subscribed) {
- terminate((Subscribed) state);
+ } else if (state instanceof Subscribed subscribed) {
+ terminate(subscribed);
} else {
throw new IllegalStateException("Unhandled close in state " + state);
}
private synchronized void onFindLocalShardComplete(final String shardName, final Throwable failure,
final ActorRef shard) {
- if (state instanceof ResolveShards) {
- localShardsResolved((ResolveShards) state, shardName, failure, shard);
+ if (state instanceof ResolveShards resolveShards) {
+ localShardsResolved(resolveShards, shardName, failure, shard);
} else {
LOG.debug("{}: lookup for shard {} turned into a noop on state {}", logContext(), shardName, state);
}
}
private synchronized void onShardSubscribed(final String shardName, final Throwable failure, final Object result) {
- if (state instanceof Subscribed) {
- final Subscribed current = (Subscribed) state;
+ if (state instanceof Subscribed current) {
if (failure != null) {
LOG.error("{}: Shard {} failed to subscribe, terminating listener {}", logContext(),
shardName,getInstance(), failure);
import java.util.Optional;
import java.util.OptionalLong;
import java.util.concurrent.TimeUnit;
+import java.util.function.Supplier;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.controller.cluster.access.ABIVersion;
import org.opendaylight.yangtools.yang.data.tree.api.DataValidationFailedException;
import org.opendaylight.yangtools.yang.data.tree.api.TreeType;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextProvider;
import scala.concurrent.duration.FiniteDuration;
/**
}
private void updateSchemaContext(final UpdateSchemaContext message) {
- updateSchemaContext(message.getEffectiveModelContext());
+ updateSchemaContext(message.modelContext());
}
@VisibleForTesting
private ShardIdentifier id;
private Map<String, String> peerAddresses = Collections.emptyMap();
private DatastoreContext datastoreContext;
- private EffectiveModelContextProvider schemaContextProvider;
+ private Supplier<@NonNull EffectiveModelContext> schemaContextProvider;
private DatastoreSnapshot.ShardSnapshot restoreFromSnapshot;
private DataTree dataTree;
return self();
}
- public T schemaContextProvider(final EffectiveModelContextProvider newSchemaContextProvider) {
+ public T schemaContextProvider(final Supplier<@NonNull EffectiveModelContext> newSchemaContextProvider) {
checkSealed();
schemaContextProvider = requireNonNull(newSchemaContextProvider);
return self();
}
public EffectiveModelContext getSchemaContext() {
- return verifyNotNull(schemaContextProvider.getEffectiveModelContext());
+ return verifyNotNull(schemaContextProvider.get());
}
public DatastoreSnapshot.ShardSnapshot getRestoreFromSnapshot() {
import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
import org.opendaylight.yangtools.concepts.Identifier;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.common.Empty;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
}
final void registerTreeChangeListener(final YangInstanceIdentifier path, final DOMDataTreeChangeListener listener,
- final Optional<DataTreeCandidate> initialState,
- final Consumer<ListenerRegistration<DOMDataTreeChangeListener>> onRegistration) {
+ final Optional<DataTreeCandidate> initialState, final Consumer<Registration> onRegistration) {
treeChangeListenerPublisher.registerTreeChangeListener(path, listener, initialState, onRegistration);
}
import java.util.Optional;
import java.util.function.Consumer;
import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate;
*/
interface ShardDataTreeChangeListenerPublisher extends ShardDataTreeNotificationPublisher {
void registerTreeChangeListener(YangInstanceIdentifier treeId, DOMDataTreeChangeListener listener,
- Optional<DataTreeCandidate> initialState,
- Consumer<ListenerRegistration<DOMDataTreeChangeListener>> onRegistration);
+ Optional<DataTreeCandidate> initialState, Consumer<Registration> onRegistration);
}
import java.util.Optional;
import java.util.function.Consumer;
import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate;
@Override
public void registerTreeChangeListener(final YangInstanceIdentifier treeId,
final DOMDataTreeChangeListener listener, final Optional<DataTreeCandidate> currentState,
- final Consumer<ListenerRegistration<DOMDataTreeChangeListener>> onRegistration) {
+ final Consumer<Registration> onRegistration) {
final ShardDataTreeChangePublisherActor.RegisterListener regMessage =
new ShardDataTreeChangePublisherActor.RegisterListener(treeId, listener, currentState, onRegistration);
log.debug("{}: Sending {} to publisher actor {}", logContext(), regMessage, publisherActor());
import java.util.Optional;
import java.util.function.Consumer;
import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate;
private final YangInstanceIdentifier path;
private final DOMDataTreeChangeListener listener;
private final Optional<DataTreeCandidate> initialState;
- private final Consumer<ListenerRegistration<DOMDataTreeChangeListener>> onRegistration;
+ private final Consumer<Registration> onRegistration;
RegisterListener(final YangInstanceIdentifier path, final DOMDataTreeChangeListener listener,
- final Optional<DataTreeCandidate> initialState,
- final Consumer<ListenerRegistration<DOMDataTreeChangeListener>> onRegistration) {
+ final Optional<DataTreeCandidate> initialState, final Consumer<Registration> onRegistration) {
this.path = requireNonNull(path);
this.listener = requireNonNull(listener);
this.initialState = requireNonNull(initialState);
*/
package org.opendaylight.controller.cluster.datastore.messages;
+import static java.util.Objects.requireNonNull;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-import org.opendaylight.yangtools.yang.model.spi.AbstractEffectiveModelContextProvider;
-public class UpdateSchemaContext extends AbstractEffectiveModelContextProvider {
- public UpdateSchemaContext(final EffectiveModelContext modelContext) {
- super(modelContext);
+@NonNullByDefault
+public record UpdateSchemaContext(EffectiveModelContext modelContext) {
+ public UpdateSchemaContext {
+ requireNonNull(modelContext);
}
}
return NormalizedNodeStreamVersion.POTASSIUM;
} else if (version >= DataStoreVersions.PHOSPHORUS_VERSION) {
return NormalizedNodeStreamVersion.MAGNESIUM;
- } else if (version == DataStoreVersions.SODIUM_SR1_VERSION) {
- return NormalizedNodeStreamVersion.SODIUM_SR1;
} else {
throw new IllegalStateException("Unsupported version " + version);
}
*/
package org.opendaylight.controller.cluster.datastore.shardmanager;
-import com.google.common.base.Verify;
+import static com.google.common.base.Verify.verifyNotNull;
+
import java.util.concurrent.atomic.AtomicReference;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextProvider;
-final class AtomicShardContextProvider extends AtomicReference<EffectiveModelContext>
- implements EffectiveModelContextProvider {
+final class AtomicShardContextProvider extends AtomicReference<EffectiveModelContext> {
+ @java.io.Serial
private static final long serialVersionUID = 1L;
- @Override
- public EffectiveModelContext getEffectiveModelContext() {
- return Verify.verifyNotNull(get());
+ @NonNull EffectiveModelContext modelContext() {
+ return verifyNotNull(get());
}
}
\ No newline at end of file
Props newProps() {
Props props = requireNonNull(builder).id(shardId).peerAddresses(initialPeerAddresses)
- .datastoreContext(datastoreContext).schemaContextProvider(schemaContextProvider).props();
+ .datastoreContext(datastoreContext).schemaContextProvider(schemaContextProvider::modelContext).props();
builder = null;
return props;
}
}
EffectiveModelContext getSchemaContext() {
- return schemaContextProvider.getEffectiveModelContext();
+ return schemaContextProvider.modelContext();
}
void setSchemaContext(final EffectiveModelContext schemaContext) {
@VisibleForTesting
final ShardPeerAddressResolver peerAddressResolver;
- private EffectiveModelContext schemaContext;
+ private EffectiveModelContext modelContext;
private DatastoreSnapshot restoreFromSnapshot;
info.setActiveMember(isActiveMember);
localShards.put(info.getShardName(), info);
- if (schemaContext != null) {
- info.setSchemaContext(schemaContext);
+ if (modelContext != null) {
+ info.setSchemaContext(modelContext);
info.setActor(newShardActor(info));
}
}
* @param message the message to send
*/
private void updateSchemaContext(final UpdateSchemaContext message) {
- schemaContext = message.getEffectiveModelContext();
+ modelContext = message.modelContext();
- LOG.debug("Got updated SchemaContext: # of modules {}", schemaContext.getModules().size());
+ LOG.debug("Got updated SchemaContext: # of modules {}", modelContext.getModules().size());
for (ShardInformation info : localShards.values()) {
- info.setSchemaContext(schemaContext);
+ info.setSchemaContext(modelContext);
if (info.getActor() == null) {
LOG.debug("Creating Shard {}", info.getShardId());
}
// Create the localShard
- if (schemaContext == null) {
+ if (modelContext == null) {
LOG.debug("{}: No SchemaContext is available in order to create a local shard instance for {}",
persistenceId(), shardName);
getSender().tell(new Status.Failure(new IllegalStateException(
shardInfo = new ShardInformation(shardName, shardId, getPeerAddresses(shardName), datastoreContext,
Shard.builder(), peerAddressResolver);
shardInfo.setActiveMember(false);
- shardInfo.setSchemaContext(schemaContext);
+ shardInfo.setSchemaContext(modelContext);
localShards.put(shardName, shardInfo);
shardInfo.setActor(newShardActor(shardInfo));
} else {
}
@Override
- public final EffectiveModelContext getEffectiveModelContext() {
- return delegate.getEffectiveModelContext();
+ public final EffectiveModelContext modelContext() {
+ return delegate.modelContext();
}
@Override
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.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.builder.DataContainerNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.data.tree.api.DataValidationFailedException;
/**
public static <T> @NonNull Stream<ShardContainer<T>> scatterAll(final ContainerNode rootNode,
final Function<PathArgument, T> childToShard, final Stream<T> allShards) {
final var builders = allShards
- .collect(Collectors.toUnmodifiableMap(Function.identity(), unused -> Builders.containerBuilder()));
+ .collect(Collectors.toUnmodifiableMap(Function.identity(), unused -> ImmutableNodes.newContainerBuilder()));
for (var child : rootNode.body()) {
final var shard = childToShard.apply(child.name());
verifyNotNull(builders.get(shard), "Failed to find builder for %s", shard).addChild(child);
*/
public static <T> @NonNull Stream<ShardContainer<T>> scatterTouched(final ContainerNode rootNode,
final Function<PathArgument, T> childToShard) {
- final var builders = new HashMap<T, DataContainerNodeBuilder<NodeIdentifier, ContainerNode>>();
+ final var builders = new HashMap<T, ContainerNode.Builder>();
for (var child : rootNode.body()) {
- builders.computeIfAbsent(childToShard.apply(child.name()), unused -> Builders.containerBuilder())
+ builders.computeIfAbsent(childToShard.apply(child.name()), unused -> ImmutableNodes.newContainerBuilder())
.addChild(child);
}
return streamContainers(rootNode.name(), builders);
}
private static <T> @NonNull Stream<ShardContainer<T>> streamContainers(final NodeIdentifier rootId,
- final Map<T, DataContainerNodeBuilder<NodeIdentifier, ContainerNode>> builders) {
+ final Map<T, ContainerNode.Builder> builders) {
return builders.entrySet().stream()
.map(entry -> new ShardContainer<>(entry.getKey(), entry.getValue().withNodeIdentifier(rootId).build()));
}
+++ /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.cluster.databroker;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertThrows;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.doThrow;
-import static org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION;
-import static org.opendaylight.mdsal.common.api.LogicalDatastoreType.OPERATIONAL;
-
-import com.google.common.util.concurrent.FluentFuture;
-import java.util.Map;
-import java.util.concurrent.ExecutionException;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.opendaylight.mdsal.common.api.CommitInfo;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
-import org.opendaylight.mdsal.common.api.TransactionDatastoreMismatchException;
-import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionFactory;
-import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
-
-@RunWith(MockitoJUnitRunner.StrictStubs.class)
-public class AbstractDOMBrokerWriteTransactionTest {
-
- @Mock
- private DOMStoreTransactionFactory txFactory;
- @Mock
- private AbstractDOMTransactionFactory<?> abstractDOMTransactionFactory;
- @Mock
- private DOMStoreWriteTransaction domStoreWriteTransaction;
-
- private class AbstractDOMBrokerWriteTransactionTestImpl
- extends AbstractDOMBrokerWriteTransaction<DOMStoreWriteTransaction> {
-
- AbstractDOMBrokerWriteTransactionTestImpl() {
- this(Map.of(CONFIGURATION, txFactory));
- }
-
- AbstractDOMBrokerWriteTransactionTestImpl(Map<LogicalDatastoreType, DOMStoreTransactionFactory> txFactoryMap) {
- super(new Object(), txFactoryMap, abstractDOMTransactionFactory);
- }
-
- @Override
- protected DOMStoreWriteTransaction createTransaction(final LogicalDatastoreType key) {
- return domStoreWriteTransaction;
- }
-
- @Override
- protected DOMStoreWriteTransaction getSubtransaction() {
- return domStoreWriteTransaction;
- }
- }
-
- @Test
- public void readyRuntimeExceptionAndCancel() {
- RuntimeException thrown = new RuntimeException();
- doThrow(thrown).when(domStoreWriteTransaction).ready();
- AbstractDOMBrokerWriteTransactionTestImpl abstractDOMBrokerWriteTransactionTestImpl =
- new AbstractDOMBrokerWriteTransactionTestImpl();
-
- FluentFuture<? extends CommitInfo> submitFuture = abstractDOMBrokerWriteTransactionTestImpl.commit();
- final var cause = assertThrows(ExecutionException.class, submitFuture::get).getCause();
- assertTrue(cause instanceof TransactionCommitFailedException);
- assertSame(thrown, cause.getCause());
- abstractDOMBrokerWriteTransactionTestImpl.cancel();
- }
-
- @Test
- public void submitRuntimeExceptionAndCancel() throws InterruptedException {
- RuntimeException thrown = new RuntimeException();
- doThrow(thrown).when(abstractDOMTransactionFactory).commit(any(), any());
- AbstractDOMBrokerWriteTransactionTestImpl abstractDOMBrokerWriteTransactionTestImpl
- = new AbstractDOMBrokerWriteTransactionTestImpl();
-
- FluentFuture<? extends CommitInfo> submitFuture = abstractDOMBrokerWriteTransactionTestImpl.commit();
- final var cause = assertThrows(ExecutionException.class, submitFuture::get).getCause();
- assertTrue(cause instanceof TransactionCommitFailedException);
- assertSame(thrown, cause.getCause());
- abstractDOMBrokerWriteTransactionTestImpl.cancel();
- }
-
- @Test
- public void getSubtransactionStoreMismatch() {
- final var testTx = new AbstractDOMBrokerWriteTransactionTestImpl(
- Map.of(CONFIGURATION, txFactory, OPERATIONAL, txFactory));
-
- assertEquals(domStoreWriteTransaction, testTx.getSubtransaction(CONFIGURATION));
-
- final var exception = assertThrows(TransactionDatastoreMismatchException.class,
- () -> testTx.getSubtransaction(OPERATIONAL));
- assertEquals(CONFIGURATION, exception.expected());
- assertEquals(OPERATIONAL, exception.encountered());
- }
-
- @Test
- public void getSubtransactionStoreUndefined() {
- final var testTx = new AbstractDOMBrokerWriteTransactionTestImpl(Map.of(OPERATIONAL, txFactory));
-
- final var exception = assertThrows(IllegalArgumentException.class,
- () -> testTx.getSubtransaction(CONFIGURATION));
- assertEquals("CONFIGURATION is not supported", exception.getMessage());
- }
-}
import org.opendaylight.controller.cluster.access.client.ClientActorContext;
import org.opendaylight.controller.cluster.databroker.actors.dds.ClientSnapshot;
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.ContainerNode;
@RunWith(MockitoJUnitRunner.StrictStubs.class)
public class ClientBackedReadTransactionTest extends ClientBackedTransactionTest<ClientBackedReadTransaction> {
private ClientBackedReadTransaction object;
@Mock
- private NormalizedNode data;
+ private ContainerNode data;
@Mock
private ClientActorContext clientContext;
@Mock
import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.controller.cluster.databroker.actors.dds.ClientTransaction;
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.ContainerNode;
@RunWith(MockitoJUnitRunner.StrictStubs.class)
public class ClientBackedReadWriteTransactionTest
@Mock
private ClientTransaction delegate;
@Mock
- private NormalizedNode data;
+ private ContainerNode data;
@Override
ClientBackedReadWriteTransaction object() {
import org.opendaylight.controller.cluster.databroker.actors.dds.ClientTransaction;
import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
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.ContainerNode;
@RunWith(MockitoJUnitRunner.StrictStubs.class)
public class ClientBackedWriteTransactionTest extends ClientBackedTransactionTest<ClientBackedWriteTransaction> {
@Mock
private ClientTransaction delegate;
@Mock
- private NormalizedNode data;
+ private ContainerNode data;
@Mock
private DOMStoreThreePhaseCommitCohort readyCohort;
import static org.opendaylight.yangtools.util.concurrent.FluentFutures.immediateTrueFluentFuture;
import com.google.common.base.Throwables;
-import com.google.common.collect.ClassToInstanceMap;
import com.google.common.collect.ImmutableMap;
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.FutureCallback;
import org.opendaylight.mdsal.common.api.CommitInfo;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
-import org.opendaylight.mdsal.dom.api.DOMDataBrokerExtension;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService;
+import org.opendaylight.mdsal.dom.api.DOMDataBroker.CommitCohortExtension;
+import org.opendaylight.mdsal.dom.api.DOMDataBroker.DataTreeChangeExtension;
import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohort;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry;
import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
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.broker.TransactionCommitFailedExceptionMapper;
+import org.opendaylight.mdsal.dom.spi.TransactionCommitFailedExceptionMapper;
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.DOMStoreWriteTransaction;
import org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore;
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.ContainerNode;
/**
* Unit tests for DOMConcurrentDataCommitCoordinator.
configDomStore), futureExecutor)) {
DOMDataTreeReadWriteTransaction dataTxn = dataBroker.newReadWriteTransaction();
- dataTxn.put(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.of(), mock(NormalizedNode.class));
- dataTxn.put(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.of(), mock(NormalizedNode.class));
+ dataTxn.put(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.of(), mock(ContainerNode.class));
+ dataTxn.put(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.of(), mock(ContainerNode.class));
dataTxn.read(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.of());
verify(configDomStore, never()).newReadWriteTransaction();
configDomStore), futureExecutor)) {
DOMDataTreeWriteTransaction dataTxn = dataBroker.newWriteOnlyTransaction();
- dataTxn.put(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.of(), mock(NormalizedNode.class));
- dataTxn.put(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.of(), mock(NormalizedNode.class));
+ dataTxn.put(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.of(), mock(ContainerNode.class));
+ dataTxn.put(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.of(), mock(ContainerNode.class));
verify(configDomStore, never()).newWriteOnlyTransaction();
verify(operationalDomStore, times(1)).newWriteOnlyTransaction();
LogicalDatastoreType.OPERATIONAL, domStore, LogicalDatastoreType.CONFIGURATION, domStore),
futureExecutor)) {
- dataBroker.createTransactionChain(mock(DOMTransactionChainListener.class));
+ dataBroker.createTransactionChain();
verify(domStore, times(2)).createTransactionChain();
}
doReturn(mockChain).when(domStore).createTransactionChain();
doReturn(operationalTransaction).when(mockChain).newWriteOnlyTransaction();
- DOMTransactionChain transactionChain = dataBroker.createTransactionChain(
- mock(DOMTransactionChainListener.class));
+ DOMTransactionChain transactionChain = dataBroker.createTransactionChain();
DOMDataTreeWriteTransaction domDataWriteTransaction = transactionChain.newWriteOnlyTransaction();
verify(mockChain, never()).newWriteOnlyTransaction();
domDataWriteTransaction.put(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.of(),
- mock(NormalizedNode.class));
+ mock(ContainerNode.class));
}
}
public void testExtensions() {
final var mockConfigStore = mock(AbstractDataStore.class);
final var mockOperStore = mock(AbstractDataStore.class);
- try (ConcurrentDOMDataBroker dataBroker = new ConcurrentDOMDataBroker(ImmutableMap.of(
+ try (var dataBroker = new ConcurrentDOMDataBroker(ImmutableMap.of(
LogicalDatastoreType.OPERATIONAL, mockOperStore,
LogicalDatastoreType.CONFIGURATION, mockConfigStore), futureExecutor)) {
+ assertNotNull(dataBroker.extension(DataTreeChangeExtension.class));
- ClassToInstanceMap<DOMDataBrokerExtension> supportedExtensions = dataBroker.getExtensions();
- assertNotNull(supportedExtensions.getInstance(DOMDataTreeChangeService.class));
-
- DOMDataTreeCommitCohortRegistry cohortRegistry = supportedExtensions.getInstance(
- DOMDataTreeCommitCohortRegistry.class);
+ final var cohortRegistry = dataBroker.extension(CommitCohortExtension.class);
assertNotNull(cohortRegistry);
- DOMDataTreeCommitCohort cohort = mock(DOMDataTreeCommitCohort.class);
- DOMDataTreeIdentifier path = new DOMDataTreeIdentifier(
- org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION,
- YangInstanceIdentifier.of());
+ final var cohort = mock(DOMDataTreeCommitCohort.class);
+ final var path = DOMDataTreeIdentifier.of(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.of());
cohortRegistry.registerCommitCohort(path, cohort);
verify(mockConfigStore).registerCommitCohort(path, cohort);
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.verify;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableMap;
import com.google.common.util.concurrent.FluentFuture;
+import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.Uninterruptibles;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runners.Parameterized.Parameter;
-import org.mockito.Mockito;
import org.opendaylight.controller.cluster.access.client.RequestTimeoutException;
import org.opendaylight.controller.cluster.databroker.ConcurrentDOMDataBroker;
import org.opendaylight.controller.cluster.datastore.TestShard.RequestFrontendMetadata;
import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
import org.opendaylight.mdsal.dom.api.DOMTransactionChainClosedException;
-import org.opendaylight.mdsal.dom.api.DOMTransactionChainListener;
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.DOMStoreWriteTransaction;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.common.Uint64;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
.put(LogicalDatastoreType.CONFIGURATION, dataStore).build(),
MoreExecutors.directExecutor());
- final DOMTransactionChainListener listener = Mockito.mock(DOMTransactionChainListener.class);
- DOMTransactionChain txChain = broker.createTransactionChain(listener);
+ DOMTransactionChain txChain = broker.createTransactionChain();
final List<ListenableFuture<?>> futures = new ArrayList<>();
.put(LogicalDatastoreType.CONFIGURATION, dataStore).build(),
MoreExecutors.directExecutor());
- final var listener = Mockito.mock(DOMTransactionChainListener.class);
- final var txChain = broker.createTransactionChain(listener);
+ final var listener = mock(FutureCallback.class);
+ final var txChain = broker.createTransactionChain();
+ txChain.addCallback(listener);
final var writeTx = txChain.newReadWriteTransaction();
assertThrows(ExecutionException.class, () -> writeTx.commit().get(5, TimeUnit.SECONDS));
- verify(listener, timeout(5000)).onTransactionChainFailed(eq(txChain), eq(writeTx),
- any(Throwable.class));
+ verify(listener, timeout(5000)).onFailure(any());
txChain.close();
broker.close();
.put(LogicalDatastoreType.CONFIGURATION, dataStore).build(),
MoreExecutors.directExecutor());
- final DOMTransactionChainListener listener = Mockito.mock(DOMTransactionChainListener.class);
- final DOMTransactionChain txChain = broker.createTransactionChain(listener);
+ final var listener = mock(FutureCallback.class);
+ final DOMTransactionChain txChain = broker.createTransactionChain();
+ txChain.addCallback(listener);
final DOMDataTreeWriteTransaction writeTx = txChain.newReadWriteTransaction();
// done for put for performance reasons.
assertThrows(ExecutionException.class, () -> writeTx.commit().get(5, TimeUnit.SECONDS));
- verify(listener, timeout(5000)).onTransactionChainFailed(eq(txChain), eq(writeTx),
- any(Throwable.class));
+ verify(listener, timeout(5000)).onFailure(any());
txChain.close();
broker.close();
final MockDataTreeChangeListener listener = new MockDataTreeChangeListener(1);
- ListenerRegistration<MockDataTreeChangeListener> listenerReg = dataStore
- .registerTreeChangeListener(TestModel.TEST_PATH, listener);
+ final var listenerReg = dataStore.registerTreeChangeListener(TestModel.TEST_PATH, listener);
assertNotNull("registerTreeChangeListener returned null", listenerReg);
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
-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.mock;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.Uninterruptibles;
import java.time.Duration;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
+import java.util.function.Consumer;
+import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Test;
-import org.mockito.stubbing.Answer;
+import org.mockito.ArgumentCaptor;
import org.opendaylight.controller.cluster.common.actor.Dispatchers;
import org.opendaylight.controller.cluster.datastore.config.Configuration;
import org.opendaylight.controller.cluster.datastore.exceptions.NotInitializedException;
import org.opendaylight.controller.cluster.datastore.utils.ActorUtils;
import org.opendaylight.controller.cluster.raft.utils.DoNothingActor;
import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
-import org.opendaylight.mdsal.dom.api.ClusteredDOMDataTreeChangeListener;
import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import scala.concurrent.ExecutionContextExecutor;
-import scala.concurrent.Future;
public class DataTreeChangeListenerProxyTest extends AbstractActorTest {
private final DOMDataTreeChangeListener mockListener = mock(DOMDataTreeChangeListener.class);
@Test(timeout = 10000)
public void testSuccessfulRegistration() {
- final TestKit kit = new TestKit(getSystem());
- ActorUtils actorUtils = new ActorUtils(getSystem(), kit.getRef(), mock(ClusterWrapper.class),
+ final var kit = new TestKit(getSystem());
+ final var actorUtils = new ActorUtils(getSystem(), kit.getRef(), mock(ClusterWrapper.class),
mock(Configuration.class));
- final YangInstanceIdentifier path = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
- final DataTreeChangeListenerProxy<DOMDataTreeChangeListener> proxy = new DataTreeChangeListenerProxy<>(
- actorUtils, mockListener, path);
+ final var path = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
+ final var proxy = startProxyAsync(actorUtils, path, false);
- new Thread(() -> proxy.init("shard-1")).start();
-
- Duration timeout = Duration.ofSeconds(5);
- FindLocalShard findLocalShard = kit.expectMsgClass(timeout, FindLocalShard.class);
- assertEquals("getShardName", "shard-1", findLocalShard.getShardName());
+ final var timeout = Duration.ofSeconds(5);
+ final var findLocalShard = kit.expectMsgClass(timeout, FindLocalShard.class);
+ assertEquals("shard-1", findLocalShard.getShardName());
kit.reply(new LocalShardFound(kit.getRef()));
- RegisterDataTreeChangeListener registerMsg = kit.expectMsgClass(timeout,
- RegisterDataTreeChangeListener.class);
- assertEquals("getPath", path, registerMsg.getPath());
- assertFalse("isRegisterOnAllInstances", registerMsg.isRegisterOnAllInstances());
+ final var registerMsg = kit.expectMsgClass(timeout, RegisterDataTreeChangeListener.class);
+ assertEquals(path, registerMsg.getPath());
+ assertFalse(registerMsg.isRegisterOnAllInstances());
kit.reply(new RegisterDataTreeNotificationListenerReply(kit.getRef()));
Uninterruptibles.sleepUninterruptibly(50, TimeUnit.MILLISECONDS);
}
- assertEquals("getListenerRegistrationActor", getSystem().actorSelection(kit.getRef().path()),
- proxy.getListenerRegistrationActor());
+ assertEquals(getSystem().actorSelection(kit.getRef().path()), proxy.getListenerRegistrationActor());
kit.watch(proxy.getDataChangeListenerActor());
@Test(timeout = 10000)
public void testSuccessfulRegistrationForClusteredListener() {
- final TestKit kit = new TestKit(getSystem());
- ActorUtils actorUtils = new ActorUtils(getSystem(), kit.getRef(), mock(ClusterWrapper.class),
+ final var kit = new TestKit(getSystem());
+ final var actorUtils = new ActorUtils(getSystem(), kit.getRef(), mock(ClusterWrapper.class),
mock(Configuration.class));
- ClusteredDOMDataTreeChangeListener mockClusteredListener = mock(
- ClusteredDOMDataTreeChangeListener.class);
-
- final YangInstanceIdentifier path = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
- final DataTreeChangeListenerProxy<ClusteredDOMDataTreeChangeListener> proxy =
- new DataTreeChangeListenerProxy<>(actorUtils, mockClusteredListener, path);
+ final var path = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
+ final var proxy = startProxyAsync(actorUtils, path, true);
- new Thread(() -> proxy.init("shard-1")).start();
-
- Duration timeout = Duration.ofSeconds(5);
- FindLocalShard findLocalShard = kit.expectMsgClass(timeout, FindLocalShard.class);
- assertEquals("getShardName", "shard-1", findLocalShard.getShardName());
+ final var timeout = Duration.ofSeconds(5);
+ final var findLocalShard = kit.expectMsgClass(timeout, FindLocalShard.class);
+ assertEquals("shard-1", findLocalShard.getShardName());
kit.reply(new LocalShardFound(kit.getRef()));
- RegisterDataTreeChangeListener registerMsg = kit.expectMsgClass(timeout,
- RegisterDataTreeChangeListener.class);
- assertEquals("getPath", path, registerMsg.getPath());
- assertTrue("isRegisterOnAllInstances", registerMsg.isRegisterOnAllInstances());
+ final var registerMsg = kit.expectMsgClass(timeout, RegisterDataTreeChangeListener.class);
+ assertEquals(path, registerMsg.getPath());
+ assertTrue(registerMsg.isRegisterOnAllInstances());
proxy.close();
}
@Test(timeout = 10000)
public void testLocalShardNotFound() {
- final TestKit kit = new TestKit(getSystem());
- ActorUtils actorUtils = new ActorUtils(getSystem(), kit.getRef(), mock(ClusterWrapper.class),
+ final var kit = new TestKit(getSystem());
+ final var actorUtils = new ActorUtils(getSystem(), kit.getRef(), mock(ClusterWrapper.class),
mock(Configuration.class));
- final YangInstanceIdentifier path = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
- final DataTreeChangeListenerProxy<DOMDataTreeChangeListener> proxy = new DataTreeChangeListenerProxy<>(
- actorUtils, mockListener, path);
-
- new Thread(() -> proxy.init("shard-1")).start();
+ final var path = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
+ final var proxy = startProxyAsync(actorUtils, path, true);
- Duration timeout = Duration.ofSeconds(5);
- FindLocalShard findLocalShard = kit.expectMsgClass(timeout, FindLocalShard.class);
- assertEquals("getShardName", "shard-1", findLocalShard.getShardName());
+ final var timeout = Duration.ofSeconds(5);
+ final var findLocalShard = kit.expectMsgClass(timeout, FindLocalShard.class);
+ assertEquals("shard-1", findLocalShard.getShardName());
kit.reply(new LocalShardNotFound("shard-1"));
@Test(timeout = 10000)
public void testLocalShardNotInitialized() {
- final TestKit kit = new TestKit(getSystem());
- ActorUtils actorUtils = new ActorUtils(getSystem(), kit.getRef(), mock(ClusterWrapper.class),
+ final var kit = new TestKit(getSystem());
+ final var actorUtils = new ActorUtils(getSystem(), kit.getRef(), mock(ClusterWrapper.class),
mock(Configuration.class));
- final YangInstanceIdentifier path = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
- final DataTreeChangeListenerProxy<DOMDataTreeChangeListener> proxy = new DataTreeChangeListenerProxy<>(
- actorUtils, mockListener, path);
+ final var path = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
+ final var proxy = startProxyAsync(actorUtils, path, false);
- new Thread(() -> proxy.init("shard-1")).start();
-
- Duration timeout = Duration.ofSeconds(5);
- FindLocalShard findLocalShard = kit.expectMsgClass(timeout, FindLocalShard.class);
- assertEquals("getShardName", "shard-1", findLocalShard.getShardName());
+ final var timeout = Duration.ofSeconds(5);
+ final var findLocalShard = kit.expectMsgClass(timeout, FindLocalShard.class);
+ assertEquals("shard-1", findLocalShard.getShardName());
kit.reply(new NotInitializedException("not initialized"));
@Test
public void testFailedRegistration() {
- final TestKit kit = new TestKit(getSystem());
- ActorSystem mockActorSystem = mock(ActorSystem.class);
+ final var kit = new TestKit(getSystem());
+ final var mockActorSystem = mock(ActorSystem.class);
- ActorRef mockActor = getSystem().actorOf(Props.create(DoNothingActor.class), "testFailedRegistration");
+ final var mockActor = getSystem().actorOf(Props.create(DoNothingActor.class), "testFailedRegistration");
doReturn(mockActor).when(mockActorSystem).actorOf(any(Props.class));
- ExecutionContextExecutor executor = ExecutionContexts.fromExecutor(MoreExecutors.directExecutor());
+ final var executor = ExecutionContexts.fromExecutor(MoreExecutors.directExecutor());
- ActorUtils actorUtils = mock(ActorUtils.class);
- final YangInstanceIdentifier path = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
+ final var actorUtils = mock(ActorUtils.class);
+ final var path = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
doReturn(executor).when(actorUtils).getClientDispatcher();
doReturn(DatastoreContext.newBuilder().build()).when(actorUtils).getDatastoreContext();
doReturn(mockActorSystem).when(actorUtils).getActorSystem();
- String shardName = "shard-1";
- final DataTreeChangeListenerProxy<DOMDataTreeChangeListener> proxy = new DataTreeChangeListenerProxy<>(
- actorUtils, mockListener, path);
-
doReturn(kit.duration("5 seconds")).when(actorUtils).getOperationDuration();
- doReturn(Futures.successful(kit.getRef())).when(actorUtils).findLocalShardAsync(eq(shardName));
+ doReturn(Futures.successful(kit.getRef())).when(actorUtils).findLocalShardAsync("shard-1");
doReturn(Futures.failed(new RuntimeException("mock"))).when(actorUtils).executeOperationAsync(
any(ActorRef.class), any(Object.class), any(Timeout.class));
- doReturn(mock(DatastoreContext.class)).when(actorUtils).getDatastoreContext();
-
- proxy.init("shard-1");
- assertEquals("getListenerRegistrationActor", null, proxy.getListenerRegistrationActor());
+ final var proxy = DataTreeChangeListenerProxy.of(actorUtils, mockListener, path, true, "shard-1");
+ assertNull(proxy.getListenerRegistrationActor());
proxy.close();
}
@Test
public void testCloseBeforeRegistration() {
- final TestKit kit = new TestKit(getSystem());
- ActorUtils actorUtils = mock(ActorUtils.class);
-
- String shardName = "shard-1";
+ final var kit = new TestKit(getSystem());
+ final var actorUtils = mock(ActorUtils.class);
doReturn(DatastoreContext.newBuilder().build()).when(actorUtils).getDatastoreContext();
doReturn(getSystem().dispatchers().defaultGlobalDispatcher()).when(actorUtils).getClientDispatcher();
doReturn(getSystem().actorSelection(kit.getRef().path())).when(actorUtils).actorSelection(
kit.getRef().path());
doReturn(kit.duration("5 seconds")).when(actorUtils).getOperationDuration();
- doReturn(Futures.successful(kit.getRef())).when(actorUtils).findLocalShardAsync(eq(shardName));
+ doReturn(Futures.successful(kit.getRef())).when(actorUtils).findLocalShardAsync("shard-1");
- final DataTreeChangeListenerProxy<DOMDataTreeChangeListener> proxy = new DataTreeChangeListenerProxy<>(
- actorUtils, mockListener, YangInstanceIdentifier.of(TestModel.TEST_QNAME));
+ final var proxy = createProxy(actorUtils, YangInstanceIdentifier.of(TestModel.TEST_QNAME), true);
+ final var instance = proxy.getKey();
- Answer<Future<Object>> answer = invocation -> {
- proxy.close();
- return Futures.successful((Object) new RegisterDataTreeNotificationListenerReply(kit.getRef()));
- };
+ doAnswer(invocation -> {
+ instance.close();
+ return Futures.successful(new RegisterDataTreeNotificationListenerReply(kit.getRef()));
+ }).when(actorUtils).executeOperationAsync(any(ActorRef.class), any(Object.class), any(Timeout.class));
+ proxy.getValue().run();
- doAnswer(answer).when(actorUtils).executeOperationAsync(any(ActorRef.class), any(Object.class),
- any(Timeout.class));
+ kit.expectMsgClass(Duration.ofSeconds(5), CloseDataTreeNotificationListenerRegistration.class);
- proxy.init(shardName);
+ assertNull(instance.getListenerRegistrationActor());
+ }
- kit.expectMsgClass(Duration.ofSeconds(5), CloseDataTreeNotificationListenerRegistration.class);
+ @NonNullByDefault
+ private DataTreeChangeListenerProxy startProxyAsync(final ActorUtils actorUtils, final YangInstanceIdentifier path,
+ final boolean clustered) {
+ return startProxyAsync(actorUtils, path, clustered, Runnable::run);
+ }
+
+ @NonNullByDefault
+ private DataTreeChangeListenerProxy startProxyAsync(final ActorUtils actorUtils, final YangInstanceIdentifier path,
+ final boolean clustered, final Consumer<Runnable> execute) {
+ final var proxy = createProxy(actorUtils, path, clustered);
+ final var thread = new Thread(proxy.getValue());
+ thread.setDaemon(true);
+ thread.start();
+ return proxy.getKey();
+ }
- assertEquals("getListenerRegistrationActor", null, proxy.getListenerRegistrationActor());
+ @NonNullByDefault
+ private Entry<DataTreeChangeListenerProxy, Runnable> createProxy(final ActorUtils actorUtils,
+ final YangInstanceIdentifier path, final boolean clustered) {
+ final var executor = mock(Executor.class);
+ final var captor = ArgumentCaptor.forClass(Runnable.class);
+ doNothing().when(executor).execute(captor.capture());
+ final var proxy = DataTreeChangeListenerProxy.ofTesting(actorUtils, mockListener, path, clustered, "shard-1",
+ executor);
+ return Map.entry(proxy, captor.getValue());
}
}
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.timeout;
import com.google.common.base.Stopwatch;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableMap;
+import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.Uninterruptibles;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
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.store.DOMStore;
import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction;
import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction;
});
try (var tx = txChain.newReadOnlyTransaction()) {
- final var body = tx.read(CarsModel.CAR_LIST_PATH).get(5, TimeUnit.SECONDS).orElseThrow().body();
- assertThat(body, instanceOf(Collection.class));
+ final var body = assertInstanceOf(Collection.class,
+ tx.read(CarsModel.CAR_LIST_PATH).get(5, TimeUnit.SECONDS).orElseThrow().body());
assertEquals(numCars, ((Collection<?>) body).size());
}
}
LogicalDatastoreType.CONFIGURATION, followerDistributedDataStore).build(),
MoreExecutors.directExecutor());
- final DOMTransactionChainListener listener = mock(DOMTransactionChainListener.class);
- final DOMTransactionChain txChain = broker.createTransactionChain(listener);
+ final var listener = mock(FutureCallback.class);
+ final DOMTransactionChain txChain = broker.createTransactionChain();
+ txChain.addCallback(listener);
final DOMDataTreeWriteTransaction writeTx = txChain.newWriteOnlyTransaction();
.withChild(ImmutableNodes.leafNode(TestModel.JUNK_QNAME, "junk"))
.build());
- final var ex = assertThrows(ExecutionException.class, () -> writeTx.commit().get(5, TimeUnit.SECONDS))
- .getCause();
- assertThat(ex, instanceOf(TransactionCommitFailedException.class));
+ final var ex = assertThrows(ExecutionException.class, () -> writeTx.commit().get(5, TimeUnit.SECONDS));
+ assertInstanceOf(TransactionCommitFailedException.class, ex.getCause());
- verify(listener, timeout(5000)).onTransactionChainFailed(eq(txChain), eq(writeTx), any(Throwable.class));
+ verify(listener, timeout(5000)).onFailure(any());
txChain.close();
broker.close();
public void testChainedTransactionFailureWithMultipleShards() throws Exception {
initDatastoresWithCarsAndPeople("testChainedTransactionFailureWithMultipleShards");
- final ConcurrentDOMDataBroker broker = new ConcurrentDOMDataBroker(
- ImmutableMap.<LogicalDatastoreType, DOMStore>builder().put(
- LogicalDatastoreType.CONFIGURATION, followerDistributedDataStore).build(),
- MoreExecutors.directExecutor());
+ try (var broker = new ConcurrentDOMDataBroker(
+ Map.of(LogicalDatastoreType.CONFIGURATION, followerDistributedDataStore), MoreExecutors.directExecutor())) {
- final DOMTransactionChainListener listener = mock(DOMTransactionChainListener.class);
- final DOMTransactionChain txChain = broker.createTransactionChain(listener);
+ final var listener = mock(FutureCallback.class);
+ final DOMTransactionChain txChain = broker.createTransactionChain();
+ txChain.addCallback(listener);
- final DOMDataTreeWriteTransaction writeTx = txChain.newWriteOnlyTransaction();
+ final DOMDataTreeWriteTransaction writeTx = txChain.newWriteOnlyTransaction();
- writeTx.put(LogicalDatastoreType.CONFIGURATION, PeopleModel.BASE_PATH, PeopleModel.emptyContainer());
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, PeopleModel.BASE_PATH, PeopleModel.emptyContainer());
- // Note that merge will validate the data and fail but put succeeds b/c deep validation is not
- // done for put for performance reasons.
- writeTx.merge(LogicalDatastoreType.CONFIGURATION, CarsModel.BASE_PATH, Builders.containerBuilder()
- .withNodeIdentifier(new NodeIdentifier(CarsModel.BASE_QNAME))
- .withChild(ImmutableNodes.leafNode(TestModel.JUNK_QNAME, "junk"))
- .build());
+ // Note that merge will validate the data and fail but put succeeds b/c deep validation is not
+ // done for put for performance reasons.
+ writeTx.merge(LogicalDatastoreType.CONFIGURATION, CarsModel.BASE_PATH, Builders.containerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(CarsModel.BASE_QNAME))
+ .withChild(ImmutableNodes.leafNode(TestModel.JUNK_QNAME, "junk"))
+ .build());
- final var ex = assertThrows(ExecutionException.class, () -> writeTx.commit().get(5, TimeUnit.SECONDS))
- .getCause();
- assertThat(ex, instanceOf(TransactionCommitFailedException.class));
+ final var ex = assertThrows(ExecutionException.class, () -> writeTx.commit().get(5, TimeUnit.SECONDS))
+ .getCause();
+ assertThat(ex, instanceOf(TransactionCommitFailedException.class));
- verify(listener, timeout(5000)).onTransactionChainFailed(eq(txChain), eq(writeTx), any(Throwable.class));
+ verify(listener, timeout(5000)).onFailure(any());
- txChain.close();
- broker.close();
+ txChain.close();
+ }
}
@Test
import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.distributed.datastore.provider.rev231229.DataStoreProperties.ExportOnRecovery;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
-import org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
public class JsonExportTest extends AbstractShardTest {
private static final String DUMMY_DATA = "Dummy data as snapshot sequence number is set to 0 in "
@Before
public void setUp() throws Exception {
super.setUp();
- final File exportTmpFolder = temporaryFolder.newFolder("persistence-export");
+ final var exportTmpFolder = temporaryFolder.newFolder("persistence-export");
actualJournalFilePath = exportTmpFolder.getAbsolutePath() + "/journals/"
+ "member-1-shard-inventory-config" + nextShardNum + "-journal.json";
actualSnapshotFilePath = exportTmpFolder.getAbsolutePath() + "/snapshots/"
@Test
public void testJsonExport() throws Exception {
// Set up the InMemorySnapshotStore.
- final DataTree source = setupInMemorySnapshotStore();
+ final var source = setupInMemorySnapshotStore();
- final DataTreeModification writeMod = source.takeSnapshot().newModification();
- writeMod.write(TestModel.OUTER_LIST_PATH, ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build());
+ final var writeMod = source.takeSnapshot().newModification();
+ writeMod.write(TestModel.OUTER_LIST_PATH, ImmutableNodes.newSystemMapBuilder()
+ .withNodeIdentifier(new NodeIdentifier(TestModel.OUTER_LIST_QNAME))
+ .build());
writeMod.ready();
InMemoryJournal.addEntry(shardID.toString(), 0, DUMMY_DATA);
// Add some ModificationPayload entries
for (int i = 1; i <= nListEntries; i++) {
- listEntryKeys.add(i);
-
- final YangInstanceIdentifier path = YangInstanceIdentifier.builder(TestModel.OUTER_LIST_PATH)
- .nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, i).build();
-
- final DataTreeModification mod = source.takeSnapshot().newModification();
- mod.merge(path, ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, i));
+ final Integer value = i;
+ listEntryKeys.add(value);
+
+ final var path = YangInstanceIdentifier.builder(TestModel.OUTER_LIST_PATH)
+ .nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, value).build();
+
+ final var mod = source.takeSnapshot().newModification();
+ mod.merge(path, ImmutableNodes.newMapEntryBuilder()
+ .withNodeIdentifier(
+ NodeIdentifierWithPredicates.of(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, value))
+ .withChild(ImmutableNodes.leafNode(TestModel.ID_QNAME, value))
+ .build());
mod.ready();
InMemoryJournal.addEntry(shardID.toString(), i + 1, new SimpleReplicatedLogEntry(i, 1,
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate;
import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
@Before
public void setUp() {
setUpStatic();
- candidate = DataTreeCandidates.fromNormalizedNode(TestModel.TEST_PATH, Builders.containerBuilder()
+ candidate = DataTreeCandidates.fromNormalizedNode(TestModel.TEST_PATH, ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
.withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo"))
.build());
YangInstanceIdentifier leafSetEntryPath = YangInstanceIdentifier.builder(TestModel.TEST_PATH).node(LEAF_SET)
.node(entryPathArg).build();
- candidate = DataTreeCandidates.fromNormalizedNode(leafSetEntryPath, Builders.leafSetEntryBuilder()
- .withNodeIdentifier(entryPathArg)
- .withValue("one")
- .build());
+ candidate = DataTreeCandidates.fromNormalizedNode(leafSetEntryPath, ImmutableNodes.leafSetEntry(entryPathArg));
CommitTransactionPayload payload = CommitTransactionPayload.create(nextTransactionId(), candidate);
assertCandidateEquals(candidate, payload.getCandidate());
}
public void testLeafSetNodeCandidate() throws Exception {
YangInstanceIdentifier leafSetPath = YangInstanceIdentifier.builder(TestModel.TEST_PATH).node(LEAF_SET).build();
- candidate = DataTreeCandidates.fromNormalizedNode(leafSetPath, Builders.leafSetBuilder()
+ candidate = DataTreeCandidates.fromNormalizedNode(leafSetPath, ImmutableNodes.newSystemLeafSetBuilder()
.withNodeIdentifier(new NodeIdentifier(LEAF_SET))
- .withChild(Builders.leafSetEntryBuilder()
- .withNodeIdentifier(new NodeWithValue<>(LEAF_SET, "one"))
- .withValue("one")
- .build())
+ .withChild(ImmutableNodes.leafSetEntry(LEAF_SET, "one"))
.build());
CommitTransactionPayload payload = CommitTransactionPayload.create(nextTransactionId(), candidate);
assertCandidateEquals(candidate, payload.getCandidate());
public void testOrderedLeafSetNodeCandidate() throws Exception {
YangInstanceIdentifier leafSetPath = YangInstanceIdentifier.builder(TestModel.TEST_PATH).node(LEAF_SET).build();
- candidate = DataTreeCandidates.fromNormalizedNode(leafSetPath, Builders.orderedLeafSetBuilder()
+ candidate = DataTreeCandidates.fromNormalizedNode(leafSetPath, ImmutableNodes.newUserLeafSetBuilder()
.withNodeIdentifier(new NodeIdentifier(LEAF_SET))
- .withChild(Builders.leafSetEntryBuilder()
- .withNodeIdentifier(new NodeWithValue<>(LEAF_SET, "one"))
- .withValue("one")
- .build())
+ .withChild(ImmutableNodes.leafSetEntry(LEAF_SET, "one"))
.build());
CommitTransactionPayload payload = CommitTransactionPayload.create(nextTransactionId(), candidate);
assertCandidateEquals(candidate, payload.getCandidate());
import org.opendaylight.mdsal.dom.api.DOMActionService;
import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
import org.opendaylight.mdsal.dom.api.DOMRpcService;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
import scala.concurrent.duration.FiniteDuration;
/**
private final DOMActionProviderService actionProvisionRegistry;
private final DOMActionService actionService;
- private ListenerRegistration<OpsListener> listenerReg;
+ private Registration listenerReg;
private ActorRef opsInvoker;
private ActorRef actionRegistry;
private ActorRef rpcRegistry;
this.rpcProvisionRegistry = requireNonNull(rpcProvisionRegistry);
this.rpcServices = requireNonNull(rpcServices);
this.config = requireNonNull(config);
- this.actionProvisionRegistry = requireNonNull(actionProviderService);
+ actionProvisionRegistry = requireNonNull(actionProviderService);
this.actionService = requireNonNull(actionService);
}
import akka.actor.Address;
import akka.actor.Props;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import org.opendaylight.controller.remote.rpc.registry.ActionRegistry.RemoteActionEndpoint;
import org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.UpdateRemoteEndpoints;
import org.opendaylight.controller.remote.rpc.registry.RpcRegistry.RemoteRpcEndpoint;
-import org.opendaylight.mdsal.dom.api.DOMActionImplementation;
import org.opendaylight.mdsal.dom.api.DOMActionProviderService;
-import org.opendaylight.mdsal.dom.api.DOMRpcImplementation;
import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
-import org.opendaylight.yangtools.concepts.ObjectRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
/**
* Actor handling registration of RPCs and Actions available on remote nodes with the local
* {@link DOMRpcProviderService} and {@link DOMActionProviderService}.
*/
final class OpsRegistrar extends AbstractUntypedActor {
- private final Map<Address, ObjectRegistration<DOMRpcImplementation>> rpcRegs = new HashMap<>();
- private final Map<Address, ObjectRegistration<DOMActionImplementation>> actionRegs = new HashMap<>();
+ private final Map<Address, Registration> rpcRegs = new HashMap<>();
+ private final Map<Address, Registration> actionRegs = new HashMap<>();
private final DOMRpcProviderService rpcProviderService;
private final RemoteOpsProviderConfig config;
private final DOMActionProviderService actionProviderService;
@Override
public void postStop() throws Exception {
- rpcRegs.values().forEach(ObjectRegistration::close);
+ rpcRegs.values().forEach(Registration::close);
rpcRegs.clear();
- actionRegs.values().forEach(ObjectRegistration::close);
+ actionRegs.values().forEach(Registration::close);
actionRegs.clear();
super.postStop();
* Note that when an RPC moves from one remote node to another, we also do not want to expose the gap,
* hence we register all new implementations before closing all registrations.
*/
- final Collection<ObjectRegistration<?>> prevRegs = new ArrayList<>(rpcEndpoints.size());
+ final var prevRegs = new ArrayList<Registration>(rpcEndpoints.size());
for (Entry<Address, Optional<RemoteRpcEndpoint>> e : rpcEndpoints.entrySet()) {
LOG.debug("Updating RPC registrations for {}", e.getKey());
- final ObjectRegistration<DOMRpcImplementation> prevReg;
+ final Registration prevReg;
final Optional<RemoteRpcEndpoint> maybeEndpoint = e.getValue();
if (maybeEndpoint.isPresent()) {
final RemoteRpcEndpoint endpoint = maybeEndpoint.orElseThrow();
}
}
- prevRegs.forEach(ObjectRegistration::close);
+ prevRegs.forEach(Registration::close);
}
/**
* Note that when an Action moves from one remote node to another, we also do not want to expose the gap,
* hence we register all new implementations before closing all registrations.
*/
- final Collection<ObjectRegistration<?>> prevRegs = new ArrayList<>(actionEndpoints.size());
+ final var prevRegs = new ArrayList<Registration>(actionEndpoints.size());
for (Entry<Address, Optional<RemoteActionEndpoint>> e : actionEndpoints.entrySet()) {
LOG.debug("Updating action registrations for {}", e.getKey());
- final ObjectRegistration<DOMActionImplementation> prevReg;
+ final Registration prevReg;
final Optional<RemoteActionEndpoint> maybeEndpoint = e.getValue();
if (maybeEndpoint.isPresent()) {
final RemoteActionEndpoint endpoint = maybeEndpoint.orElseThrow();
}
}
- prevRegs.forEach(ObjectRegistration::close);
+ prevRegs.forEach(Registration::close);
}
}
import org.opendaylight.mdsal.dom.api.DOMActionInstance;
import org.opendaylight.mdsal.dom.api.DOMActionProviderService;
import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier;
-import org.opendaylight.mdsal.dom.api.DOMRpcImplementationRegistration;
import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
import org.opendaylight.yangtools.concepts.ObjectRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
@Mock
private DOMActionProviderService actionService;
@Mock
- private DOMRpcImplementationRegistration<RemoteRpcImplementation> oldReg;
+ private Registration oldReg;
@Mock
- private DOMRpcImplementationRegistration<RemoteRpcImplementation> newReg;
+ private Registration newReg;
@Mock
private ObjectRegistration<RemoteActionImplementation> oldActionReg;
@Mock
public DefaultInstanceIdentifierSupport(@Reference final BindingCodecTree bindingCodecTree,
@Reference final BindingRuntimeContext runtimeContext) {
bindingCodec = bindingCodecTree.getInstanceIdentifierCodec();
- jsonCodec = JSONCodecFactorySupplier.RFC7951.createLazy(runtimeContext.getEffectiveModelContext())
+ jsonCodec = JSONCodecFactorySupplier.RFC7951.createLazy(runtimeContext.modelContext())
.codecFor(new FakeLeafDefinition(), null);
}
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.opendaylight.clustering.it.karaf.cli.AbstractRpcAction;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.rev140818.RegisterCommitCohort;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.rev140818.RegisterCommitCohortInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
@Command(scope = "test-app", name = "register-commit-cohort", description = "Run a register-commit-cohort test")
public class RegisterCommitCohortCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcService;
+ private RpcService rpcService;
@Override
protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.opendaylight.clustering.it.karaf.cli.AbstractRpcAction;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.rev140818.RegisterLoggingDtcl;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.rev140818.RegisterLoggingDtclInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
@Command(scope = "test-app", name = "register-logging-dtcl", description = "Run a register-logging-dtcl test")
public class RegisterLoggingDtclCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcService;
+ private RpcService rpcService;
@Override
protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.opendaylight.clustering.it.karaf.cli.AbstractRpcAction;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.rev140818.RegisterOwnership;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.rev140818.RegisterOwnershipInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
@Command(scope = "test-app", name = "register-ownership", description = "Run a register-ownership test")
public class RegisterOwnershipCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcService;
+ private RpcService rpcService;
@Argument(index = 0, name = "car-id", required = true)
private String carId;
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.opendaylight.clustering.it.karaf.cli.AbstractRpcAction;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.rev140818.StopStressTest;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.rev140818.StopStressTestInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
@Command(scope = "test-app" , name = "stop-stress-test", description = "Run a stop-stress-test")
public class StopStressTestCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcService;
+ private RpcService rpcService;
@Override
protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.opendaylight.clustering.it.karaf.cli.AbstractRpcAction;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.rev140818.StressTest;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.rev140818.StressTestInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
@Command(scope = "test-app" , name = "stress-test", description = "Run a stress-test")
public class StressTestCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcService;
+ private RpcService rpcService;
@Argument(index = 0, name = "rate", required = true)
private int rate;
@Argument(index = 1, name = "count", required = true)
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.opendaylight.clustering.it.karaf.cli.AbstractRpcAction;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.rev140818.UnregisterCommitCohort;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.rev140818.UnregisterCommitCohortInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
@Command(scope = "test-app", name = "unregister-commit-cohort", description = "Run a unregister-commit-cohort test")
public class UnregisterCommitCohortCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcService;
+ private RpcService rpcService;
@Override
protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.opendaylight.clustering.it.karaf.cli.AbstractRpcAction;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.rev140818.UnregisterLoggingDtcls;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.rev140818.UnregisterLoggingDtclsInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
@Command(scope = "test-app", name = "unregister-logging-dtcls", description = "Run and unregister-logging-dtcls test")
public class UnregisterLoggingDtclsCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcService;
+ private RpcService rpcService;
@Override
protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.opendaylight.clustering.it.karaf.cli.AbstractRpcAction;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.rev140818.UnregisterOwnership;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.rev140818.UnregisterOwnershipInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
@Command(scope = "test-app", name = "unregister-ownership", description = "Run an unregister-ownership test")
public class UnregisterOwnershipCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcService;
+ private RpcService rpcService;
@Argument(index = 0, name = "car-id", required = true)
private String carId;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.opendaylight.clustering.it.karaf.cli.AbstractRpcAction;
import org.opendaylight.clustering.it.karaf.cli.InstanceIdentifierSupport;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.purchase.rev140818.BuyCar;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.purchase.rev140818.BuyCarInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.rev140818.CarId;
@Command(scope = "test-app", name = "buy-car", description = "Run a buy-car test")
public class BuyCarCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcService;
+ private RpcService rpcService;
@Reference
private InstanceIdentifierSupport iidSupport;
@Argument(index = 0, name = "person-ref", required = true)
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.opendaylight.clustering.it.karaf.cli.AbstractRpcAction;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.AddShardReplica;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.AddShardReplicaInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
@Command(scope = "test-app", name = "add-shard-replica", description = "Run an add-shard-replica test")
public class AddShardReplicaCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcService;
+ private RpcService rpcService;
@Argument(index = 0, name = "shard-name", required = true)
private String shardName;
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.opendaylight.clustering.it.karaf.cli.AbstractRpcAction;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.CheckPublishNotifications;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.CheckPublishNotificationsInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
description = "Run a check-publish-notifications test")
public class CheckPublishNotificationsCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcService;
+ private RpcService rpcService;
@Argument(index = 0, name = "id", required = true)
private String id;
@Override
protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
return rpcService.getRpc(CheckPublishNotifications.class)
- .invoke(new CheckPublishNotificationsInputBuilder()
- .setId(id)
- .build());
+ .invoke(new CheckPublishNotificationsInputBuilder().setId(id).build());
}
}
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.opendaylight.clustering.it.karaf.cli.AbstractRpcAction;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.IsClientAborted;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.IsClientAbortedInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
@Command(scope = "test-app", name = "is-client-aborted", description = "Run an is-client-aborted test")
public class IsClientAbortedCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcService;
+ private RpcService rpcService;
@Override
protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.opendaylight.clustering.it.karaf.cli.AbstractRpcAction;
import org.opendaylight.clustering.it.karaf.cli.InstanceIdentifierSupport;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.RegisterBoundConstant;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.RegisterBoundConstantInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
@Command(scope = "test-app", name = "register-bound-constant", description = "Run a register-bound-constant test")
public class RegisterBoundConstantCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcService;
+ private RpcService rpcService;
@Reference
private InstanceIdentifierSupport iidSupport;
@Argument(index = 0, name = "context", required = true)
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.opendaylight.clustering.it.karaf.cli.AbstractRpcAction;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.RegisterConstant;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.RegisterConstantInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
@Command(scope = "test-app", name = "register-contact", description = "Run a register-contact test")
public class RegisterConstantCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcService;
+ private RpcService rpcService;
@Argument(index = 0, name = "constant", required = true)
private String constant;
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.opendaylight.clustering.it.karaf.cli.AbstractRpcAction;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.RegisterDefaultConstant;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.RegisterDefaultConstantInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
@Command(scope = "test-app", name = "register-default-constant", description = "Run a register-default-constant test")
public class RegisterDefaultConstantCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcService;
+ private RpcService rpcService;
@Argument(index = 0, name = "constant", required = true)
private String constant;
@Override
protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
return rpcService.getRpc(RegisterDefaultConstant.class)
- .invoke(new RegisterDefaultConstantInputBuilder()
- .setConstant(constant)
- .build());
+ .invoke(new RegisterDefaultConstantInputBuilder().setConstant(constant).build());
}
}
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.opendaylight.clustering.it.karaf.cli.AbstractRpcAction;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.RegisterFlappingSingleton;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.RegisterFlappingSingletonInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
description = "Run a register-flapping-singleton test")
public class RegisterFlappingSingletonCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcService;
+ private RpcService rpcService;
@Override
protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.opendaylight.clustering.it.karaf.cli.AbstractRpcAction;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.RegisterSingletonConstant;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.RegisterSingletonConstantInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
description = "Run a register-singleton-constant text")
public class RegisterSingletonConstantCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcService;
+ private RpcService rpcService;
@Argument(index = 0, name = "constant", required = true)
private String constant;
@Override
protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
return rpcService.getRpc(RegisterSingletonConstant.class)
- .invoke(new RegisterSingletonConstantInputBuilder()
- .setConstant(constant)
- .build());
-
+ .invoke(new RegisterSingletonConstantInputBuilder().setConstant(constant).build());
}
}
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.opendaylight.clustering.it.karaf.cli.AbstractRpcAction;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.RemoveShardReplica;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.RemoveShardReplicaInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
@Command(scope = "test-app", name = "remove-shard-replica", description = "Run a remove-shard-replica test")
public class RemoveShardReplicaCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcService;
+ private RpcService rpcService;
@Argument(index = 0, name = "shard-name", required = true)
private String shardName;
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.opendaylight.clustering.it.karaf.cli.AbstractRpcAction;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.ShutdownShardReplica;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.ShutdownShardReplicaInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
@Command(scope = "test-app", name = "shutdown-shard-replica", description = " Run a shutdown-shard-replica test")
public class ShutdownShardReplicaCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcService;
+ private RpcService rpcService;
@Argument(index = 0, name = "shard-name", required = true)
private String shardName;
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.opendaylight.clustering.it.karaf.cli.AbstractRpcAction;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.StartPublishNotifications;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.StartPublishNotificationsInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
description = "Run a start-publish-notifications test")
public class StartPublishNotificationsCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcService;
+ private RpcService rpcService;
@Argument(index = 0, name = "id", required = true)
private String id;
@Argument(index = 1, name = "seconds", required = true)
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.opendaylight.clustering.it.karaf.cli.AbstractRpcAction;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.SubscribeDdtl;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.SubscribeDdtlInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
@Command(scope = "test-app", name = "subscribe-ddtl", description = "Run a subscribe-ddtl test")
public class SubscribeDdtlCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcService;
+ private RpcService rpcService;
@Override
protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.opendaylight.clustering.it.karaf.cli.AbstractRpcAction;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.SubscribeDtcl;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.SubscribeDtclInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
@Command(scope = "test-app", name = "subscribe-dtcl", description = "Run a subscribe-dtcl test")
public class SubscribeDtclCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcService;
+ private RpcService rpcService;
@Override
protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.opendaylight.clustering.it.karaf.cli.AbstractRpcAction;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.SubscribeYnl;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.SubscribeYnlInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
@Command(scope = "test-app", name = "subscribe-ynl", description = "Run a subscribe-ynl test")
public class SubscribeYnlCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcService;
+ private RpcService rpcService;
@Argument(index = 0, name = "id", required = true)
private String id;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.opendaylight.clustering.it.karaf.cli.AbstractRpcAction;
import org.opendaylight.clustering.it.karaf.cli.InstanceIdentifierSupport;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnregisterBoundConstant;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnregisterBoundConstantInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
@Command(scope = "test-app", name = "unregister-bound-constant", description = "Run an unregister-bound-constant test")
public class UnregisterBoundConstantCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcService;
+ private RpcService rpcService;
@Reference
private InstanceIdentifierSupport iidSupport;
@Argument(index = 0, name = "context", required = true)
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.opendaylight.clustering.it.karaf.cli.AbstractRpcAction;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnregisterConstant;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnregisterConstantInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
@Command(scope = "test-app", name = "unregister-constant", description = "Run an unregister-constant test")
public class UnregisterConstantCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcService;
+ private RpcService rpcService;
@Override
protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.opendaylight.clustering.it.karaf.cli.AbstractRpcAction;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnregisterDefaultConstant;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnregisterDefaultConstantInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
description = "Run an unregister-default-constant test")
public class UnregisterDefaultConstantCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcService;
+ private RpcService rpcService;
@Override
protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.opendaylight.clustering.it.karaf.cli.AbstractRpcAction;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnregisterFlappingSingleton;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnregisterFlappingSingletonInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
description = "Run an unregister-flapping-singleton test")
public class UnregisterFlappingSingletonCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcService;
+ private RpcService rpcService;
@Override
protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.opendaylight.clustering.it.karaf.cli.AbstractRpcAction;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnregisterSingletonConstant;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnregisterSingletonConstantInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
description = "Run an unregister-singleton-constant test")
public class UnregisterSingletonConstantCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcService;
+ private RpcService rpcService;
@Override
protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.opendaylight.clustering.it.karaf.cli.AbstractRpcAction;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnsubscribeDdtl;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnsubscribeDdtlInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
@Command(scope = "test-app", name = "unsubscribe-ddtl", description = "Run an unsubscribe-ddtl test")
public class UnsubscribeDdtlCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcService;
+ private RpcService rpcService;
@Override
protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.opendaylight.clustering.it.karaf.cli.AbstractRpcAction;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnsubscribeDtcl;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnsubscribeDtclInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
@Command(scope = "test-app", name = "unsubscribe-dtcl", description = "Run an unsubscribe-dtcl test")
public class UnsubscribeDtclCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcService;
+ private RpcService rpcService;
@Override
protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.opendaylight.clustering.it.karaf.cli.AbstractRpcAction;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnsubscribeYnl;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnsubscribeYnlInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
@Command(scope = "test-app", name = "unsubscribe-ynl", description = "Run an unsubscribe-ynl test")
public class UnsubscribeYnlCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcService;
+ private RpcService rpcService;
@Argument(index = 0, name = "id", required = true)
private String id;
@Override
protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
return rpcService.getRpc(UnsubscribeYnl.class)
- .invoke(new UnsubscribeYnlInputBuilder()
- .setId(id)
- .build());
+ .invoke(new UnsubscribeYnlInputBuilder().setId(id).build());
}
}
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.opendaylight.clustering.it.karaf.cli.AbstractRpcAction;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.WriteTransactions;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.WriteTransactionsInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
@Command(scope = "test-app", name = "write-transactions", description = "Run a write-transactions test")
public class WriteTransactionsCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcService;
+ private RpcService rpcService;
@Argument(index = 0, name = "id", required = true)
private String id;
@Argument(index = 1, name = "seconds", required = true)
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.opendaylight.clustering.it.karaf.cli.AbstractRpcAction;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.people.rev140818.AddPerson;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.people.rev140818.AddPersonInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.people.rev140818.PersonId;
@Command(scope = "test-app", name = "add-person", description = " Run an add-person test")
public class AddPersonCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcService;
+ private RpcService rpcService;
@Argument(index = 0, name = "id", required = true)
private PersonId id;
@Argument(index = 1, name = "gender", required = true)
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.opendaylight.clustering.it.karaf.cli.AbstractRpcAction;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.controller.basic.rpc.test.rev160120.BasicGlobal;
import org.opendaylight.yang.gen.v1.urn.opendaylight.controller.basic.rpc.test.rev160120.BasicGlobalInputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
@Command(scope = "test-app", name = "global-basic", description = "Run a global-basic test")
public class BasicGlobalCommand extends AbstractRpcAction {
@Reference
- private RpcConsumerRegistry rpcService;
+ private RpcService rpcService;
@Override
protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
</dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-singleton-common-api</artifactId>
+ <artifactId>mdsal-singleton-api</artifactId>
</dependency>
<dependency>
<groupId>org.opendaylight.controller.samples</groupId>
import javax.inject.Inject;
import javax.inject.Singleton;
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.mdsal.singleton.api.ClusterSingletonService;
+import org.opendaylight.mdsal.singleton.api.ClusterSingletonServiceProvider;
+import org.opendaylight.mdsal.singleton.api.ServiceGroupIdentifier;
import org.opendaylight.yang.gen.v1.urn.opendaylight.controller.basic.rpc.test.rev160120.BasicGlobal;
import org.opendaylight.yang.gen.v1.urn.opendaylight.controller.basic.rpc.test.rev160120.BasicGlobalOutputBuilder;
import org.opendaylight.yangtools.concepts.Registration;
@Component(service = { })
public final class BasicRpcTestProvider implements ClusterSingletonService {
private static final Logger LOG = LoggerFactory.getLogger(BasicRpcTestProvider.class);
- private static final ServiceGroupIdentifier IDENTIFIER = ServiceGroupIdentifier.create("Basic-rpc-test");
+ private static final ServiceGroupIdentifier IDENTIFIER = new ServiceGroupIdentifier("Basic-rpc-test");
private final RpcProviderService rpcProviderRegistry;
private final Registration singletonRegistration;
*/
package org.opendaylight.controller.clustering.it.provider;
-import org.opendaylight.mdsal.binding.api.DataObjectModification;
-import org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType;
+import java.util.List;
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;
import org.slf4j.LoggerFactory;
private static final Logger LOG = LoggerFactory.getLogger(CarDataTreeChangeListener.class);
@Override
- public void onDataTreeChanged(final java.util.Collection<DataTreeModification<Cars>> changes) {
+ public void onDataTreeChanged(final List<DataTreeModification<Cars>> changes) {
if (LOG.isTraceEnabled()) {
- for (DataTreeModification<Cars> change : changes) {
+ for (var change : changes) {
outputChanges(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();
+ final var rootNode = change.getRootNode();
+ final var modificationType = rootNode.modificationType();
+ final var rootIdentifier = change.getRootPath().path();
switch (modificationType) {
- case WRITE:
- case SUBTREE_MODIFIED: {
+ case WRITE, SUBTREE_MODIFIED -> {
LOG.trace("onDataTreeChanged - Cars config with path {} was added or changed from {} to {}",
- rootIdentifier, rootNode.getDataBefore(), rootNode.getDataAfter());
- break;
+ rootIdentifier, rootNode.dataBefore(), rootNode.dataAfter());
}
- case DELETE: {
+ case DELETE -> {
LOG.trace("onDataTreeChanged - Cars config with path {} was deleted", rootIdentifier);
- break;
}
- default: {
+ default -> {
LOG.trace("onDataTreeChanged called with unknown modificationType: {}", modificationType);
- break;
}
}
}
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.dom.api.DOMDataBroker.CommitCohortExtension;
import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
import org.opendaylight.mdsal.eos.binding.api.Entity;
import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipListener;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.rev140818.UnregisterOwnershipOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.rev140818.cars.CarEntry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.rev140818.cars.CarEntryBuilder;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.Rpc;
private final AtomicLong succcessCounter = new AtomicLong();
private final AtomicLong failureCounter = new AtomicLong();
- private final EntityOwnershipListener ownershipListener =
- ownershipChange -> LOG.info("ownershipChanged: {}", ownershipChange);
+ private final EntityOwnershipListener ownershipListener = (entity, change, inJeopardy) ->
+ LOG.info("ownershipChanged: entity={} change={} inJeopardy={}", entity, change, inJeopardy);
private final AtomicBoolean registeredListener = new AtomicBoolean();
-
- private final Set<ListenerRegistration<?>> carsDclRegistrations = ConcurrentHashMap.newKeySet();
-
+ private final AtomicReference<Registration> commitCohortReg = new AtomicReference<>();
+ private final Set<ObjectRegistration<?>> carsDclRegistrations = ConcurrentHashMap.newKeySet();
private final Set<Registration> regs = new HashSet<>();
- private final Set<ListenerRegistration<CarDataTreeChangeListener>> carsDtclRegistrations =
- ConcurrentHashMap.newKeySet();
+ private final Set<Registration> carsDtclRegistrations = ConcurrentHashMap.newKeySet();
private volatile Thread testThread;
private volatile boolean stopThread;
- private final AtomicReference<DOMDataTreeCommitCohortRegistration<CarEntryDataTreeCommitCohort>> commitCohortReg =
- new AtomicReference<>();
@Inject
@Activate
private ListenableFuture<RpcResult<RegisterLoggingDtclOutput>> registerLoggingDtcl(
final RegisterLoggingDtclInput input) {
LOG.info("Registering a new CarDataTreeChangeListener");
- final ListenerRegistration<CarDataTreeChangeListener> carsDtclRegistration =
- dataProvider.registerDataTreeChangeListener(CARS_DTID, new CarDataTreeChangeListener());
-
- carsDtclRegistrations.add(carsDtclRegistration);
+ final var reg = dataProvider.registerDataTreeChangeListener(CARS_DTID, new CarDataTreeChangeListener());
+ carsDtclRegistrations.add(reg);
return RpcResultBuilder.success(new RegisterLoggingDtclOutputBuilder().build()).buildFuture();
}
LOG.info("Unregistering the CarDataTreeChangeListener(s)");
synchronized (carsDtclRegistrations) {
int numListeners = 0;
- for (ListenerRegistration<CarDataTreeChangeListener> carsDtclRegistration : carsDtclRegistrations) {
+ for (var carsDtclRegistration : carsDtclRegistrations) {
carsDtclRegistration.close();
numListeners++;
}
}
private void closeCommitCohortRegistration() {
- final DOMDataTreeCommitCohortRegistration<CarEntryDataTreeCommitCohort> reg = commitCohortReg.getAndSet(null);
+ final var reg = commitCohortReg.getAndSet(null);
if (reg != null) {
reg.close();
LOG.info("Unregistered commit cohort");
return RpcResultBuilder.success(new RegisterCommitCohortOutputBuilder().build()).buildFuture();
}
- final DOMDataTreeCommitCohortRegistry commitCohortRegistry = domDataBroker.getExtensions().getInstance(
- DOMDataTreeCommitCohortRegistry.class);
-
+ final var commitCohortRegistry = domDataBroker.extension(CommitCohortExtension.class);
if (commitCohortRegistry == null) {
// Shouldn't happen
return RpcResultBuilder.<RegisterCommitCohortOutput>failed().withError(ErrorType.APPLICATION,
// to address all list entries, the second path argument is wild-carded by specifying just the CarEntry.QNAME.
final YangInstanceIdentifier carEntryPath = YangInstanceIdentifier.builder(
YangInstanceIdentifier.of(Cars.QNAME)).node(CarEntry.QNAME).node(CarEntry.QNAME).build();
- commitCohortReg.set(commitCohortRegistry.registerCommitCohort(new DOMDataTreeIdentifier(
+ commitCohortReg.set(commitCohortRegistry.registerCommitCohort(DOMDataTreeIdentifier.of(
LogicalDatastoreType.CONFIGURATION, carEntryPath), new CarEntryDataTreeCommitCohort()));
LOG.info("Registered commit cohort");
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.DOMDataBroker.DataTreeChangeExtension;
import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
-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.mdsal.singleton.api.ClusterSingletonServiceProvider;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.AddShardReplica;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.AddShardReplicaInput;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.AddShardReplicaOutput;
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.target.rev170215.IdSequence;
import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.concepts.ObjectRegistration;
import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
private final NotificationService notificationService;
private final ClusterSingletonServiceProvider singletonService;
private final DOMRpcProviderService domRpcService;
- private final DOMDataTreeChangeService domDataTreeChangeService;
-
- private final Map<InstanceIdentifier<?>, DOMRpcImplementationRegistration<RoutedGetConstantService>>
- routedRegistrations = new HashMap<>();
+ private final DataTreeChangeExtension dataTreeChangeExtension;
+ private final Map<InstanceIdentifier<?>, Registration> routedRegistrations = new HashMap<>();
private final Map<String, ObjectRegistration<YnlListener>> ynlRegistrations = new HashMap<>();
+ private final Map<String, PublishNotificationsTask> publishNotificationsTasks = new HashMap<>();
- private DOMRpcImplementationRegistration<GetConstantService> globalGetConstantRegistration = null;
- private ClusterSingletonServiceRegistration getSingletonConstantRegistration;
+ private Registration globalGetConstantRegistration = null;
+ private Registration getSingletonConstantRegistration;
private FlappingSingletonService flappingSingletonService;
- private ListenerRegistration<DOMDataTreeChangeListener> dtclReg;
+ private Registration dtclReg;
private IdIntsListener idIntsListener;
- private final Map<String, PublishNotificationsTask> publishNotificationsTasks = new HashMap<>();
@Inject
@Activate
this.domDataBroker = domDataBroker;
this.configDataStore = configDataStore;
- domDataTreeChangeService = domDataBroker.getExtensions().getInstance(DOMDataTreeChangeService.class);
+ dataTreeChangeExtension = domDataBroker.extension(DataTreeChangeExtension.class);
registration = rpcRegistry.registerRpcImplementations(ImmutableClassToInstanceMap.<Rpc<?, ?>>builder()
.put(UnregisterSingletonConstant.class, this::unregisterSingletonConstant)
idIntsListener = new IdIntsListener();
- dtclReg = domDataTreeChangeService.registerDataTreeChangeListener(
+ dtclReg = dataTreeChangeExtension.registerDataTreeChangeListener(
new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, WriteTransactionsHandler.ID_INT_YID),
idIntsListener);
final UnregisterBoundConstantInput input) {
LOG.info("In unregisterBoundConstant - {}", input);
- final DOMRpcImplementationRegistration<RoutedGetConstantService> rpcRegistration =
- routedRegistrations.remove(input.getContext());
-
+ final var rpcRegistration = routedRegistrations.remove(input.getContext());
if (rpcRegistration == null) {
return RpcResultBuilder.<UnregisterBoundConstantOutput>failed()
.withError(ErrorType.RPC, ErrorTag.DATA_MISSING,
.buildFuture();
}
- final DOMRpcImplementationRegistration<RoutedGetConstantService> rpcRegistration =
- RoutedGetConstantService.registerNew(bindingNormalizedNodeSerializer, domRpcService,
- input.getConstant(), input.getContext());
+ final var rpcRegistration = RoutedGetConstantService.registerNew(bindingNormalizedNodeSerializer, domRpcService,
+ input.getConstant(), input.getContext());
routedRegistrations.put(input.getContext(), rpcRegistration);
return RpcResultBuilder.success(new RegisterBoundConstantOutputBuilder().build()).buildFuture();
*/
package org.opendaylight.controller.clustering.it.provider.impl;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
-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.mdsal.singleton.api.ClusterSingletonService;
+import org.opendaylight.mdsal.singleton.api.ClusterSingletonServiceProvider;
+import org.opendaylight.mdsal.singleton.api.ServiceGroupIdentifier;
+import org.opendaylight.yangtools.concepts.Registration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class FlappingSingletonService implements ClusterSingletonService {
private static final Logger LOG = LoggerFactory.getLogger(FlappingSingletonService.class);
private static final ServiceGroupIdentifier SERVICE_GROUP_IDENTIFIER =
- ServiceGroupIdentifier.create("flapping-singleton-service");
+ new ServiceGroupIdentifier("flapping-singleton-service");
private final ClusterSingletonServiceProvider singletonServiceProvider;
private final AtomicBoolean active = new AtomicBoolean(true);
-
private final AtomicLong flapCount = new AtomicLong();
- private volatile ClusterSingletonServiceRegistration registration;
+
+ private volatile Registration registration;
public FlappingSingletonService(final ClusterSingletonServiceProvider singletonServiceProvider) {
LOG.debug("Registering flapping-singleton-service.");
-
- this.singletonServiceProvider = singletonServiceProvider;
+ this.singletonServiceProvider = requireNonNull(singletonServiceProvider);
registration = singletonServiceProvider.registerClusterSingletonService(this);
}
import com.google.common.util.concurrent.ListenableFuture;
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.concepts.Registration;
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.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
this.constant = constant;
}
- public static DOMRpcImplementationRegistration<GetConstantService> registerNew(
- final DOMRpcProviderService rpcProviderService, final String constant) {
+ public static Registration registerNew(final DOMRpcProviderService rpcProviderService, final String constant) {
LOG.debug("Registering get-constant service, constant value: {}", constant);
return rpcProviderService.registerRpcImplementation(new GetConstantService(constant),
DOMRpcIdentifier.create(GET_CONSTANT));
public ListenableFuture<DOMRpcResult> invokeRpc(final DOMRpcIdentifier rpc, final ContainerNode input) {
LOG.debug("get-constant invoked, current value: {}", constant);
- return Futures.immediateFuture(new DefaultDOMRpcResult(Builders.containerBuilder()
+ return Futures.immediateFuture(new DefaultDOMRpcResult(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(OUTPUT))
.withChild(ImmutableNodes.leafNode(CONSTANT, constant))
.build()));
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.concepts.Registration;
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.XMLNamespace;
import org.opendaylight.yangtools.yang.common.YangConstants;
-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.impl.schema.Builders;
this.constant = constant;
}
- public static DOMRpcImplementationRegistration<RoutedGetConstantService> registerNew(
- final BindingNormalizedNodeSerializer codec, final DOMRpcProviderService rpcProviderService,
- final String constant, final InstanceIdentifier<?> context) {
+ public static Registration registerNew(final BindingNormalizedNodeSerializer codec,
+ final DOMRpcProviderService rpcProviderService, final String constant,
+ final InstanceIdentifier<?> context) {
LOG.debug("Registering get-contexted-constant on context: {}, with value: {}", context, constant);
- final YangInstanceIdentifier yid = codec.toYangInstanceIdentifier(context);
- final DOMRpcIdentifier id = DOMRpcIdentifier.create(GET_CONTEXTED_CONSTANT, yid);
+ final var yid = codec.toYangInstanceIdentifier(context);
+ final var id = DOMRpcIdentifier.create(GET_CONTEXTED_CONSTANT, yid);
return rpcProviderService.registerRpcImplementation(new RoutedGetConstantService(constant), id);
}
import com.google.common.util.concurrent.ListenableFuture;
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.mdsal.singleton.api.ClusterSingletonService;
+import org.opendaylight.mdsal.singleton.api.ClusterSingletonServiceProvider;
+import org.opendaylight.mdsal.singleton.api.ServiceGroupIdentifier;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
import org.opendaylight.yangtools.yang.common.Revision;
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");
+ new ServiceGroupIdentifier("get-singleton-constant-service");
private final DOMRpcProviderService rpcProviderService;
private final String constant;
- private DOMRpcImplementationRegistration<SingletonGetConstantService> rpcRegistration = null;
+ private Registration rpcRegistration = null;
private SingletonGetConstantService(final DOMRpcProviderService rpcProviderService, final String constant) {
this.rpcProviderService = rpcProviderService;
this.constant = constant;
}
- public static ClusterSingletonServiceRegistration registerNew(
- final ClusterSingletonServiceProvider singletonService, final DOMRpcProviderService rpcProviderService,
- final String constant) {
+ public static Registration registerNew(final ClusterSingletonServiceProvider singletonService,
+ final DOMRpcProviderService rpcProviderService, final String constant) {
LOG.debug("Registering get-singleton-constant into ClusterSingletonService, value {}", constant);
return singletonService.registerClusterSingletonService(
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.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
import java.util.LinkedHashSet;
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.opendaylight.yangtools.yang.common.Empty;
import org.opendaylight.yangtools.yang.common.ErrorType;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.slf4j.LoggerFactory;
public abstract class WriteTransactionsHandler extends AbstractTransactionHandler {
- private static final class Chained extends WriteTransactionsHandler implements DOMTransactionChainListener {
+ private static final class Chained extends WriteTransactionsHandler implements FutureCallback<Empty> {
private final SplittableRandom random = new SplittableRandom();
private final DOMTransactionChain transactionChain;
Chained(final DOMDataBroker dataBroker, final YangInstanceIdentifier idListItem,
final WriteTransactionsInput input) {
super(idListItem, input);
- transactionChain = dataBroker.createTransactionChain(this);
+ transactionChain = dataBroker.createTransactionChain();
+ transactionChain.addCallback(this);
}
@Override
}
@Override
- public void onTransactionChainFailed(final DOMTransactionChain chain, final DOMDataTreeTransaction transaction,
- final Throwable cause) {
+ public void onFailure(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 DOMTransactionChain chain) {
+ public void onSuccess(final Empty result) {
LOG.debug("Transaction chain closed successfully.");
}
}
import org.opendaylight.controller.sample.kitchen.api.KitchenServiceRuntimeMXBean;
import org.opendaylight.mdsal.binding.api.NotificationService;
import org.opendaylight.mdsal.binding.api.NotificationService.CompositeListener;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.MakeToast;
import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.MakeToastInputBuilder;
import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.MakeToastOutput;
@Inject
@Activate
- public KitchenServiceImpl(@Reference final RpcConsumerRegistry rpcRegistry,
+ public KitchenServiceImpl(@Reference final RpcService rpcService,
@Reference final NotificationService notifService) {
super("KitchenService", "toaster-consumer", null);
- makeToast = rpcRegistry.getRpc(MakeToast.class);
+ makeToast = rpcService.getRpc(MakeToast.class);
reg = notifService.registerCompositeListener(new CompositeListener(Set.of(
new CompositeListener.Component<>(ToasterOutOfBread.class, notification -> {
LOG.info("ToasterOutOfBread notification");
package org.opendaylight.controller.sample.toaster.provider;
import static java.util.Objects.requireNonNull;
-import static org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType.DELETE;
-import static org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType.WRITE;
import static org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION;
import static org.opendaylight.mdsal.common.api.LogicalDatastoreType.OPERATIONAL;
import static org.opendaylight.yangtools.yang.common.ErrorType.APPLICATION;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.SettableFuture;
-import java.util.Collection;
+import java.util.List;
import java.util.Optional;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.controller.md.sal.common.util.jmx.AbstractMXBean;
import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.DataObjectModification;
import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
import org.opendaylight.mdsal.binding.api.DataTreeModification;
import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterOutOfBreadBuilder;
import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterRestocked;
import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterRestockedBuilder;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.Rpc;
import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.opendaylight.yangtools.yang.common.Uint32;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
private final DataBroker dataBroker;
private final NotificationPublishService notificationProvider;
- private final ListenerRegistration<OpendaylightToaster> dataTreeChangeListenerRegistration;
+ private final Registration dataTreeChangeListenerRegistration;
private final Registration reg;
private final ExecutorService executor;
LOG.info("Initializing...");
dataTreeChangeListenerRegistration = requireNonNull(dataBroker, "dataBroker must be set")
- .registerDataTreeChangeListener(DataTreeIdentifier.create(CONFIGURATION, TOASTER_IID), this);
+ .registerTreeChangeListener(DataTreeIdentifier.of(CONFIGURATION, TOASTER_IID), this);
try {
setToasterStatusUp(null).get();
} catch (InterruptedException | ExecutionException e) {
* Implemented from the DataTreeChangeListener interface.
*/
@Override
- public void onDataTreeChanged(final Collection<DataTreeModification<Toaster>> changes) {
- for (DataTreeModification<Toaster> change: changes) {
- DataObjectModification<Toaster> rootNode = change.getRootNode();
- if (rootNode.getModificationType() == WRITE) {
- Toaster oldToaster = rootNode.getDataBefore();
- Toaster newToaster = rootNode.getDataAfter();
- LOG.info("onDataTreeChanged - Toaster config with path {} was added or replaced: "
- + "old Toaster: {}, new Toaster: {}", change.getRootPath().getRootIdentifier(),
- oldToaster, newToaster);
-
- Uint32 darkness = newToaster.getDarknessFactor();
- if (darkness != null) {
- darknessFactor.set(darkness.toJava());
+ public void onDataTreeChanged(final List<DataTreeModification<Toaster>> changes) {
+ for (var change: changes) {
+ final var rootNode = change.getRootNode();
+ switch (rootNode.modificationType()) {
+ case WRITE -> {
+ final var oldToaster = rootNode.dataBefore();
+ final var newToaster = rootNode.dataAfter();
+ LOG.info("onDataTreeChanged - Toaster config with path {} was added or replaced: old Toaster: {}, "
+ + "new Toaster: {}", change.getRootPath().path(), oldToaster, newToaster);
+
+ final var darkness = newToaster.getDarknessFactor();
+ if (darkness != null) {
+ darknessFactor.set(darkness.toJava());
+ }
+ }
+ case DELETE -> LOG.info("onDataTreeChanged - Toaster config with path {} was deleted: old Toaster: {}",
+ change.getRootPath().path(), rootNode.dataBefore());
+ default -> {
+ // No-op
}
- } else if (rootNode.getModificationType() == DELETE) {
- LOG.info("onDataTreeChanged - Toaster config with path {} was deleted: old Toaster: {}",
- change.getRootPath().getRootIdentifier(), rootNode.getDataBefore());
}
}
}
* RPC call implemented from the ToasterService interface that cancels the current toast, if any.
*/
private ListenableFuture<RpcResult<CancelToastOutput>> cancelToast(final CancelToastInput input) {
- Future<?> current = currentMakeToastTask.getAndSet(null);
+ final var current = currentMakeToastTask.getAndSet(null);
if (current != null) {
current.cancel(true);
}