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);
}
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));
}
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);
}
}
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);
}
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);
}
}
Aggregations