use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTestUtil method getDefaultMapRequestBuilder.
/*
* PACKETS CREATION METHODS
*
* In general we return "Builders" so that the caller can customize the fields, but that means it also needs to
* call .build() on the received objects.
*/
/* Map-Request */
/**
* Create a default MapRequestBuilder object.
*
* @param eid the requested EID
* @return the MapRequestBuilder object
*/
static MapRequestBuilder getDefaultMapRequestBuilder(Eid eid) {
MapRequestBuilder mrBuilder = new MapRequestBuilder().setAuthoritative(false).setEidItem(new ArrayList<>()).setItrRloc(new ArrayList<>()).setMapDataPresent(true).setNonce((long) 4).setPitr(false).setProbe(false).setSmr(false).setSmrInvoked(false).setSourceEid(new SourceEidBuilder().setEid(DEFAULT_IPV4_EID).build()).setItrRloc(getDefaultItrRlocList(DEFAULT_IPV4_ITR_RLOC));
mrBuilder.getEidItem().add(new EidItemBuilder().setEid(eid).build());
return mrBuilder;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTestUtil method getDefaultMappingRecordBuilder.
/**
* Create a default MappingRecordBuilder object.
*
* @param eid EID for the mapping record, if null, a default will be added
* @param rlocs RLOCs for the mapping record, if null, no locator record will be added
* @return the MappingRecordBuilder object
*/
static MappingRecordBuilder getDefaultMappingRecordBuilder(Eid eid, List<Rloc> rlocs) {
if (eid == null) {
eid = DEFAULT_IPV4_EID_PREFIX;
LOG.warn("getDefaultMappingRecordBuilder(): null EID received, using the default {}", DEFAULT_IPV4_EID_STRING);
}
MappingRecordBuilder mrb = new MappingRecordBuilder().setEid(eid).setAction(MappingRecord.Action.NoAction).setAuthoritative(false).setLocatorRecord(new ArrayList<>()).setMapVersion((short) 0).setRecordTtl(60).setSiteId(DEFAULT_SITE_ID).setXtrId(DEFAULT_XTR_ID).setTimestamp(System.currentTimeMillis());
// We want to allow for empty locator records, so we only add one if rloc is not null
if (rlocs != null) {
for (Rloc rloc : rlocs) {
mrb.getLocatorRecord().add(getDefaultLocatorBuilder(rloc).build());
}
}
return mrb;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTestUtil method getDefaultLocatorBuilder.
/**
* Create a default LocatorRecordBuilder object.
*
* @param rloc RLOC for the mapping record, if null, a default will be added
* @return the LocatorRecordBuilder object
*/
static LocatorRecordBuilder getDefaultLocatorBuilder(Rloc rloc) {
if (rloc == null) {
rloc = DEFAULT_IPV4_RLOC;
LOG.warn("getDefaultLocatorBuilder(): null RLOC received, using the default {}", DEFAULT_IPV4_RLOC_STRING);
}
return new LocatorRecordBuilder().setLocalLocator(true).setMulticastPriority((short) 255).setMulticastWeight((short) 0).setPriority((short) 1).setRlocProbed(false).setRouted(true).setWeight((short) 1).setKey(new LocatorRecordKey(LispAddressStringifier.getString(rloc))).setRloc(rloc);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTestUtil method getDefaultMapRegisterBuilder.
/**
* Create a default MapRegisterBuilder object.
*
* @param eid EID for the single mapping record, if null, a default will be added
* @param rloc RLOC for the single mapping record, if null, no locator record will be added
* @return the MapRegisterBuilder object
*/
static MapRegisterBuilder getDefaultMapRegisterBuilder(Eid eid, Rloc rloc) {
final MapRegisterBuilder mapRegisterBuilder = new MapRegisterBuilder().setProxyMapReply(true).setWantMapNotify(true).setKeyId((short) 0).setMappingRecordItem(new ArrayList<>()).setMergeEnabled(true).setNonce(8L).setSiteId(DEFAULT_SITE_ID).setXtrId(DEFAULT_XTR_ID).setXtrSiteIdPresent(true);
mapRegisterBuilder.getMappingRecordItem().add(getDefaultMappingRecordItemBuilder(eid, rloc).build());
return mapRegisterBuilder;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object in project lispflowmapping by opendaylight.
the class MappingMergeUtil method mergeXtrIdMappings.
public static MappingData mergeXtrIdMappings(List<Object> mappingDataList, List<MappingData> expiredMappingDataList, Set<IpAddressBinary> sourceRlocs) {
MappingRecordBuilder mrb = null;
XtrId xtrId = null;
Long timestamp = Long.MAX_VALUE;
for (int i = 0; i < mappingDataList.size(); i++) {
MappingData mappingData = (MappingData) mappingDataList.get(i);
MappingRecord record = mappingData.getRecord();
// Skip expired mappings and add them to a list to be returned to the caller
if (timestampIsExpired(mappingData.getTimestamp())) {
expiredMappingDataList.add(mappingData);
continue;
}
if (mrb == null) {
mrb = new MappingRecordBuilder(record);
}
// Save the oldest valid timestamp
if (mappingData.getTimestamp().getTime() < timestamp) {
timestamp = mappingData.getTimestamp().getTime();
xtrId = mappingData.getXtrId();
}
// Merge record fields and locators
mergeCommonMappingRecordFields(mrb, record);
mergeLocatorRecords(mrb, record);
// Save source locator for use in Map-Notify
sourceRlocs.add(record.getSourceRloc());
}
if (mrb == null) {
LOG.warn("All mappings expired when merging! Unexpected!");
return null;
}
mrb.setXtrId(xtrId);
return new MappingData(mrb.build(), new Date(timestamp));
}
Aggregations