use of org.onosproject.net.group.DefaultGroupKey in project fabric-tna by stratum.
the class FabricIntProgrammableTest method testInit.
private void testInit() {
final List<GroupDescription> expectedGroups = Lists.newArrayList();
final Capture<GroupDescription> capturedGroup = newCapture(CaptureType.ALL);
final Map<Integer, Long> recircPorts = intProgrammable.capabilities.isArchV1model() ? V1MODEL_MIRROR_SESS_TO_RECIRC_PORTS : QUAD_PIPE_MIRROR_SESS_TO_RECIRC_PORTS;
recircPorts.forEach((sessionId, port) -> {
// Set up mirror sessions
final List<GroupBucket> buckets = ImmutableList.of(getCloneBucket(port));
expectedGroups.add(new DefaultGroupDescription(LEAF_DEVICE_ID, GroupDescription.Type.CLONE, new GroupBuckets(buckets), new DefaultGroupKey(KRYO.serialize(sessionId)), sessionId, APP_ID));
groupService.addGroup(capture(capturedGroup));
});
replay(groupService, flowRuleService);
assertTrue(intProgrammable.init());
for (int i = 0; i < recircPorts.size(); i++) {
GroupDescription expectGroup = expectedGroups.get(i);
GroupDescription actualGroup = capturedGroup.getValues().get(i);
assertEquals(expectGroup, actualGroup);
}
verify(groupService, flowRuleService);
reset(groupService, flowRuleService);
}
use of org.onosproject.net.group.DefaultGroupKey in project fabric-tna by stratum.
the class FabricIntProgrammable method init.
@Override
public boolean init() {
if (!setupBehaviour()) {
return false;
}
Map<Integer, Long> sessionToPortMap = null;
if (capabilities.isArchTna()) {
final int hwPipeCount = capabilities.hwPipeCount();
switch(hwPipeCount) {
case 4:
sessionToPortMap = QUAD_PIPE_MIRROR_SESS_TO_RECIRC_PORTS;
break;
case 2:
sessionToPortMap = DUAL_PIPE_MIRROR_SESS_TO_RECIRC_PORTS;
break;
default:
log.error("{} it not a valid HW pipe count", hwPipeCount);
return false;
}
} else if (capabilities.isArchV1model()) {
sessionToPortMap = V1MODEL_MIRROR_SESS_TO_RECIRC_PORT;
}
// Mirroring sessions for report cloning.
sessionToPortMap.forEach((sessionId, port) -> {
// Set up mirror sessions
TrafficTreatment.Builder trafficTreatment = DefaultTrafficTreatment.builder().setOutput(PortNumber.portNumber(port));
if (capabilities.isArchTna()) {
trafficTreatment.truncate(INT_MIRROR_TRUNCATE_MAX_LEN);
}
final List<GroupBucket> buckets = ImmutableList.of(createCloneGroupBucket(trafficTreatment.build()));
groupService.addGroup(new DefaultGroupDescription(deviceId, GroupDescription.Type.CLONE, new GroupBuckets(buckets), new DefaultGroupKey(KRYO.serialize(sessionId)), sessionId, appId));
});
return true;
}
Aggregations