use of org.projectfloodlight.openflow.protocol.OFGroupDescStatsReply in project open-kilda by telstra.
the class GroupVerifyCommand method handleGroupStats.
private MirrorConfig handleGroupStats(List<OFGroupDescStatsReply> groupDescStatsReply) {
OFGroupDescStatsEntry target = null;
List<OFGroupDescStatsEntry> groupDescStatsEntries = groupDescStatsReply.stream().map(OFGroupDescStatsReply::getEntries).flatMap(List::stream).collect(toList());
for (OFGroupDescStatsEntry entry : groupDescStatsEntries) {
if (mirrorConfig.getGroupId().intValue() == entry.getGroup().getGroupNumber()) {
target = entry;
break;
}
}
if (target == null) {
throw maskCallbackException(new SwitchMissingGroupException(getSw().getId(), mirrorConfig.getGroupId()));
}
validateGroupConfig(target);
return mirrorConfig;
}
use of org.projectfloodlight.openflow.protocol.OFGroupDescStatsReply in project open-kilda by telstra.
the class OfBatchExecutor method verifyGroups.
private void verifyGroups() {
log.debug("Verify groups with key: {} (hasGroups={})", kafkaKey, hasGroups);
if (!hasGroups) {
return;
}
try {
List<OFGroupDescStatsReply> replies = groupStats.get();
List<GroupSpeakerData> switchGroups = new ArrayList<>();
replies.forEach(reply -> switchGroups.addAll(OfGroupConverter.INSTANCE.convertToGroupSpeakerData(reply)));
for (GroupSpeakerData switchGroup : switchGroups) {
GroupSpeakerData expectedGroup = holder.getByGroupId(switchGroup.getGroupId());
if (expectedGroup != null) {
if (switchGroup.equals(expectedGroup)) {
holder.recordSuccessUuid(expectedGroup.getUuid());
} else {
holder.recordFailedUuid(expectedGroup.getUuid(), format("Failed to validate group on a switch. Expected: %s, actual: %s", expectedGroup, switchGroup));
}
}
}
} catch (Exception e) {
log.error("Failed to verify groups for message", e);
}
}
use of org.projectfloodlight.openflow.protocol.OFGroupDescStatsReply in project open-kilda by telstra.
the class SwitchManagerTest method mockGetGroupsRequest.
private void mockGetGroupsRequest(List<Integer> groupIds) throws Exception {
List<OFGroupDescStatsEntry> meterConfigs = new ArrayList<>(groupIds.size());
for (Integer groupId : groupIds) {
OFBucket firstBucket = mock(OFBucket.class);
OFBucket secondBucket = mock(OFBucket.class);
OFActionSetField setDestMacAction = ofFactory.actions().buildSetField().setField(ofFactory.oxms().buildEthDst().setValue(convertDpIdToMac(dpid)).build()).build();
OFActionOutput sendToControllerAction = ofFactory.actions().output(OFPort.CONTROLLER, 0xFFFFFFFF);
TransportPort udpPort = TransportPort.of(LATENCY_PACKET_UDP_PORT);
OFActionSetField setUdpDstAction = ofFactory.actions().setField(ofFactory.oxms().udpDst(udpPort));
OFActionOutput sendInPortAction = ofFactory.actions().output(OFPort.IN_PORT, 0xFFFFFFFF);
expect(firstBucket.getActions()).andStubReturn(Lists.newArrayList(setDestMacAction, sendToControllerAction));
expect(secondBucket.getActions()).andStubReturn(Lists.newArrayList(setUdpDstAction, sendInPortAction));
OFGroupDescStatsEntry groupEntry = mock(OFGroupDescStatsEntry.class);
expect(groupEntry.getGroup()).andStubReturn(OFGroup.of(groupId));
expect(groupEntry.getBuckets()).andStubReturn(Lists.newArrayList(firstBucket, secondBucket));
replay(firstBucket, secondBucket, groupEntry);
meterConfigs.add(groupEntry);
}
OFGroupDescStatsReply statsReply = mock(OFGroupDescStatsReply.class);
expect(statsReply.getEntries()).andStubReturn(meterConfigs);
ListenableFuture<List<OFGroupDescStatsReply>> ofStatsFuture = mock(ListenableFuture.class);
expect(ofStatsFuture.get(anyLong(), anyObject())).andStubReturn(Collections.singletonList(statsReply));
expect(iofSwitch.writeStatsRequest(isA(OFGroupDescStatsRequest.class))).andStubReturn(ofStatsFuture);
replay(statsReply, ofStatsFuture);
}
use of org.projectfloodlight.openflow.protocol.OFGroupDescStatsReply in project open-kilda by telstra.
the class SwitchManager method dumpGroups.
private List<OFGroupDescStatsEntry> dumpGroups(IOFSwitch sw) {
OFFactory ofFactory = sw.getOFFactory();
OFGroupDescStatsRequest groupRequest = ofFactory.buildGroupDescStatsRequest().build();
List<OFGroupDescStatsReply> replies;
try {
ListenableFuture<List<OFGroupDescStatsReply>> future = sw.writeStatsRequest(groupRequest);
replies = future.get(10, TimeUnit.SECONDS);
} catch (ExecutionException | TimeoutException e) {
logger.error("Could not dump groups on switch {}.", sw.getId(), e);
return Collections.emptyList();
} catch (InterruptedException e) {
logger.error("Could not dump groups on switch {}.", sw.getId(), e);
Thread.currentThread().interrupt();
return Collections.emptyList();
}
return replies.stream().map(OFGroupDescStatsReply::getEntries).flatMap(List::stream).collect(toList());
}
Aggregations