Search in sources :

Example 16 with PersistenceManager

use of org.openkilda.persistence.PersistenceManager in project open-kilda by telstra.

the class RerouteServiceTest method testRerouteInactivePinnedFlowsTwoFailedSegments.

@Test
public void testRerouteInactivePinnedFlowsTwoFailedSegments() {
    pinnedFlow.setStatus(FlowStatus.DOWN);
    for (FlowPath flowPath : pinnedFlow.getPaths()) {
        flowPath.setStatus(FlowPathStatus.INACTIVE);
        for (PathSegment pathSegment : flowPath.getSegments()) {
            pathSegment.setFailed(true);
        }
    }
    RepositoryFactory repositoryFactory = mock(RepositoryFactory.class);
    FlowRepository flowRepository = mock(FlowRepository.class);
    when(flowRepository.findInactiveFlows()).thenReturn(Collections.singletonList(pinnedFlow));
    when(repositoryFactory.createFlowRepository()).thenReturn(flowRepository);
    FlowPathRepository pathRepository = mock(FlowPathRepository.class);
    when(repositoryFactory.createFlowPathRepository()).thenReturn(pathRepository);
    PathSegmentRepository pathSegmentRepository = mock(PathSegmentRepository.class);
    when(repositoryFactory.createPathSegmentRepository()).thenReturn(pathSegmentRepository);
    MessageSender messageSender = mock(MessageSender.class);
    PersistenceManager persistenceManager = mock(PersistenceManager.class);
    when(persistenceManager.getRepositoryFactory()).thenReturn(repositoryFactory);
    when(persistenceManager.getTransactionManager()).thenReturn(transactionManager);
    RerouteService rerouteService = new RerouteService(persistenceManager);
    rerouteService.rerouteInactiveFlows(messageSender, CORRELATION_ID, REROUTE_INACTIVE_FLOWS_COMMAND);
    verify(pathRepository, times(0)).updateStatus(any(), any());
    assertTrue(FlowStatus.DOWN.equals(pinnedFlow.getStatus()));
    for (FlowPath fp : pinnedFlow.getPaths()) {
        assertTrue(FlowPathStatus.INACTIVE.equals(fp.getStatus()));
        for (PathSegment ps : fp.getSegments()) {
            if (ps.containsNode(SWITCH_ID_A, PORT)) {
                assertFalse(ps.isFailed());
            } else {
                assertTrue(ps.isFailed());
            }
        }
    }
}
Also used : FlowRepository(org.openkilda.persistence.repositories.FlowRepository) YFlowRepository(org.openkilda.persistence.repositories.YFlowRepository) FlowPathRepository(org.openkilda.persistence.repositories.FlowPathRepository) PathSegmentRepository(org.openkilda.persistence.repositories.PathSegmentRepository) PersistenceManager(org.openkilda.persistence.PersistenceManager) MessageSender(org.openkilda.wfm.topology.reroute.bolts.MessageSender) PathSegment(org.openkilda.model.PathSegment) RepositoryFactory(org.openkilda.persistence.repositories.RepositoryFactory) FlowPath(org.openkilda.model.FlowPath) Test(org.junit.Test)

Example 17 with PersistenceManager

use of org.openkilda.persistence.PersistenceManager in project open-kilda by telstra.

the class RerouteServiceTest method processManualRerouteRequest.

@Test
public void processManualRerouteRequest() {
    FlowRepository flowRepository = mock(FlowRepository.class);
    when(flowRepository.findById(regularFlow.getFlowId())).thenReturn(Optional.of(regularFlow));
    RepositoryFactory repositoryFactory = mock(RepositoryFactory.class);
    when(repositoryFactory.createFlowRepository()).thenReturn(flowRepository);
    PersistenceManager persistenceManager = mock(PersistenceManager.class);
    when(persistenceManager.getRepositoryFactory()).thenReturn(repositoryFactory);
    when(persistenceManager.getTransactionManager()).thenReturn(transactionManager);
    RerouteService rerouteService = new RerouteService(persistenceManager);
    FlowRerouteRequest request = new FlowRerouteRequest(regularFlow.getFlowId(), true, true, false, Collections.emptySet(), "reason", true);
    rerouteService.processRerouteRequest(carrier, CORRELATION_ID, request);
    FlowThrottlingData expected = FlowThrottlingData.builder().correlationId(CORRELATION_ID).priority(regularFlow.getPriority()).timeCreate(regularFlow.getTimeCreate()).affectedIsl(Collections.emptySet()).force(true).effectivelyDown(true).reason("reason").build();
    verify(carrier).emitManualRerouteCommand(eq(regularFlow.getFlowId()), eq(expected));
}
Also used : FlowRepository(org.openkilda.persistence.repositories.FlowRepository) YFlowRepository(org.openkilda.persistence.repositories.YFlowRepository) PersistenceManager(org.openkilda.persistence.PersistenceManager) FlowThrottlingData(org.openkilda.wfm.topology.reroute.model.FlowThrottlingData) FlowRerouteRequest(org.openkilda.messaging.command.flow.FlowRerouteRequest) YFlowRerouteRequest(org.openkilda.messaging.command.yflow.YFlowRerouteRequest) RepositoryFactory(org.openkilda.persistence.repositories.RepositoryFactory) Test(org.junit.Test)

Example 18 with PersistenceManager

use of org.openkilda.persistence.PersistenceManager in project open-kilda by telstra.

the class FlowHsTopology method createTopology.

@Override
public StormTopology createTopology() {
    TopologyBuilder tb = new TopologyBuilder();
    inputSpout(tb);
    inputRouter(tb);
    PersistenceManager persistenceManager = new PersistenceManager(configurationProvider);
    flowCreateHub(tb, persistenceManager);
    flowUpdateHub(tb, persistenceManager);
    flowRerouteHub(tb, persistenceManager);
    flowDeleteHub(tb, persistenceManager);
    flowSwapProtectedHub(tb, persistenceManager);
    flowSwapEndpointsHub(tb, persistenceManager);
    flowCreateMirrorPointHub(tb, persistenceManager);
    flowDeleteMirrorPointHub(tb, persistenceManager);
    flowValidationHub(tb, persistenceManager);
    yFlowCreateHub(tb, persistenceManager);
    yFlowUpdateHub(tb, persistenceManager);
    yFlowRerouteHub(tb, persistenceManager);
    yFlowDeleteHub(tb, persistenceManager);
    yFlowReadBolt(tb, persistenceManager);
    yFlowValidationHub(tb, persistenceManager);
    speakerSpout(tb);
    flowCreateSpeakerWorker(tb);
    flowUpdateSpeakerWorker(tb);
    flowRerouteSpeakerWorker(tb);
    flowDeleteSpeakerWorker(tb);
    flowPathSwapSpeakerWorker(tb);
    flowCreateMirrorPointSpeakerWorker(tb);
    flowDeleteMirrorPointSpeakerWorker(tb);
    flowValidationSpeakerWorker(tb);
    yFlowCreateSpeakerWorker(tb);
    yFlowUpdateSpeakerWorker(tb);
    yFlowRerouteSpeakerWorker(tb);
    yFlowDeleteSpeakerWorker(tb);
    yFlowValidationSpeakerWorker(tb);
    speakerOutput(tb);
    speakerOutputForDumps(tb);
    coordinator(tb);
    northboundOutput(tb);
    rerouteTopologyOutput(tb);
    pingOutput(tb);
    server42ControlTopologyOutput(tb);
    flowMonitoringTopologyOutput(tb);
    statsTopologyOutput(tb);
    history(tb, persistenceManager);
    zkSpout(tb);
    zkBolt(tb);
    metrics(tb);
    return tb.createTopology();
}
Also used : TopologyBuilder(org.apache.storm.topology.TopologyBuilder) PersistenceManager(org.openkilda.persistence.PersistenceManager)

Example 19 with PersistenceManager

use of org.openkilda.persistence.PersistenceManager in project open-kilda by telstra.

the class YFlowValidatorTest method setup.

@BeforeClass
public static void setup() {
    RepositoryFactory repositoryFactory = mock(RepositoryFactory.class);
    when(repositoryFactory.createFlowRepository()).thenReturn(mock(FlowRepository.class));
    when(repositoryFactory.createSwitchRepository()).thenReturn(mock(SwitchRepository.class));
    when(repositoryFactory.createIslRepository()).thenReturn(mock(IslRepository.class));
    when(repositoryFactory.createSwitchPropertiesRepository()).thenReturn(mock(SwitchPropertiesRepository.class));
    when(repositoryFactory.createFlowMirrorPathRepository()).thenReturn(mock(FlowMirrorPathRepository.class));
    when(repositoryFactory.createYFlowRepository()).thenReturn(mock(YFlowRepository.class));
    PersistenceManager persistenceManager = mock(PersistenceManager.class);
    when(persistenceManager.getRepositoryFactory()).thenReturn(repositoryFactory);
    yFlowValidator = new YFlowValidator(persistenceManager);
}
Also used : SwitchPropertiesRepository(org.openkilda.persistence.repositories.SwitchPropertiesRepository) YFlowRepository(org.openkilda.persistence.repositories.YFlowRepository) FlowRepository(org.openkilda.persistence.repositories.FlowRepository) IslRepository(org.openkilda.persistence.repositories.IslRepository) YFlowRepository(org.openkilda.persistence.repositories.YFlowRepository) PersistenceManager(org.openkilda.persistence.PersistenceManager) FlowMirrorPathRepository(org.openkilda.persistence.repositories.FlowMirrorPathRepository) SwitchRepository(org.openkilda.persistence.repositories.SwitchRepository) RepositoryFactory(org.openkilda.persistence.repositories.RepositoryFactory) BeforeClass(org.junit.BeforeClass)

Example 20 with PersistenceManager

use of org.openkilda.persistence.PersistenceManager in project open-kilda by telstra.

the class FlowMonitoringTopology method createTopology.

@Override
public StormTopology createTopology() {
    TopologyBuilder tb = new TopologyBuilder();
    flowSpout(tb);
    flowLatencySpout(tb);
    islSpout(tb);
    islLatencySpout(tb);
    zooKeeperSpout(tb);
    islSplitterBolt(tb);
    flowSplitterBolt(tb);
    tickBolt(tb);
    PersistenceManager persistenceManager = new PersistenceManager(configurationProvider);
    flowStateCacheBolt(tb, persistenceManager);
    flowCacheBolt(tb, persistenceManager);
    islCacheBolt(tb, persistenceManager);
    actionBolt(tb, persistenceManager);
    outputReroute(tb);
    statsBolt(tb);
    zooKeeperBolt(tb);
    return tb.createTopology();
}
Also used : TopologyBuilder(org.apache.storm.topology.TopologyBuilder) PersistenceManager(org.openkilda.persistence.PersistenceManager)

Aggregations

PersistenceManager (org.openkilda.persistence.PersistenceManager)22 RepositoryFactory (org.openkilda.persistence.repositories.RepositoryFactory)13 YFlowRepository (org.openkilda.persistence.repositories.YFlowRepository)11 Test (org.junit.Test)10 FlowRepository (org.openkilda.persistence.repositories.FlowRepository)9 FlowPathRepository (org.openkilda.persistence.repositories.FlowPathRepository)8 TopologyBuilder (org.apache.storm.topology.TopologyBuilder)6 FlowThrottlingData (org.openkilda.wfm.topology.reroute.model.FlowThrottlingData)6 PathSegmentRepository (org.openkilda.persistence.repositories.PathSegmentRepository)5 RerouteAffectedFlows (org.openkilda.messaging.command.reroute.RerouteAffectedFlows)3 PathNode (org.openkilda.messaging.info.event.PathNode)3 BeforeClass (org.junit.BeforeClass)2 YFlowRerouteRequest (org.openkilda.messaging.command.yflow.YFlowRerouteRequest)2 FlowPath (org.openkilda.model.FlowPath)2 PathSegment (org.openkilda.model.PathSegment)2 CoordinatorBolt (org.openkilda.wfm.share.hubandspoke.CoordinatorBolt)2 CoordinatorSpout (org.openkilda.wfm.share.hubandspoke.CoordinatorSpout)2 HubBolt (org.openkilda.wfm.share.hubandspoke.HubBolt)2 WorkerBolt (org.openkilda.wfm.share.hubandspoke.WorkerBolt)2 ZooKeeperBolt (org.openkilda.wfm.share.zk.ZooKeeperBolt)2