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);
}
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);
}
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);
}
}
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);
}
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);
}
}
Aggregations