Search in sources :

Example 36 with Switch

use of org.openkilda.model.Switch in project open-kilda by telstra.

the class SwitchConnectedDeviceFrame method getSwitchObj.

@Override
public Switch getSwitchObj() {
    if (switchObj == null) {
        List<? extends SwitchFrame> switchFrames = traverse(v -> v.in(HAS_BY_EDGE).hasLabel(SwitchFrame.FRAME_LABEL)).toListExplicit(SwitchFrame.class);
        switchObj = !switchFrames.isEmpty() ? new Switch(switchFrames.get(0)) : null;
        SwitchId switchId = switchObj != null ? switchObj.getSwitchId() : null;
        if (!Objects.equals(getSwitchId(), switchId)) {
            throw new IllegalStateException(format("The connected device %s has inconsistent switch %s / %s", getId(), getSwitchId(), switchId));
        }
    }
    return switchObj;
}
Also used : Switch(org.openkilda.model.Switch) Instant(java.time.Instant) ConnectedDeviceType(org.openkilda.model.ConnectedDeviceType) SwitchIdConverter(org.openkilda.persistence.ferma.frames.converters.SwitchIdConverter) String.format(java.lang.String.format) Objects(java.util.Objects) Direction(org.apache.tinkerpop.gremlin.structure.Direction) List(java.util.List) Convert(org.openkilda.persistence.ferma.frames.converters.Convert) SwitchId(org.openkilda.model.SwitchId) InstantStringConverter(org.openkilda.persistence.ferma.frames.converters.InstantStringConverter) Property(com.syncleus.ferma.annotations.Property) ConnectedDeviceTypeConverter(org.openkilda.persistence.ferma.frames.converters.ConnectedDeviceTypeConverter) SwitchConnectedDeviceData(org.openkilda.model.SwitchConnectedDevice.SwitchConnectedDeviceData) VertexFrame(com.syncleus.ferma.VertexFrame) Edge(org.apache.tinkerpop.gremlin.structure.Edge) Switch(org.openkilda.model.Switch) SwitchId(org.openkilda.model.SwitchId)

Example 37 with Switch

use of org.openkilda.model.Switch in project open-kilda by telstra.

the class SwitchPropertiesFrame method getSwitchObj.

@Override
public Switch getSwitchObj() {
    if (switchObj == null) {
        List<? extends SwitchFrame> switchFrames = traverse(v -> v.in(HAS_BY_EDGE).hasLabel(SwitchFrame.FRAME_LABEL)).toListExplicit(SwitchFrame.class);
        switchObj = !switchFrames.isEmpty() ? new Switch(switchFrames.get(0)) : null;
        SwitchId switchId = switchObj != null ? switchObj.getSwitchId() : null;
        if (!Objects.equals(getSwitchId(), switchId)) {
            throw new IllegalStateException(format("The switch properties %s has inconsistent switch %s / %s", getId(), getSwitchId(), switchId));
        }
    }
    return switchObj;
}
Also used : SwitchPropertiesData(org.openkilda.model.SwitchProperties.SwitchPropertiesData) FlowEncapsulationType(org.openkilda.model.FlowEncapsulationType) Switch(org.openkilda.model.Switch) Collection(java.util.Collection) Set(java.util.Set) FlowEncapsulationTypeConverter(org.openkilda.persistence.ferma.frames.converters.FlowEncapsulationTypeConverter) SwitchIdConverter(org.openkilda.persistence.ferma.frames.converters.SwitchIdConverter) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) MacAddressConverter(org.openkilda.persistence.ferma.frames.converters.MacAddressConverter) HashSet(java.util.HashSet) Objects(java.util.Objects) MacAddress(org.openkilda.model.MacAddress) VertexProperty(org.apache.tinkerpop.gremlin.structure.VertexProperty) Direction(org.apache.tinkerpop.gremlin.structure.Direction) List(java.util.List) Convert(org.openkilda.persistence.ferma.frames.converters.Convert) SwitchId(org.openkilda.model.SwitchId) Property(com.syncleus.ferma.annotations.Property) RttState(org.openkilda.model.SwitchProperties.RttState) VertexFrame(com.syncleus.ferma.VertexFrame) Edge(org.apache.tinkerpop.gremlin.structure.Edge) Switch(org.openkilda.model.Switch) SwitchId(org.openkilda.model.SwitchId)

Example 38 with Switch

use of org.openkilda.model.Switch in project open-kilda by telstra.

the class PortPropertiesFrame method getSwitchObj.

@Override
public Switch getSwitchObj() {
    if (switchObj == null) {
        List<? extends SwitchFrame> switchFrames = traverse(v -> v.in(OWNS_SWITCH_EDGE).hasLabel(SwitchFrame.FRAME_LABEL)).toListExplicit(SwitchFrame.class);
        switchObj = !switchFrames.isEmpty() ? new Switch(switchFrames.get(0)) : null;
        SwitchId switchId = switchObj != null ? switchObj.getSwitchId() : null;
        if (!Objects.equals(getSwitchId(), switchId)) {
            throw new IllegalStateException(format("The port properties %s has inconsistent switch %s / %s", getId(), getSwitchId(), switchId));
        }
    }
    return switchObj;
}
Also used : Objects(java.util.Objects) Switch(org.openkilda.model.Switch) Direction(org.apache.tinkerpop.gremlin.structure.Direction) List(java.util.List) Convert(org.openkilda.persistence.ferma.frames.converters.Convert) SwitchId(org.openkilda.model.SwitchId) Property(com.syncleus.ferma.annotations.Property) VertexFrame(com.syncleus.ferma.VertexFrame) PortPropertiesData(org.openkilda.model.PortProperties.PortPropertiesData) SwitchIdConverter(org.openkilda.persistence.ferma.frames.converters.SwitchIdConverter) String.format(java.lang.String.format) Edge(org.apache.tinkerpop.gremlin.structure.Edge) Switch(org.openkilda.model.Switch) SwitchId(org.openkilda.model.SwitchId)

Example 39 with Switch

use of org.openkilda.model.Switch in project open-kilda by telstra.

the class FermaFlowRepositoryTest method shouldFind2SegmentFlowById.

@Test
public void shouldFind2SegmentFlowById() {
    Switch switchC = createTestSwitch(TEST_SWITCH_C_ID.getId());
    createTestFlowWithIntermediate(TEST_FLOW_ID, switchA, switchC, 100, switchB);
    Optional<Flow> foundFlow = flowRepository.findById(TEST_FLOW_ID);
    assertTrue(foundFlow.isPresent());
}
Also used : Switch(org.openkilda.model.Switch) Flow(org.openkilda.model.Flow) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 40 with Switch

use of org.openkilda.model.Switch in project open-kilda by telstra.

the class FermaPortPropertiesRepositoryTest method shouldCreatePortPropertiesWithRelation.

@Test
public void shouldCreatePortPropertiesWithRelation() {
    Switch origSwitch = createTestSwitch(TEST_SWITCH_ID.getId());
    PortProperties portProperties = PortProperties.builder().switchObj(origSwitch).discoveryEnabled(false).build();
    portPropertiesRepository.add(portProperties);
    Collection<PortProperties> portPropertiesResult = portPropertiesRepository.findAll();
    assertEquals(1, portPropertiesResult.size());
    assertNotNull(portPropertiesResult.iterator().next().getSwitchObj());
}
Also used : Switch(org.openkilda.model.Switch) PortProperties(org.openkilda.model.PortProperties) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Aggregations

Switch (org.openkilda.model.Switch)230 Test (org.junit.Test)126 Flow (org.openkilda.model.Flow)68 SwitchId (org.openkilda.model.SwitchId)67 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)46 FlowPath (org.openkilda.model.FlowPath)34 PathId (org.openkilda.model.PathId)32 Utils.buildSwitch (org.openkilda.rulemanager.Utils.buildSwitch)32 PathComputer (org.openkilda.pce.PathComputer)28 GetPathsResult (org.openkilda.pce.GetPathsResult)23 List (java.util.List)22 SwitchProperties (org.openkilda.model.SwitchProperties)21 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)20 SpeakerData (org.openkilda.rulemanager.SpeakerData)19 String.format (java.lang.String.format)17 Set (java.util.Set)17 Isl (org.openkilda.model.Isl)15 HashSet (java.util.HashSet)14 ArrayList (java.util.ArrayList)13 Collections (java.util.Collections)13