Search in sources :

Example 36 with Endpoint

use of org.openkilda.wfm.share.model.Endpoint in project open-kilda by telstra.

the class WatchListHandler method makeDefaultTuple.

private Values makeDefaultTuple(WatcherCommand command) {
    Endpoint endpoint = command.getEndpoint();
    CommandContext forkedContext = getCommandContext().fork(endpoint.getDatapath().toString()).fork(String.format("p%d", endpoint.getPortNumber()));
    return new Values(endpoint.getDatapath(), endpoint.getPortNumber(), command, forkedContext);
}
Also used : Endpoint(org.openkilda.wfm.share.model.Endpoint) CommandContext(org.openkilda.wfm.CommandContext) Values(org.apache.storm.tuple.Values)

Example 37 with Endpoint

use of org.openkilda.wfm.share.model.Endpoint in project open-kilda by telstra.

the class PollIntegrationTest method happyPath.

@Test
public void happyPath() {
    final long latency = 100L;
    final long speed = 100000L;
    NetworkIntegrationCarrier integrationCarrier = new NetworkIntegrationCarrier() {

        @Override
        public void sendDiscovery(DiscoverIslCommandData discoveryRequest) {
            // Emulate response from FL
            watcherCarrier.sendDiscovery(discoveryRequest);
            IslInfoData response = IslInfoData.builder().latency(latency).source(new PathNode(discoveryRequest.getSwitchId(), discoveryRequest.getPortNumber(), 0)).destination(new PathNode(new SwitchId(10), 10, 0)).state(IslChangeType.DISCOVERED).speed(speed).underMaintenance(false).packetId(discoveryRequest.getPacketId()).build();
            watcherService.confirmation(Endpoint.of(discoveryRequest.getSwitchId(), discoveryRequest.getPortNumber()), discoveryRequest.getPacketId());
            watcherService.discovery(response);
        }
    };
    IWatcherCarrier watcherCarrier = mock(IWatcherCarrier.class);
    NetworkWatchListService watchListService = new NetworkWatchListService(integrationCarrier, 10, 15, 20);
    NetworkWatcherService watcherService = new NetworkWatcherService(integrationCarrier, 100, taskId);
    NetworkDecisionMakerService decisionMakerService = new NetworkDecisionMakerService(carrier, 200, 100);
    integrationCarrier.configure(watcherService, watchListService, decisionMakerService);
    integrationCarrier.setWatcherCarrier(watcherCarrier);
    // should produce discovery request
    Endpoint endpoint = Endpoint.of(new SwitchId(1), 1);
    watchListService.addWatch(endpoint, 1);
    ArgumentCaptor<DiscoverIslCommandData> discoveryRequestCatcher = ArgumentCaptor.forClass(DiscoverIslCommandData.class);
    verify(watcherCarrier).sendDiscovery(discoveryRequestCatcher.capture());
    DiscoverIslCommandData request = discoveryRequestCatcher.getValue();
    Assert.assertEquals(endpoint.getDatapath(), request.getSwitchId());
    Assert.assertEquals(endpoint.getPortNumber(), request.getPortNumber());
    IslInfoData expectedDiscoveryEvent = IslInfoData.builder().latency(latency).source(new PathNode(new SwitchId(1), 1, 0)).destination(new PathNode(new SwitchId(10), 10, 0)).state(IslChangeType.DISCOVERED).speed(speed).underMaintenance(false).packetId(0L).build();
    verify(carrier).linkDiscovered(eq(expectedDiscoveryEvent));
}
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) Test(org.junit.Test)

Example 38 with Endpoint

use of org.openkilda.wfm.share.model.Endpoint in project open-kilda by telstra.

the class CacheService method initCache.

private void initCache() {
    cache.clear();
    try {
        islRepository.findAllActive().forEach(isl -> {
            Endpoint source = Endpoint.of(isl.getSrcSwitchId(), isl.getSrcPort());
            Endpoint destination = Endpoint.of(isl.getDestSwitchId(), isl.getDestPort());
            cache.put(source, destination);
            cache.put(destination, source);
        });
        log.debug("Isl latency cache: {}", cache);
        log.info("Isl latency cache: Initialized");
    } catch (Exception ex) {
        log.error("Error during isl latency cache initialization", ex);
    }
}
Also used : Endpoint(org.openkilda.wfm.share.model.Endpoint) IslNotFoundException(org.openkilda.wfm.error.IslNotFoundException) IllegalIslStateException(org.openkilda.wfm.error.IllegalIslStateException)

Example 39 with Endpoint

use of org.openkilda.wfm.share.model.Endpoint in project open-kilda by telstra.

the class DiscoveryMovedMonitor method actualUpdate.

@Override
protected void actualUpdate(IslFsmEvent event, IslFsmContext context) {
    Endpoint endpoint = context.getEndpoint();
    Boolean update = discoveryData.get(endpoint);
    switch(event) {
        case ISL_MOVE:
            update = true;
            break;
        case ISL_UP:
        case ISL_DOWN:
            update = false;
            break;
        default:
    }
    discoveryData.put(endpoint, update);
}
Also used : Endpoint(org.openkilda.wfm.share.model.Endpoint)

Example 40 with Endpoint

use of org.openkilda.wfm.share.model.Endpoint in project open-kilda by telstra.

the class IslFsm method handleInstalledRule.

// FIXME(surabujin): protect from stale responses
public void handleInstalledRule(IslFsmState from, IslFsmState to, IslFsmEvent event, IslFsmContext context) {
    Endpoint endpoint = context.getInstalledRulesEndpoint();
    if (endpoint == null) {
        throw new IllegalArgumentException(makeInvalidResourceManipulationResponseMessage());
    }
    log.info("Receive response on ISL resource allocation request for {} (from {})", reference, endpoint.getDatapath());
    endpointResourcesManagementCompleteStatus.put(endpoint, true);
    if (isResourcesManagementCompleted()) {
        fire(IslFsmEvent._RESOURCES_DONE, context);
    }
}
Also used : Endpoint(org.openkilda.wfm.share.model.Endpoint)

Aggregations

Endpoint (org.openkilda.wfm.share.model.Endpoint)72 Test (org.junit.Test)33 Isl (org.openkilda.model.Isl)17 IslInfoData (org.openkilda.messaging.info.event.IslInfoData)13 SwitchId (org.openkilda.model.SwitchId)10 Switch (org.openkilda.model.Switch)8 IslReference (org.openkilda.wfm.share.model.IslReference)8 PathNode (org.openkilda.messaging.info.event.PathNode)7 Instant (java.time.Instant)6 IslDataHolder (org.openkilda.wfm.topology.network.model.IslDataHolder)6 HashSet (java.util.HashSet)4 Set (java.util.Set)4 DiscoverIslCommandData (org.openkilda.messaging.command.discovery.DiscoverIslCommandData)4 IslNotFoundException (org.openkilda.wfm.error.IslNotFoundException)4 Values (org.apache.storm.tuple.Values)3 IslRoundTripLatency (org.openkilda.messaging.info.event.IslRoundTripLatency)3 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)3 CommandContext (org.openkilda.wfm.CommandContext)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 HashMap (java.util.HashMap)2