<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>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>controller-artifacts</artifactId>
- <version>8.0.4</version>
+ <version>9.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>controller-artifacts</artifactId>
- <version>8.0.4</version>
+ <version>9.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
-->
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-lispflowmapping-inmemorydb">
<feature name="odl-lispflowmapping-inmemorydb">
- <feature version="[8,9)">odl-mdsal-broker</feature>
+ <feature version="[9,10)">odl-mdsal-broker</feature>
</feature>
</features>
<dependency>
<groupId>org.opendaylight.netconf</groupId>
<artifactId>netconf-artifacts</artifactId>
- <version>6.0.6</version>
+ <version>7.0.0</version>
<scope>import</scope>
<type>pom</type>
</dependency>
-->
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-lispflowmapping-mappingservice">
<feature name="odl-lispflowmapping-mappingservice">
- <feature version="[6,7)">odl-restconf</feature>
+ <feature version="[7,8)">odl-restconf</feature>
</feature>
</features>
<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>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-lispflowmapping-models">
<feature name="odl-lispflowmapping-models">
<feature version="[13,14)">odl-apache-commons-lang3</feature>
- <feature version="[12,13)">odl-mdsal-model-rfc6991</feature>
+ <feature version="[13,14)">odl-mdsal-model-rfc6991</feature>
</feature>
</features>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>controller-artifacts</artifactId>
- <version>8.0.4</version>
+ <version>9.0.0</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.opendaylight.netconf</groupId>
<artifactId>netconf-artifacts</artifactId>
- <version>6.0.6</version>
+ <version>7.0.0</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-lispflowmapping-southbound">
<feature name="odl-lispflowmapping-southbound">
<feature version="[12,14)">odl-netty-4</feature>
- <feature version="[8,9)">odl-mdsal-broker</feature>
- <feature version="[6,7)">odl-restconf</feature>
+ <feature version="[9,10)">odl-mdsal-broker</feature>
+ <feature version="[7,8)">odl-restconf</feature>
</feature>
</features>
<parent>
<groupId>org.opendaylight.controller</groupId>
<artifactId>mdsal-it-parent</artifactId>
- <version>8.0.4</version>
+ <version>9.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>binding-parent</artifactId>
- <version>12.0.4</version>
+ <version>13.0.0</version>
<relativePath/>
</parent>
import static java.util.Objects.requireNonNull;
+import com.google.common.annotations.VisibleForTesting;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import org.opendaylight.lispflowmapping.lisp.util.LispAddressStringifier;
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.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.lfm.mappingservice.rev150906.mapping.database.LastUpdated;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.mapping.database.LastUpdatedBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.mapping.database.VirtualNetworkIdentifier;
+import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.Empty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
*
* @author Lorand Jakab
*/
-public class DataStoreBackEnd implements TransactionChainListener {
+public class DataStoreBackEnd {
private static final Logger LOG = LoggerFactory.getLogger(DataStoreBackEnd.class);
private static final InstanceIdentifier<MappingDatabase> DATABASE_ROOT =
InstanceIdentifier.create(MappingDatabase.class);
@SuppressFBWarnings(value = "MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR", justification = "Non-final for mocking")
public DataStoreBackEnd(DataBroker broker) {
LOG.debug("Creating DataStoreBackEnd transaction chain...");
- configTxChain = broker.createMergingTransactionChain(this);
- operTxChain = broker.createMergingTransactionChain(this);
+ configTxChain = broker.createMergingTransactionChain();
+ operTxChain = broker.createMergingTransactionChain();
+ configTxChain.addCallback(new FutureCallback<Empty>() {
+ @Override
+ public void onSuccess(Empty result) {
+ onTransactionChainSuccessful(configTxChain);
+ }
+
+ @Override
+ public void onFailure(Throwable cause) {
+ onTransactionChainFailed(configTxChain, cause);
+ }
+ });
+ operTxChain.addCallback(new FutureCallback<Empty>() {
+ @Override
+ public void onSuccess(Empty result) {
+ onTransactionChainSuccessful(operTxChain);
+ }
+
+ @Override
+ public void onFailure(Throwable cause) {
+ onTransactionChainFailed(operTxChain, cause);
+ }
+ });
}
public void addAuthenticationKey(AuthenticationKey authenticationKey) {
public void saveLastUpdateTimestamp() {
Long timestamp = System.currentTimeMillis();
- LOG.debug("MD-SAL: Saving last update timestamp to operational datastore: {}", new Date(timestamp).toString());
+ LOG.debug("MD-SAL: Saving last update timestamp to operational datastore: {}", new Date(timestamp));
writePutTransaction(LAST_UPDATED, new LastUpdatedBuilder().setLastUpdated(timestamp).build(),
LogicalDatastoreType.OPERATIONAL, "Couldn't save last update timestamp to operational datastore");
}
};
}
- private <U extends org.opendaylight.yangtools.yang.binding.DataObject> void writePutTransaction(
- InstanceIdentifier<U> addIID, U data, LogicalDatastoreType logicalDatastoreType, String errMsg) {
+ private <U extends DataObject> void writePutTransaction(InstanceIdentifier<U> addIID, U data,
+ LogicalDatastoreType logicalDatastoreType, String errMsg) {
WriteTransaction writeTx = getChain(logicalDatastoreType).newWriteOnlyTransaction();
// TODO: is is a utility method, hence we do not have enough lifecycle knowledge to use plain put()
writeTx.mergeParentStructurePut(logicalDatastoreType, addIID, data);
writeTx.commit().addCallback(new FutureCallback<CommitInfo>() {
-
@Override
public void onSuccess(CommitInfo result) {
+ // No-op
}
@Override
}, MoreExecutors.directExecutor());
}
- private <U extends org.opendaylight.yangtools.yang.binding.DataObject> U readTransaction(
- InstanceIdentifier<U> readIID, LogicalDatastoreType logicalDatastoreType) {
+ private <U extends DataObject> U readTransaction(InstanceIdentifier<U> readIID,
+ LogicalDatastoreType logicalDatastoreType) {
final ListenableFuture<Optional<U>> readFuture;
try (ReadTransaction readTx = getChain(logicalDatastoreType).newReadOnlyTransaction()) {
readFuture = readTx.read(logicalDatastoreType, readIID);
return null;
}
- private <U extends org.opendaylight.yangtools.yang.binding.DataObject> void deleteTransaction(
- InstanceIdentifier<U> deleteIID, LogicalDatastoreType logicalDatastoreType, String errMsg) {
+ private <U extends DataObject> void deleteTransaction(InstanceIdentifier<U> deleteIID,
+ LogicalDatastoreType logicalDatastoreType, String errMsg) {
WriteTransaction writeTx = getChain(logicalDatastoreType).newWriteOnlyTransaction();
writeTx.delete(logicalDatastoreType, deleteIID);
writeTx.commit().addCallback(new FutureCallback<CommitInfo>() {
}, MoreExecutors.directExecutor());
}
- @Override
- public void onTransactionChainFailed(TransactionChain chain, Transaction transaction, Throwable cause) {
- LOG.error("Broken chain {} in DataStoreBackEnd, transaction {}, cause {}", chain, transaction.getIdentifier(),
- cause.getMessage());
+ @VisibleForTesting
+ void onTransactionChainFailed(TransactionChain chain, Throwable cause) {
+ LOG.error("Broken chain {} in DataStoreBackEnd, cause {}", chain, cause.getMessage());
}
- @Override
- public void onTransactionChainSuccessful(TransactionChain chain) {
+ @VisibleForTesting
+ void onTransactionChainSuccessful(TransactionChain chain) {
LOG.info("DataStoreBackEnd closed successfully, chain {}", chain);
}
import org.opendaylight.lispflowmapping.lisp.util.LispAddressUtil;
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.WriteTransaction;
import org.opendaylight.mdsal.common.api.CommitInfo;
PowerMockito.when(LoggerFactory.getLogger(DataStoreBackEnd.class))
.thenReturn(logMock);
Mockito.when(logMock.isDebugEnabled()).thenReturn(true);
- Mockito.when(brokerMock.createMergingTransactionChain(Mockito.any(DataStoreBackEnd.class)))
+ Mockito.when(brokerMock.createMergingTransactionChain())
.thenReturn(txChainMock);
dataStoreBackEnd = PowerMockito.spy(new DataStoreBackEnd(brokerMock));
*/
@Test
public void onTransactionChainFailedTest() {
- Transaction asyncTransactionMock = Mockito.mock(Transaction.class);
- Mockito.when(asyncTransactionMock.getIdentifier()).thenReturn(new Object());
- dataStoreBackEnd.onTransactionChainFailed(Mockito.mock(TransactionChain.class), asyncTransactionMock,
- Mockito.mock(Throwable.class));
+ dataStoreBackEnd.onTransactionChainFailed(Mockito.mock(TransactionChain.class), Mockito.mock(Throwable.class));
}
/**
<!-- needed for osgi console -->
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-singleton-common-api</artifactId>
+ <artifactId>mdsal-singleton-api</artifactId>
</dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-singleton-dom-impl</artifactId>
+ <artifactId>mdsal-singleton-impl</artifactId>
</dependency>
</dependencies>
import org.opendaylight.lispflowmapping.lisp.util.LispAddressStringifier;
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.singleton.common.api.ClusterSingletonService;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
-import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
+import org.opendaylight.mdsal.binding.api.RpcService;
+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.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapNotify;
immediate = true, property = "type=default")
public class LispMappingService implements IFlowMapping, IMapRequestResultHandler,
IMapNotifyHandler, AutoCloseable, ClusterSingletonService {
- private static final String LISPFLOWMAPPING_ENTITY_NAME = "lispflowmapping";
- private static final ServiceGroupIdentifier SERVICE_GROUP_IDENTIFIER = ServiceGroupIdentifier.create(
- LISPFLOWMAPPING_ENTITY_NAME);
+ private static final ServiceGroupIdentifier SERVICE_GROUP_IDENTIFIER =
+ new ServiceGroupIdentifier("lispflowmapping");
private static final Logger LOG = LoggerFactory.getLogger(LispMappingService.class);
@Activate
public LispMappingService(@Reference final IMappingService mappingService,
@Reference final ClusterSingletonServiceProvider clusterSingletonService,
- @Reference final RpcConsumerRegistry rpcService, @Reference final NotificationService notificationService) {
+ @Reference final RpcService rpcService, @Reference final NotificationService notificationService) {
this.mapService = mappingService;
sendMapRequest = rpcService.getRpc(SendMapRequest.class);
sendMapReply = rpcService.getRpc(SendMapReply.class);
*/
package org.opendaylight.lispflowmapping.implementation.mdsal;
-import org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener;
import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
* The superclass for the different MD-SAL data change event listeners.
*
*/
-public abstract class AbstractDataListener<T extends DataObject> implements ClusteredDataTreeChangeListener<T> {
+public abstract class AbstractDataListener<T extends DataObject> implements DataTreeChangeListener<T> {
private DataBroker broker;
private InstanceIdentifier<T> path;
- private ListenerRegistration<ClusteredDataTreeChangeListener<T>> configRegistration;
- private ListenerRegistration<ClusteredDataTreeChangeListener<T>> operRegistration;
+ private Registration configRegistration;
+ private Registration operRegistration;
void registerDataChangeListener() {
- final DataTreeIdentifier<T> configDataTreeIdentifier = DataTreeIdentifier.create(
- LogicalDatastoreType.CONFIGURATION, path);
- final DataTreeIdentifier<T> operDataTreeIdentifier = DataTreeIdentifier.create(
- LogicalDatastoreType.OPERATIONAL, path);
-
- configRegistration = broker.registerDataTreeChangeListener(configDataTreeIdentifier, this);
- operRegistration = broker.registerDataTreeChangeListener(operDataTreeIdentifier, this);
+ configRegistration = broker.registerTreeChangeListener(
+ DataTreeIdentifier.of(LogicalDatastoreType.CONFIGURATION, path), this);
+ operRegistration = broker.registerTreeChangeListener(
+ DataTreeIdentifier.of(LogicalDatastoreType.OPERATIONAL, path), this);
}
public void closeDataChangeListener() {
void setPath(InstanceIdentifier<T> path) {
this.path = path;
}
-
}
*/
package org.opendaylight.lispflowmapping.implementation.mdsal;
-import java.util.Collection;
+import java.util.List;
import org.opendaylight.lispflowmapping.interfaces.mapcache.IMappingSystem;
import org.opendaylight.lispflowmapping.lisp.util.LispAddressUtil;
import org.opendaylight.mdsal.binding.api.DataBroker;
}
@Override
- public void onDataTreeChanged(Collection<DataTreeModification<AuthenticationKey>> changes) {
+ public void onDataTreeChanged(List<DataTreeModification<AuthenticationKey>> changes) {
for (DataTreeModification<AuthenticationKey> change : changes) {
final DataObjectModification<AuthenticationKey> mod = change.getRootNode();
- if (ModificationType.DELETE == mod.getModificationType()) {
- final AuthenticationKey authKey = mod.getDataBefore();
+ if (ModificationType.DELETE == mod.modificationType()) {
+ final AuthenticationKey authKey = mod.dataBefore();
LOG.trace("Received deleted data");
- LOG.trace("Key: {}", change.getRootPath().getRootIdentifier());
+ LOG.trace("Key: {}", change.getRootPath().path());
LOG.trace("Value: {}", authKey);
final AuthenticationKey convertedAuthKey = convertToBinaryIfNecessary(authKey);
mapSystem.removeAuthenticationKey(convertedAuthKey.getEid());
- } else if (ModificationType.WRITE == mod.getModificationType() || ModificationType.SUBTREE_MODIFIED == mod
- .getModificationType()) {
- if (ModificationType.WRITE == mod.getModificationType()) {
+ } else if (ModificationType.WRITE == mod.modificationType()
+ || ModificationType.SUBTREE_MODIFIED == mod.modificationType()) {
+ if (ModificationType.WRITE == mod.modificationType()) {
LOG.trace("Received created data");
} else {
LOG.trace("Received updated data");
}
// Process newly created or updated authentication keys
- final AuthenticationKey authKey = mod.getDataAfter();
+ final AuthenticationKey authKey = mod.dataAfter();
- LOG.trace("Key: {}", change.getRootPath().getRootIdentifier());
+ LOG.trace("Key: {}", change.getRootPath().path());
LOG.trace("Value: {}", authKey);
final AuthenticationKey convertedAuthKey = convertToBinaryIfNecessary(authKey);
mapSystem.addAuthenticationKey(convertedAuthKey.getEid(), convertedAuthKey.getMappingAuthkey());
} else {
- LOG.warn("Ignoring unhandled modification type {}", mod.getModificationType());
+ LOG.warn("Ignoring unhandled modification type {}", mod.modificationType());
}
}
}
}
void setMappingSystem(IMappingSystem msmr) {
- this.mapSystem = msmr;
+ mapSystem = msmr;
}
}
package org.opendaylight.lispflowmapping.implementation.mdsal;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.List;
import org.opendaylight.lispflowmapping.interfaces.mapcache.IMappingSystem;
import org.opendaylight.lispflowmapping.lisp.type.MappingData;
}
@Override
- public void onDataTreeChanged(Collection<DataTreeModification<Mapping>> changes) {
+ public void onDataTreeChanged(List<DataTreeModification<Mapping>> changes) {
for (DataTreeModification<Mapping> change : changes) {
final DataObjectModification<Mapping> mod = change.getRootNode();
- if (ModificationType.DELETE == mod.getModificationType()) {
+ if (ModificationType.DELETE == mod.modificationType()) {
// Process deleted mappings
- final Mapping mapping = mod.getDataBefore();
+ final Mapping mapping = mod.dataBefore();
// Only treat mapping changes caused by Northbound, since Southbound changes are already handled
// before being persisted, except for cluster slaves
}
LOG.trace("Received deleted data");
- LOG.trace("Key: {}", change.getRootPath().getRootIdentifier());
+ LOG.trace("Key: {}", change.getRootPath().path());
LOG.trace("Value: {}", mapping);
final Mapping convertedMapping = convertToBinaryIfNecessary(mapping);
mapSystem.removeMapping(convertedMapping.getOrigin(), convertedMapping.getMappingRecord().getEid());
- } else if (ModificationType.SUBTREE_MODIFIED == mod.getModificationType() || ModificationType.WRITE == mod
- .getModificationType()) {
- final Mapping mapping = mod.getDataAfter();
+ } else if (ModificationType.SUBTREE_MODIFIED == mod.modificationType()
+ || ModificationType.WRITE == mod.modificationType()) {
+ final Mapping mapping = mod.dataAfter();
// Only treat mapping changes caused by Northbound, since Southbound changes are already handled
// before being persisted, except for cluster slaves XXX separate NB and SB to avoid ignoring
final Mapping convertedMapping = convertToBinaryIfNecessary(mapping);
Eid convertedEid = convertedMapping.getMappingRecord().getEid();
- if (ModificationType.SUBTREE_MODIFIED == mod.getModificationType()) {
+ if (ModificationType.SUBTREE_MODIFIED == mod.modificationType()) {
LOG.trace("Received update data");
- LOG.trace("Key: {}", change.getRootPath().getRootIdentifier());
+ LOG.trace("Key: {}", change.getRootPath().path());
LOG.trace("Value: {}", mapping);
mapSystem.updateMapping(convertedMapping.getOrigin(), convertedEid,
new MappingData(convertedMapping.getMappingRecord()));
} else {
LOG.trace("Received write data");
- LOG.trace("Key: {}", change.getRootPath().getRootIdentifier());
+ LOG.trace("Key: {}", change.getRootPath().path());
LOG.trace("Value: {}", mapping);
mapSystem.addMapping(convertedMapping.getOrigin(), convertedEid,
new MappingData(convertedMapping.getMappingRecord()));
}
} else {
- LOG.warn("Ignoring unhandled modification type {}", mod.getModificationType());
+ LOG.warn("Ignoring unhandled modification type {}", mod.modificationType());
}
}
}
import org.opendaylight.lispflowmapping.lisp.type.LispMessage;
import org.opendaylight.lispflowmapping.lisp.util.LispAddressUtil;
import org.opendaylight.mdsal.binding.api.NotificationService;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
+import org.opendaylight.mdsal.binding.api.RpcService;
+import org.opendaylight.mdsal.singleton.api.ClusterSingletonServiceProvider;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.IpAddressBinary;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.Ipv4AddressBinary;
@Mock(name = "sendMapNotify") private static SendMapNotify sendMapNotify;
private final NotificationService notificationService = Mockito.mock(NotificationService.class);
- private final RpcConsumerRegistry rpcService = Mockito.mock(RpcConsumerRegistry.class);
+ private final RpcService rpcService = Mockito.mock(RpcService.class);
private final IMappingService mappingService = Mockito.mock(IMappingService.class);
private final ClusterSingletonServiceProvider clusterSingletonService = Mockito.mock(
ClusterSingletonServiceProvider.class);
*/
package org.opendaylight.lispflowmapping.implementation.mdsal;
-import com.google.common.collect.Lists;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkeyBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.EidUri;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingDatabase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKeyBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKeyKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.mapping.database.VirtualNetworkIdentifier;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.Uint16;
iMappingSystemMock = Mockito.mock(IMappingSystem.class);
authenticationKeyDataListener = new AuthenticationKeyDataListener(dataBrokerMock, iMappingSystemMock);
- final InstanceIdentifier<AuthenticationKey> instanceIdentifierMock = Mockito.mock(InstanceIdentifier.class);
- final DataTreeIdentifier<AuthenticationKey> dataTreeIdentifier =
- DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION, instanceIdentifierMock);
+ final DataTreeIdentifier<AuthenticationKey> dataTreeIdentifier = DataTreeIdentifier.of(
+ LogicalDatastoreType.CONFIGURATION,
+ InstanceIdentifier.create(MappingDatabase.class).child(VirtualNetworkIdentifier.class)
+ .child(AuthenticationKey.class));
change_del = Mockito.mock(DataTreeModification.class);
change_subtreeModified = Mockito.mock(DataTreeModification.class);
Mockito.when(change_subtreeModified.getRootNode()).thenReturn(mod_subtreeModified);
Mockito.when(change_write.getRootPath()).thenReturn(dataTreeIdentifier);
Mockito.when(change_write.getRootNode()).thenReturn(mod_write);
- Mockito.when(mod_del.getModificationType()).thenReturn(ModificationType.DELETE);
- Mockito.when(mod_subtreeModified.getModificationType()).thenReturn(ModificationType.SUBTREE_MODIFIED);
- Mockito.when(mod_write.getModificationType()).thenReturn(ModificationType.WRITE);
+ Mockito.when(mod_del.modificationType()).thenReturn(ModificationType.DELETE);
+ Mockito.when(mod_subtreeModified.modificationType()).thenReturn(ModificationType.SUBTREE_MODIFIED);
+ Mockito.when(mod_write.modificationType()).thenReturn(ModificationType.WRITE);
}
/**
*/
@Test
public void onDataTreeChangedTest_delete() {
- final List<DataTreeModification<AuthenticationKey>> changes = Lists.newArrayList(change_del);
- Mockito.when(mod_del.getDataBefore()).thenReturn(AUTHENTICATION_KEY_1);
+ Mockito.when(mod_del.dataBefore()).thenReturn(AUTHENTICATION_KEY_1);
- authenticationKeyDataListener.onDataTreeChanged(changes);
+ authenticationKeyDataListener.onDataTreeChanged(List.of(change_del));
Mockito.verify(iMappingSystemMock).removeAuthenticationKey(IPV4_EID_1);
}
*/
@Test
public void onDataTreeChangedTest_write() {
- final List<DataTreeModification<AuthenticationKey>> changes = Lists.newArrayList(change_write);
- Mockito.when(mod_write.getDataAfter()).thenReturn(AUTHENTICATION_KEY_2);
+ Mockito.when(mod_write.dataAfter()).thenReturn(AUTHENTICATION_KEY_2);
- authenticationKeyDataListener.onDataTreeChanged(changes);
+ authenticationKeyDataListener.onDataTreeChanged(List.of(change_write));
Mockito.verify(iMappingSystemMock).addAuthenticationKey(IPV4_EID_2, AUTHENTICATION_KEY_2.getMappingAuthkey());
}
*/
@Test
public void onDataTreeChangedTest_subtreeModified() {
- final List<DataTreeModification<AuthenticationKey>> changes = Lists.newArrayList(change_subtreeModified);
- Mockito.when(mod_subtreeModified.getDataAfter()).thenReturn(AUTHENTICATION_KEY_3);
+ Mockito.when(mod_subtreeModified.dataAfter()).thenReturn(AUTHENTICATION_KEY_3);
- authenticationKeyDataListener.onDataTreeChanged(changes);
+ authenticationKeyDataListener.onDataTreeChanged(List.of(change_subtreeModified));
Mockito.verify(iMappingSystemMock).addAuthenticationKey(IPV4_EID_3, AUTHENTICATION_KEY_3.getMappingAuthkey());
}
*/
@Test
public void onDataTreeChangedTest_multipleModTypes() {
- final List<DataTreeModification<AuthenticationKey>> changes =
- Lists.newArrayList(change_del, change_write, change_subtreeModified);
+ Mockito.when(mod_del.dataBefore()).thenReturn(AUTHENTICATION_KEY_1);
+ Mockito.when(mod_write.dataAfter()).thenReturn(AUTHENTICATION_KEY_2);
+ Mockito.when(mod_subtreeModified.dataAfter()).thenReturn(AUTHENTICATION_KEY_3);
- Mockito.when(mod_del.getDataBefore()).thenReturn(AUTHENTICATION_KEY_1);
- Mockito.when(mod_write.getDataAfter()).thenReturn(AUTHENTICATION_KEY_2);
- Mockito.when(mod_subtreeModified.getDataAfter()).thenReturn(AUTHENTICATION_KEY_3);
-
- authenticationKeyDataListener.onDataTreeChanged(changes);
+ authenticationKeyDataListener.onDataTreeChanged(List.of(change_del, change_write, change_subtreeModified));
Mockito.verify(iMappingSystemMock).removeAuthenticationKey(IPV4_EID_1);
Mockito.verify(iMappingSystemMock).addAuthenticationKey(IPV4_EID_2, AUTHENTICATION_KEY_2.getMappingAuthkey());
Mockito.verify(iMappingSystemMock).addAuthenticationKey(IPV4_EID_3, AUTHENTICATION_KEY_3.getMappingAuthkey());
public void onDataTreeChangedTest_noModType() {
final DataTreeModification<AuthenticationKey> changeNoModType = Mockito.mock(DataTreeModification.class);
final DataObjectModification<AuthenticationKey> modNoType = Mockito.mock(DataObjectModification.class);
- final List<DataTreeModification<AuthenticationKey>> changes = Lists.newArrayList(changeNoModType);
Mockito.when(changeNoModType.getRootNode()).thenReturn(modNoType);
- Mockito.when(modNoType.getModificationType()).thenReturn(null);
+ Mockito.when(modNoType.modificationType()).thenReturn(null);
- authenticationKeyDataListener.onDataTreeChanged(changes);
+ authenticationKeyDataListener.onDataTreeChanged(List.of(changeNoModType));
Mockito.verifyZeroInteractions(iMappingSystemMock);
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.EidUri;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingChange;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingChanged;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingDatabase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingOrigin;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.MappingBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.MappingKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.mapping.database.VirtualNetworkIdentifier;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public class MappingDataListenerTest {
-
private static IMappingSystem iMappingSystemMock;
private static NotificationPublishService notificationPublishServiceMock;
mappingDataListener =
new MappingDataListener(dataBrokerMock, iMappingSystemMock, notificationPublishServiceMock);
- final InstanceIdentifier<Mapping> instanceIdentifierMock = Mockito.mock(InstanceIdentifier.class);
- final DataTreeIdentifier<Mapping> dataTreeIdentifier =
- DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION, instanceIdentifierMock);
+ final DataTreeIdentifier<Mapping> dataTreeIdentifier = DataTreeIdentifier.of(
+ LogicalDatastoreType.CONFIGURATION,
+ InstanceIdentifier.create(MappingDatabase.class)
+ .child(VirtualNetworkIdentifier.class)
+ .child(Mapping.class));
change_del = Mockito.mock(DataTreeModification.class);
change_subtreeModified = Mockito.mock(DataTreeModification.class);
Mockito.when(change_subtreeModified.getRootNode()).thenReturn(mod_subtreeModified);
Mockito.when(change_write.getRootPath()).thenReturn(dataTreeIdentifier);
Mockito.when(change_write.getRootNode()).thenReturn(mod_write);
- Mockito.when(mod_del.getModificationType()).thenReturn(ModificationType.DELETE);
- Mockito.when(mod_subtreeModified.getModificationType()).thenReturn(ModificationType.SUBTREE_MODIFIED);
- Mockito.when(mod_write.getModificationType()).thenReturn(ModificationType.WRITE);
+ Mockito.when(mod_del.modificationType()).thenReturn(ModificationType.DELETE);
+ Mockito.when(mod_subtreeModified.modificationType()).thenReturn(ModificationType.SUBTREE_MODIFIED);
+ Mockito.when(mod_write.modificationType()).thenReturn(ModificationType.WRITE);
Mockito.when(iMappingSystemMock.isMaster()).thenReturn(true);
}
@Test
public void onDataTreeChangedTest_delete_NB() throws InterruptedException {
final List<DataTreeModification<Mapping>> changes = Lists.newArrayList(change_del);
- Mockito.when(mod_del.getDataBefore()).thenReturn(MAPPING_EID_1_NB);
+ Mockito.when(mod_del.dataBefore()).thenReturn(MAPPING_EID_1_NB);
mappingDataListener.onDataTreeChanged(changes);
Mockito.verify(iMappingSystemMock).removeMapping(MappingOrigin.Northbound, IPV4_EID_1);
@Test
public void onDataTreeChangedTest_delete_SB() {
final List<DataTreeModification<Mapping>> changes = Lists.newArrayList(change_del);
- Mockito.when(mod_del.getDataBefore()).thenReturn(MAPPING_EID_1_SB);
+ Mockito.when(mod_del.dataBefore()).thenReturn(MAPPING_EID_1_SB);
mappingDataListener.onDataTreeChanged(changes);
//Mockito.verifyZeroInteractions(iMappingSystemMock);
final List<DataTreeModification<Mapping>> changes = Lists.newArrayList(change_subtreeModified);
final MappingChanged mapChanged = MSNotificationInputUtil.toMappingChanged(
MAPPING_EID_2_NB.getMappingRecord(), null, null, null, MappingChange.Updated);
- Mockito.when(mod_subtreeModified.getDataAfter()).thenReturn(MAPPING_EID_2_NB);
+ Mockito.when(mod_subtreeModified.dataAfter()).thenReturn(MAPPING_EID_2_NB);
mappingDataListener.onDataTreeChanged(changes);
final ArgumentCaptor<MappingData> captor = ArgumentCaptor.forClass(MappingData.class);
@Test
public void onDataTreeChangedTest_subtreeModified_SB() {
final List<DataTreeModification<Mapping>> changes = Lists.newArrayList(change_subtreeModified);
- Mockito.when(mod_subtreeModified.getDataAfter()).thenReturn(MAPPING_EID_2_SB);
+ Mockito.when(mod_subtreeModified.dataAfter()).thenReturn(MAPPING_EID_2_SB);
mappingDataListener.onDataTreeChanged(changes);
//Mockito.verifyZeroInteractions(iMappingSystemMock);
final List<DataTreeModification<Mapping>> changes = Lists.newArrayList(change_write);
final MappingChanged mapChanged = MSNotificationInputUtil.toMappingChanged(
MAPPING_EID_3_NB.getMappingRecord(), null, null, null, MappingChange.Created);
- Mockito.when(mod_write.getDataAfter()).thenReturn(MAPPING_EID_3_NB);
+ Mockito.when(mod_write.dataAfter()).thenReturn(MAPPING_EID_3_NB);
mappingDataListener.onDataTreeChanged(changes);
final ArgumentCaptor<MappingData> captor = ArgumentCaptor.forClass(MappingData.class);
@Test
public void onDataTreeChangedTest_write_SB() {
final List<DataTreeModification<Mapping>> changes = Lists.newArrayList(change_write);
- Mockito.when(mod_write.getDataAfter()).thenReturn(MAPPING_EID_3_SB);
+ Mockito.when(mod_write.dataAfter()).thenReturn(MAPPING_EID_3_SB);
mappingDataListener.onDataTreeChanged(changes);
//Mockito.verifyZeroInteractions(iMappingSystemMock);
final MappingChanged mapChangedSubtreeMod = MSNotificationInputUtil.toMappingChanged(
MAPPING_EID_2_NB.getMappingRecord(), null, null, null, MappingChange.Updated);
- Mockito.when(mod_del.getDataBefore()).thenReturn(MAPPING_EID_1_NB);
- Mockito.when(mod_subtreeModified.getDataAfter()).thenReturn(MAPPING_EID_2_NB);
- Mockito.when(mod_write.getDataAfter()).thenReturn(MAPPING_EID_3_SB);
+ Mockito.when(mod_del.dataBefore()).thenReturn(MAPPING_EID_1_NB);
+ Mockito.when(mod_subtreeModified.dataAfter()).thenReturn(MAPPING_EID_2_NB);
+ Mockito.when(mod_write.dataAfter()).thenReturn(MAPPING_EID_3_SB);
mappingDataListener.onDataTreeChanged(changes);
final ArgumentCaptor<MappingData> captor = ArgumentCaptor.forClass(MappingData.class);
final List<DataTreeModification<Mapping>> changes = Lists.newArrayList(changeNoModType);
Mockito.when(changeNoModType.getRootNode()).thenReturn(modNoType);
- Mockito.when(modNoType.getModificationType()).thenReturn(null);
+ Mockito.when(modNoType.modificationType()).thenReturn(null);
mappingDataListener.onDataTreeChanged(changes);
Mockito.verifyZeroInteractions(notificationPublishServiceMock);
}
-
private static Mapping getDefaultMapping(Eid eid, MappingOrigin origin) {
final MappingRecord record = new MappingRecordBuilder().setEid(eid).build();
return new MappingBuilder()
<parent>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>binding-parent</artifactId>
- <version>12.0.4</version>
+ <version>13.0.0</version>
<relativePath/>
</parent>
<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>
</dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-singleton-common-api</artifactId>
+ <artifactId>mdsal-singleton-api</artifactId>
</dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-singleton-dom-impl</artifactId>
+ <artifactId>mdsal-singleton-impl</artifactId>
</dependency>
<!-- osgi annotations -->
<dependency>
import org.opendaylight.lispflowmapping.type.sbplugin.IConfigLispSouthboundPlugin;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.NotificationPublishService;
-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.lfm.inet.binary.types.rev160303.IpAddressBinary;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MessageType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid;
protected static final Logger LOG = LoggerFactory.getLogger(LispSouthboundPlugin.class);
public static final String LISPFLOWMAPPING_ENTITY_NAME = "lispflowmapping";
public static final ServiceGroupIdentifier SERVICE_GROUP_IDENTIFIER =
- ServiceGroupIdentifier.create(LISPFLOWMAPPING_ENTITY_NAME);
+ new ServiceGroupIdentifier(LISPFLOWMAPPING_ENTITY_NAME);
private static final String DEFAULT_BINDING_ADDRESS = "0.0.0.0";
private static final long DEFAULT_MAP_REGISTER_CACHE_TIMEOUT = 90000;
*/
package org.opendaylight.lispflowmapping.southbound.lisp;
-import java.util.Collection;
+import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.opendaylight.lispflowmapping.lisp.util.LispAddressUtil;
import org.opendaylight.lispflowmapping.mapcache.AuthKeyDb;
-import org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener;
import org.opendaylight.mdsal.binding.api.DataBroker;
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.DataTreeIdentifier;
import org.opendaylight.mdsal.binding.api.DataTreeModification;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKeyBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.mapping.database.VirtualNetworkIdentifier;
-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;
* DataListener for all AuthenticationKey modification events.
*
*/
-public class AuthenticationKeyDataListener implements ClusteredDataTreeChangeListener<AuthenticationKey> {
+public class AuthenticationKeyDataListener implements DataTreeChangeListener<AuthenticationKey> {
private static final Logger LOG = LoggerFactory.getLogger(AuthenticationKeyDataListener.class);
private final AuthKeyDb akdb;
- private final DataBroker broker;
private final InstanceIdentifier<AuthenticationKey> path;
- private final ListenerRegistration<ClusteredDataTreeChangeListener<AuthenticationKey>> registration;
+ private final Registration registration;
private final ConcurrentHashMap<Eid, Long> updatedEntries;
public AuthenticationKeyDataListener(final DataBroker broker, final AuthKeyDb akdb) {
- this.broker = broker;
this.akdb = akdb;
- this.path = InstanceIdentifier.create(MappingDatabase.class).child(VirtualNetworkIdentifier.class)
+ path = InstanceIdentifier.create(MappingDatabase.class).child(VirtualNetworkIdentifier.class)
.child(AuthenticationKey.class);
LOG.trace("Registering AuthenticationKey listener.");
- final DataTreeIdentifier<AuthenticationKey> dataTreeIdentifier = DataTreeIdentifier.create(
- LogicalDatastoreType.CONFIGURATION, path);
- registration = broker.registerDataTreeChangeListener(dataTreeIdentifier, this);
- this.updatedEntries = new ConcurrentHashMap<>();
+ registration = broker.registerTreeChangeListener(
+ DataTreeIdentifier.of(LogicalDatastoreType.CONFIGURATION, path), this);
+ updatedEntries = new ConcurrentHashMap<>();
}
public void closeDataChangeListener() {
}
@Override
- public synchronized void onDataTreeChanged(Collection<DataTreeModification<AuthenticationKey>> changes) {
+ public synchronized void onDataTreeChanged(final List<DataTreeModification<AuthenticationKey>> changes) {
for (DataTreeModification<AuthenticationKey> change : changes) {
final DataObjectModification<AuthenticationKey> mod = change.getRootNode();
- if (ModificationType.DELETE == mod.getModificationType()) {
- final AuthenticationKey authKey = mod.getDataBefore();
+ if (ModificationType.DELETE == mod.modificationType()) {
+ final AuthenticationKey authKey = mod.dataBefore();
LOG.trace("Received deleted data");
- LOG.trace("Key: {}", change.getRootPath().getRootIdentifier());
+ LOG.trace("Key: {}", change.getRootPath().path());
LOG.trace("Value: {}", authKey);
final AuthenticationKey convertedAuthKey = convertToBinaryIfNecessary(authKey);
akdb.removeAuthenticationKey(convertedAuthKey.getEid());
updatedEntries.put(convertedAuthKey.getEid(), System.currentTimeMillis());
- } else if (ModificationType.WRITE == mod.getModificationType() || ModificationType.SUBTREE_MODIFIED == mod
- .getModificationType()) {
- if (ModificationType.WRITE == mod.getModificationType()) {
+ } else if (ModificationType.WRITE == mod.modificationType()
+ || ModificationType.SUBTREE_MODIFIED == mod.modificationType()) {
+ if (ModificationType.WRITE == mod.modificationType()) {
LOG.trace("Received created data");
} else {
LOG.trace("Received updated data");
}
// Process newly created or updated authentication keys
- final AuthenticationKey authKey = mod.getDataAfter();
+ final AuthenticationKey authKey = mod.dataAfter();
- LOG.trace("Key: {}", change.getRootPath().getRootIdentifier());
+ LOG.trace("Key: {}", change.getRootPath().path());
LOG.trace("Value: {}", authKey);
final AuthenticationKey convertedAuthKey = convertToBinaryIfNecessary(authKey);
akdb.addAuthenticationKey(convertedAuthKey.getEid(), convertedAuthKey.getMappingAuthkey());
updatedEntries.put(convertedAuthKey.getEid(), System.currentTimeMillis());
} else {
- LOG.warn("Ignoring unhandled modification type {}", mod.getModificationType());
+ LOG.warn("Ignoring unhandled modification type {}", mod.modificationType());
}
}
}
* @param timeout MapRegister cache timeout value
* @return false if any of the EIDs in the eids list was updated in the last timout period, true otherwise
*/
- public synchronized boolean authKeysForEidsUnchanged(Map<EidLispAddressKey, EidLispAddress> eids, long timeout) {
+ public synchronized boolean authKeysForEidsUnchanged(final Map<EidLispAddressKey, EidLispAddress> eids,
+ final long timeout) {
boolean result = true;
Long currentTime = System.currentTimeMillis();
for (EidLispAddress eidLispAddress : eids.values()) {
return result;
}
- private static AuthenticationKey convertToBinaryIfNecessary(AuthenticationKey authKey) {
+ private static AuthenticationKey convertToBinaryIfNecessary(final AuthenticationKey authKey) {
Eid originalEid = authKey.getEid();
if (LispAddressUtil.addressNeedsConversionToBinary(originalEid.getAddress())) {
AuthenticationKeyBuilder akb = new AuthenticationKeyBuilder(authKey);
import org.opendaylight.lispflowmapping.southbound.lisp.LispSouthboundHandler;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.NotificationPublishService;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
+import org.opendaylight.mdsal.singleton.api.ClusterSingletonServiceProvider;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.IpAddressBinary;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.Ipv4AddressBinary;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKeyBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKeyKey;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.Uint16;
@Mock(name = "akdb") private static AuthKeyDb akdbMock;
@Mock(name = "broker") private static DataBroker brokerMock;
- @Mock(name = "registration") private static ListenerRegistration<AuthenticationKeyDataListener>
- registrationMock;
+ @Mock(name = "registration") private static Registration registrationMock;
@InjectMocks private static AuthenticationKeyDataListener authenticationKeyDataListener;
private static DataTreeModification<AuthenticationKey> change_del;
public void init() {
final InstanceIdentifier<AuthenticationKey> instanceIdentifierMock = Mockito.mock(InstanceIdentifier.class);
final DataTreeIdentifier<AuthenticationKey> dataTreeIdentifier =
- DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION, instanceIdentifierMock);
+ DataTreeIdentifier.of(LogicalDatastoreType.CONFIGURATION, instanceIdentifierMock);
change_del = Mockito.mock(DataTreeModification.class);
change_subtreeModified = Mockito.mock(DataTreeModification.class);
Mockito.when(change_subtreeModified.getRootNode()).thenReturn(mod_subtreeModified);
Mockito.when(change_write.getRootPath()).thenReturn(dataTreeIdentifier);
Mockito.when(change_write.getRootNode()).thenReturn(mod_write);
- Mockito.when(mod_del.getModificationType()).thenReturn(DataObjectModification.ModificationType.DELETE);
- Mockito.when(mod_subtreeModified.getModificationType())
+ Mockito.when(mod_del.modificationType()).thenReturn(DataObjectModification.ModificationType.DELETE);
+ Mockito.when(mod_subtreeModified.modificationType())
.thenReturn(DataObjectModification.ModificationType.SUBTREE_MODIFIED);
- Mockito.when(mod_write.getModificationType()).thenReturn(DataObjectModification.ModificationType.WRITE);
+ Mockito.when(mod_write.modificationType()).thenReturn(DataObjectModification.ModificationType.WRITE);
- Mockito.when(brokerMock.registerDataTreeChangeListener(Mockito.any(DataTreeIdentifier.class),
+ Mockito.when(brokerMock.registerTreeChangeListener(Mockito.any(DataTreeIdentifier.class),
Mockito.any(AuthenticationKeyDataListener.class))).thenReturn(registrationMock);
authenticationKeyDataListener = new AuthenticationKeyDataListener(brokerMock, akdbMock);
}
*/
@Test
public void onDataTreeChangedTest_delete_BinaryEid() {
- Mockito.when(mod_del.getDataBefore()).thenReturn(AUTHENTICATION_KEY_1);
+ Mockito.when(mod_del.dataBefore()).thenReturn(AUTHENTICATION_KEY_1);
authenticationKeyDataListener.onDataTreeChanged(Lists.newArrayList(change_del));
Mockito.verify(akdbMock).removeAuthenticationKey(IPV4_BINARY_EID_1);
*/
@Test
public void onDataTreeChangedTest_delete_Ipv4PrefixEid() {
- Mockito.when(mod_del.getDataBefore()).thenReturn(AUTHENTICATION_KEY_PREFIX);
+ Mockito.when(mod_del.dataBefore()).thenReturn(AUTHENTICATION_KEY_PREFIX);
authenticationKeyDataListener.onDataTreeChanged(Lists.newArrayList(change_del));
Mockito.verify(akdbMock).removeAuthenticationKey(IPV4_PREFIX_BINARY_EID);
*/
@Test
public void onDataTreeChangedTest_subtreeModified() {
- Mockito.when(mod_subtreeModified.getDataAfter()).thenReturn(AUTHENTICATION_KEY_2);
+ Mockito.when(mod_subtreeModified.dataAfter()).thenReturn(AUTHENTICATION_KEY_2);
authenticationKeyDataListener.onDataTreeChanged(Lists.newArrayList(change_subtreeModified));
Mockito.verify(akdbMock).addAuthenticationKey(IPV4_BINARY_EID_2, MAPPING_AUTHKEY);
*/
@Test
public void onDataTreeChangedTest_write() {
- Mockito.when(mod_write.getDataAfter()).thenReturn(AUTHENTICATION_KEY_3);
+ Mockito.when(mod_write.dataAfter()).thenReturn(AUTHENTICATION_KEY_3);
authenticationKeyDataListener.onDataTreeChanged(Lists.newArrayList(change_write));
Mockito.verify(akdbMock).addAuthenticationKey(IPV4_BINARY_EID_3, MAPPING_AUTHKEY);
final DataTreeModification<AuthenticationKey> change_nullModType = Mockito.mock(DataTreeModification.class);
final DataObjectModification mod_nullModType = Mockito.mock(DataObjectModification.class);
Mockito.when(change_nullModType.getRootNode()).thenReturn(mod_nullModType);
- Mockito.when(mod_nullModType.getModificationType()).thenReturn(null);
+ Mockito.when(mod_nullModType.modificationType()).thenReturn(null);
authenticationKeyDataListener.onDataTreeChanged(Lists.newArrayList(change_nullModType));
Mockito.verifyNoInteractions(akdbMock);
Mockito.verify(registrationMock).close();
}
- private static AuthenticationKey getAuthenticationKey(Eid eid) {
+ private static AuthenticationKey getAuthenticationKey(final Eid eid) {
return new AuthenticationKeyBuilder()
.withKey(new AuthenticationKeyKey(new EidUri("uri-1")))
.setEid(eid)