Search in sources :

Example 36 with CommandContext

use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.

the class WatchListHandler method makeDefaultTuple.

private Values makeDefaultTuple(WatcherCommand command) {
    Endpoint endpoint = command.getEndpoint();
    CommandContext forkedContext = getCommandContext().fork(endpoint.getDatapath().toString()).fork(String.format("p%d", endpoint.getPortNumber()));
    return new Values(endpoint.getDatapath(), endpoint.getPortNumber(), command, forkedContext);
}
Also used : Endpoint(org.openkilda.wfm.share.model.Endpoint) CommandContext(org.openkilda.wfm.CommandContext) Values(org.apache.storm.tuple.Values)

Example 37 with CommandContext

use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.

the class TimeoutManager method handleRequest.

private void handleRequest(Tuple input) throws PipelineException {
    PingContext pingContext = pullPingContext(input);
    CommandContext commandContext = pullContext(input);
    scheduleTimeout(pingContext, commandContext);
    emitRequest(input, pingContext, commandContext);
}
Also used : CommandContext(org.openkilda.wfm.CommandContext) PingContext(org.openkilda.wfm.topology.ping.model.PingContext)

Example 38 with CommandContext

use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.

the class RerouteQueueService method injectRetry.

private void injectRetry(String flowId, RerouteQueue rerouteQueue, boolean ignoreBandwidth) {
    log.info("Injecting retry for flow {} wuth ignore b/w flag {}", flowId, ignoreBandwidth);
    FlowThrottlingData retryRequest = rerouteQueue.getInProgress();
    if (retryRequest == null) {
        throw new IllegalStateException(format("Can not retry 'null' reroute request for flow %s.", flowId));
    }
    retryRequest.setIgnoreBandwidth(computeIgnoreBandwidth(retryRequest, ignoreBandwidth));
    if (retryRequest.getRetryCounter() < maxRetry) {
        retryRequest.increaseRetryCounter();
        String retryCorrelationId = new CommandContext(retryRequest.getCorrelationId()).fork(format("retry #%d ignore_bw %b", retryRequest.getRetryCounter(), retryRequest.isIgnoreBandwidth())).getCorrelationId();
        retryRequest.setCorrelationId(retryCorrelationId);
        FlowThrottlingData toSend = rerouteQueue.processRetryRequest(retryRequest, carrier);
        sendRerouteRequest(flowId, toSend);
    } else {
        log.error("No more retries available for reroute request {}.", retryRequest);
        FlowThrottlingData toSend = rerouteQueue.processPending();
        if (toSend != null) {
            toSend.setIgnoreBandwidth(computeIgnoreBandwidth(toSend, ignoreBandwidth));
        }
        sendRerouteRequest(flowId, toSend);
    }
}
Also used : CommandContext(org.openkilda.wfm.CommandContext) FlowThrottlingData(org.openkilda.wfm.topology.reroute.model.FlowThrottlingData)

Example 39 with CommandContext

use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.

the class FlowRerouteQueueBolt method sendRerouteRequest.

@Override
public void sendRerouteRequest(String correlationId, YFlowRerouteRequest request) {
    log.info("Send reroute request {} with correlationId {}", request, correlationId);
    // emit without anchor to prevent a possible loop
    emit(STREAM_OPERATION_QUEUE_ID, new Values(request.getYFlowId(), request, new CommandContext(correlationId)));
    registerCallback(correlationId);
}
Also used : CommandContext(org.openkilda.wfm.CommandContext) Values(org.apache.storm.tuple.Values)

Example 40 with CommandContext

use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.

the class OperationQueueBolt method handleInput.

@Override
protected void handleInput(Tuple tuple) throws PipelineException {
    CommandContext context = pullContext(tuple);
    MessageData data = pullValue(tuple, FIELD_ID_PAYLOAD, MessageData.class);
    if (data instanceof FlowPathSwapRequest) {
        FlowPathSwapRequest flowPathSwapRequest = (FlowPathSwapRequest) data;
        service.addFirst(flowPathSwapRequest.getFlowId(), context.getCorrelationId(), flowPathSwapRequest);
    } else if (data instanceof FlowRerouteRequest) {
        FlowRerouteRequest flowRerouteRequest = (FlowRerouteRequest) data;
        service.addLast(flowRerouteRequest.getFlowId(), context.getCorrelationId(), flowRerouteRequest);
    } else if (data instanceof YFlowRerouteRequest) {
        YFlowRerouteRequest yFlowRerouteRequest = (YFlowRerouteRequest) data;
        service.addLast(yFlowRerouteRequest.getYFlowId(), context.getCorrelationId(), yFlowRerouteRequest);
    } else if (data instanceof RerouteResultInfoData) {
        RerouteResultInfoData rerouteResultInfoData = (RerouteResultInfoData) data;
        service.operationCompleted(rerouteResultInfoData.getFlowId(), rerouteResultInfoData);
        emitRerouteResponse(rerouteResultInfoData);
    } else if (data instanceof PathSwapResult) {
        PathSwapResult pathSwapResult = (PathSwapResult) data;
        service.operationCompleted(pathSwapResult.getFlowId(), pathSwapResult);
    } else {
        unhandledInput(tuple);
    }
}
Also used : CommandContext(org.openkilda.wfm.CommandContext) MessageData(org.openkilda.messaging.MessageData) FlowPathSwapRequest(org.openkilda.messaging.command.flow.FlowPathSwapRequest) YFlowRerouteRequest(org.openkilda.messaging.command.yflow.YFlowRerouteRequest) FlowRerouteRequest(org.openkilda.messaging.command.flow.FlowRerouteRequest) YFlowRerouteRequest(org.openkilda.messaging.command.yflow.YFlowRerouteRequest) RerouteResultInfoData(org.openkilda.messaging.info.reroute.RerouteResultInfoData) PathSwapResult(org.openkilda.messaging.info.reroute.PathSwapResult)

Aggregations

CommandContext (org.openkilda.wfm.CommandContext)95 Test (org.junit.Test)28 Values (org.apache.storm.tuple.Values)27 FlowSegmentRequest (org.openkilda.floodlight.api.request.FlowSegmentRequest)15 Flow (org.openkilda.model.Flow)15 AbstractYFlowTest (org.openkilda.wfm.topology.flowhs.service.AbstractYFlowTest)14 Tuple (org.apache.storm.tuple.Tuple)12 SwitchId (org.openkilda.model.SwitchId)11 YFlow (org.openkilda.model.YFlow)11 BaseSpeakerCommandsRequest (org.openkilda.floodlight.api.request.rulemanager.BaseSpeakerCommandsRequest)9 SpeakerResponse (org.openkilda.floodlight.api.response.SpeakerResponse)9 YFlowRequest (org.openkilda.messaging.command.yflow.YFlowRequest)9 InfoMessage (org.openkilda.messaging.info.InfoMessage)9 TupleImpl (org.apache.storm.tuple.TupleImpl)8 FlowPath (org.openkilda.model.FlowPath)8 ArrayList (java.util.ArrayList)7 FlowRerouteRequest (org.openkilda.messaging.command.flow.FlowRerouteRequest)7 FlowProcessingException (org.openkilda.wfm.topology.flowhs.exception.FlowProcessingException)7 UnknownKeyException (org.openkilda.wfm.topology.flowhs.exception.UnknownKeyException)7 List (java.util.List)6