use of org.opendaylight.lispflowmapping.interfaces.dao.IRowVisitor in project lispflowmapping by opendaylight.
the class LispMapCacheStringifier method printMTMCMappings.
public static String printMTMCMappings(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;
}
});
final IRowVisitor vniVisitor = (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(key + "\t");
}
if ((valueKey.equals(SubKeys.LCAF_SRCDST))) {
sb.append(valueKey + "= { ");
((ILispDAO) value).getAll(innerVisitor);
sb.append("}\t");
} else {
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(vniVisitor);
sb.append("}\t");
} else {
sb.append(valueKey + "=" + value + "\t");
}
lastKey = key;
}
});
sb.append("\n");
return sb.toString();
}
use of org.opendaylight.lispflowmapping.interfaces.dao.IRowVisitor in project lispflowmapping by opendaylight.
the class SimpleMapCache method getXtrIdMappingList.
// Returns the list of mappings stored in an xTR-ID DAO
private List<Object> getXtrIdMappingList(ILispDAO lispDAO) {
if (lispDAO != null) {
final List<Object> records = new ArrayList<>();
lispDAO.getAll(new IRowVisitor() {
public void visitRow(Object keyId, String valueKey, Object value) {
if (valueKey.equals(SubKeys.RECORD)) {
records.add(value);
}
}
});
return records;
}
return null;
}
use of org.opendaylight.lispflowmapping.interfaces.dao.IRowVisitor 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();
}
use of org.opendaylight.lispflowmapping.interfaces.dao.IRowVisitor in project lispflowmapping by opendaylight.
the class LispMapCacheStringifier method prettyPrintKeys.
@SuppressWarnings("unchecked")
public static String prettyPrintKeys(ILispDAO dao) {
final StringBuilder sb = new StringBuilder();
final IRowVisitor innerVisitor = (new IRowVisitor() {
public void visitRow(Object keyId, String valueKey, Object value) {
switch(valueKey) {
case SubKeys.AUTH_KEY:
String eid = LispAddressStringifier.getString((Eid) keyId);
sb.append(" ");
sb.append(eid);
int padLen = Math.max(2, Constants.INET6_ADDRSTRLEN - eid.length());
sb.append(Stringifier.getSpacesAsString(padLen));
MappingAuthkey authKey = (MappingAuthkey) value;
String hmac = LispKeyIDEnum.valueOf(authKey.getKeyType().shortValue()).getAuthenticationName();
sb.append(hmac);
sb.append(Stringifier.getSpacesAsString(Math.max(2, 22 - hmac.length())));
sb.append(authKey.getKeyString());
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");
sb.append(" -> EID HMAC Algorithm Shared Key\n");
}
if (valueKey.equals(SubKeys.VNI)) {
((ILispDAO) value).getAll(innerVisitor);
}
lastKey = key;
}
});
return sb.toString();
}
Aggregations