Search in sources :

Example 96 with SwitchId

use of org.openkilda.model.SwitchId in project open-kilda by telstra.

the class NetworkWatcherServiceTest method discoveryBeforeConfirmation.

@Test
public void discoveryBeforeConfirmation() {
    final int awaitTime = 10;
    PathNode source = new PathNode(new SwitchId(1), 1, 0);
    PathNode destination = new PathNode(new SwitchId(2), 1, 0);
    NetworkWatcherService w = makeService(awaitTime);
    w.addWatch(Endpoint.of(source.getSwitchId(), source.getPortNo()), 1);
    verify(carrier, times(1)).sendDiscovery(any(DiscoverIslCommandData.class));
    IslInfoData islAlphaBeta = IslInfoData.builder().source(source).destination(destination).packetId(0L).build();
    w.discovery(islAlphaBeta);
    w.confirmation(new Endpoint(source), 0);
    w.tick(awaitTime + 1);
    verify(carrier).oneWayDiscoveryReceived(eq(new Endpoint(source)), eq(0L), eq(islAlphaBeta), anyLong());
    verify(carrier, never()).discoveryFailed(eq(new Endpoint(source)), anyLong(), anyLong());
    assertThat(w.getConfirmedPackets().size(), is(0));
}
Also used : DiscoverIslCommandData(org.openkilda.messaging.command.discovery.DiscoverIslCommandData) Endpoint(org.openkilda.wfm.share.model.Endpoint) SwitchId(org.openkilda.model.SwitchId) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) PathNode(org.openkilda.messaging.info.event.PathNode) Endpoint(org.openkilda.wfm.share.model.Endpoint) Test(org.junit.Test)

Example 97 with SwitchId

use of org.openkilda.model.SwitchId in project open-kilda by telstra.

the class WatcherHandler method sendDiscovery.

@Override
public void sendDiscovery(DiscoverIslCommandData discoveryRequest) {
    SwitchId switchId = discoveryRequest.getSwitchId();
    emit(STREAM_SPEAKER_ID, getCurrentTuple(), makeSpeakerTuple(switchId.toString(), discoveryRequest));
}
Also used : SwitchId(org.openkilda.model.SwitchId)

Example 98 with SwitchId

use of org.openkilda.model.SwitchId in project open-kilda by telstra.

the class LinkServiceImpl method updateLinkUnderMaintenance.

@Override
public CompletableFuture<List<LinkDto>> updateLinkUnderMaintenance(LinkUnderMaintenanceDto link) {
    final String correlationId = RequestCorrelationId.getId();
    logger.debug("Update under maintenance link request processing");
    UpdateLinkUnderMaintenanceRequest data = null;
    try {
        data = new UpdateLinkUnderMaintenanceRequest(new NetworkEndpoint(new SwitchId(link.getSrcSwitch()), link.getSrcPort()), new NetworkEndpoint(new SwitchId(link.getDstSwitch()), link.getDstPort()), link.isUnderMaintenance(), link.isEvacuate());
    } 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 'update ISL Under maintenance' request");
    }
    CommandMessage message = new CommandMessage(data, System.currentTimeMillis(), correlationId, Destination.WFM);
    return messagingChannel.sendAndGetChunked(nbworkerTopic, message).thenApply(response -> response.stream().map(IslInfoData.class::cast).map(linkMapper::mapResponse).collect(Collectors.toList()));
}
Also used : UpdateLinkUnderMaintenanceRequest(org.openkilda.messaging.nbtopology.request.UpdateLinkUnderMaintenanceRequest) NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) MessageException(org.openkilda.messaging.error.MessageException) SwitchId(org.openkilda.model.SwitchId) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 99 with SwitchId

use of org.openkilda.model.SwitchId in project open-kilda by telstra.

the class LinkController method updateLinkEnableBfd.

/**
 * Update "enable bfd" flag in the link.
 *
 * @return updated link.
 */
@ApiOperation(value = "Update \"enable bfd\" flag for the link.", response = LinkDto.class, responseContainer = "List")
@PatchMapping(path = "/links/enable-bfd", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseStatus(HttpStatus.OK)
public CompletableFuture<List<LinkDto>> updateLinkEnableBfd(@RequestBody LinkEnableBfdDto link) {
    NetworkEndpoint source = makeSourceEndpoint(new SwitchId(link.getSrcSwitch()), link.getSrcPort());
    NetworkEndpoint destination = makeDestinationEndpoint(new SwitchId(link.getDstSwitch()), link.getDstPort());
    return linkService.writeBfdProperties(source, destination, link.isEnableBfd());
}
Also used : NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) SwitchId(org.openkilda.model.SwitchId) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) ApiOperation(io.swagger.annotations.ApiOperation) PatchMapping(org.springframework.web.bind.annotation.PatchMapping)

Example 100 with SwitchId

use of org.openkilda.model.SwitchId in project open-kilda by telstra.

the class LinkPropsMapper method toLinkProps.

/**
 * Converts {@link org.openkilda.northbound.dto.v1.links.LinkPropsDto} into {@link LinkPropsDto}.
 */
default LinkPropsDto toLinkProps(org.openkilda.northbound.dto.v1.links.LinkPropsDto input) {
    NetworkEndpoint source = new NetworkEndpoint(new SwitchId(input.getSrcSwitch()), input.getSrcPort());
    NetworkEndpoint dest = new NetworkEndpoint(new SwitchId(input.getDstSwitch()), input.getDstPort());
    return new LinkPropsDto(source, dest, input.getProps());
}
Also used : NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) LinkPropsDto(org.openkilda.messaging.model.LinkPropsDto) SwitchId(org.openkilda.model.SwitchId)

Aggregations

SwitchId (org.openkilda.model.SwitchId)339 Test (org.junit.Test)149 Flow (org.openkilda.model.Flow)73 Switch (org.openkilda.model.Switch)69 List (java.util.List)59 FlowPath (org.openkilda.model.FlowPath)49 ArrayList (java.util.ArrayList)44 Collectors (java.util.stream.Collectors)37 PathId (org.openkilda.model.PathId)36 PathComputer (org.openkilda.pce.PathComputer)35 Set (java.util.Set)34 YFlow (org.openkilda.model.YFlow)33 Map (java.util.Map)30 GetPathsResult (org.openkilda.pce.GetPathsResult)30 InfoMessage (org.openkilda.messaging.info.InfoMessage)29 String.format (java.lang.String.format)28 HashSet (java.util.HashSet)27 Optional (java.util.Optional)27 Collection (java.util.Collection)26 Collections (java.util.Collections)26