use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKey in project lispflowmapping by opendaylight.
the class DataStoreBackEndTest method updateAuthenticationKeyTest.
/**
* Tests {@link DataStoreBackEnd#updateAuthenticationKey} method.
*/
@Test
public void updateAuthenticationKeyTest() {
final AuthenticationKey authenticationKey = getDefaultAuthenticationKeyBuilder().build();
dataStoreBackEnd.updateAuthenticationKey(authenticationKey);
Mockito.verify(wTxMock).put(Mockito.eq(LogicalDatastoreType.CONFIGURATION), iidCaptorAuthKey.capture(), Mockito.eq(authenticationKey), Mockito.eq(true));
// result
AuthenticationKeyKey result = iidCaptorAuthKey.getValue().firstKeyOf(AuthenticationKey.class);
assertEquals("ipv4:" + IPV4_STRING_1, result.getEidUri().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKey in project lispflowmapping by opendaylight.
the class DataStoreBackEndTest method getDefaultMappingDatabase.
private static MappingDatabaseBuilder getDefaultMappingDatabase() {
final Mapping mapping_1 = new MappingBuilder().setMappingRecord(getDefaultMappingRecordBuilder().build()).build();
final Mapping mapping_2 = new MappingBuilder().setMappingRecord(getDefaultMappingRecordBuilder().setEid(EID_IPV4_2).build()).build();
final Mapping mapping_3 = new MappingBuilder().setMappingRecord(getDefaultMappingRecordBuilder().setEid(EID_IPV4_3).build()).build();
final Mapping mapping_4 = new MappingBuilder().setMappingRecord(getDefaultMappingRecordBuilder().setEid(EID_IPV4_4).build()).build();
final AuthenticationKey authenticationKey_1 = new AuthenticationKeyBuilder().setKey(new AuthenticationKeyKey(new EidUri("uri-1"))).build();
final AuthenticationKey authenticationKey_2 = new AuthenticationKeyBuilder().setKey(new AuthenticationKeyKey(new EidUri("uri-2"))).build();
final AuthenticationKey authenticationKey_3 = new AuthenticationKeyBuilder().setKey(new AuthenticationKeyKey(new EidUri("uri-3"))).build();
final AuthenticationKey authenticationKey_4 = new AuthenticationKeyBuilder().setKey(new AuthenticationKeyKey(new EidUri("uri-4"))).build();
final VirtualNetworkIdentifier vni_1 = new VirtualNetworkIdentifierBuilder().setVni(new VniUri("vni/uri/1")).setMapping(Lists.newArrayList(mapping_1, mapping_2)).setAuthenticationKey(Lists.newArrayList(authenticationKey_1, authenticationKey_2)).build();
final VirtualNetworkIdentifier vni_2 = new VirtualNetworkIdentifierBuilder().setVni(new VniUri("vni/uri/2")).setMapping(Lists.newArrayList(mapping_3, mapping_4)).setAuthenticationKey(Lists.newArrayList(authenticationKey_3, authenticationKey_4)).build();
return new MappingDatabaseBuilder().setVirtualNetworkIdentifier(Lists.newArrayList(vni_1, vni_2));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKey in project lispflowmapping by opendaylight.
the class AuthenticationKeyDataListenerTest method onDataTreeChangedTest_nullModType.
/**
* Tests {@link AuthenticationKeyDataListener#onDataTreeChanged} method with null mod type.
*/
@Test
@SuppressWarnings("unchecked")
public void onDataTreeChangedTest_nullModType() {
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);
authenticationKeyDataListener.onDataTreeChanged(Lists.newArrayList(change_nullModType));
Mockito.verifyZeroInteractions(akdbMock);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKey in project lispflowmapping by opendaylight.
the class AuthenticationKeyDataListener method authKeysForEidsUnchanged.
/**
* We maintain a HashMap with the update times of AuthenticationKey objects in the updatedEntries field. We keep
* entries in the HashMap for the Map-Register cache timeout interval, and lazy remove them afterwards. As a result
* the same EID will be considered updated during that interval, even on subsequent queries. This is necessary
* because more than one xTR may register the same EID, and to avoid complexity we don't store origin information.
* The performance trade-off is not significant, because during a typical cache timeout the same xTR will send only
* a few registration packets (2 for the default value of 90s, when UDP Map-Registers are sent at 1 minute
* intervals).
*
* @param eids List of EIDs to check
* @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(List<EidLispAddress> eids, long timeout) {
boolean result = true;
Long currentTime = System.currentTimeMillis();
for (EidLispAddress eidLispAddress : eids) {
Long updateTime = updatedEntries.get(eidLispAddress.getEid());
if (updateTime != null) {
result = false;
if (currentTime - updateTime > timeout) {
updatedEntries.remove(eidLispAddress.getEid());
}
}
}
return result;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKey in project lispflowmapping by opendaylight.
the class AuthenticationKeyDataListener method convertToBinaryIfNecessary.
private static AuthenticationKey convertToBinaryIfNecessary(AuthenticationKey authKey) {
Eid originalEid = authKey.getEid();
if (LispAddressUtil.addressNeedsConversionToBinary(originalEid.getAddress())) {
AuthenticationKeyBuilder akb = new AuthenticationKeyBuilder(authKey);
akb.setEid(LispAddressUtil.convertToBinary(originalEid));
return akb.build();
}
return authKey;
}
Aggregations