Search in sources :

Example 86 with Object

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;
}
Also used : SourceEidBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.SourceEidBuilder) ArrayList(java.util.ArrayList) MapRequestBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequestBuilder) EidItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItemBuilder)

Example 87 with Object

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;
}
Also used : MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) ArrayList(java.util.ArrayList) Rloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc) ItrRloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc)

Example 88 with Object

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);
}
Also used : LocatorRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder) LocatorRecordKey(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordKey)

Example 89 with Object

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;
}
Also used : ArrayList(java.util.ArrayList) MapRegisterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapregistermessage.MapRegisterBuilder)

Example 90 with Object

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));
}
Also used : MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) Date(java.util.Date) XtrId(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.XtrId)

Aggregations

ArrayList (java.util.ArrayList)94 ByteBuf (io.netty.buffer.ByteBuf)82 Test (org.junit.Test)62 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)34 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object)33 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)33 ExecutionException (java.util.concurrent.ExecutionException)30 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)29 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)25 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes)25 List (java.util.List)21 HashMap (java.util.HashMap)19 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object)18 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)17 Nullable (org.eclipse.jdt.annotation.Nullable)16 UnknownObject (org.opendaylight.protocol.pcep.spi.UnknownObject)16 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)15 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)15 FutureCallback (com.google.common.util.concurrent.FutureCallback)14 BigInteger (java.math.BigInteger)14