use of org.openkilda.messaging.info.group.GroupDumpResponse in project open-kilda by telstra.
the class SwitchManagerHub method onWorkerResponse.
@Override
protected void onWorkerResponse(Tuple input) throws PipelineException {
String key = KeyProvider.getParentKey(input.getStringByField(MessageKafkaTranslator.FIELD_ID_KEY));
Message message = pullValue(input, MessageKafkaTranslator.FIELD_ID_PAYLOAD, Message.class);
if (message instanceof InfoMessage) {
InfoData data = ((InfoMessage) message).getData();
if (data instanceof FlowDumpResponse) {
validateService.handleFlowEntriesResponse(key, (FlowDumpResponse) data);
} else if (data instanceof GroupDumpResponse) {
validateService.handleGroupEntriesResponse(key, (GroupDumpResponse) data);
} else if (data instanceof DumpLogicalPortsResponse) {
validateService.handleLogicalPortResponse(key, (DumpLogicalPortsResponse) data);
} else if (data instanceof MeterDumpResponse) {
validateService.handleMeterEntriesResponse(key, (MeterDumpResponse) data);
} else if (data instanceof SwitchMeterData) {
handleMetersResponse(key, (SwitchMeterData) data);
} else if (data instanceof FlowInstallResponse) {
syncService.handleInstallRulesResponse(key);
} else if (data instanceof FlowRemoveResponse) {
syncService.handleRemoveRulesResponse(key);
} else if (data instanceof FlowReinstallResponse) {
syncService.handleReinstallDefaultRulesResponse(key, (FlowReinstallResponse) data);
} else if (data instanceof DeleteMeterResponse) {
syncService.handleRemoveMetersResponse(key);
} else if (data instanceof ModifyMeterResponse) {
syncService.handleModifyMetersResponse(key);
} else if (data instanceof InstallGroupResponse) {
syncService.handleInstallGroupResponse(key);
} else if (data instanceof ModifyGroupResponse) {
syncService.handleModifyGroupResponse(key);
} else if (data instanceof DeleteGroupResponse) {
syncService.handleDeleteGroupResponse(key);
} else if (data instanceof SwitchRulesResponse) {
switchRuleService.rulesResponse(key, (SwitchRulesResponse) data);
} else if (data instanceof CreateLogicalPortResponse) {
createLagPortService.handleGrpcResponse(key, (CreateLogicalPortResponse) data);
syncService.handleCreateLogicalPortResponse(key);
} else if (data instanceof DeleteLogicalPortResponse) {
deleteLagPortService.handleGrpcResponse(key, (DeleteLogicalPortResponse) data);
syncService.handleDeleteLogicalPortResponse(key);
} else {
log.warn("Receive unexpected InfoData for key {}: {}", key, data);
}
} else if (message instanceof ErrorMessage) {
log.warn("Receive ErrorMessage for key {}", key);
validateService.handleTaskError(key, (ErrorMessage) message);
syncService.handleTaskError(key, (ErrorMessage) message);
createLagPortService.handleTaskError(key, (ErrorMessage) message);
deleteLagPortService.handleTaskError(key, (ErrorMessage) message);
}
}
use of org.openkilda.messaging.info.group.GroupDumpResponse in project open-kilda by telstra.
the class SwitchValidateServiceImplTest method handleDataReceiveAndValidate.
private void handleDataReceiveAndValidate() {
service.handleFlowEntriesResponse(KEY, new FlowDumpResponse(SWITCH_ID, singletonList(flowSpeakerData)));
service.handleMeterEntriesResponse(KEY, new MeterDumpResponse(SWITCH_ID, singletonList(meterSpeakerData)));
service.handleGroupEntriesResponse(KEY, new GroupDumpResponse(SWITCH_ID, emptyList()));
verify(validationService).validateRules(eq(SWITCH_ID), any(), any());
verify(validationService).validateMeters(eq(SWITCH_ID), any(), any());
verify(validationService).validateGroups(eq(SWITCH_ID), any(), any());
}
use of org.openkilda.messaging.info.group.GroupDumpResponse in project open-kilda by telstra.
the class SwitchValidateServiceImplTest method validationSuccessWithUnsupportedMeters.
@Test
public void validationSuccessWithUnsupportedMeters() {
handleRequestAndInitDataReceive();
service.handleFlowEntriesResponse(KEY, new FlowDumpResponse(SWITCH_ID, singletonList(flowSpeakerData)));
service.handleMetersUnsupportedResponse(KEY);
service.handleGroupEntriesResponse(KEY, new GroupDumpResponse(SWITCH_ID, emptyList()));
verify(validationService).validateRules(eq(SWITCH_ID), any(), any());
verify(validationService).validateGroups(eq(SWITCH_ID), any(), any());
verify(carrier).cancelTimeoutCallback(eq(KEY));
ArgumentCaptor<InfoMessage> responseCaptor = ArgumentCaptor.forClass(InfoMessage.class);
verify(carrier).response(eq(KEY), responseCaptor.capture());
SwitchValidationResponse response = (SwitchValidationResponse) responseCaptor.getValue().getData();
assertEquals(singletonList(flowSpeakerData.getCookie().getValue()), response.getRules().getMissing());
assertNull(response.getMeters());
verifyNoMoreInteractions(carrier);
verifyNoMoreInteractions(validationService);
}
use of org.openkilda.messaging.info.group.GroupDumpResponse in project open-kilda by telstra.
the class SwitchValidateServiceImplTest method validationWithoutMetersSuccess.
@Test
public void validationWithoutMetersSuccess() {
request = SwitchValidateRequest.builder().switchId(SWITCH_ID).build();
service.handleSwitchValidateRequest(KEY, request);
verify(carrier, times(2)).sendCommandToSpeaker(eq(KEY), any(CommandData.class));
service.handleFlowEntriesResponse(KEY, new FlowDumpResponse(SWITCH_ID, singletonList(flowSpeakerData)));
service.handleGroupEntriesResponse(KEY, new GroupDumpResponse(SWITCH_ID, emptyList()));
verify(validationService).validateRules(eq(SWITCH_ID), any(), any());
verify(validationService).validateGroups(eq(SWITCH_ID), any(), any());
verify(carrier).cancelTimeoutCallback(eq(KEY));
ArgumentCaptor<InfoMessage> responseCaptor = ArgumentCaptor.forClass(InfoMessage.class);
verify(carrier).response(eq(KEY), responseCaptor.capture());
SwitchValidationResponse response = (SwitchValidationResponse) responseCaptor.getValue().getData();
assertEquals(singletonList(flowSpeakerData.getCookie().getValue()), response.getRules().getMissing());
assertNull(response.getMeters());
verifyNoMoreInteractions(carrier);
verifyNoMoreInteractions(validationService);
}
use of org.openkilda.messaging.info.group.GroupDumpResponse in project open-kilda by telstra.
the class RecordHandler method dumpRuleMangerGroupsRequest.
private void dumpRuleMangerGroupsRequest(SwitchId switchId, java.util.function.Consumer<MessageData> sender) {
try {
logger.debug("Loading installed groups for switch {}", switchId);
List<OFGroupDescStatsEntry> ofGroupDescStatsEntries = context.getSwitchManager().dumpGroups(DatapathId.of(switchId.toLong()));
List<GroupSpeakerData> groups = ofGroupDescStatsEntries.stream().map(OfGroupConverter.INSTANCE::convertToGroupSpeakerData).collect(Collectors.toList());
GroupDumpResponse response = GroupDumpResponse.builder().switchId(switchId).groupSpeakerData(groups).build();
sender.accept(response);
} catch (SwitchOperationException e) {
logger.error("Dumping of groups on switch '{}' was unsuccessful: {}", switchId, e.getMessage());
ErrorData errorData = anError(ErrorType.NOT_FOUND).withMessage(e.getMessage()).withDescription("The switch was not found when requesting a groups dump.").buildData();
sender.accept(errorData);
}
}
Aggregations