use of org.openkilda.messaging.info.flow.UpdateFlowCommand in project open-kilda by telstra.
the class NotifyFlowMonitorAction method getFlowInfo.
private CommandData getFlowInfo(String flowId) {
Optional<Flow> flow = flowRepository.findById(flowId);
if (!flow.isPresent() || flow.get().isOneSwitchFlow()) {
return new RemoveFlowCommand(flowId);
}
FlowPathDto flowPathDto = toFlowPathDtoBuilder(flow.get()).build();
return new UpdateFlowCommand(flowId, flowPathDto, flow.get().getMaxLatency(), flow.get().getMaxLatencyTier2());
}
use of org.openkilda.messaging.info.flow.UpdateFlowCommand in project open-kilda by telstra.
the class FlowCacheBolt method handleInput.
@Override
protected void handleInput(Tuple input) throws PipelineException {
if (active) {
if (ComponentId.FLOW_STATE_CACHE_BOLT.name().equals(input.getSourceComponent())) {
if (FLOW_UPDATE_STREAM_ID.name().equals(input.getSourceStreamId())) {
UpdateFlowCommand updateFlowCommand = pullValue(input, COMMAND_DATA_FIELD, UpdateFlowCommand.class);
flowCacheService.updateFlowInfo(updateFlowCommand);
emit(FLOW_UPDATE_STREAM_ID.name(), input, new Values(updateFlowCommand.getFlowId(), updateFlowCommand, getCommandContext()));
} else if (FLOW_REMOVE_STREAM_ID.name().equals(input.getSourceStreamId())) {
String flowId = pullValue(input, FLOW_ID_FIELD, String.class);
flowCacheService.removeFlowInfo(flowId);
emit(FLOW_REMOVE_STREAM_ID.name(), input, new Values(flowId, getCommandContext()));
} else {
String flowId = pullValue(input, FLOW_ID_FIELD, String.class);
flowCacheService.processFlowLatencyCheck(flowId);
}
return;
}
if (ComponentId.ISL_CACHE_BOLT.name().equals(input.getSourceComponent())) {
String requestId = pullValue(input, REQUEST_ID_FIELD, String.class);
Link link = pullValue(input, LINK_FIELD, Link.class);
Duration latency = pullValue(input, LATENCY_FIELD, Duration.class);
calculateFlowLatencyService.handleGetLinkLatencyResponse(requestId, link, latency);
return;
}
FlowRttStatsData flowRttStatsData = pullValue(input, INFO_DATA_FIELD, FlowRttStatsData.class);
flowCacheService.processFlowRttStatsData(flowRttStatsData);
}
}
use of org.openkilda.messaging.info.flow.UpdateFlowCommand in project open-kilda by telstra.
the class FlowSplitterBolt method handleInput.
@Override
protected void handleInput(Tuple input) throws PipelineException {
Message message = pullValue(input, FIELD_ID_PAYLOAD, Message.class);
if (message instanceof InfoMessage) {
InfoData infoData = ((InfoMessage) message).getData();
if (infoData instanceof FlowRttStatsData) {
FlowRttStatsData flowRttStatsData = (FlowRttStatsData) infoData;
emit(input, new Values(flowRttStatsData.getFlowId(), flowRttStatsData, getCommandContext()));
} else {
unhandledInput(input);
}
return;
}
if (message instanceof CommandMessage) {
CommandData commandData = pullValue(input, FIELD_ID_PAYLOAD, CommandMessage.class).getData();
if (commandData instanceof UpdateFlowCommand) {
UpdateFlowCommand updateFlowCommand = (UpdateFlowCommand) commandData;
emit(FLOW_UPDATE_STREAM_ID.name(), input, new Values(updateFlowCommand.getFlowId(), updateFlowCommand, getCommandContext()));
} else if (commandData instanceof RemoveFlowCommand) {
RemoveFlowCommand removeFlowCommand = (RemoveFlowCommand) commandData;
emit(FLOW_REMOVE_STREAM_ID.name(), input, new Values(removeFlowCommand.getFlowId(), getCommandContext()));
} else {
unhandledInput(input);
}
} else {
unhandledInput(input);
}
}
use of org.openkilda.messaging.info.flow.UpdateFlowCommand in project open-kilda by telstra.
the class ActionServiceTest method shouldUpdateFlowInfo.
@Test
public void shouldUpdateFlowInfo() {
service.processFlowLatencyMeasurement(flow.getFlowId(), FlowDirection.FORWARD, NANOSECOND);
service.processFlowLatencyMeasurement(flow.getFlowId(), FlowDirection.REVERSE, NANOSECOND);
FlowPathDto path = FlowPathDto.builder().forwardPath(Arrays.asList(new PathNodePayload(SRC_SWITCH, 1, 2), new PathNodePayload(DST_SWITCH, 3, 4))).reversePath(Arrays.asList(new PathNodePayload(DST_SWITCH, 4, 3), new PathNodePayload(SRC_SWITCH, 2, 1))).build();
long maxLatency = flow.getMaxLatency() / 2;
long maxLatencyTier2 = flow.getMaxLatencyTier2() / 2;
UpdateFlowCommand info = new UpdateFlowCommand(flow.getFlowId(), path, maxLatency, maxLatencyTier2);
service.updateFlowInfo(info);
assertEquals(2, service.fsms.values().size());
FlowLatencyMonitoringFsm fsm = service.fsms.values().stream().findAny().orElseThrow(() -> new IllegalStateException("Fsm not found"));
assertEquals(maxLatency, fsm.getMaxLatency());
assertEquals(maxLatencyTier2, fsm.getMaxLatencyTier2());
verifyNoMoreInteractions(carrier);
}
use of org.openkilda.messaging.info.flow.UpdateFlowCommand in project open-kilda by telstra.
the class ActionBolt method handleInput.
@Override
protected void handleInput(Tuple input) throws PipelineException {
if (!active) {
return;
}
if (FLOW_UPDATE_STREAM_ID.name().equals(input.getSourceStreamId())) {
UpdateFlowCommand updateFlowCommand = pullValue(input, COMMAND_DATA_FIELD, UpdateFlowCommand.class);
actionService.updateFlowInfo(updateFlowCommand);
return;
}
if (FLOW_REMOVE_STREAM_ID.name().equals(input.getSourceStreamId())) {
String flowId = pullValue(input, FLOW_ID_FIELD, String.class);
actionService.removeFlowInfo(flowId);
return;
}
if (ACTION_STREAM_ID.name().equals(input.getSourceStreamId())) {
String flowId = pullValue(input, FLOW_ID_FIELD, String.class);
FlowDirection direction = pullValue(input, FLOW_DIRECTION_FIELD, FlowDirection.class);
Duration latency = pullValue(input, LATENCY_FIELD, Duration.class);
actionService.processFlowLatencyMeasurement(flowId, direction, latency);
return;
}
if (ComponentId.TICK_BOLT.name().equals(input.getSourceComponent())) {
actionService.processTick();
} else {
unhandledInput(input);
}
}
Aggregations