Search in sources :

Example 1 with StatsRequest

use of org.openkilda.messaging.command.stats.StatsRequest in project open-kilda by telstra.

the class ControllerToSpeakerProxyServiceTest method verifyStatsPreferRoRegions.

@Test
public void verifyStatsPreferRoRegions() {
    ControllerToSpeakerProxyService subject = makeSubject();
    // stats/RO only region
    subject.switchMappingUpdate(new RegionMappingAdd(SWITCH_ALPHA, REGION_STATS, false));
    subject.switchMappingUpdate(new RegionMappingAdd(SWITCH_BETA, REGION_STATS, false));
    // management/RW region
    subject.switchMappingUpdate(new RegionMappingAdd(SWITCH_BETA, REGION_MANAGEMENT, false));
    subject.switchMappingUpdate(new RegionMappingAdd(SWITCH_BETA, REGION_MANAGEMENT, true));
    subject.switchMappingUpdate(new RegionMappingAdd(SWITCH_GAMMA, REGION_MANAGEMENT, false));
    subject.switchMappingUpdate(new RegionMappingAdd(SWITCH_GAMMA, REGION_MANAGEMENT, true));
    verifyZeroInteractions(carrier);
    String correlationId = "dummy-request";
    StatsRequest request = new StatsRequest();
    subject.statsRequest(request, correlationId);
    // RO only region
    verify(carrier).sendToSpeaker(makeStatsRegionRequest(request, ImmutableSet.of(SWITCH_ALPHA, SWITCH_BETA), correlationId), REGION_STATS);
    verify(carrier).sendToSpeaker(makeStatsRegionRequest(request, ImmutableSet.of(SWITCH_GAMMA), correlationId), REGION_MANAGEMENT);
    verifyNoMoreInteractions(carrier);
}
Also used : RegionMappingAdd(org.openkilda.wfm.topology.floodlightrouter.model.RegionMappingAdd) StatsRequest(org.openkilda.messaging.command.stats.StatsRequest) Test(org.junit.Test)

Example 2 with StatsRequest

use of org.openkilda.messaging.command.stats.StatsRequest in project open-kilda by telstra.

the class BroadcastWrapperTest method serializeLoop.

@Test
public void serializeLoop() throws Exception {
    StatsRequest payload = new StatsRequest();
    BroadcastWrapper wrapper = new BroadcastWrapper(ImmutableSet.of(new SwitchId(2), new SwitchId(3)), payload);
    CommandMessage envelope = new CommandMessage(wrapper, System.currentTimeMillis(), getClass().getSimpleName());
    String json = Utils.MAPPER.writeValueAsString(envelope);
    verifyDecoding(Utils.MAPPER.readValue(json, CommandMessage.class), wrapper);
}
Also used : SwitchId(org.openkilda.model.SwitchId) StatsRequest(org.openkilda.messaging.command.stats.StatsRequest) Test(org.junit.Test)

Example 3 with StatsRequest

use of org.openkilda.messaging.command.stats.StatsRequest in project open-kilda by telstra.

the class StatsRequesterBolt method sendStatsRequest.

private void sendStatsRequest(Tuple input) {
    CommandMessage statsRequest = new CommandMessage(new StatsRequest(), System.currentTimeMillis(), getCommandContext().getCorrelationId());
    Values values = new Values(statsRequest);
    emit(STATS_REQUEST_STREAM, input, values);
    if (featureTogglesRepository.getOrDefault().getCollectGrpcStats()) {
        Collection<Switch> switches = switchRepository.findActive();
        for (Switch sw : switches) {
            if (sw.getOfDescriptionSoftware() != null && Switch.isNoviflowSwitch(sw.getOfDescriptionSoftware())) {
                emitGrpcStatsRequest(input, sw);
            }
        }
    }
}
Also used : Switch(org.openkilda.model.Switch) Values(org.apache.storm.tuple.Values) GetPacketInOutStatsRequest(org.openkilda.messaging.command.grpc.GetPacketInOutStatsRequest) StatsRequest(org.openkilda.messaging.command.stats.StatsRequest) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Aggregations

StatsRequest (org.openkilda.messaging.command.stats.StatsRequest)3 Test (org.junit.Test)2 Values (org.apache.storm.tuple.Values)1 CommandMessage (org.openkilda.messaging.command.CommandMessage)1 GetPacketInOutStatsRequest (org.openkilda.messaging.command.grpc.GetPacketInOutStatsRequest)1 Switch (org.openkilda.model.Switch)1 SwitchId (org.openkilda.model.SwitchId)1 RegionMappingAdd (org.openkilda.wfm.topology.floodlightrouter.model.RegionMappingAdd)1