use of org.openkilda.messaging.model.Flow in project open-kilda by telstra.
the class CrudBolt method handleDumpRequest.
private void handleDumpRequest(CommandMessage message, Tuple tuple) {
List<Flow> flows = flowCache.dumpFlows().stream().map(this::buildFlowResponse).collect(Collectors.toList());
logger.info("Dump flows: {}", flows);
Values northbound = new Values(new InfoMessage(new FlowsResponse(flows), message.getTimestamp(), message.getCorrelationId(), Destination.NORTHBOUND));
outputCollector.emit(StreamType.RESPONSE.toString(), tuple, northbound);
}
use of org.openkilda.messaging.model.Flow in project open-kilda by telstra.
the class CrudBolt method handleStatusRequest.
private void handleStatusRequest(String flowId, CommandMessage message, Tuple tuple) throws IOException {
ImmutablePair<Flow, Flow> flow = flowCache.getFlow(flowId);
FlowState status = flow.getLeft().getState();
logger.info("Status flow: {}={}", flowId, status);
Values northbound = new Values(new InfoMessage(new FlowStatusResponse(new FlowIdStatusPayload(flowId, status)), message.getTimestamp(), message.getCorrelationId(), Destination.NORTHBOUND));
outputCollector.emit(StreamType.RESPONSE.toString(), tuple, northbound);
}
use of org.openkilda.messaging.model.Flow in project open-kilda by telstra.
the class CrudBolt method handleStateRequest.
/**
* This method changes the state of the Flow. It sets the state of both left and right to the
* same state.
*
* It is currently called from 2 places - a failed update (set flow to DOWN), and a STATUS
* update from the TransactionBolt.
*/
private void handleStateRequest(String flowId, FlowState state, Tuple tuple) throws IOException {
ImmutablePair<Flow, Flow> flow = flowCache.getFlow(flowId);
logger.info("State flow: {}={}", flowId, state);
flow.getLeft().setState(state);
flow.getRight().setState(state);
final String correlationId = UUID.randomUUID().toString();
FlowInfoData data = new FlowInfoData(flowId, flow, FlowOperation.STATE, correlationId);
InfoMessage infoMessage = new InfoMessage(data, System.currentTimeMillis(), correlationId);
Values topology = new Values(Utils.MAPPER.writeValueAsString(infoMessage));
outputCollector.emit(StreamType.STATUS.toString(), tuple, topology);
}
use of org.openkilda.messaging.model.Flow in project open-kilda by telstra.
the class FlowTopologyTest method createFlow.
private Flow createFlow(final String flowId) throws IOException {
System.out.println("NORTHBOUND: Create flow");
Flow flowPayload = new Flow(flowId, 10000, false, "", "test-switch", 1, 2, "test-switch", 1, 2);
FlowCreateRequest commandData = new FlowCreateRequest(flowPayload);
CommandMessage message = new CommandMessage(commandData, 0, "create-flow", Destination.WFM);
// sendNorthboundMessage(message);
sendFlowMessage(message);
return flowPayload;
}
use of org.openkilda.messaging.model.Flow in project open-kilda by telstra.
the class FlowTopologyTest method getFlowTopologyEngineBoltTest.
@Test
@Ignore
public void getFlowTopologyEngineBoltTest() throws Exception {
ConsumerRecord<String, String> nbRecord;
String flowId = UUID.randomUUID().toString();
Flow payload = getFlowCommand(flowId);
nbRecord = nbConsumer.pollMessage();
assertNotNull(nbRecord);
assertNotNull(nbRecord.value());
InfoMessage response = objectMapper.readValue(nbRecord.value(), InfoMessage.class);
assertNotNull(response);
FlowResponse responseData = (FlowResponse) response.getData();
assertNotNull(responseData);
assertEquals(payload, responseData.getPayload());
}
Aggregations