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