use of org.openkilda.messaging.nbtopology.response.LinkPropsResponse in project open-kilda by telstra.
the class LinkServiceTest method updateMaxBandwidth.
@Test
public void updateMaxBandwidth() {
final String correlationId = "update-max-bw-corrId";
Long maxBandwidth = 1000L;
SwitchId srcSwitch = new SwitchId("ff:fe:00:00:00:00:00:01");
Integer srcPort = 8;
SwitchId dstSwitch = new SwitchId("ff:fe:00:00:00:00:00:02");
Integer dstPort = 9;
LinkMaxBandwidthRequest inputRequest = new LinkMaxBandwidthRequest();
inputRequest.setMaxBandwidth(maxBandwidth);
HashMap<String, String> requestProps = new HashMap<>();
requestProps.put(LinkProps.MAX_BANDWIDTH_PROP_NAME, String.valueOf(maxBandwidth));
org.openkilda.messaging.model.LinkPropsDto linkProps = new org.openkilda.messaging.model.LinkPropsDto(new NetworkEndpoint(srcSwitch, srcPort), new NetworkEndpoint(dstSwitch, dstPort), requestProps);
LinkPropsRequest request = new LinkPropsPut(linkProps);
LinkPropsResponse payload = new LinkPropsResponse(request, linkProps, null);
messageExchanger.mockResponse(correlationId, payload);
RequestCorrelationId.create(correlationId);
LinkMaxBandwidthDto result = linkService.updateLinkBandwidth(srcSwitch, srcPort, dstSwitch, dstPort, inputRequest).join();
assertEquals(srcSwitch.toString(), result.getSrcSwitch());
assertEquals(dstSwitch.toString(), result.getDstSwitch());
assertEquals(srcPort, result.getSrcPort());
assertEquals(dstPort, result.getDstPort());
assertEquals(maxBandwidth, result.getMaxBandwidth());
}
use of org.openkilda.messaging.nbtopology.response.LinkPropsResponse in project open-kilda by telstra.
the class LinkServiceImpl method updateLinkBandwidth.
/**
* {@inheritDoc}
*/
@Override
public CompletableFuture<LinkMaxBandwidthDto> updateLinkBandwidth(SwitchId srcSwitch, Integer srcPort, SwitchId dstSwitch, Integer dstPort, LinkMaxBandwidthRequest input) {
if (input.getMaxBandwidth() == null || input.getMaxBandwidth() < 0) {
throw new MessageException(ErrorType.PARAMETERS_INVALID, "Invalid value of max_bandwidth", "Maximum bandwidth must not be null");
}
if (srcPort < 0) {
throw new MessageException(ErrorType.PARAMETERS_INVALID, "Invalid value of source port", "Port number can't be negative");
}
if (dstPort < 0) {
throw new MessageException(ErrorType.PARAMETERS_INVALID, "Invalid value of destination port", "Port number can't be negative");
}
org.openkilda.messaging.model.LinkPropsDto linkProps = org.openkilda.messaging.model.LinkPropsDto.builder().source(new NetworkEndpoint(srcSwitch, srcPort)).dest(new NetworkEndpoint(dstSwitch, dstPort)).props(ImmutableMap.of(LinkProps.MAX_BANDWIDTH_PROP_NAME, input.getMaxBandwidth().toString())).build();
LinkPropsPut request = new LinkPropsPut(linkProps);
String correlationId = RequestCorrelationId.getId();
CommandMessage message = new CommandMessage(request, System.currentTimeMillis(), correlationId);
return messagingChannel.sendAndGet(nbworkerTopic, message).thenApply(response -> linkPropsMapper.toLinkMaxBandwidth(((LinkPropsResponse) response).getLinkProps()));
}
Aggregations