use of org.openkilda.messaging.model.NetworkEndpointMask in project open-kilda by telstra.
the class LinkServiceImpl method getLinkProps.
@Override
public CompletableFuture<List<LinkPropsDto>> getLinkProps(SwitchId srcSwitch, Integer srcPort, SwitchId dstSwitch, Integer dstPort) {
final String correlationId = RequestCorrelationId.getId();
logger.debug("Get link properties request received");
LinkPropsGet request = new LinkPropsGet(new NetworkEndpointMask(srcSwitch, srcPort), new NetworkEndpointMask(dstSwitch, dstPort));
CommandMessage message = new CommandMessage(request, System.currentTimeMillis(), correlationId);
return messagingChannel.sendAndGetChunked(nbworkerTopic, message).thenApply(response -> response.stream().map(LinkPropsData.class::cast).map(linkPropsMapper::toDto).collect(Collectors.toList()));
}
use of org.openkilda.messaging.model.NetworkEndpointMask in project open-kilda by telstra.
the class LinkServiceImpl method getLinks.
@Override
public CompletableFuture<List<LinkDto>> getLinks(SwitchId srcSwitch, Integer srcPort, SwitchId dstSwitch, Integer dstPort) {
final String correlationId = RequestCorrelationId.getId();
logger.debug("Get links request received");
GetLinksRequest request = null;
try {
request = new GetLinksRequest(new NetworkEndpointMask(srcSwitch, srcPort), new NetworkEndpointMask(dstSwitch, dstPort));
} catch (IllegalArgumentException e) {
logger.error("Can not parse arguments: {}", e.getMessage());
throw new MessageException(correlationId, System.currentTimeMillis(), ErrorType.DATA_INVALID, e.getMessage(), "Can not parse arguments when create 'get links' request");
}
CommandMessage message = new CommandMessage(request, System.currentTimeMillis(), correlationId);
return messagingChannel.sendAndGetChunked(nbworkerTopic, message).thenApply(response -> response.stream().map(IslInfoData.class::cast).map(linkMapper::mapResponse).collect(Collectors.toList()));
}
use of org.openkilda.messaging.model.NetworkEndpointMask in project open-kilda by telstra.
the class LinkPropsMapper method toLinkPropsMask.
/**
* Converts {@link org.openkilda.northbound.dto.v1.links.LinkPropsDto} into {@link LinkPropsMask}.
*/
default LinkPropsMask toLinkPropsMask(org.openkilda.northbound.dto.v1.links.LinkPropsDto input) {
NetworkEndpointMask source = new NetworkEndpointMask(new SwitchId(input.getSrcSwitch()), input.getSrcPort());
NetworkEndpointMask dest = new NetworkEndpointMask(new SwitchId(input.getDstSwitch()), input.getDstPort());
return new LinkPropsMask(source, dest);
}
use of org.openkilda.messaging.model.NetworkEndpointMask in project open-kilda by telstra.
the class LinkServiceTest method dropLinkProps.
@Test
public void dropLinkProps() {
final String correlationId = getClass().getCanonicalName();
LinkPropsDto input = new LinkPropsDto("ff:fe:00:00:00:00:00:01", 8, "ff:fe:00:00:00:00:00:05", null, null);
LinkPropsDrop request = new LinkPropsDrop(new LinkPropsMask(new NetworkEndpointMask(new SwitchId(input.getSrcSwitch()), input.getSrcPort()), new NetworkEndpointMask(new SwitchId(input.getDstSwitch()), input.getDstPort())));
org.openkilda.messaging.model.LinkPropsDto linkProps = new org.openkilda.messaging.model.LinkPropsDto(new NetworkEndpoint(new SwitchId(input.getSrcSwitch()), input.getSrcPort()), new NetworkEndpoint(new SwitchId("ff:fe:00:00:00:00:00:02"), 9), new HashMap<>());
LinkPropsResponse payload = new LinkPropsResponse(request, linkProps, null);
String requestIdBatch = idFactory.produceChained(String.valueOf(requestIdIndex++), correlationId);
messageExchanger.mockChunkedResponse(requestIdBatch, Collections.singletonList(payload));
RequestCorrelationId.create(correlationId);
BatchResults result = linkService.delLinkProps(Collections.singletonList(input)).join();
assertThat(result.getFailures(), is(0));
assertThat(result.getSuccesses(), is(1));
assertTrue(result.getMessages().isEmpty());
}
Aggregations