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