use of org.openkilda.messaging.info.event.IslInfoData in project open-kilda by telstra.
the class TopologyEventsBasicTest method links_are_added_between_the_new_switch_and_its_neighbor.
@When("^links are added between the new switch and its neighbor$")
public void links_are_added_between_the_new_switch_and_its_neighbor() throws Exception {
List<IslInfoData> links = LinksUtils.dumpLinks();
List<SwitchInfoData> switches = SwitchesUtils.dumpSwitches();
SwitchInfoData switchWithoutLinks = switches.stream().filter(sw -> links.stream().anyMatch(isl -> isLinkBelongToSwitch(sw.getSwitchId(), isl))).findAny().orElseThrow(() -> new IllegalStateException("At least one switch should exist"));
SwitchInfoData latestConnectedSwitch = switches.stream().sorted(Comparator.comparing(SwitchInfoData::getSwitchId).reversed()).findFirst().get();
assertTrue(LinksUtils.addLink(getSwitchName(switchWithoutLinks.getSwitchId()), getSwitchName(latestConnectedSwitch.getSwitchId())));
assertTrue(LinksUtils.addLink(getSwitchName(switchWithoutLinks.getSwitchId()), getSwitchName(latestConnectedSwitch.getSwitchId())));
TimeUnit.SECONDS.sleep(1);
}
use of org.openkilda.messaging.info.event.IslInfoData in project open-kilda by telstra.
the class NetworkCache method getIsl.
/**
* Get {@link IslInfoData} instance.
*
* @param islId {@link IslInfoData} instance id
* @return {@link IslInfoData} instance with specified {@link IslInfoData} instance id
* @throws CacheException if {@link IslInfoData} instance with specified id does not exist
*/
public IslInfoData getIsl(String islId) throws CacheException {
logger.debug("Get {} isl", islId);
IslInfoData isl = islPool.get(islId);
if (isl == null) {
throw new CacheException(ErrorType.NOT_FOUND, "Can not get isl", String.format("Isl %s not found", islId));
}
return islPool.get(islId);
}
use of org.openkilda.messaging.info.event.IslInfoData in project open-kilda by telstra.
the class NetworkCache method deleteIsl.
/**
* Deletes {@link IslInfoData} instance.
*
* @param islId {@link IslInfoData} instance id
* @return removed {@link IslInfoData} instance
* @throws CacheException if {@link IslInfoData} instance with specified id does not exist
*/
public IslInfoData deleteIsl(String islId) throws CacheException {
logger.debug("Delete {} isl", islId);
IslInfoData isl = islPool.remove(islId);
if (isl == null) {
throw new CacheException(ErrorType.NOT_FOUND, "Can not delete isl", String.format("Isl %s not found", islId));
}
network.removeEdge(isl);
return isl;
}
use of org.openkilda.messaging.info.event.IslInfoData in project open-kilda by telstra.
the class NetworkCache method updateIsl.
/**
* Updates {@link IslInfoData} instance.
*
* @param isl new {@link IslInfoData} instance
* @return {@link IslInfoData} instance previously associated with {@link IslInfoData} instance id or null otherwise
* @throws CacheException if {@link SwitchInfoData} related to {@link IslInfoData} instance do not exist
*/
public IslInfoData updateIsl(IslInfoData isl) throws CacheException {
String islId = isl.getId();
logger.debug("Update {} isl with {} parameters", islId, isl);
IslInfoData oldIsl = islPool.get(islId);
network.removeEdge(oldIsl);
isl.copyTimeTag(oldIsl);
isl.setUpdatedInCacheNow();
EndpointPair<SwitchInfoData> nodes = getIslSwitches(isl);
network.addEdge(nodes.source(), nodes.target(), isl);
return islPool.put(islId, isl);
}
use of org.openkilda.messaging.info.event.IslInfoData in project open-kilda by telstra.
the class IslServiceImplTest method updateLinkLatency.
@Test
public void updateLinkLatency() throws Exception {
PathNode srcNode = new PathNode(srcSwitchId, 1, 0);
PathNode dstNode = new PathNode(dstSwitchId, 1, 1);
List<PathNode> list = new ArrayList<>();
list.add(srcNode);
list.add(dstNode);
IslInfoData forwardIsl = new IslInfoData(100L, list, 10000000L);
islService.discoverLink(forwardIsl);
Isl isl = islService.getLink(forwardIsl);
assertNotNull(isl);
assertEquals(100L, isl.getLatency());
forwardIsl = new IslInfoData(200L, list, 10000000L);
islService.discoverLink(forwardIsl);
isl = islService.getLink(forwardIsl);
assertNotNull(isl);
assertEquals(200L, isl.getLatency());
}
Aggregations