use of org.openkilda.messaging.info.InfoMessage in project open-kilda by telstra.
the class CrudBolt method handleDumpRequest.
private void handleDumpRequest(CommandMessage message, Tuple tuple) {
List<Flow> flows = flowCache.dumpFlows().stream().map(this::buildFlowResponse).collect(Collectors.toList());
logger.info("Dump flows: {}", flows);
Values northbound = new Values(new InfoMessage(new FlowsResponse(flows), message.getTimestamp(), message.getCorrelationId(), Destination.NORTHBOUND));
outputCollector.emit(StreamType.RESPONSE.toString(), tuple, northbound);
}
use of org.openkilda.messaging.info.InfoMessage in project open-kilda by telstra.
the class CrudBolt method handleStatusRequest.
private void handleStatusRequest(String flowId, CommandMessage message, Tuple tuple) throws IOException {
ImmutablePair<Flow, Flow> flow = flowCache.getFlow(flowId);
FlowState status = flow.getLeft().getState();
logger.info("Status flow: {}={}", flowId, status);
Values northbound = new Values(new InfoMessage(new FlowStatusResponse(new FlowIdStatusPayload(flowId, status)), message.getTimestamp(), message.getCorrelationId(), Destination.NORTHBOUND));
outputCollector.emit(StreamType.RESPONSE.toString(), tuple, northbound);
}
use of org.openkilda.messaging.info.InfoMessage in project open-kilda by telstra.
the class CrudBolt method handleStateRequest.
/**
* This method changes the state of the Flow. It sets the state of both left and right to the
* same state.
*
* It is currently called from 2 places - a failed update (set flow to DOWN), and a STATUS
* update from the TransactionBolt.
*/
private void handleStateRequest(String flowId, FlowState state, Tuple tuple) throws IOException {
ImmutablePair<Flow, Flow> flow = flowCache.getFlow(flowId);
logger.info("State flow: {}={}", flowId, state);
flow.getLeft().setState(state);
flow.getRight().setState(state);
final String correlationId = UUID.randomUUID().toString();
FlowInfoData data = new FlowInfoData(flowId, flow, FlowOperation.STATE, correlationId);
InfoMessage infoMessage = new InfoMessage(data, System.currentTimeMillis(), correlationId);
Values topology = new Values(Utils.MAPPER.writeValueAsString(infoMessage));
outputCollector.emit(StreamType.STATUS.toString(), tuple, topology);
}
use of org.openkilda.messaging.info.InfoMessage 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.info.InfoMessage in project open-kilda by telstra.
the class FlowMetricGenBolt method execute.
@Override
public void execute(Tuple input) {
StatsComponentType componentId = StatsComponentType.valueOf(input.getSourceComponent());
InfoMessage message = (InfoMessage) input.getValueByField(MESSAGE_FIELD);
if (!Destination.WFM_STATS.equals(message.getDestination())) {
collector.ack(input);
return;
}
LOGGER.debug("Flow stats message: {}={}, component={}, stream={}", CORRELATION_ID, message.getCorrelationId(), componentId, StatsStreamType.valueOf(input.getSourceStreamId()));
FlowStatsData data = (FlowStatsData) message.getData();
long timestamp = message.getTimestamp();
String switchId = data.getSwitchId().replaceAll(":", "");
try {
for (FlowStatsReply reply : data.getStats()) {
for (FlowStatsEntry entry : reply.getEntries()) {
emit(entry, timestamp, switchId);
}
}
collector.ack(input);
} catch (ServiceUnavailableException e) {
LOGGER.error("Error process: {}", input.toString(), e);
// If we can't connect to Neo then don't know if valid input
collector.fail(input);
} catch (Exception e) {
// We tried, no need to try again
collector.ack(input);
}
}
Aggregations