Search in sources :

Example 1 with IslFrame

use of org.openkilda.persistence.ferma.frames.IslFrame in project open-kilda by telstra.

the class FermaIslRepository method updateAvailableBandwidth.

private long updateAvailableBandwidth(FramedGraph framedGraph, String srcSwitchId, int srcPort, String dstSwitchId, int dstPort, long usedBandwidth) {
    log.debug("Updating ISL {}_{} - {}_{} with used bandwidth {}", srcSwitchId, srcPort, dstSwitchId, dstPort, usedBandwidth);
    IslFrame isl = findIsl(framedGraph, srcSwitchId, srcPort, dstSwitchId, dstPort).orElseThrow(() -> new PersistenceException(format("ISL %s_%d - %s_%d not found to be updated", srcSwitchId, srcPort, dstSwitchId, dstPort)));
    long updatedAvailableBandwidth = isl.getMaxBandwidth() - usedBandwidth;
    isl.setAvailableBandwidth(updatedAvailableBandwidth);
    return updatedAvailableBandwidth;
}
Also used : IslFrame(org.openkilda.persistence.ferma.frames.IslFrame) PersistenceException(org.openkilda.persistence.exceptions.PersistenceException)

Example 2 with IslFrame

use of org.openkilda.persistence.ferma.frames.IslFrame in project open-kilda by telstra.

the class FermaIslRepository method doAdd.

@Override
protected IslFrame doAdd(IslData data) {
    String srcSwitchId = SwitchIdConverter.INSTANCE.toGraphProperty(data.getSrcSwitchId());
    SwitchFrame source = SwitchFrame.load(framedGraph(), srcSwitchId).orElseThrow(() -> new IllegalArgumentException("Unable to locate the switch " + srcSwitchId));
    String dstSwitchId = SwitchIdConverter.INSTANCE.toGraphProperty(data.getDestSwitchId());
    SwitchFrame destination = SwitchFrame.load(framedGraph(), dstSwitchId).orElseThrow(() -> new IllegalArgumentException("Unable to locate the switch " + dstSwitchId));
    IslFrame frame = KildaBaseEdgeFrame.addNewFramedEdge(framedGraph(), source, destination, IslFrame.FRAME_LABEL, IslFrame.class);
    frame.setProperty(IslFrame.SRC_SWITCH_ID_PROPERTY, srcSwitchId);
    frame.setProperty(IslFrame.DST_SWITCH_ID_PROPERTY, dstSwitchId);
    Isl.IslCloner.INSTANCE.copyWithoutSwitches(data, frame);
    return frame;
}
Also used : IslFrame(org.openkilda.persistence.ferma.frames.IslFrame) SwitchFrame(org.openkilda.persistence.ferma.frames.SwitchFrame)

Aggregations

IslFrame (org.openkilda.persistence.ferma.frames.IslFrame)2 PersistenceException (org.openkilda.persistence.exceptions.PersistenceException)1 SwitchFrame (org.openkilda.persistence.ferma.frames.SwitchFrame)1