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);
}
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);
}
}
}
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++;
}
}
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());
}
Aggregations