use of org.openkilda.messaging.command.flow.MeterModifyCommandRequest in project open-kilda by telstra.
the class FlowMeterModifyFsm method modifyMeters.
protected void modifyMeters(FlowMeterModifyState from, FlowMeterModifyState to, FlowMeterModifyEvent event, Object context) {
log.info("Key: {}; Send commands to modify meters", key);
SwitchId forwardSwitchId = flow.getForwardPath().getSrcSwitchId();
SwitchId reverseSwitchId = flow.getReversePath().getSrcSwitchId();
long bandwidth = flow.getForwardPath().getBandwidth();
MeterId forwardMeterId = flow.getForwardPath().getMeterId();
MeterId reverseMeterId = flow.getReversePath().getMeterId();
if (forwardMeterId == null || reverseMeterId == null) {
sendException(String.format("Flow '%s' is unmetered", flowId), "Modify meters in FlowMeterModifyFsm ", ErrorType.REQUEST_INVALID);
return;
}
carrier.sendCommandToSpeakerWorker(key, new MeterModifyCommandRequest(forwardSwitchId, forwardMeterId.getValue(), bandwidth));
carrier.sendCommandToSpeakerWorker(key, new MeterModifyCommandRequest(reverseSwitchId, reverseMeterId.getValue(), bandwidth));
}
use of org.openkilda.messaging.command.flow.MeterModifyCommandRequest in project open-kilda by telstra.
the class RecordHandler method doModifyMeterRequest.
private void doModifyMeterRequest(CommandMessage message) {
MeterModifyCommandRequest request = (MeterModifyCommandRequest) message.getData();
final IKafkaProducerService producerService = getKafkaProducer();
String replyToTopic = context.getKafkaNbWorkerTopic();
SwitchId switchId = request.getSwitchId();
DatapathId datapathId = DatapathId.of(switchId.toLong());
long meterId = request.getMeterId();
ISwitchManager switchManager = context.getSwitchManager();
try {
switchManager.modifyMeterForFlow(datapathId, meterId, request.getBandwidth());
MeterEntry meterEntry = OfMeterConverter.toMeterEntry(switchManager.dumpMeterById(datapathId, meterId));
SwitchMeterEntries response = SwitchMeterEntries.builder().switchId(switchId).meterEntries(ImmutableList.of(meterEntry)).build();
InfoMessage infoMessage = new InfoMessage(response, message.getTimestamp(), message.getCorrelationId());
producerService.sendMessageAndTrack(replyToTopic, message.getCorrelationId(), infoMessage);
} catch (UnsupportedSwitchOperationException e) {
String messageString = String.format("Not supported: %s", new SwitchId(e.getDpId().getLong()));
logger.error(messageString, e);
anError(ErrorType.PARAMETERS_INVALID).withMessage(e.getMessage()).withDescription(messageString).withCorrelationId(message.getCorrelationId()).withTopic(replyToTopic).sendVia(producerService);
} catch (SwitchNotFoundException e) {
logger.error("Update switch meters is unsuccessful. Switch {} not found", new SwitchId(e.getDpId().getLong()));
anError(ErrorType.NOT_FOUND).withMessage(e.getMessage()).withDescription(new SwitchId(e.getDpId().getLong()).toString()).withCorrelationId(message.getCorrelationId()).withTopic(replyToTopic).sendVia(producerService);
} catch (SwitchOperationException e) {
String messageString = "Unable to update meter";
logger.error(messageString, e);
anError(ErrorType.NOT_FOUND).withMessage(e.getMessage()).withDescription(messageString).withCorrelationId(message.getCorrelationId()).withTopic(replyToTopic).sendVia(producerService);
}
}
use of org.openkilda.messaging.command.flow.MeterModifyCommandRequest in project open-kilda by telstra.
the class RecordHandler method handleCommand.
@VisibleForTesting
void handleCommand(CommandMessage message) {
logger.debug("Handling message: '{}'.", message);
CommandData data = message.getData();
if (data instanceof DiscoverIslCommandData) {
doDiscoverIslCommand((DiscoverIslCommandData) data, message.getCorrelationId());
} else if (data instanceof DiscoverPathCommandData) {
doDiscoverPathCommand(data);
} else if (data instanceof RemoveFlowForSwitchManagerRequest) {
doDeleteFlowForSwitchManager(message);
} else if (data instanceof ModifyFlowMeterForSwitchManagerRequest) {
doModifyFlowMeterForSwitchManager(message);
} else if (data instanceof ModifyDefaultMeterForSwitchManagerRequest) {
doModifyDefaultMeterForSwitchManager(message);
} else if (data instanceof ReinstallDefaultFlowForSwitchManagerRequest) {
doReinstallDefaultFlowForSwitchManager(message);
} else if (data instanceof NetworkCommandData) {
doNetworkDump((NetworkCommandData) data);
} else if (data instanceof SwitchRulesDeleteRequest) {
doDeleteSwitchRules(message);
} else if (data instanceof SwitchRulesInstallRequest) {
doInstallSwitchRules(message);
} else if (data instanceof DumpRulesForFlowHsRequest) {
doDumpRulesForFlowHsRequest(message);
} else if (data instanceof DumpRulesRequest) {
doDumpRulesRequest(message);
} else if (data instanceof DumpRulesForSwitchManagerRequest) {
doDumpRulesForSwitchManagerRequest(message);
} else if (data instanceof InstallFlowForSwitchManagerRequest) {
doInstallFlowForSwitchManager(message);
} else if (data instanceof DeleterMeterForSwitchManagerRequest) {
doDeleteMeter(message, context.getKafkaSwitchManagerTopic());
} else if (data instanceof DeleteMeterRequest) {
doDeleteMeter(message, context.getKafkaNorthboundTopic());
} else if (data instanceof PortConfigurationRequest) {
doConfigurePort(message);
} else if (data instanceof DumpSwitchPortsDescriptionRequest) {
doDumpSwitchPortsDescriptionRequest(message);
} else if (data instanceof DumpPortDescriptionRequest) {
doDumpPortDescriptionRequest(message);
} else if (data instanceof DumpMetersRequest) {
doDumpMetersRequest(message);
} else if (data instanceof DumpMetersForSwitchManagerRequest) {
doDumpMetersForSwitchManagerRequest(message);
} else if (data instanceof DumpMetersForFlowHsRequest) {
doDumpMetersForFlowHsRequest(message);
} else if (data instanceof MeterModifyCommandRequest) {
doModifyMeterRequest(message);
} else if (data instanceof AliveRequest) {
doAliveRequest(message);
} else if (data instanceof InstallIslDefaultRulesCommand) {
doInstallIslDefaultRule(message);
} else if (data instanceof RemoveIslDefaultRulesCommand) {
doRemoveIslDefaultRule(message);
} else if (data instanceof DumpGroupsForSwitchManagerRequest) {
doDumpGroupsForSwitchManagerRequest(message);
} else if (data instanceof DumpGroupsForFlowHsRequest) {
doDumpGroupsForFlowHsRequest(message);
} else if (data instanceof InstallGroupRequest) {
doInstallGroupRequest(message);
} else if (data instanceof ModifyGroupRequest) {
doModifyGroupRequest(message);
} else if (data instanceof DeleteGroupRequest) {
doDeleteGroupRequest(message);
} else if (data instanceof BroadcastWrapper) {
handleBroadcastCommand(message, (BroadcastWrapper) data);
} else {
handlerNotFound(data);
}
}
Aggregations