Search in sources :

Example 71 with SwitchId

use of org.openkilda.model.SwitchId 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 72 with SwitchId

use of org.openkilda.model.SwitchId 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 73 with SwitchId

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

the class TimeModifyPropertyOnFramesTest method shouldUpdateTimeModifyOnImplementedPropertyChange.

@Test
public void shouldUpdateTimeModifyOnImplementedPropertyChange() {
    Instant timeModifyBefore = transactionManager.doInTransaction(() -> createTestSwitch(1).getTimeModify());
    waitUntilNowIsAfter(timeModifyBefore);
    transactionManager.doInTransaction(() -> switchRepository.findById(new SwitchId(1)).get().setSocketAddress(new IpSocketAddress("192.168.10.20", 12345)));
    Instant timeModifyAfter = switchRepository.findById(new SwitchId(1)).get().getTimeModify();
    assertNotEquals(timeModifyBefore, timeModifyAfter);
}
Also used : Instant(java.time.Instant) SwitchId(org.openkilda.model.SwitchId) IpSocketAddress(org.openkilda.model.IpSocketAddress) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 74 with SwitchId

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

the class TimeModifyPropertyOnFramesTest method shouldNotUpdateTimeModifyOnAnnotatedPropertyWithConverterAndSameValueChange.

@Test
public void shouldNotUpdateTimeModifyOnAnnotatedPropertyWithConverterAndSameValueChange() {
    Instant timeModifyBefore = transactionManager.doInTransaction(() -> createTestSwitch(1).getTimeModify());
    waitUntilNowIsAfter(timeModifyBefore);
    transactionManager.doInTransaction(() -> {
        Switch sw = switchRepository.findById(new SwitchId(1)).get();
        sw.setStatus(sw.getStatus());
    });
    Instant timeModifyAfter = switchRepository.findById(new SwitchId(1)).get().getTimeModify();
    assertEquals(timeModifyBefore, timeModifyAfter);
}
Also used : Switch(org.openkilda.model.Switch) Instant(java.time.Instant) SwitchId(org.openkilda.model.SwitchId) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 75 with SwitchId

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

the class TimeModifyPropertyOnFramesTest method shouldUpdateTimeModifyOnAnnotatedPropertyWithConverterChange.

@Test
public void shouldUpdateTimeModifyOnAnnotatedPropertyWithConverterChange() {
    Instant timeModifyBefore = transactionManager.doInTransaction(() -> createTestSwitch(1).getTimeModify());
    waitUntilNowIsAfter(timeModifyBefore);
    transactionManager.doInTransaction(() -> {
        switchRepository.findById(new SwitchId(1)).get().setStatus(SwitchStatus.REMOVED);
    });
    Instant timeModifyAfter = switchRepository.findById(new SwitchId(1)).get().getTimeModify();
    assertNotEquals(timeModifyBefore, timeModifyAfter);
}
Also used : Instant(java.time.Instant) SwitchId(org.openkilda.model.SwitchId) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Aggregations

SwitchId (org.openkilda.model.SwitchId)339 Test (org.junit.Test)149 Flow (org.openkilda.model.Flow)73 Switch (org.openkilda.model.Switch)69 List (java.util.List)59 FlowPath (org.openkilda.model.FlowPath)49 ArrayList (java.util.ArrayList)44 Collectors (java.util.stream.Collectors)37 PathId (org.openkilda.model.PathId)36 PathComputer (org.openkilda.pce.PathComputer)35 Set (java.util.Set)34 YFlow (org.openkilda.model.YFlow)33 Map (java.util.Map)30 GetPathsResult (org.openkilda.pce.GetPathsResult)30 InfoMessage (org.openkilda.messaging.info.InfoMessage)29 String.format (java.lang.String.format)28 HashSet (java.util.HashSet)27 Optional (java.util.Optional)27 Collection (java.util.Collection)26 Collections (java.util.Collections)26