Search in sources :

Example 1 with NetworkEndpointMask

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()));
}
Also used : LinkPropsGet(org.openkilda.messaging.nbtopology.request.LinkPropsGet) NetworkEndpointMask(org.openkilda.messaging.model.NetworkEndpointMask) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 2 with NetworkEndpointMask

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()));
}
Also used : GetLinksRequest(org.openkilda.messaging.nbtopology.request.GetLinksRequest) NetworkEndpointMask(org.openkilda.messaging.model.NetworkEndpointMask) MessageException(org.openkilda.messaging.error.MessageException) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 3 with NetworkEndpointMask

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);
}
Also used : NetworkEndpointMask(org.openkilda.messaging.model.NetworkEndpointMask) SwitchId(org.openkilda.model.SwitchId) LinkPropsMask(org.openkilda.messaging.model.LinkPropsMask)

Example 4 with NetworkEndpointMask

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());
}
Also used : NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) LinkPropsDto(org.openkilda.northbound.dto.v1.links.LinkPropsDto) SwitchId(org.openkilda.model.SwitchId) LinkPropsMask(org.openkilda.messaging.model.LinkPropsMask) BatchResults(org.openkilda.northbound.dto.BatchResults) LinkPropsDrop(org.openkilda.messaging.nbtopology.request.LinkPropsDrop) NetworkEndpointMask(org.openkilda.messaging.model.NetworkEndpointMask) LinkPropsResponse(org.openkilda.messaging.nbtopology.response.LinkPropsResponse) Test(org.junit.Test)

Aggregations

NetworkEndpointMask (org.openkilda.messaging.model.NetworkEndpointMask)4 CommandMessage (org.openkilda.messaging.command.CommandMessage)2 LinkPropsMask (org.openkilda.messaging.model.LinkPropsMask)2 SwitchId (org.openkilda.model.SwitchId)2 Test (org.junit.Test)1 MessageException (org.openkilda.messaging.error.MessageException)1 NetworkEndpoint (org.openkilda.messaging.model.NetworkEndpoint)1 GetLinksRequest (org.openkilda.messaging.nbtopology.request.GetLinksRequest)1 LinkPropsDrop (org.openkilda.messaging.nbtopology.request.LinkPropsDrop)1 LinkPropsGet (org.openkilda.messaging.nbtopology.request.LinkPropsGet)1 LinkPropsResponse (org.openkilda.messaging.nbtopology.response.LinkPropsResponse)1 BatchResults (org.openkilda.northbound.dto.BatchResults)1 LinkPropsDto (org.openkilda.northbound.dto.v1.links.LinkPropsDto)1