Search in sources :

Example 6 with Subscriber

use of org.opendaylight.lispflowmapping.interfaces.dao.Subscriber in project lispflowmapping by opendaylight.

the class MapServer method handleSmr.

private void handleSmr(Eid eid, Set<Subscriber> subscribers) {
    sendSmrs(eid, subscribers);
    // For SrcDst LCAF also send SMRs to Dst prefix
    if (eid.getAddress() instanceof SourceDestKey) {
        Eid dstAddr = SourceDestKeyHelper.getDstBinary(eid);
        Set<Subscriber> dstSubs = mapService.getSubscribers(dstAddr);
        sendSmrs(dstAddr, dstSubs);
    }
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) Subscriber(org.opendaylight.lispflowmapping.interfaces.dao.Subscriber) SourceDestKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey)

Example 7 with Subscriber

use of org.opendaylight.lispflowmapping.interfaces.dao.Subscriber in project lispflowmapping by opendaylight.

the class MappingServiceIntegrationTest method testRepeatedSmr.

private void testRepeatedSmr() throws SocketTimeoutException, UnknownHostException {
    cleanUP();
    long timeout = ConfigIni.getInstance().getSmrTimeout();
    ConfigIni.getInstance().setSmrRetryCount(5);
    final InstanceIdType iid = new InstanceIdType(1L);
    final Eid eid1 = LispAddressUtil.asIpv4Eid("1.1.1.1", 1L);
    final Eid subscriberEid = LispAddressUtil.asIpv4Eid("2.2.2.2", 1L);
    final int expectedSmrs1 = 2;
    final int expectedSmrs2 = 3;
    /* set auth */
    final Eid eid = LispAddressUtil.asIpv4PrefixBinaryEid("0.0.0.0/0", iid);
    mapService.addAuthenticationKey(eid, NULL_AUTH_KEY);
    /* add subscribers */
    final String subscriberSrcRloc1 = "127.0.0.3";
    final String subscriberSrcRloc2 = "127.0.0.4";
    final Set<Subscriber> subscriberSet1 = Sets.newHashSet(newSubscriber(subscriberEid, subscriberSrcRloc1), newSubscriber(subscriberEid, subscriberSrcRloc2));
    mapService.addData(MappingOrigin.Southbound, eid1, SubKeys.SUBSCRIBERS, subscriberSet1);
    final SocketReader reader1 = startSocketReader(subscriberSrcRloc1, 15000);
    final SocketReader reader2 = startSocketReader(subscriberSrcRloc2, 15000);
    sleepForSeconds(1);
    /* add mapping */
    final MappingRecord mapping1 = new MappingRecordBuilder().setEid(eid1).setTimestamp(System.currentTimeMillis()).setRecordTtl(1440).build();
    mapService.addMapping(MappingOrigin.Northbound, eid1, null, new MappingData(mapping1));
    sleepForMilliseconds((timeout * expectedSmrs1) - (timeout / 2));
    final List<MapRequest> requests1 = processSmrPackets(reader1, subscriberSrcRloc1, expectedSmrs1);
    final MapReply mapReply1 = lms.handleMapRequest(new MapRequestBuilder(requests1.get(0)).setSourceEid(new SourceEidBuilder().setEid(subscriberEid).build()).setItrRloc(Lists.newArrayList(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc(subscriberSrcRloc1)).build())).setEidItem(Lists.newArrayList(new EidItemBuilder().setEid(eid1).build())).setSmrInvoked(true).setSmr(false).build());
    // sleep to get 1 extra smr request
    sleepForMilliseconds(timeout * 1);
    final List<MapRequest> requests2 = processSmrPackets(reader2, subscriberSrcRloc2, expectedSmrs2);
    final MapReply mapReply2 = lms.handleMapRequest(new MapRequestBuilder(requests2.get(0)).setSourceEid(new SourceEidBuilder().setEid(subscriberEid).build()).setItrRloc(Lists.newArrayList(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc(subscriberSrcRloc2)).build())).setEidItem(Lists.newArrayList(new EidItemBuilder().setEid(eid1).build())).setSmrInvoked(true).setSmr(false).build());
    sleepForSeconds(3);
    assertEquals(expectedSmrs1, requests1.size());
    assertEquals(expectedSmrs2, requests2.size());
    assertEquals((long) mapReply1.getNonce(), (long) requests1.get(0).getNonce());
    assertEquals((long) mapReply2.getNonce(), (long) requests2.get(0).getNonce());
    assertNextBufferEmpty(reader1);
    assertNextBufferEmpty(reader2);
    reader1.stopReading();
    reader2.stopReading();
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) MapRequest(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest) MapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply) GotMapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) 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) InstanceIdType(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.InstanceIdType) Subscriber(org.opendaylight.lispflowmapping.interfaces.dao.Subscriber) ItrRlocBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRlocBuilder) SourceEidBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.SourceEidBuilder) MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData)

Example 8 with Subscriber

use of org.opendaylight.lispflowmapping.interfaces.dao.Subscriber in project lispflowmapping by opendaylight.

the class LispMapCacheStringifier method prettyPrintMTMCMappings.

@SuppressWarnings("unchecked")
public static String prettyPrintMTMCMappings(ILispDAO dao) {
    final StringBuilder sb = new StringBuilder();
    final IRowVisitor mappingVisitor = (new IRowVisitor() {

        public void visitRow(Object keyId, String valueKey, Object value) {
            switch(valueKey) {
                case SubKeys.RECORD:
                    MappingData md = (MappingData) value;
                    sb.append(Stringifier.getString(md.getRecord(), 2));
                    sb.append("\n");
                    break;
                case SubKeys.SUBSCRIBERS:
                    Set<Subscriber> subscribers = (Set<Subscriber>) value;
                    sb.append(prettyPrintSubscriberSet(subscribers, 4));
                    sb.append("\n");
                    break;
                case SubKeys.LCAF_SRCDST:
                    ((ILispDAO) value).getAll(this);
                    break;
                default:
                    break;
            }
        }
    });
    dao.getAll(new IRowVisitor() {

        String lastKey = "";

        public void visitRow(Object keyId, String valueKey, Object value) {
            String key = keyId.getClass().getSimpleName() + "#" + keyId;
            if (!lastKey.equals(key)) {
                sb.append("Instance ID " + keyId + "\n");
            }
            if (valueKey.equals(SubKeys.VNI)) {
                ((ILispDAO) value).getAll(mappingVisitor);
            }
            lastKey = key;
        }
    });
    return sb.toString();
}
Also used : IRowVisitor(org.opendaylight.lispflowmapping.interfaces.dao.IRowVisitor) Set(java.util.Set) Subscriber(org.opendaylight.lispflowmapping.interfaces.dao.Subscriber) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData)

Example 9 with Subscriber

use of org.opendaylight.lispflowmapping.interfaces.dao.Subscriber in project lispflowmapping by opendaylight.

the class LispMapCacheStringifier method prettyPrintSubscriberSet.

/**
 * Given a Set of Subscriber objects, and the level of indentation, create a nicely formatted String to be added
 * to a map-cache print-out in a tabular form.
 *
 * @param subscribers the Set of Subscriber objects to be printed
 * @param indentation indentation level
 * @return the formatted String
 */
public static String prettyPrintSubscriberSet(Set<Subscriber> subscribers, int indentation) {
    final String indent = new String(new char[indentation]).replace("\0", " ");
    StringBuilder sb = new StringBuilder(indent);
    sb.append("   -----------------------------------------------------------------\n");
    sb.append(indent);
    if (subscribers == null) {
        return sb.append("   No subscribers").toString();
    }
    sb.append("-> Subscriber RLOC                                 Subscriber EID\n   ");
    sb.append(indent);
    boolean first = true;
    for (Subscriber subscriber : subscribers) {
        if (first) {
            first = false;
        } else {
            sb.append("\n   ");
            sb.append(indent);
        }
        String srcRloc = LispAddressStringifier.getString(subscriber.getSrcRloc());
        int padLen = Constants.INET6_ADDRSTRLEN + 2 - srcRloc.length();
        sb.append(srcRloc);
        sb.append(new String(new char[padLen]).replace("\0", " "));
        sb.append(LispAddressStringifier.getString(subscriber.getSrcEid()));
    }
    return sb.toString();
}
Also used : Subscriber(org.opendaylight.lispflowmapping.interfaces.dao.Subscriber)

Example 10 with Subscriber

use of org.opendaylight.lispflowmapping.interfaces.dao.Subscriber in project lispflowmapping by opendaylight.

the class MappingSystem method notifyChange.

public void notifyChange(Eid eid, MappingRecord mapping, MappingChange mappingChange) {
    Set<Subscriber> subscribers = getSubscribers(eid);
    Set<Subscriber> dstSubscribers = null;
    // For SrcDst LCAF also send SMRs to Dst prefix
    if (eid.getAddress() instanceof SourceDestKey) {
        Eid dstAddr = SourceDestKeyHelper.getDstBinary(eid);
        dstSubscribers = getSubscribers(dstAddr);
        notifyChildren(dstAddr, mapping, mappingChange);
    }
    // No reason to send a notification when no subscribers exist
    if (subscribers != null || dstSubscribers != null) {
        publishNotification(mapping, eid, subscribers, dstSubscribers, mappingChange);
    }
    notifyChildren(eid, mapping, mappingChange);
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) Subscriber(org.opendaylight.lispflowmapping.interfaces.dao.Subscriber) SourceDestKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey)

Aggregations

Subscriber (org.opendaylight.lispflowmapping.interfaces.dao.Subscriber)14 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)8 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)6 SourceDestKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey)4 MappingRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder)4 Ignore (org.junit.Ignore)3 Test (org.junit.Test)3 Set (java.util.Set)2 IRowVisitor (org.opendaylight.lispflowmapping.interfaces.dao.IRowVisitor)2 MapRequest (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest)2 EidItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItemBuilder)2 LocatorRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder)2 MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)2 ItrRloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc)2 InstanceIdType (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.InstanceIdType)1 MacAfi (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.MacAfi)1 SourceDestKeyLcaf (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SourceDestKeyLcaf)1 Mac (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Mac)1 MacBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.MacBuilder)1 NoAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.NoAddress)1