use of org.openkilda.model.FlowMeter in project open-kilda by telstra.
the class DatabaseSupportImpl method updateFlowMeterId.
@Override
public void updateFlowMeterId(String flowId, long newMeterId) {
// TODO(andriidovhan) rewrite it, FlowPair flowPair -> Flow
// FlowPair flowPair = flowPairRepository.findById(flowId)
// .orElseThrow(() -> new RuntimeException(format("Unable to find Flow for %s", flowId)));
// flowPair.getForward().setMeterId(newMeterId.getValue());
// flowPair.getReverse().setMeterId(newMeterId.getValue());
// flowRepository.createOrUpdate(flowPair);
// flow path
transactionManager.doInTransaction(() -> {
Collection<FlowPath> flowPaths = flowPathRepository.findByFlowId(flowId);
long meterId = newMeterId;
for (FlowPath flowPath : flowPaths) {
flowPath.setMeterId(new MeterId(meterId));
Optional<FlowMeter> meter = flowMeterRepository.findByPathId(flowPath.getPathId());
if (meter.isPresent()) {
meter.get().setMeterId(new MeterId(meterId++));
}
}
});
}
use of org.openkilda.model.FlowMeter in project open-kilda by telstra.
the class MeterPool method addMeter.
private void addMeter(String flowId, PathId pathId, SwitchId switchId, MeterId meterId) {
FlowMeter flowMeter = FlowMeter.builder().meterId(meterId).switchId(switchId).flowId(flowId).pathId(pathId).build();
flowMeterRepository.add(flowMeter);
}
use of org.openkilda.model.FlowMeter in project open-kilda by telstra.
the class PersistenceDummyEntityFactory method makeFlowMeter.
/**
* Create {@link FlowMeter} object.
*/
public FlowMeter makeFlowMeter(SwitchId swId, String flowId, PathId pathId) {
FlowMeter meter = FlowMeter.builder().switchId(swId).meterId(idProvider.provideMeterId(swId)).pathId(pathId).flowId(flowId).build();
flowMeterRepository.add(meter);
return meter;
}
use of org.openkilda.model.FlowMeter in project open-kilda by telstra.
the class ValidationServiceImpl method convertMeter.
private MeterInfoEntry convertMeter(SwitchId switchId, MeterSpeakerData meterSpeakerData) {
MeterInfoEntry meterInfoEntry = MeterEntryConverter.INSTANCE.toMeterEntry(meterSpeakerData);
Optional<FlowMeter> flowMeter = flowMeterRepository.findById(switchId, meterSpeakerData.getMeterId());
if (flowMeter.isPresent()) {
meterInfoEntry.setFlowId(flowMeter.get().getFlowId());
Optional<FlowPath> flowPath = flowPathRepository.findById(flowMeter.get().getPathId());
if (flowPath.isPresent()) {
meterInfoEntry.setCookie(flowPath.get().getCookie().getValue());
}
}
return meterInfoEntry;
}
use of org.openkilda.model.FlowMeter in project open-kilda by telstra.
the class FermaFlowMeterRepositoryTest method shouldGetZeroMetersForPath.
@Test
public void shouldGetZeroMetersForPath() {
Optional<FlowMeter> meters = flowMeterRepository.findByPathId(new PathId(TEST_PATH_ID));
assertFalse(meters.isPresent());
}
Aggregations