Search in sources :

Example 1 with LinkPropsDrop

use of org.openkilda.messaging.nbtopology.request.LinkPropsDrop 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)

Example 2 with LinkPropsDrop

use of org.openkilda.messaging.nbtopology.request.LinkPropsDrop in project open-kilda by telstra.

the class LinkServiceImpl method delLinkProps.

@Override
public CompletableFuture<BatchResults> delLinkProps(List<LinkPropsDto> linkPropsList) {
    List<CompletableFuture<List<InfoData>>> pendingRequest = new ArrayList<>(linkPropsList.size());
    for (LinkPropsDto requestItem : linkPropsList) {
        LinkPropsDrop request = new LinkPropsDrop(linkPropsMapper.toLinkPropsMask(requestItem));
        String requestId = idFactory.produceChained(RequestCorrelationId.getId());
        CommandMessage message = new CommandMessage(request, System.currentTimeMillis(), requestId);
        pendingRequest.add(messagingChannel.sendAndGetChunked(nbworkerTopic, message));
    }
    return collectChunkedResponses(pendingRequest, LinkPropsResponse.class).thenApply(responses -> getLinkPropsResult(responses, new ArrayList<>()));
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) LinkPropsResponse(org.openkilda.messaging.nbtopology.response.LinkPropsResponse) InfoData(org.openkilda.messaging.info.InfoData) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) ArrayList(java.util.ArrayList) LinkPropsDto(org.openkilda.northbound.dto.v1.links.LinkPropsDto) LinkPropsDrop(org.openkilda.messaging.nbtopology.request.LinkPropsDrop) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Aggregations

LinkPropsDrop (org.openkilda.messaging.nbtopology.request.LinkPropsDrop)2 LinkPropsResponse (org.openkilda.messaging.nbtopology.response.LinkPropsResponse)2 LinkPropsDto (org.openkilda.northbound.dto.v1.links.LinkPropsDto)2 ArrayList (java.util.ArrayList)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 Test (org.junit.Test)1 CommandMessage (org.openkilda.messaging.command.CommandMessage)1 InfoData (org.openkilda.messaging.info.InfoData)1 IslInfoData (org.openkilda.messaging.info.event.IslInfoData)1 LinkPropsMask (org.openkilda.messaging.model.LinkPropsMask)1 NetworkEndpoint (org.openkilda.messaging.model.NetworkEndpoint)1 NetworkEndpointMask (org.openkilda.messaging.model.NetworkEndpointMask)1 SwitchId (org.openkilda.model.SwitchId)1 BatchResults (org.openkilda.northbound.dto.BatchResults)1