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