Search in sources :

Example 6 with FlowMeter

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++));
            }
        }
    });
}
Also used : FlowPath(org.openkilda.model.FlowPath) FlowMeter(org.openkilda.model.FlowMeter) MeterId(org.openkilda.model.MeterId)

Example 7 with FlowMeter

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);
}
Also used : FlowMeter(org.openkilda.model.FlowMeter)

Example 8 with 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;
}
Also used : FlowMeter(org.openkilda.model.FlowMeter)

Example 9 with FlowMeter

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;
}
Also used : MeterInfoEntry(org.openkilda.messaging.info.switches.MeterInfoEntry) FlowPath(org.openkilda.model.FlowPath) FlowMeter(org.openkilda.model.FlowMeter)

Example 10 with FlowMeter

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());
}
Also used : PathId(org.openkilda.model.PathId) FlowMeter(org.openkilda.model.FlowMeter) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Aggregations

FlowMeter (org.openkilda.model.FlowMeter)11 Test (org.junit.Test)4 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)4 MeterId (org.openkilda.model.MeterId)3 FlowPath (org.openkilda.model.FlowPath)2 PathId (org.openkilda.model.PathId)2 MeterInfoEntry (org.openkilda.messaging.info.switches.MeterInfoEntry)1 Flow (org.openkilda.model.Flow)1 SwitchId (org.openkilda.model.SwitchId)1 YFlow (org.openkilda.model.YFlow)1 SharedEndpoint (org.openkilda.model.YFlow.SharedEndpoint)1 YSubFlow (org.openkilda.model.YSubFlow)1 YFlowRepository (org.openkilda.persistence.repositories.YFlowRepository)1