Search in sources :

Example 16 with PingContext

use of org.openkilda.wfm.topology.ping.model.PingContext in project open-kilda by telstra.

the class Blacklist method handleInput.

@Override
protected void handleInput(Tuple input) throws Exception {
    if (!PingRouter.BOLT_ID.equals(input.getSourceComponent())) {
        unhandledInput(input);
        return;
    }
    String stream = input.getSourceStreamId();
    PingContext pingContext = pullPingContext(input);
    if (PingRouter.STREAM_BLACKLIST_FILTER_ID.equals(stream)) {
        filter(input, pingContext);
    } else if (PingRouter.STREAM_BLACKLIST_UPDATE_ID.equals(stream)) {
        update(pingContext);
    } else {
        unhandledInput(input);
    }
}
Also used : PingContext(org.openkilda.wfm.topology.ping.model.PingContext)

Example 17 with PingContext

use of org.openkilda.wfm.topology.ping.model.PingContext in project open-kilda by telstra.

the class OnDemandResultManager method handleYFlowResponse.

private void handleYFlowResponse(Tuple input, Group group) throws PipelineException {
    try {
        YFlowPingResponse response = buildYFlowPingResponse(group);
        emit(input, response);
    } catch (IllegalArgumentException e) {
        String yFlowId = group.getRecords().stream().map(PingContext::getYFlowId).filter(Objects::nonNull).findFirst().orElse(null);
        YFlowPingResponse errorResponse = new YFlowPingResponse(yFlowId, e.getMessage(), null);
        emit(input, errorResponse);
    }
}
Also used : YFlowPingResponse(org.openkilda.messaging.info.flow.YFlowPingResponse) PingContext(org.openkilda.wfm.topology.ping.model.PingContext)

Example 18 with PingContext

use of org.openkilda.wfm.topology.ping.model.PingContext in project open-kilda by telstra.

the class OnDemandResultManager method collectResults.

private FlowPingResponse collectResults(Group group) {
    FlowPingResponseBuilder builder = FlowPingResponse.builder();
    HashSet<String> idSet = new HashSet<>();
    for (PingContext entry : group.getRecords()) {
        idSet.add(entry.getFlowId());
        switch(entry.getDirection()) {
            case FORWARD:
                builder.forward(makeResponse(entry));
                break;
            case REVERSE:
                builder.reverse(makeResponse(entry));
                break;
            default:
                throw new IllegalArgumentException(format("Unsupported %s.%s value", entry.getDirection().getClass().getName(), entry.getDirection()));
        }
    }
    if (idSet.size() != 1) {
        throw new IllegalArgumentException(format("Expect exact one flow id in pings group response, got - \"%s\"", String.join("\", \"", idSet)));
    }
    builder.flowId(idSet.iterator().next());
    return builder.build();
}
Also used : FlowPingResponseBuilder(org.openkilda.messaging.info.flow.FlowPingResponse.FlowPingResponseBuilder) PingContext(org.openkilda.wfm.topology.ping.model.PingContext) HashSet(java.util.HashSet)

Example 19 with PingContext

use of org.openkilda.wfm.topology.ping.model.PingContext in project open-kilda by telstra.

the class ResultDispatcher method handleInput.

@Override
protected void handleInput(Tuple input) throws Exception {
    PingContext pingContext = pullPingContext(input);
    final String stream = dispatch(pingContext);
    Values output = new Values(pingContext, pullContext(input));
    getOutput().emit(stream, input, output);
}
Also used : Values(org.apache.storm.tuple.Values) PingContext(org.openkilda.wfm.topology.ping.model.PingContext)

Aggregations

PingContext (org.openkilda.wfm.topology.ping.model.PingContext)19 Values (org.apache.storm.tuple.Values)5 GroupId (org.openkilda.wfm.topology.ping.model.GroupId)4 HashSet (java.util.HashSet)3 YFlowPingResponse (org.openkilda.messaging.info.flow.YFlowPingResponse)3 CommandContext (org.openkilda.wfm.CommandContext)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 YFlowPingRequest (org.openkilda.messaging.command.flow.YFlowPingRequest)2 Flow (org.openkilda.model.Flow)2 FlowTransitEncapsulation (org.openkilda.model.FlowTransitEncapsulation)2 YFlow (org.openkilda.model.YFlow)2 YSubFlow (org.openkilda.model.YSubFlow)2 FlowPingRequest (org.openkilda.messaging.command.flow.FlowPingRequest)1 FlowPingResponse (org.openkilda.messaging.info.flow.FlowPingResponse)1 FlowPingResponseBuilder (org.openkilda.messaging.info.flow.FlowPingResponse.FlowPingResponseBuilder)1 SubFlowPingPayload (org.openkilda.messaging.info.flow.SubFlowPingPayload)1 UniFlowPingResponse (org.openkilda.messaging.info.flow.UniFlowPingResponse)1 UniSubFlowPingPayload (org.openkilda.messaging.info.flow.UniSubFlowPingPayload)1 WorkflowException (org.openkilda.wfm.error.WorkflowException)1