Search in sources :

Example 36 with Flow

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);
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) Values(org.apache.storm.tuple.Values) Flow(org.openkilda.messaging.model.Flow)

Example 37 with Flow

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);
}
Also used : FlowState(org.openkilda.messaging.payload.flow.FlowState) FlowIdStatusPayload(org.openkilda.messaging.payload.flow.FlowIdStatusPayload) InfoMessage(org.openkilda.messaging.info.InfoMessage) Values(org.apache.storm.tuple.Values) Flow(org.openkilda.messaging.model.Flow)

Example 38 with Flow

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);
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) Values(org.apache.storm.tuple.Values) Flow(org.openkilda.messaging.model.Flow)

Example 39 with Flow

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;
}
Also used : FlowCreateRequest(org.openkilda.messaging.command.flow.FlowCreateRequest) RemoveFlow(org.openkilda.messaging.command.flow.RemoveFlow) Flow(org.openkilda.messaging.model.Flow) InstallOneSwitchFlow(org.openkilda.messaging.command.flow.InstallOneSwitchFlow) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 40 with Flow

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());
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) FlowResponse(org.openkilda.messaging.info.flow.FlowResponse) RemoveFlow(org.openkilda.messaging.command.flow.RemoveFlow) Flow(org.openkilda.messaging.model.Flow) InstallOneSwitchFlow(org.openkilda.messaging.command.flow.InstallOneSwitchFlow) Ignore(org.junit.Ignore) AbstractStormTest(org.openkilda.wfm.AbstractStormTest) Test(org.junit.Test)

Aggregations

Flow (org.openkilda.messaging.model.Flow)54 InfoMessage (org.openkilda.messaging.info.InfoMessage)23 Values (org.apache.storm.tuple.Values)14 PathInfoData (org.openkilda.messaging.info.event.PathInfoData)14 InstallOneSwitchFlow (org.openkilda.messaging.command.flow.InstallOneSwitchFlow)13 RemoveFlow (org.openkilda.messaging.command.flow.RemoveFlow)13 Test (org.junit.Test)12 CommandMessage (org.openkilda.messaging.command.CommandMessage)8 ImmutablePair (org.openkilda.messaging.model.ImmutablePair)8 AbstractStormTest (org.openkilda.wfm.AbstractStormTest)8 FlowResponse (org.openkilda.messaging.info.flow.FlowResponse)6 Then (cucumber.api.java.en.Then)5 FlowIdStatusPayload (org.openkilda.messaging.payload.flow.FlowIdStatusPayload)5 UnroutablePathException (org.openkilda.pce.provider.UnroutablePathException)5 Driver (org.neo4j.driver.v1.Driver)4 MessageException (org.openkilda.messaging.error.MessageException)4 FlowPayload (org.openkilda.messaging.payload.flow.FlowPayload)4 And (cucumber.api.java.en.And)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3