Search in sources :

Example 16 with FlowThrottlingData

use of org.openkilda.wfm.topology.reroute.model.FlowThrottlingData in project open-kilda by telstra.

the class RerouteQueueServiceTest method shouldNotInjectRetryWhenReceivedFailedRuleInstallResponseOnTerminatingSwitch.

@Test
public void shouldNotInjectRetryWhenReceivedFailedRuleInstallResponseOnTerminatingSwitch() {
    FlowThrottlingData inProgress = getFlowThrottlingData(flow, CORRELATION_ID).build();
    RerouteQueue rerouteQueue = RerouteQueue.builder().inProgress(inProgress).build();
    rerouteQueueService.getReroutes().put(FLOW_ID, rerouteQueue);
    RerouteResultInfoData rerouteResultInfoData = RerouteResultInfoData.builder().flowId(FLOW_ID).success(false).rerouteError(new SpeakerRequestError("Failed to install rules", Collections.singleton(SWITCH_B.getSwitchId()))).build();
    rerouteQueueService.processRerouteResult(rerouteResultInfoData, CORRELATION_ID);
    assertNull(rerouteQueue.getInProgress());
    assertNull(rerouteQueue.getPending());
    assertNull(rerouteQueue.getThrottling());
}
Also used : FlowThrottlingData(org.openkilda.wfm.topology.reroute.model.FlowThrottlingData) RerouteQueue(org.openkilda.wfm.topology.reroute.model.RerouteQueue) RerouteResultInfoData(org.openkilda.messaging.info.reroute.RerouteResultInfoData) SpeakerRequestError(org.openkilda.messaging.info.reroute.error.SpeakerRequestError) Test(org.junit.Test)

Example 17 with FlowThrottlingData

use of org.openkilda.wfm.topology.reroute.model.FlowThrottlingData in project open-kilda by telstra.

the class RerouteQueueServiceTest method shouldComputeIgnoreBandwidthFlag.

@Test
public void shouldComputeIgnoreBandwidthFlag() {
    FlowThrottlingData data = FlowThrottlingData.builder().affectedIsl(Collections.emptySet()).ignoreBandwidth(true).strictBandwidth(false).build();
    assertTrue(rerouteQueueService.computeIgnoreBandwidth(data, true));
    assertTrue(rerouteQueueService.computeIgnoreBandwidth(data, false));
    data = FlowThrottlingData.builder().affectedIsl(Collections.emptySet()).ignoreBandwidth(false).strictBandwidth(false).build();
    assertTrue(rerouteQueueService.computeIgnoreBandwidth(data, true));
    assertFalse(rerouteQueueService.computeIgnoreBandwidth(data, false));
    data = FlowThrottlingData.builder().affectedIsl(Collections.emptySet()).ignoreBandwidth(true).strictBandwidth(true).build();
    assertFalse(rerouteQueueService.computeIgnoreBandwidth(data, true));
    assertFalse(rerouteQueueService.computeIgnoreBandwidth(data, false));
    data = FlowThrottlingData.builder().affectedIsl(Collections.emptySet()).ignoreBandwidth(false).strictBandwidth(true).build();
    assertFalse(rerouteQueueService.computeIgnoreBandwidth(data, true));
    assertFalse(rerouteQueueService.computeIgnoreBandwidth(data, false));
}
Also used : FlowThrottlingData(org.openkilda.wfm.topology.reroute.model.FlowThrottlingData) Test(org.junit.Test)

Example 18 with FlowThrottlingData

use of org.openkilda.wfm.topology.reroute.model.FlowThrottlingData in project open-kilda by telstra.

the class RerouteQueueServiceTest method shouldMergeAndSendRetryWithPendingRequestWhenReceivedFailedRuleInstallResponseOnTransitSwitch.

@Test
public void shouldMergeAndSendRetryWithPendingRequestWhenReceivedFailedRuleInstallResponseOnTransitSwitch() {
    FlowThrottlingData inProgress = getFlowThrottlingData(flow, CORRELATION_ID).build();
    FlowThrottlingData pending = FlowThrottlingData.builder().correlationId("pending").priority(7).timeCreate(flow.getTimeCreate()).affectedIsl(Collections.singleton(new IslEndpoint(SWITCH_ID_A, 1))).force(false).effectivelyDown(true).reason("another reason").build();
    RerouteQueue rerouteQueue = RerouteQueue.builder().inProgress(inProgress).pending(pending).build();
    rerouteQueueService.getReroutes().put(FLOW_ID, rerouteQueue);
    RerouteResultInfoData rerouteResultInfoData = RerouteResultInfoData.builder().flowId(FLOW_ID).success(false).rerouteError(new SpeakerRequestError("Failed to install rules", Collections.singleton(SWITCH_C.getSwitchId()))).build();
    rerouteQueueService.processRerouteResult(rerouteResultInfoData, CORRELATION_ID);
    String retryCorrelationId = CORRELATION_ID + " : retry #1 ignore_bw false";
    FlowThrottlingData expected = getFlowThrottlingData(flow, retryCorrelationId).build();
    expected.setPriority(pending.getPriority());
    expected.setReason(pending.getReason());
    assertEquals(expected, rerouteQueue.getInProgress());
    assertNull(rerouteQueue.getPending());
    assertNull(rerouteQueue.getThrottling());
    FlowRerouteRequest expectedRequest = getFlowRerouteRequest(FLOW_ID, expected);
    verify(carrier).sendRerouteRequest(eq(retryCorrelationId), eq(expectedRequest));
}
Also used : IslEndpoint(org.openkilda.model.IslEndpoint) FlowThrottlingData(org.openkilda.wfm.topology.reroute.model.FlowThrottlingData) RerouteQueue(org.openkilda.wfm.topology.reroute.model.RerouteQueue) FlowRerouteRequest(org.openkilda.messaging.command.flow.FlowRerouteRequest) YFlowRerouteRequest(org.openkilda.messaging.command.yflow.YFlowRerouteRequest) RerouteResultInfoData(org.openkilda.messaging.info.reroute.RerouteResultInfoData) SpeakerRequestError(org.openkilda.messaging.info.reroute.error.SpeakerRequestError) Test(org.junit.Test)

Example 19 with FlowThrottlingData

use of org.openkilda.wfm.topology.reroute.model.FlowThrottlingData 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 20 with FlowThrottlingData

use of org.openkilda.wfm.topology.reroute.model.FlowThrottlingData in project open-kilda by telstra.

the class FlowRerouteQueueBolt method handleRerouteBoltMessage.

private void handleRerouteBoltMessage(Tuple tuple) throws PipelineException {
    String flowId = pullValue(tuple, RerouteBolt.FLOW_ID_FIELD, String.class);
    FlowThrottlingData throttlingData;
    switch(tuple.getSourceStreamId()) {
        case STREAM_REROUTE_REQUEST_ID:
            throttlingData = (FlowThrottlingData) tuple.getValueByField(RerouteBolt.THROTTLING_DATA_FIELD);
            rerouteQueueService.processAutomaticRequest(flowId, throttlingData);
            break;
        case STREAM_MANUAL_REROUTE_REQUEST_ID:
            throttlingData = (FlowThrottlingData) tuple.getValueByField(RerouteBolt.THROTTLING_DATA_FIELD);
            rerouteQueueService.processManualRequest(flowId, throttlingData);
            break;
        default:
            unhandledInput(tuple);
    }
}
Also used : FlowThrottlingData(org.openkilda.wfm.topology.reroute.model.FlowThrottlingData)

Aggregations

FlowThrottlingData (org.openkilda.wfm.topology.reroute.model.FlowThrottlingData)34 Test (org.junit.Test)26 RerouteQueue (org.openkilda.wfm.topology.reroute.model.RerouteQueue)17 YFlowRerouteRequest (org.openkilda.messaging.command.yflow.YFlowRerouteRequest)9 IslEndpoint (org.openkilda.model.IslEndpoint)8 PersistenceManager (org.openkilda.persistence.PersistenceManager)7 FlowRerouteRequest (org.openkilda.messaging.command.flow.FlowRerouteRequest)6 RerouteResultInfoData (org.openkilda.messaging.info.reroute.RerouteResultInfoData)6 RepositoryFactory (org.openkilda.persistence.repositories.RepositoryFactory)6 YFlowRepository (org.openkilda.persistence.repositories.YFlowRepository)6 YFlow (org.openkilda.model.YFlow)5 PathNode (org.openkilda.messaging.info.event.PathNode)4 SpeakerRequestError (org.openkilda.messaging.info.reroute.error.SpeakerRequestError)4 Flow (org.openkilda.model.Flow)4 FlowPathRepository (org.openkilda.persistence.repositories.FlowPathRepository)4 FlowRepository (org.openkilda.persistence.repositories.FlowRepository)4 SwitchId (org.openkilda.model.SwitchId)3 HashMap (java.util.HashMap)2 Set (java.util.Set)2 RerouteAffectedFlows (org.openkilda.messaging.command.reroute.RerouteAffectedFlows)2