use of org.openkilda.messaging.Message in project open-kilda by telstra.
the class RouteAction method handle.
@Override
protected void handle() throws MessageFormatException, JsonProcessingException {
KafkaMessage input = new KafkaMessage(getTuple());
Message payload = input.getPayload();
if (!(payload instanceof CtrlRequest)) {
getLogger().debug(String.format("Skip foreign message (correlation-id: %s timestamp: %s)", payload.getCorrelationId(), payload.getTimestamp()));
return;
}
handleMessage((CtrlRequest) payload);
}
use of org.openkilda.messaging.Message in project open-kilda by telstra.
the class SwitchPortsSpout method nextTuple.
@Override
public void nextTuple() {
Message message = buildPortsCommand(REQUESTER);
logger.debug("emitting portsCommand: {}", message.toString());
// Note that no tupleId which means this is an untracked tuple which is
collector.emit(new Values(message));
try {
// required for the sleep
Thread.sleep(frequency * 1000);
} catch (InterruptedException e) {
logger.error("Error sleeping");
}
}
use of org.openkilda.messaging.Message in project open-kilda by telstra.
the class SpeakerBolt method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute(Tuple tuple) {
logger.debug("Ingoing tuple: {}", tuple);
String request = tuple.getString(0);
// String request = tuple.getStringByField("value");
try {
Message stats = Utils.MAPPER.readValue(request, Message.class);
if (!Destination.WFM_STATS.equals(stats.getDestination()) || !(stats instanceof InfoMessage)) {
return;
}
InfoMessage message = (InfoMessage) stats;
final InfoData data = message.getData();
if (data instanceof PortStatsData) {
logger.debug("Port stats message: {}", new Values(request));
outputCollector.emit(PORT_STATS_STREAM, tuple, new Values(message));
} else if (data instanceof MeterConfigStatsData) {
logger.debug("Meter config stats message: {}", new Values(request));
outputCollector.emit(METER_CFG_STATS_STREAM, tuple, new Values(message));
} else if (data instanceof FlowStatsData) {
logger.debug("Flow stats message: {}", new Values(request));
outputCollector.emit(FLOW_STATS_STREAM, tuple, new Values(message));
}
} catch (IOException exception) {
logger.error("Could not deserialize message={}", request, exception);
} finally {
outputCollector.ack(tuple);
logger.debug("Message ack: {}", request);
}
}
use of org.openkilda.messaging.Message in project open-kilda by telstra.
the class HealthCheckBolt method execute.
@Override
public void execute(Tuple input) {
String request = input.getString(0);
try {
Message message = MAPPER.readValue(request, Message.class);
if (message instanceof CommandMessage) {
Values values = new Values(Utils.MAPPER.writeValueAsString(new InfoMessage(healthCheck, System.currentTimeMillis(), message.getCorrelationId(), Destination.NORTHBOUND)));
collector.emit(Topic.HEALTH_CHECK, input, values);
}
} catch (IOException exception) {
logger.error("Could not deserialize message: ", request, exception);
} finally {
collector.ack(input);
}
}
use of org.openkilda.messaging.Message in project open-kilda by telstra.
the class CacheTopologyTest method getNetworkDump.
private NetworkDump getNetworkDump(ConsumerRecord<String, String> raw) throws IOException {
Message responseGeneric = objectMapper.readValue(raw.value(), Message.class);
CtrlResponse response = (CtrlResponse) responseGeneric;
DumpStateResponseData data = (DumpStateResponseData) response.getData();
CacheBoltState cacheState = (CacheBoltState) data.getState();
return cacheState.getNetwork();
}
Aggregations