Search in sources :

Example 6 with PortInfoData

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

the class IPortImpl method makePorChangetMessage.

public InfoMessage makePorChangetMessage() throws IOException {
    PortChangeType type = isActive ? PortChangeType.UP : PortChangeType.DOWN;
    PortInfoData data = new PortInfoData(sw.getDpid().toString(), number, type);
    return new InfoMessage(data, Instant.now().toEpochMilli(), UUID.randomUUID().toString(), null);
}
Also used : PortChangeType(org.openkilda.messaging.info.event.PortChangeType) InfoMessage(org.openkilda.messaging.info.InfoMessage) PortInfoData(org.openkilda.messaging.info.event.PortInfoData)

Example 7 with PortInfoData

use of org.openkilda.messaging.info.event.PortInfoData 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)

Example 8 with PortInfoData

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

the class SpeakerBoltTest method testAddSwitchValues.

@Test
public void testAddSwitchValues() throws Exception {
    List<Values> values = speakerBolt.addSwitch(switchMessage);
    assertEquals(3, values.size());
    int count = 0;
    for (Values value : values) {
        InfoMessage infoMessage = mapper.readValue((String) value.get(1), InfoMessage.class);
        if (count < 2) {
            assertThat(infoMessage.getData(), instanceOf(SwitchInfoData.class));
            SwitchInfoData sw = (SwitchInfoData) infoMessage.getData();
            assertEquals("00:00:" + dpid, sw.getSwitchId());
        } else {
            assertThat(infoMessage.getData(), instanceOf(PortInfoData.class));
            PortInfoData port = (PortInfoData) infoMessage.getData();
            assertEquals("00:00:" + dpid, port.getSwitchId());
            if (port.getPortNo() == localLinkPort) {
                assertEquals(PortChangeType.UP, port.getState());
            } else {
                assertEquals(PortChangeType.DOWN, port.getState());
            }
        }
        count++;
    }
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) Values(org.apache.storm.tuple.Values) PortInfoData(org.openkilda.messaging.info.event.PortInfoData) SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData) Test(org.junit.Test)

Example 9 with PortInfoData

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

the class OFELinkBoltTest method cacheLoadCheck.

/**
 * Part of warm mechanism checks. That test verifies appropriately unpack and fill inner
 * cache after getting network dump information from FL.
 */
@Test
public void cacheLoadCheck() throws IOException {
    // Send cache data and verify is inner state is ok
    SwitchInfoData sw1 = new SwitchInfoData("sw1", SwitchState.ADDED, "127.0.0.1", "localhost", "test switch", "kilda");
    SwitchInfoData sw2 = new SwitchInfoData("sw2", SwitchState.ADDED, "127.0.0.1", "localhost", "test switch", "kilda");
    PortInfoData sw1Port1 = new PortInfoData(sw1.getSwitchId(), 1, null, UP);
    PortInfoData sw2Port1 = new PortInfoData(sw2.getSwitchId(), 1, null, UP);
    NetworkInfoData dump = new NetworkInfoData("test", new HashSet<>(Arrays.asList(sw1, sw2)), new HashSet<>(Arrays.asList(sw1Port1, sw2Port1)), Collections.emptySet(), Collections.emptySet());
    InfoMessage info = new InfoMessage(dump, 0, DEFAULT_CORRELATION_ID, Destination.WFM);
    String request = objectMapper.writeValueAsString(info);
    Tuple dumpTuple = new TupleImpl(context, new Values(request), TASK_ID_BOLT, STREAM_ID_INPUT);
    bolt.doWork(dumpTuple);
    List<DiscoveryNode> discoveryQueue = bolt.getDiscoveryQueue();
    // I don't check discoveryQueue contents because that should be done in a test for
    // handleSwitchEvent and handlePortEvent.
    assertEquals(2, discoveryQueue.size());
}
Also used : NetworkInfoData(org.openkilda.messaging.info.discovery.NetworkInfoData) DiscoveryNode(org.openkilda.messaging.model.DiscoveryNode) InfoMessage(org.openkilda.messaging.info.InfoMessage) Values(org.apache.storm.tuple.Values) PortInfoData(org.openkilda.messaging.info.event.PortInfoData) SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData) TupleImpl(org.apache.storm.tuple.TupleImpl) Tuple(org.apache.storm.tuple.Tuple) AbstractStormTest(org.openkilda.wfm.AbstractStormTest) Test(org.junit.Test)

Aggregations

PortInfoData (org.openkilda.messaging.info.event.PortInfoData)9 InfoMessage (org.openkilda.messaging.info.InfoMessage)8 SwitchInfoData (org.openkilda.messaging.info.event.SwitchInfoData)5 Test (org.junit.Test)4 NetworkInfoData (org.openkilda.messaging.info.discovery.NetworkInfoData)4 IOException (java.io.IOException)2 Values (org.apache.storm.tuple.Values)2 BaseMessage (org.openkilda.messaging.BaseMessage)2 CommandMessage (org.openkilda.messaging.command.CommandMessage)2 IslInfoData (org.openkilda.messaging.info.event.IslInfoData)2 PortChangeType (org.openkilda.messaging.info.event.PortChangeType)2 java.util (java.util)1 Arrays.asList (java.util.Arrays.asList)1 Collectors (java.util.stream.Collectors)1 IOFSwitch (net.floodlightcontroller.core.IOFSwitch)1 ConsumerRecord (org.apache.kafka.clients.consumer.ConsumerRecord)1 Tuple (org.apache.storm.tuple.Tuple)1 TupleImpl (org.apache.storm.tuple.TupleImpl)1 IOFSwitchConverter (org.openkilda.floodlight.converter.IOFSwitchConverter)1 OFFlowStatsConverter (org.openkilda.floodlight.converter.OFFlowStatsConverter)1