use of org.openkilda.messaging.command.flow.ModifyDefaultMeterForSwitchManagerRequest in project open-kilda by telstra.
the class SwitchSyncFsm method sendMetersCommands.
protected void sendMetersCommands(SwitchSyncState from, SwitchSyncState to, SwitchSyncEvent event, Object context) {
if (excessMeters.isEmpty() && misconfiguredMeters.isEmpty()) {
log.info("Nothing to do with meters (switch={}, key={})", switchId, key);
fire(NEXT);
return;
}
if (!excessMeters.isEmpty()) {
log.info("Request to remove switch meters has been sent (switch={}, key={})", switchId, key);
excessMetersPendingResponsesCount = excessMeters.size();
for (Long meterId : excessMeters) {
carrier.sendCommandToSpeaker(key, new DeleterMeterForSwitchManagerRequest(switchId, meterId));
}
}
if (!misconfiguredMeters.isEmpty()) {
log.info("Request to modify switch meters has been sent (switch={}, key={})", switchId, key);
misconfiguredMetersPendingResponsesCount = misconfiguredMeters.size();
for (ModifyDefaultMeterForSwitchManagerRequest request : misconfiguredMeters) {
carrier.sendCommandToSpeaker(key, request);
}
}
}
use of org.openkilda.messaging.command.flow.ModifyDefaultMeterForSwitchManagerRequest 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);
}
}
use of org.openkilda.messaging.command.flow.ModifyDefaultMeterForSwitchManagerRequest 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);
}
}
use of org.openkilda.messaging.command.flow.ModifyDefaultMeterForSwitchManagerRequest in project open-kilda by telstra.
the class CommandBuilderImpl method buildCommandsToModifyMisconfiguredMeters.
@Override
public List<ModifyDefaultMeterForSwitchManagerRequest> buildCommandsToModifyMisconfiguredMeters(SwitchId switchId, List<Long> misconfiguredDefaultMeters, List<MeterInfoEntry> misconfiguredFlowMeters) {
List<ModifyDefaultMeterForSwitchManagerRequest> commands = misconfiguredDefaultMeters.stream().map(meterId -> new ModifyDefaultMeterForSwitchManagerRequest(switchId, meterId)).collect(Collectors.toList());
for (MeterInfoEntry meter : misconfiguredFlowMeters) {
long rate = Optional.ofNullable(meter.getExpected().getRate()).orElse(meter.getRate());
commands.add(new ModifyFlowMeterForSwitchManagerRequest(switchId, meter.getMeterId(), rate));
}
return commands;
}
Aggregations