use of org.openkilda.messaging.command.grpc.GetPacketInOutStatsRequest in project open-kilda by telstra.
the class StatsRequesterBolt method emitGrpcStatsRequest.
private void emitGrpcStatsRequest(Tuple input, Switch sw) {
Optional<String> address = Optional.ofNullable(sw.getSocketAddress()).map(IpSocketAddress::getAddress);
if (!address.isPresent()) {
return;
}
GetPacketInOutStatsRequest packetInOutStatsRequest = new GetPacketInOutStatsRequest(address.get(), sw.getSwitchId());
String correlationId = getCommandContext().getCorrelationId().concat(" : ").concat(address.get());
CommandMessage grpcRequest = new CommandMessage(packetInOutStatsRequest, System.currentTimeMillis(), correlationId);
emit(GRPC_REQUEST_STREAM, input, new Values(grpcRequest));
}
use of org.openkilda.messaging.command.grpc.GetPacketInOutStatsRequest in project open-kilda by telstra.
the class SpeakerStatsRequesterBoltTest method requestGrpcStatsForNoviflowSwitchesTest.
@Test
public void requestGrpcStatsForNoviflowSwitchesTest() {
KildaFeatureToggles featureToggles = new KildaFeatureToggles(KildaFeatureToggles.DEFAULTS);
featureToggles.setCollectGrpcStats(true);
String address = "192.168.1.1";
Switch sw = Switch.builder().switchId(new SwitchId(1)).socketAddress(new IpSocketAddress(address, 20)).build();
sw.setOfDescriptionSoftware("NW500.1.1");
when(switchRepository.findActive()).thenReturn(Collections.singleton(sw));
when(featureTogglesRepository.getOrDefault()).thenReturn(featureToggles);
StatsRequesterBolt statsRequesterBolt = new StatsRequesterBolt(persistenceManager, ZooKeeperSpout.SPOUT_ID);
statsRequesterBolt.prepare(Collections.emptyMap(), topologyContext, output);
statsRequesterBolt.execute(startTuple);
verify(output).emit(eq(ZkStreams.ZK.toString()), any(Tuple.class), anyList());
statsRequesterBolt.execute(input);
ArgumentCaptor<Values> values = ArgumentCaptor.forClass(Values.class);
verify(output, times(1)).emit(eq(STATS_REQUEST_STREAM), any(Tuple.class), anyList());
verify(output, times(1)).emit(eq(GRPC_REQUEST_STREAM), any(Tuple.class), values.capture());
Values capturedValues = values.getValue();
assertTrue(capturedValues.get(0) instanceof CommandMessage);
CommandMessage commandMessage = (CommandMessage) capturedValues.get(0);
assertTrue(commandMessage.getData() instanceof GetPacketInOutStatsRequest);
GetPacketInOutStatsRequest request = (GetPacketInOutStatsRequest) commandMessage.getData();
assertEquals(address, request.getAddress());
}
use of org.openkilda.messaging.command.grpc.GetPacketInOutStatsRequest in project open-kilda by telstra.
the class MessageProcessor method handleCommandMessage.
private void handleCommandMessage(CommandMessage command, String key) {
CommandData data = command.getData();
String correlationId = command.getCorrelationId();
CompletableFuture<Response> result;
if (data instanceof CreateLogicalPortRequest) {
result = handleCreateLogicalPortRequest((CreateLogicalPortRequest) data);
} else if (data instanceof DumpLogicalPortsRequest) {
result = handleDumpLogicalPortsRequest((DumpLogicalPortsRequest) data);
} else if (data instanceof GetSwitchInfoRequest) {
result = handleGetSwitchInfoRequest((GetSwitchInfoRequest) data);
} else if (data instanceof GetPacketInOutStatsRequest) {
result = handleGetPacketInOutStatsRequest((GetPacketInOutStatsRequest) data);
} else if (data instanceof DeleteLogicalPortRequest) {
result = handleDeleteLogicalPortRequest((DeleteLogicalPortRequest) data);
} else {
result = unhandledMessage(command);
}
result.thenAccept(response -> sendResponse(response, correlationId, key));
}
Aggregations