Search in sources :

Example 1 with FlowPingResponse

use of org.openkilda.messaging.info.flow.FlowPingResponse in project open-kilda by telstra.

the class OnDemandResultManager method produceFlowErrors.

private List<FlowPingResponse> produceFlowErrors(Group group, String errorMessage) {
    HashSet<String> seen = new HashSet<>();
    ArrayList<FlowPingResponse> results = new ArrayList<>();
    for (PingContext pingContext : group.getRecords()) {
        if (!seen.add(pingContext.getFlowId())) {
            continue;
        }
        log.info("Produce error response (group={}, flow={}): {}", group.getId(), pingContext.getFlowId(), errorMessage);
        results.add(new FlowPingResponse(pingContext.getFlowId(), errorMessage));
    }
    return results;
}
Also used : ArrayList(java.util.ArrayList) PingContext(org.openkilda.wfm.topology.ping.model.PingContext) YFlowPingResponse(org.openkilda.messaging.info.flow.YFlowPingResponse) UniFlowPingResponse(org.openkilda.messaging.info.flow.UniFlowPingResponse) FlowPingResponse(org.openkilda.messaging.info.flow.FlowPingResponse) HashSet(java.util.HashSet)

Example 2 with FlowPingResponse

use of org.openkilda.messaging.info.flow.FlowPingResponse in project open-kilda by telstra.

the class FlowMapperTest method testPingOutput.

@Test
public void testPingOutput() {
    FlowPingResponse response = new FlowPingResponse(FLOW_ID, new UniFlowPingResponse(false, Errors.TIMEOUT, null, null), new UniFlowPingResponse(true, null, new PingMeters(1, 2, 3), null), ERROR_MESSAGE);
    PingOutput output = flowMapper.toPingOutput(response);
    assertEquals(response.getFlowId(), output.getFlowId());
    assertEquals(response.getError(), output.getError());
    assertEquals(response.getForward().isPingSuccess(), output.getForward().isPingSuccess());
    assertEquals(0, output.getForward().getLatency());
    assertEquals(TIMEOUT_ERROR_MESSAGE, output.getForward().getError());
    assertEquals(response.getReverse().isPingSuccess(), output.getReverse().isPingSuccess());
    assertEquals(1, output.getReverse().getLatency());
    assertNull(output.getReverse().getError());
}
Also used : UniFlowPingResponse(org.openkilda.messaging.info.flow.UniFlowPingResponse) PingOutput(org.openkilda.northbound.dto.v1.flows.PingOutput) UniFlowPingResponse(org.openkilda.messaging.info.flow.UniFlowPingResponse) FlowPingResponse(org.openkilda.messaging.info.flow.FlowPingResponse) PingMeters(org.openkilda.messaging.model.PingMeters) Test(org.junit.Test)

Example 3 with FlowPingResponse

use of org.openkilda.messaging.info.flow.FlowPingResponse in project open-kilda by telstra.

the class FlowFetcher method emitOnDemandResponse.

private void emitOnDemandResponse(Tuple input, FlowPingRequest request, String errorMessage) throws PipelineException {
    FlowPingResponse response = new FlowPingResponse(request.getFlowId(), errorMessage);
    Values output = new Values(response, pullContext(input));
    getOutput().emit(STREAM_ON_DEMAND_RESPONSE_ID, input, output);
}
Also used : Values(org.apache.storm.tuple.Values) YFlowPingResponse(org.openkilda.messaging.info.flow.YFlowPingResponse) FlowPingResponse(org.openkilda.messaging.info.flow.FlowPingResponse)

Example 4 with FlowPingResponse

use of org.openkilda.messaging.info.flow.FlowPingResponse in project open-kilda by telstra.

the class OnDemandResultManager method handleFlowResponse.

private void handleFlowResponse(Tuple input, Group group) throws PipelineException {
    try {
        FlowPingResponse response = collectResults(group);
        emit(input, response);
    } catch (IllegalArgumentException e) {
        for (FlowPingResponse errorResponse : produceFlowErrors(group, e.getMessage())) {
            emit(input, errorResponse);
        }
    }
}
Also used : YFlowPingResponse(org.openkilda.messaging.info.flow.YFlowPingResponse) UniFlowPingResponse(org.openkilda.messaging.info.flow.UniFlowPingResponse) FlowPingResponse(org.openkilda.messaging.info.flow.FlowPingResponse)

Aggregations

FlowPingResponse (org.openkilda.messaging.info.flow.FlowPingResponse)4 UniFlowPingResponse (org.openkilda.messaging.info.flow.UniFlowPingResponse)3 YFlowPingResponse (org.openkilda.messaging.info.flow.YFlowPingResponse)3 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Values (org.apache.storm.tuple.Values)1 Test (org.junit.Test)1 PingMeters (org.openkilda.messaging.model.PingMeters)1 PingOutput (org.openkilda.northbound.dto.v1.flows.PingOutput)1 PingContext (org.openkilda.wfm.topology.ping.model.PingContext)1