Search in sources :

Example 1 with IRowVisitor

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

the class LispMapCacheStringifier method printSMCMappings.

public static String printSMCMappings(ILispDAO dao) {
    final StringBuilder sb = new StringBuilder();
    sb.append("Keys\tValues\n");
    final IRowVisitor innerVisitor = (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("\n" + key + "\t");
            }
            sb.append(valueKey + "=" + value + "\t");
            lastKey = key;
        }
    });
    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("\n" + key + "\t");
            }
            if (valueKey.equals(SubKeys.VNI)) {
                sb.append(valueKey + "= { ");
                ((ILispDAO) value).getAll(innerVisitor);
                sb.append("}\t");
            } else {
                sb.append(valueKey + "=" + value + "\t");
            }
            lastKey = key;
        }
    });
    sb.append("\n");
    return sb.toString();
}
Also used : IRowVisitor(org.opendaylight.lispflowmapping.interfaces.dao.IRowVisitor)

Example 2 with IRowVisitor

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

the class LispMapCacheStringifier method printKeys.

public static String printKeys(ILispDAO dao) {
    final StringBuilder sb = new StringBuilder();
    sb.append("Keys\tValues\n");
    final IRowVisitor innerVisitor = (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("\n" + key + "\t");
            }
            sb.append(valueKey + "=" + value + "\t");
            lastKey = key;
        }
    });
    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("\n" + key + "\t");
            }
            if (valueKey.equals(SubKeys.VNI)) {
                sb.append(valueKey + "= { ");
                ((ILispDAO) value).getAll(innerVisitor);
                sb.append("}\t");
            } else {
                sb.append(valueKey + "=" + value + "\t");
            }
            lastKey = key;
        }
    });
    sb.append("\n");
    return sb.toString();
}
Also used : IRowVisitor(org.opendaylight.lispflowmapping.interfaces.dao.IRowVisitor)

Example 3 with IRowVisitor

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

the class LispMapCacheStringifier method prettyPrintFMCMappings.

public static String prettyPrintFMCMappings(ILispDAO dao) {
    final StringBuilder sb = new StringBuilder();
    dao.getAll(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;
                default:
                    break;
            }
        }
    });
    sb.append("\n");
    return sb.toString();
}
Also used : IRowVisitor(org.opendaylight.lispflowmapping.interfaces.dao.IRowVisitor) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData)

Example 4 with IRowVisitor

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

the class LispMapCacheStringifier method prettyPrintSMCMappings.

@SuppressWarnings("unchecked")
public static String prettyPrintSMCMappings(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;
                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 5 with IRowVisitor

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

the class LispMapCacheStringifier method printFMCMappings.

public static String printFMCMappings(ILispDAO dao) {
    final StringBuilder sb = new StringBuilder();
    sb.append("Keys\tValues\n");
    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("\n" + key + "\t");
            }
            sb.append(valueKey + "=" + value + "\t");
            lastKey = key;
        }
    });
    sb.append("\n");
    return sb.toString();
}
Also used : IRowVisitor(org.opendaylight.lispflowmapping.interfaces.dao.IRowVisitor)

Aggregations

IRowVisitor (org.opendaylight.lispflowmapping.interfaces.dao.IRowVisitor)9 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)3 Set (java.util.Set)2 Subscriber (org.opendaylight.lispflowmapping.interfaces.dao.Subscriber)2 ArrayList (java.util.ArrayList)1 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)1 MappingAuthkey (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey)1