use of org.openkilda.messaging.command.yflow.YFlowRerouteRequest in project open-kilda by telstra.
the class YFlowRerouteHubBolt method onRequest.
@Override
protected void onRequest(Tuple input) throws PipelineException {
currentKey = pullKey(input);
YFlowRerouteRequest payload = pullValue(input, FIELD_ID_PAYLOAD, YFlowRerouteRequest.class);
try {
yFlowRerouteService.handleRequest(currentKey, pullContext(input), payload);
} catch (DuplicateKeyException e) {
log.error("Failed to handle a request with key {}. {}", currentKey, e.getMessage());
}
}
use of org.openkilda.messaging.command.yflow.YFlowRerouteRequest in project open-kilda by telstra.
the class YFlowRerouteServiceTest method shouldFailIfNoResourcesAvailable.
@Test
public void shouldFailIfNoResourcesAvailable() throws UnroutableFlowException, RecoverableException, ResourceAllocationException, DuplicateKeyException {
// given
YFlowRequest createYFlowRequest = createYFlow();
YFlowRerouteRequest request = new YFlowRerouteRequest(createYFlowRequest.getYFlowId(), "reason");
preparePathComputationForReroute("test_flow_1", buildFirstSubFlowPathPairWithNewTransit());
preparePathComputationForReroute("test_flow_2", buildSecondSubFlowPathPairWithNewTransit());
prepareYPointComputation(SWITCH_SHARED, SWITCH_FIRST_EP, SWITCH_SECOND_EP, SWITCH_NEW_TRANSIT);
doThrow(new ResourceAllocationException(injectedErrorMessage)).when(flowResourcesManager).allocateMeter(eq("test_successful_yflow"), eq(SWITCH_NEW_TRANSIT));
// when
processRerouteRequestAndSpeakerCommands(request);
verifyYFlowStatus(request.getYFlowId(), FlowStatus.UP);
verify(flowResourcesManager, times(METER_ALLOCATION_RETRIES_LIMIT + 1)).allocateMeter(eq("test_successful_yflow"), eq(SWITCH_NEW_TRANSIT));
verify(yFlowRerouteHubCarrier).sendYFlowRerouteResultStatus(eq(createYFlowRequest.getYFlowId()), eq(new RerouteError("Failed to allocate y-flow resources. Unit-test injected failure")), anyString());
}
use of org.openkilda.messaging.command.yflow.YFlowRerouteRequest in project open-kilda by telstra.
the class RerouteQueueService method sendRerouteRequest.
private void sendRerouteRequest(String flowId, FlowThrottlingData throttlingData) {
if (throttlingData != null) {
if (throttlingData.isYFlow()) {
YFlowRerouteRequest request = new YFlowRerouteRequest(flowId, throttlingData.getAffectedIsl(), throttlingData.isForce(), throttlingData.getReason(), throttlingData.isIgnoreBandwidth());
carrier.sendRerouteRequest(throttlingData.getCorrelationId(), request);
} else {
FlowRerouteRequest request = new FlowRerouteRequest(flowId, throttlingData.isForce(), throttlingData.isEffectivelyDown(), throttlingData.isIgnoreBandwidth(), throttlingData.getAffectedIsl(), throttlingData.getReason(), false);
carrier.sendRerouteRequest(throttlingData.getCorrelationId(), request);
}
}
}
use of org.openkilda.messaging.command.yflow.YFlowRerouteRequest in project open-kilda by telstra.
the class RerouteServiceTest method processManualRerouteRequestForYFlow.
@Test
public void processManualRerouteRequestForYFlow() {
RepositoryFactory repositoryFactory = mock(RepositoryFactory.class);
YFlowRepository yFlowRepository = mock(YFlowRepository.class);
when(repositoryFactory.createYFlowRepository()).thenReturn(yFlowRepository);
PersistenceManager persistenceManager = mock(PersistenceManager.class);
when(persistenceManager.getRepositoryFactory()).thenReturn(repositoryFactory);
when(persistenceManager.getTransactionManager()).thenReturn(transactionManager);
when(yFlowRepository.findById(YFLOW_ID)).thenReturn(Optional.of(regularYFlow));
RerouteService rerouteService = new RerouteService(persistenceManager);
YFlowRerouteRequest request = new YFlowRerouteRequest(regularYFlow.getYFlowId(), Collections.emptySet(), true, "reason", false);
rerouteService.processRerouteRequest(carrier, CORRELATION_ID, request);
FlowThrottlingData expected = FlowThrottlingData.builder().correlationId(CORRELATION_ID).priority(regularYFlow.getPriority()).timeCreate(regularYFlow.getTimeCreate()).affectedIsl(Collections.emptySet()).force(true).reason("reason").yFlow(true).build();
verify(carrier).emitManualRerouteCommand(eq(regularYFlow.getYFlowId()), eq(expected));
}
use of org.openkilda.messaging.command.yflow.YFlowRerouteRequest 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