use of org.openkilda.messaging.info.switches.ModifyMeterResponse 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.switches.ModifyMeterResponse in project open-kilda by telstra.
the class RecordHandler method doModifyFlowMeterForSwitchManager.
private void doModifyFlowMeterForSwitchManager(CommandMessage message) {
ModifyFlowMeterForSwitchManagerRequest request = (ModifyFlowMeterForSwitchManagerRequest) message.getData();
IKafkaProducerService producerService = getKafkaProducer();
long meterId = request.getMeterId();
SwitchId switchId = request.getSwitchId();
MeterConfig meterConfig = new MeterConfig(new MeterId(request.getMeterId()), request.getRate());
logger.info("Modifying flow meter {} on Switch {}", meterId, switchId);
handleSpeakerCommand(new MeterModifyCommand(new MessageContext(message), switchId, meterConfig));
InfoMessage response = new InfoMessage(new ModifyMeterResponse(switchId, request.getMeterId()), System.currentTimeMillis(), message.getCorrelationId());
producerService.sendMessageAndTrack(context.getKafkaSwitchManagerTopic(), message.getCorrelationId(), response);
}
use of org.openkilda.messaging.info.switches.ModifyMeterResponse in project open-kilda by telstra.
the class RecordHandler method doModifyDefaultMeterForSwitchManager.
private void doModifyDefaultMeterForSwitchManager(CommandMessage message) {
ModifyDefaultMeterForSwitchManagerRequest request = (ModifyDefaultMeterForSwitchManagerRequest) message.getData();
IKafkaProducerService producerService = getKafkaProducer();
String replyToTopic = context.getKafkaSwitchManagerTopic();
long meterId = request.getMeterId();
SwitchId switchId = request.getSwitchId();
DatapathId dpid = DatapathId.of(switchId.toLong());
try {
context.getSwitchManager().modifyDefaultMeter(dpid, request.getMeterId());
InfoMessage response = new InfoMessage(new ModifyMeterResponse(switchId, request.getMeterId()), System.currentTimeMillis(), message.getCorrelationId());
producerService.sendMessageAndTrack(replyToTopic, message.getCorrelationId(), response);
} catch (UnsupportedSwitchOperationException e) {
logger.warn(format("Skip meter %d modification on switch %s because switch doesn't support meters", meterId, switchId), e);
} catch (InvalidMeterIdException | OfInstallException | SwitchNotFoundException e) {
logger.error("Failed to modify meter {} for switch: '{}'", request.getSwitchId(), meterId, e);
ErrorType errorType;
if (e instanceof InvalidMeterIdException) {
errorType = ErrorType.DATA_INVALID;
} else if (e instanceof SwitchNotFoundException) {
errorType = ErrorType.NOT_FOUND;
} else {
errorType = ErrorType.INTERNAL_ERROR;
}
anError(errorType).withMessage(e.getMessage()).withDescription(request.getSwitchId().toString()).withCorrelationId(message.getCorrelationId()).withTopic(replyToTopic).sendVia(producerService);
}
}
Aggregations