Search in sources :

Example 1 with YFlowRerouteRequest

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());
    }
}
Also used : YFlowRerouteRequest(org.openkilda.messaging.command.yflow.YFlowRerouteRequest) DuplicateKeyException(org.openkilda.wfm.topology.flowhs.exception.DuplicateKeyException)

Example 2 with YFlowRerouteRequest

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());
}
Also used : YFlowRerouteRequest(org.openkilda.messaging.command.yflow.YFlowRerouteRequest) RerouteError(org.openkilda.messaging.info.reroute.error.RerouteError) ResourceAllocationException(org.openkilda.wfm.share.flow.resources.ResourceAllocationException) YFlowRequest(org.openkilda.messaging.command.yflow.YFlowRequest) Test(org.junit.Test) AbstractYFlowTest(org.openkilda.wfm.topology.flowhs.service.AbstractYFlowTest)

Example 3 with YFlowRerouteRequest

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);
        }
    }
}
Also used : YFlowRerouteRequest(org.openkilda.messaging.command.yflow.YFlowRerouteRequest) FlowRerouteRequest(org.openkilda.messaging.command.flow.FlowRerouteRequest) YFlowRerouteRequest(org.openkilda.messaging.command.yflow.YFlowRerouteRequest)

Example 4 with YFlowRerouteRequest

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));
}
Also used : YFlowRepository(org.openkilda.persistence.repositories.YFlowRepository) PersistenceManager(org.openkilda.persistence.PersistenceManager) FlowThrottlingData(org.openkilda.wfm.topology.reroute.model.FlowThrottlingData) YFlowRerouteRequest(org.openkilda.messaging.command.yflow.YFlowRerouteRequest) RepositoryFactory(org.openkilda.persistence.repositories.RepositoryFactory) Test(org.junit.Test)

Example 5 with YFlowRerouteRequest

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

YFlowRerouteRequest (org.openkilda.messaging.command.yflow.YFlowRerouteRequest)20 Test (org.junit.Test)13 YFlowRequest (org.openkilda.messaging.command.yflow.YFlowRequest)11 AbstractYFlowTest (org.openkilda.wfm.topology.flowhs.service.AbstractYFlowTest)10 RerouteError (org.openkilda.messaging.info.reroute.error.RerouteError)5 IslEndpoint (org.openkilda.model.IslEndpoint)5 FlowRerouteRequest (org.openkilda.messaging.command.flow.FlowRerouteRequest)4 CommandContext (org.openkilda.wfm.CommandContext)3 FlowThrottlingData (org.openkilda.wfm.topology.reroute.model.FlowThrottlingData)3 MessageData (org.openkilda.messaging.MessageData)2 CommandMessage (org.openkilda.messaging.command.CommandMessage)2 FlowPathSwapRequest (org.openkilda.messaging.command.flow.FlowPathSwapRequest)2 RerouteResultInfoData (org.openkilda.messaging.info.reroute.RerouteResultInfoData)2 UnroutableFlowException (org.openkilda.pce.exception.UnroutableFlowException)2 RerouteQueue (org.openkilda.wfm.topology.reroute.model.RerouteQueue)2 HashSet (java.util.HashSet)1 Values (org.apache.storm.tuple.Values)1 CommandData (org.openkilda.messaging.command.CommandData)1 CreateFlowLoopRequest (org.openkilda.messaging.command.flow.CreateFlowLoopRequest)1 DeleteFlowLoopRequest (org.openkilda.messaging.command.flow.DeleteFlowLoopRequest)1