Search in sources :

Example 16 with FlowIdStatusPayload

use of org.openkilda.messaging.payload.flow.FlowIdStatusPayload in project open-kilda by telstra.

the class FlowServiceImplTest method deleteFlow.

@Test
public void deleteFlow() throws Exception {
    FlowEndpointPayload firstEndpoint = new FlowEndpointPayload(srcSwitchId, 10, 100);
    FlowEndpointPayload secondEndpoint = new FlowEndpointPayload(dstSwitchId, 20, 100);
    FlowPayload flowPayload = new FlowPayload(flowId, 0L, secondEndpoint, firstEndpoint, 10000L, "", "", OutputVlanType.NONE);
    FlowIdStatusPayload flowIdStatusPayload = new FlowIdStatusPayload(flowId);
    flowService.createFlow(flowPayload, DEFAULT_CORRELATION_ID);
    flowService.deleteFlow(flowIdStatusPayload, DEFAULT_CORRELATION_ID);
    Set<Flow> flows = flowRepository.findByFlowId(flowId);
    assertNotNull(flows);
    assertTrue(flows.isEmpty());
}
Also used : FlowPayload(org.openkilda.messaging.payload.flow.FlowPayload) FlowIdStatusPayload(org.openkilda.messaging.payload.flow.FlowIdStatusPayload) FlowEndpointPayload(org.openkilda.messaging.payload.flow.FlowEndpointPayload) Flow(org.openkilda.topology.domain.Flow) Test(org.junit.Test)

Example 17 with FlowIdStatusPayload

use of org.openkilda.messaging.payload.flow.FlowIdStatusPayload in project open-kilda by telstra.

the class CrudBolt method handlePushRequest.

private void handlePushRequest(String flowId, InfoMessage message, Tuple tuple) throws IOException {
    logger.info("PUSH flow: {} :: {}", flowId, message);
    FlowInfoData fid = (FlowInfoData) message.getData();
    ImmutablePair<Flow, Flow> flow = fid.getPayload();
    flowCache.pushFlow(flow);
    Values northbound = new Values(new InfoMessage(new FlowStatusResponse(new FlowIdStatusPayload(flowId, FlowState.UP)), message.getTimestamp(), message.getCorrelationId(), Destination.NORTHBOUND));
    outputCollector.emit(StreamType.RESPONSE.toString(), tuple, northbound);
}
Also used : 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 18 with FlowIdStatusPayload

use of org.openkilda.messaging.payload.flow.FlowIdStatusPayload in project open-kilda by telstra.

the class CrudBolt method handleUnpushRequest.

private void handleUnpushRequest(String flowId, InfoMessage message, Tuple tuple) throws IOException {
    logger.info("UNPUSH flow: {} :: {}", flowId, message);
    FlowInfoData fid = (FlowInfoData) message.getData();
    flowCache.deleteFlow(flowId);
    Values northbound = new Values(new InfoMessage(new FlowStatusResponse(new FlowIdStatusPayload(flowId, FlowState.DOWN)), message.getTimestamp(), message.getCorrelationId(), Destination.NORTHBOUND));
    outputCollector.emit(StreamType.RESPONSE.toString(), tuple, northbound);
}
Also used : FlowIdStatusPayload(org.openkilda.messaging.payload.flow.FlowIdStatusPayload) InfoMessage(org.openkilda.messaging.info.InfoMessage) Values(org.apache.storm.tuple.Values)

Example 19 with FlowIdStatusPayload

use of org.openkilda.messaging.payload.flow.FlowIdStatusPayload 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 20 with FlowIdStatusPayload

use of org.openkilda.messaging.payload.flow.FlowIdStatusPayload in project open-kilda by telstra.

the class FlowTopologyTest method statusFlowTest.

@Test
public void statusFlowTest() throws Exception {
    String flowId = UUID.randomUUID().toString();
    ConsumerRecord<String, String> record;
    createFlow(flowId);
    record = cacheConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    record = nbConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    statusFlow(flowId);
    record = nbConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    InfoMessage infoMessage = objectMapper.readValue(record.value(), InfoMessage.class);
    assertNotNull(infoMessage);
    FlowStatusResponse infoData = (FlowStatusResponse) infoMessage.getData();
    assertNotNull(infoData);
    FlowIdStatusPayload flowNbPayload = infoData.getPayload();
    assertNotNull(flowNbPayload);
    assertEquals(flowId, flowNbPayload.getId());
    assertEquals(FlowState.ALLOCATED, flowNbPayload.getStatus());
}
Also used : FlowStatusResponse(org.openkilda.messaging.info.flow.FlowStatusResponse) FlowIdStatusPayload(org.openkilda.messaging.payload.flow.FlowIdStatusPayload) InfoMessage(org.openkilda.messaging.info.InfoMessage) AbstractStormTest(org.openkilda.wfm.AbstractStormTest) Test(org.junit.Test)

Aggregations

FlowIdStatusPayload (org.openkilda.messaging.payload.flow.FlowIdStatusPayload)29 InfoMessage (org.openkilda.messaging.info.InfoMessage)16 CommandMessage (org.openkilda.messaging.command.CommandMessage)12 Test (org.junit.Test)9 FlowStatusResponse (org.openkilda.messaging.info.flow.FlowStatusResponse)8 Message (org.openkilda.messaging.Message)6 AbstractStormTest (org.openkilda.wfm.AbstractStormTest)6 FlowPayload (org.openkilda.messaging.payload.flow.FlowPayload)5 Then (cucumber.api.java.en.Then)3 Values (org.apache.storm.tuple.Values)3 FlowGetRequest (org.openkilda.messaging.command.flow.FlowGetRequest)3 FlowPathRequest (org.openkilda.messaging.command.flow.FlowPathRequest)3 FlowsGetRequest (org.openkilda.messaging.command.flow.FlowsGetRequest)3 Flow (org.openkilda.messaging.model.Flow)3 FlowState (org.openkilda.messaging.payload.flow.FlowState)3 FlowStatusRequest (org.openkilda.messaging.command.flow.FlowStatusRequest)2 InstallOneSwitchFlow (org.openkilda.messaging.command.flow.InstallOneSwitchFlow)2 RemoveFlow (org.openkilda.messaging.command.flow.RemoveFlow)2 ErrorData (org.openkilda.messaging.error.ErrorData)2 ErrorMessage (org.openkilda.messaging.error.ErrorMessage)2