Search in sources :

Example 21 with SwitchInfoData

use of org.openkilda.messaging.info.event.SwitchInfoData in project open-kilda by telstra.

the class SwitchServiceImplTest method add.

@Test
@Transactional
public void add() throws Exception {
    SwitchInfoData data = new SwitchInfoData(switchId, SwitchEventType.ADDED, address, name, description);
    Switch sw = switchService.add(data);
    assertEquals(sw.getName(), switchId);
    assertEquals(sw.getState(), SwitchStateType.INACTIVE.toString().toLowerCase());
}
Also used : Switch(org.openkilda.topology.domain.Switch) SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 22 with SwitchInfoData

use of org.openkilda.messaging.info.event.SwitchInfoData in project open-kilda by telstra.

the class SwitchServiceImplTest method deactivate.

@Test
@Transactional
public void deactivate() throws Exception {
    SwitchInfoData data = new SwitchInfoData(switchId, SwitchEventType.DEACTIVATED, address, name, description);
    switchService.add(data);
    assertNotNull(switchService.get(switchId));
    switchService.deactivate(data);
    Switch sw = switchService.get(switchId);
    assertEquals(SwitchStateType.INACTIVE.toString().toLowerCase(), sw.getState());
    Iterable<Switch> switches = switchService.dump();
    assertEquals(1, Iterables.size(switches));
}
Also used : Switch(org.openkilda.topology.domain.Switch) SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 23 with SwitchInfoData

use of org.openkilda.messaging.info.event.SwitchInfoData in project open-kilda by telstra.

the class SwitchServiceImplTest method activate.

@Test
@Transactional
public void activate() throws Exception {
    SwitchInfoData data = new SwitchInfoData(switchId, SwitchEventType.ACTIVATED, address, name, description);
    switchService.add(data);
    assertNotNull(switchService.get(switchId));
    switchService.activate(data);
    Switch sw = switchService.get(switchId);
    assertEquals(SwitchStateType.ACTIVE.toString().toLowerCase(), sw.getState());
    Iterable<Switch> switches = switchService.dump();
    assertEquals(1, Iterables.size(switches));
}
Also used : Switch(org.openkilda.topology.domain.Switch) SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 24 with SwitchInfoData

use of org.openkilda.messaging.info.event.SwitchInfoData in project open-kilda by telstra.

the class SwitchServiceImplTest method remove.

@Test
@Transactional
public void remove() throws Exception {
    SwitchInfoData data = new SwitchInfoData(switchId, SwitchEventType.REMOVED, address, name, description);
    switchService.add(data);
    assertNotNull(switchService.get(switchId));
    switchService.remove(data);
    assertNull(switchService.get(switchId));
}
Also used : SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 25 with SwitchInfoData

use of org.openkilda.messaging.info.event.SwitchInfoData in project open-kilda by telstra.

the class OFELinkBolt method doWork.

@Override
protected void doWork(Tuple tuple) {
    if (CtrlAction.boltHandlerEntrance(this, tuple))
        return;
    // 
    // (crimi) - commenting out the filter code until we re-evaluate the design. Also, this code
    // should probably be embedded in "handleIslEvent"
    // /*
    // * Check whether ISL Filter needs to be engaged.
    // */
    // String source = tuple.getSourceComponent();
    // if (source.equals(OFEventWFMTopology.SPOUT_ID_INPUT)) {
    // PopulateIslFilterAction action = new PopulateIslFilterAction(this, tuple, islFilter);
    // action.run();
    // return;
    // }
    String json = tuple.getString(0);
    try {
        BaseMessage bm = MAPPER.readValue(json, BaseMessage.class);
        watchDog.reset();
        if (bm instanceof InfoMessage) {
            InfoData data = ((InfoMessage) bm).getData();
            if (data instanceof NetworkInfoData) {
                handleNetworkDump(tuple, (NetworkInfoData) data);
                isReceivedCacheInfo = true;
            } else if (!isReceivedCacheInfo) {
                logger.debug("Bolt is not initialized mark tuple as fail");
            } else if (data instanceof SwitchInfoData) {
                handleSwitchEvent(tuple, (SwitchInfoData) data);
                passToTopologyEngine(tuple);
            } else if (data instanceof PortInfoData) {
                handlePortEvent(tuple, (PortInfoData) data);
                passToTopologyEngine(tuple);
            } else if (data instanceof IslInfoData) {
                handleIslEvent(tuple, (IslInfoData) data);
            } else {
                logger.warn("Unknown InfoData type={}", data);
            }
        } else if (bm instanceof HeartBeat) {
            logger.debug("Got speaker's heart beat");
        }
    } catch (IOException e) {
        // All messages should be derived from BaseMessage .. so an exception here
        // means that we found something that isn't. If this criteria changes, then
        // change the logger level.
        logger.error("Unknown Message type={}", json);
    } finally {
        // We mark as fail all tuples while bolt is not initialized
        if (isReceivedCacheInfo) {
            collector.ack(tuple);
        } else {
            collector.fail(tuple);
        }
    }
}
Also used : HeartBeat(org.openkilda.messaging.HeartBeat) NetworkInfoData(org.openkilda.messaging.info.discovery.NetworkInfoData) BaseMessage(org.openkilda.messaging.BaseMessage) InfoMessage(org.openkilda.messaging.info.InfoMessage) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) NetworkInfoData(org.openkilda.messaging.info.discovery.NetworkInfoData) SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData) PortInfoData(org.openkilda.messaging.info.event.PortInfoData) InfoData(org.openkilda.messaging.info.InfoData) PortInfoData(org.openkilda.messaging.info.event.PortInfoData) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) IOException(java.io.IOException) SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData)

Aggregations

SwitchInfoData (org.openkilda.messaging.info.event.SwitchInfoData)38 Test (org.junit.Test)11 InfoMessage (org.openkilda.messaging.info.InfoMessage)9 IslInfoData (org.openkilda.messaging.info.event.IslInfoData)9 CacheException (org.openkilda.messaging.error.CacheException)8 CommandMessage (org.openkilda.messaging.command.CommandMessage)7 PathNode (org.openkilda.messaging.info.event.PathNode)6 PortInfoData (org.openkilda.messaging.info.event.PortInfoData)5 Transactional (org.springframework.transaction.annotation.Transactional)5 IOException (java.io.IOException)4 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 InfoData (org.openkilda.messaging.info.InfoData)4 NetworkInfoData (org.openkilda.messaging.info.discovery.NetworkInfoData)4 AbstractStormTest (org.openkilda.wfm.AbstractStormTest)4 Then (cucumber.api.java.en.Then)3 When (cucumber.api.java.en.When)3 Comparator (java.util.Comparator)3 Switch (org.openkilda.topology.domain.Switch)3 PendingException (cucumber.api.PendingException)2