use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKey in project lispflowmapping by opendaylight.
the class MappingSystem method restoreDaoFromDatastore.
/**
* Restore all mappings and keys from mdsal datastore.
*/
private void restoreDaoFromDatastore() {
List<AuthenticationKey> authKeys = dsbe.getAllAuthenticationKeys();
List<Mapping> mappings = dsbe.getAllMappings(LogicalDatastoreType.CONFIGURATION);
/*
* XXX By default, the operational datastore is not persisted to disk, either at run-time, or on shutdown,
* so the following will have no effect (getLastUpdateTimestamp() will fail, since it's reading from
* the operational datastore, and even if it didn't getAllMappings() will fail anyway). According to rovarga it
* should be possible to turn on persistence for the operational datastore editing
* etc/opendaylight/karaf/05-clustering.xml, by setting <persistence>true</persistence>. At the time of writing
* the below code block that didn't seem to work though.
*/
Long lastUpdateTimestamp = dsbe.getLastUpdateTimestamp();
if (lastUpdateTimestamp != null && System.currentTimeMillis() - lastUpdateTimestamp > ConfigIni.getInstance().getRegistrationValiditySb()) {
LOG.warn("Restore threshold passed, not restoring operational datastore into DAO");
} else {
mappings.addAll(dsbe.getAllMappings(LogicalDatastoreType.OPERATIONAL));
}
dsbe.removeLastUpdateTimestamp();
LOG.info("Restoring {} mappings and {} keys from datastore into DAO", mappings.size(), authKeys.size());
for (Mapping mapping : mappings) {
addMapping(mapping.getOrigin(), mapping.getMappingRecord().getEid(), new MappingData(mapping.getMappingRecord()));
}
for (AuthenticationKey authKey : authKeys) {
addAuthenticationKey(authKey.getEid(), authKey.getMappingAuthkey());
}
}
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;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKey in project lispflowmapping by opendaylight.
the class AuthenticationKeyDataListener method onDataTreeChanged.
@Override
public void onDataTreeChanged(Collection<DataTreeModification<AuthenticationKey>> changes) {
for (DataTreeModification<AuthenticationKey> change : changes) {
final DataObjectModification<AuthenticationKey> mod = change.getRootNode();
if (ModificationType.DELETE == mod.getModificationType()) {
final AuthenticationKey authKey = mod.getDataBefore();
LOG.trace("Received deleted data");
LOG.trace("Key: {}", change.getRootPath().getRootIdentifier());
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()) {
LOG.trace("Received created data");
} else {
LOG.trace("Received updated data");
}
// Process newly created or updated authentication keys
final AuthenticationKey authKey = mod.getDataAfter();
LOG.trace("Key: {}", change.getRootPath().getRootIdentifier());
LOG.trace("Value: {}", authKey);
final AuthenticationKey convertedAuthKey = convertToBinaryIfNecessary(authKey);
mapSystem.addAuthenticationKey(convertedAuthKey.getEid(), convertedAuthKey.getMappingAuthkey());
} else {
LOG.warn("Ignoring unhandled modification type {}", mod.getModificationType());
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKey in project lispflowmapping by opendaylight.
the class DSBEInputUtil method toAuthenticationKey.
public static AuthenticationKey toAuthenticationKey(Eid key, MappingAuthkey authKey) {
AuthenticationKeyBuilder akb = new AuthenticationKeyBuilder();
akb.setEidUri(new EidUri(LispAddressStringifier.getURIString(key)));
akb.setEid(key);
akb.setMappingAuthkey(authKey);
return akb.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKey in project lispflowmapping by opendaylight.
the class RPCInputConvertorUtil method toAuthenticationKey.
private static AuthenticationKey toAuthenticationKey(Eid address, MappingAuthkey key) {
AuthenticationKeyBuilder akb = new AuthenticationKeyBuilder();
akb.setEidUri(new EidUri(LispAddressStringifier.getURIString(address)));
akb.setEid(address);
if (key != null) {
akb.setMappingAuthkey(key);
}
return akb.build();
}
Aggregations