Search in sources :

Example 1 with FlowPingResponseBuilder

use of org.openkilda.messaging.info.flow.FlowPingResponse.FlowPingResponseBuilder 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)

Aggregations

HashSet (java.util.HashSet)1 FlowPingResponseBuilder (org.openkilda.messaging.info.flow.FlowPingResponse.FlowPingResponseBuilder)1 PingContext (org.openkilda.wfm.topology.ping.model.PingContext)1