use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Sent 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.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Sent in project lispflowmapping by opendaylight.
the class MapServer method handleMapRegister.
@SuppressWarnings("unchecked")
public void handleMapRegister(MapRegister mapRegister) {
boolean mappingUpdated = false;
boolean merge = ConfigIni.getInstance().mappingMergeIsSet() && mapRegister.isMergeEnabled();
MappingRecord oldMapping;
if (merge) {
if (!mapRegister.isXtrSiteIdPresent() || mapRegister.getXtrId() == null) {
LOG.error("Merge bit is set in Map-Register, but xTR-ID is not present. Will not merge.");
merge = false;
} else if (Arrays.equals(mapRegister.getXtrId().getValue(), ALL_ZEROES_XTR_ID)) {
LOG.warn("Merge bit is set in Map-Register, but xTR-ID is all zeroes.");
}
}
for (MappingRecordItem record : mapRegister.getMappingRecordItem()) {
MappingRecord mapping = record.getMappingRecord();
Eid eid = mapping.getEid();
MappingData mappingData = new MappingData(mapping, System.currentTimeMillis());
mappingData.setMergeEnabled(merge);
mappingData.setXtrId(mapRegister.getXtrId());
oldMapping = getMappingRecord(mapService.getMapping(MappingOrigin.Southbound, eid));
mapService.addMapping(MappingOrigin.Southbound, eid, getSiteId(mapRegister), mappingData);
if (merge) {
MappingRecord newMapping = getMappingRecord(mapService.getMapping(MappingOrigin.Southbound, eid));
if (MappingRecordUtil.mappingChanged(oldMapping, newMapping)) {
// If there is a SB mapping change with merge on, Map-Notify will be sent to ALL xTRs, not jus the
// one registering (merging is done in the MappingSystem code)
mappingUpdated = true;
}
}
}
if (BooleanUtils.isTrue(mapRegister.isWantMapNotify())) {
LOG.trace("MapRegister wants MapNotify");
MapNotifyBuilder builder = new MapNotifyBuilder();
List<TransportAddress> rlocs = null;
if (merge) {
Set<IpAddressBinary> notifyRlocs = new HashSet<IpAddressBinary>();
List<MappingRecordItem> mergedMappings = new ArrayList<MappingRecordItem>();
for (MappingRecordItem record : mapRegister.getMappingRecordItem()) {
MappingRecord mapping = record.getMappingRecord();
MappingRecord currentRecord = getMappingRecord(mapService.getMapping(MappingOrigin.Southbound, mapping.getEid()));
mergedMappings.add(new MappingRecordItemBuilder().setMappingRecord(currentRecord).build());
Set<IpAddressBinary> sourceRlocs = (Set<IpAddressBinary>) mapService.getData(MappingOrigin.Southbound, mapping.getEid(), SubKeys.SRC_RLOCS);
if (sourceRlocs != null) {
notifyRlocs.addAll(sourceRlocs);
}
}
MapNotifyBuilderHelper.setFromMapRegisterAndMappingRecordItems(builder, mapRegister, mergedMappings);
// send map-notify to merge group only when mapping record is changed
if (mappingUpdated) {
rlocs = getTransportAddresses(notifyRlocs);
}
} else {
MapNotifyBuilderHelper.setFromMapRegister(builder, mapRegister);
}
List<MappingRecordItem> mappings = builder.getMappingRecordItem();
if (mappings != null && mappings.get(0) != null && mappings.get(0).getMappingRecord() != null && mappings.get(0).getMappingRecord().getEid() != null) {
MappingAuthkey authkey = mapService.getAuthenticationKey(mappings.get(0).getMappingRecord().getEid());
if (authkey != null) {
builder.setAuthenticationData(LispAuthenticationUtil.createAuthenticationData(builder.build(), authkey.getKeyString()));
}
}
notifyHandler.handleMapNotify(builder.build(), rlocs);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Sent in project genius by opendaylight.
the class ArpUtilImpl method getMac.
@Override
public Future<RpcResult<GetMacOutput>> getMac(GetMacInput input) {
try {
final String dstIpAddress = getIpAddressInString(input.getIpaddress());
LOG.trace("getMac rpc invoked for ip {}", dstIpAddress);
if (macAddrs.get(dstIpAddress) != null) {
if (LOG.isInfoEnabled()) {
LOG.info("get mac already in progress for the ip {}", dstIpAddress);
}
return macAddrs.get(dstIpAddress);
}
SendArpRequestInputBuilder builder = new SendArpRequestInputBuilder().setInterfaceAddress(input.getInterfaceAddress()).setIpaddress(input.getIpaddress());
Future<RpcResult<Void>> arpReqFt = sendArpRequest(builder.build());
final SettableFuture<RpcResult<GetMacOutput>> ft = SettableFuture.create();
Futures.addCallback(JdkFutureAdapters.listenInPoolThread(arpReqFt, threadPool), new FutureCallback<RpcResult<Void>>() {
@Override
public void onFailure(Throwable ex) {
RpcResultBuilder<GetMacOutput> resultBuilder = RpcResultBuilder.<GetMacOutput>failed().withError(ErrorType.APPLICATION, ex.getMessage(), ex);
ft.set(resultBuilder.build());
}
@Override
public void onSuccess(RpcResult<Void> result) {
LOG.trace("Successfully sent the arp pkt out for ip {}", dstIpAddress);
}
}, MoreExecutors.directExecutor());
macAddrs.put(dstIpAddress, ft);
return ft;
} catch (UnknownHostException e) {
LOG.error("Failed to handle getMac request for {}", input.getIpaddress(), e);
RpcResultBuilder<GetMacOutput> resultBuilder = RpcResultBuilder.<GetMacOutput>failed().withError(ErrorType.APPLICATION, e.getMessage(), e);
return Futures.immediateFuture(resultBuilder.build());
}
}
Aggregations