use of org.openkilda.wfm.topology.reroute.model.RerouteQueue in project open-kilda by telstra.
the class RerouteQueueService method flushThrottling.
/**
* Move reroute requests form throttling to pending/in-progress.
*/
public void flushThrottling() {
Map<String, FlowThrottlingData> requestsToSend = new HashMap<>();
reroutes.forEach((flowId, rerouteQueue) -> rerouteQueue.flushThrottling().ifPresent(flowThrottlingData -> requestsToSend.put(flowId, flowThrottlingData)));
log.info("Send reroute requests for flows {}", requestsToSend.keySet());
Comparator<FlowThrottlingData> comparator = ((Comparator<FlowThrottlingData>) this::comparePriority).thenComparing(this::compareAvailableBandwidth).thenComparing(this::compareTimeCreate);
requestsToSend.entrySet().stream().sorted(Map.Entry.comparingByValue(comparator)).forEach(es -> {
String flowId = es.getKey();
FlowThrottlingData flowThrottlingData = es.getValue();
sendRerouteRequest(flowId, flowThrottlingData);
});
}
use of org.openkilda.wfm.topology.reroute.model.RerouteQueue in project open-kilda by telstra.
the class RerouteQueueService method processAutomaticRequest.
/**
* Put reroute request to throttling.
*
* @param flowId flow id
* @param throttlingData reroute request params
*/
public void processAutomaticRequest(String flowId, FlowThrottlingData throttlingData) {
if (throttlingData.isYFlow()) {
Optional<YFlow> flow = yFlowRepository.findById(flowId);
if (!flow.isPresent()) {
log.warn(format("Y-flow %s not found. Skip the reroute operation of this flow.", flowId));
return;
} else if (flow.get().isPinned()) {
log.info(format("Y-flow %s is pinned. Skip the reroute operation of this flow.", flowId));
return;
}
} else {
Optional<Flow> flow = flowRepository.findById(flowId);
if (!flow.isPresent()) {
log.warn(format("Flow %s not found. Skip the reroute operation of this flow.", flowId));
return;
} else if (flow.get().isPinned()) {
log.info(format("Flow %s is pinned. Skip the reroute operation of this flow.", flowId));
return;
}
}
log.info("Puts reroute request for flow {} with correlationId {}.", flowId, throttlingData.getCorrelationId());
RerouteQueue rerouteQueue = getRerouteQueue(flowId);
rerouteQueue.putToThrottling(throttlingData);
carrier.sendExtendTimeWindowEvent();
}
use of org.openkilda.wfm.topology.reroute.model.RerouteQueue in project open-kilda by telstra.
the class RerouteQueueService method processRerouteResult.
/**
* Process reroute result. Check fail reason, decide if retry is needed and schedule it if yes.
*
* @param rerouteResultInfoData reroute result
* @param correlationId correlation id
*/
public void processRerouteResult(RerouteResultInfoData rerouteResultInfoData, String correlationId) {
String flowId = rerouteResultInfoData.getFlowId();
RerouteQueue rerouteQueue = getRerouteQueue(flowId);
FlowThrottlingData inProgress = rerouteQueue.getInProgress();
if (inProgress == null || !Objects.equals(inProgress.getCorrelationId(), correlationId)) {
log.error("Skipped unexpected reroute result for flow {} with correlation id {}.", flowId, correlationId);
return;
}
carrier.cancelTimeout(correlationId);
if (rerouteResultInfoData.isSuccess()) {
FlowThrottlingData toSend = rerouteQueue.processPending();
sendRerouteRequest(flowId, toSend);
} else {
RerouteError rerouteError = rerouteResultInfoData.getRerouteError();
if (isRetryRequired(flowId, rerouteError, rerouteResultInfoData.isYFlow())) {
injectRetry(flowId, rerouteQueue, rerouteError instanceof NoPathFoundError);
} else {
FlowThrottlingData toSend = rerouteQueue.processPending();
sendRerouteRequest(flowId, toSend);
}
}
}
use of org.openkilda.wfm.topology.reroute.model.RerouteQueue in project open-kilda by telstra.
the class RerouteQueueServiceTest method shouldSendManualRerouteRequestWithoutThrottling.
@Test
public void shouldSendManualRerouteRequestWithoutThrottling() {
FlowThrottlingData throttling = getFlowThrottlingData(flow, "another one").build();
RerouteQueue rerouteQueue = RerouteQueue.builder().throttling(throttling).build();
rerouteQueueService.getReroutes().put(FLOW_ID, rerouteQueue);
FlowThrottlingData actual = getFlowThrottlingData(flow, CORRELATION_ID).build();
rerouteQueueService.processManualRequest(FLOW_ID, actual);
assertEquals(1, rerouteQueueService.getReroutes().size());
assertEquals(actual, rerouteQueue.getInProgress());
assertNull(rerouteQueue.getPending());
assertEquals(throttling, rerouteQueue.getThrottling());
FlowRerouteRequest expected = getFlowRerouteRequest(FLOW_ID, actual);
verify(carrier).sendRerouteRequest(eq(CORRELATION_ID), eq(expected));
}
use of org.openkilda.wfm.topology.reroute.model.RerouteQueue in project open-kilda by telstra.
the class RerouteQueueServiceTest method shouldSendExtendTimeWindowEventForRerouteRequestInThrottling.
@Test
public void shouldSendExtendTimeWindowEventForRerouteRequestInThrottling() {
FlowThrottlingData actual = getFlowThrottlingData(flow, CORRELATION_ID).build();
rerouteQueueService.processAutomaticRequest(FLOW_ID, actual);
assertEquals(1, rerouteQueueService.getReroutes().size());
assertNotNull(rerouteQueueService.getReroutes().get(FLOW_ID));
RerouteQueue rerouteQueue = rerouteQueueService.getReroutes().get(FLOW_ID);
assertNull(rerouteQueue.getInProgress());
assertNull(rerouteQueue.getPending());
assertEquals(actual, rerouteQueue.getThrottling());
verify(carrier).sendExtendTimeWindowEvent();
}
Aggregations