use of org.openkilda.messaging.Message in project open-kilda by telstra.
the class CacheBolt method emitFlowCrudMessage.
private void emitFlowCrudMessage(InfoData data, Tuple tuple, String correlationId) throws IOException {
Message message = new InfoMessage(data, System.currentTimeMillis(), correlationId, Destination.WFM);
outputCollector.emit(StreamType.WFM_DUMP.toString(), tuple, new Values(MAPPER.writeValueAsString(message)));
logger.info("Flow command message sent");
}
use of org.openkilda.messaging.Message in project open-kilda by telstra.
the class CacheBolt method emitFlowMessage.
private void emitFlowMessage(InfoData data, Tuple tuple, String correlationId) throws IOException {
Message message = new InfoMessage(data, System.currentTimeMillis(), correlationId, Destination.TOPOLOGY_ENGINE);
outputCollector.emit(StreamType.TPE.toString(), tuple, new Values(MAPPER.writeValueAsString(message)));
logger.info("Flow command message sent");
}
use of org.openkilda.messaging.Message in project open-kilda by telstra.
the class PopulateIslFilterAction method handle.
@Override
protected void handle() throws MessageFormatException, UnsupportedActionException, JsonProcessingException {
KafkaMessage input = new KafkaMessage(getTuple());
Message message = input.getPayload();
if (message.getDestination() != Destination.WFM_OF_DISCOVERY) {
return;
}
if (!(message instanceof CommandMessage)) {
return;
}
CommandMessage command = (CommandMessage) message;
if (!(command.getData() instanceof DiscoveryFilterPopulateData)) {
return;
}
DiscoveryFilterPopulateData payload = (DiscoveryFilterPopulateData) command.getData();
logger.info("Clean ISL filter");
filter.clear();
for (DiscoveryFilterEntity entity : payload.getFilter()) {
logger.info("Add ISL filter record - switcID=\"{}\" portId=\"{}\"", entity.switchId, entity.portId);
filter.add(entity.switchId, entity.portId);
}
}
use of org.openkilda.messaging.Message in project open-kilda by telstra.
the class CrudBolt method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute(Tuple tuple) {
if (CtrlAction.boltHandlerEntrance(this, tuple))
return;
logger.trace("Flow Cache before: {}", flowCache);
ComponentType componentId = ComponentType.valueOf(tuple.getSourceComponent());
StreamType streamId = StreamType.valueOf(tuple.getSourceStreamId());
String flowId = tuple.getStringByField(Utils.FLOW_ID);
String correlationId = Utils.DEFAULT_CORRELATION_ID;
try {
logger.debug("Request tuple={}", tuple);
switch(componentId) {
case SPLITTER_BOLT:
Message msg = (Message) tuple.getValueByField(AbstractTopology.MESSAGE_FIELD);
correlationId = msg.getCorrelationId();
CommandMessage cmsg = (msg instanceof CommandMessage) ? (CommandMessage) msg : null;
InfoMessage imsg = (msg instanceof InfoMessage) ? (InfoMessage) msg : null;
logger.info("Flow request: {}={}, {}={}, component={}, stream={}", Utils.CORRELATION_ID, correlationId, Utils.FLOW_ID, flowId, componentId, streamId);
switch(streamId) {
case CREATE:
handleCreateRequest(cmsg, tuple);
break;
case UPDATE:
handleUpdateRequest(cmsg, tuple);
break;
case DELETE:
handleDeleteRequest(flowId, cmsg, tuple);
break;
case PUSH:
handlePushRequest(flowId, imsg, tuple);
break;
case UNPUSH:
handleUnpushRequest(flowId, imsg, tuple);
break;
case PATH:
handlePathRequest(flowId, cmsg, tuple);
break;
case RESTORE:
handleRestoreRequest(cmsg, tuple);
break;
case REROUTE:
handleRerouteRequest(cmsg, tuple);
break;
case STATUS:
handleStatusRequest(flowId, cmsg, tuple);
break;
case CACHE_SYNC:
handleCacheSyncRequest(cmsg, tuple);
break;
case READ:
if (flowId != null) {
handleReadRequest(flowId, cmsg, tuple);
} else {
handleDumpRequest(cmsg, tuple);
}
break;
default:
logger.debug("Unexpected stream: component={}, stream={}", componentId, streamId);
break;
}
break;
case SPEAKER_BOLT:
case TRANSACTION_BOLT:
FlowState newStatus = (FlowState) tuple.getValueByField(FlowTopology.STATUS_FIELD);
logger.info("Flow {} status {}: component={}, stream={}", flowId, newStatus, componentId, streamId);
switch(streamId) {
case STATUS:
handleStateRequest(flowId, newStatus, tuple);
break;
default:
logger.debug("Unexpected stream: component={}, stream={}", componentId, streamId);
break;
}
break;
case TOPOLOGY_ENGINE_BOLT:
ErrorMessage errorMessage = (ErrorMessage) tuple.getValueByField(AbstractTopology.MESSAGE_FIELD);
logger.info("Flow {} error: component={}, stream={}", flowId, componentId, streamId);
switch(streamId) {
case STATUS:
handleErrorRequest(flowId, errorMessage, tuple);
break;
default:
logger.debug("Unexpected stream: component={}, stream={}", componentId, streamId);
break;
}
break;
default:
logger.debug("Unexpected component: {}", componentId);
break;
}
} catch (CacheException exception) {
String logMessage = format("%s: %s", exception.getErrorMessage(), exception.getErrorDescription());
logger.error("{}, {}={}, {}={}, component={}, stream={}", logMessage, Utils.CORRELATION_ID, correlationId, Utils.FLOW_ID, flowId, componentId, streamId, exception);
ErrorMessage errorMessage = buildErrorMessage(correlationId, exception.getErrorType(), logMessage, componentId.toString().toLowerCase());
Values error = new Values(errorMessage, exception.getErrorType());
outputCollector.emit(StreamType.ERROR.toString(), tuple, error);
} catch (IOException exception) {
logger.error("Could not deserialize message {}", tuple, exception);
} finally {
logger.debug("Command message ack: component={}, stream={}, tuple={}", tuple.getSourceComponent(), tuple.getSourceStreamId(), tuple);
outputCollector.ack(tuple);
}
logger.trace("Flow Cache after: {}", flowCache);
}
use of org.openkilda.messaging.Message in project open-kilda by telstra.
the class NorthboundReplyBolt method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute(Tuple tuple) {
ComponentType componentId = ComponentType.valueOf(tuple.getSourceComponent());
StreamType streamId = StreamType.valueOf(tuple.getSourceStreamId());
Message message = (Message) tuple.getValueByField(AbstractTopology.MESSAGE_FIELD);
Values values = null;
try {
logger.debug("Request tuple={}", tuple);
switch(componentId) {
case TOPOLOGY_ENGINE_BOLT:
case CRUD_BOLT:
case ERROR_BOLT:
logger.debug("Flow response: {}={}, component={}, stream={}, message={}", Utils.CORRELATION_ID, message.getCorrelationId(), componentId, streamId, message);
message.setDestination(Destination.NORTHBOUND);
values = new Values(MAPPER.writeValueAsString(message));
outputCollector.emit(StreamType.RESPONSE.toString(), tuple, values);
break;
default:
logger.debug("Flow unknown response: {}={}, component={}, stream={}, message={}", Utils.CORRELATION_ID, message.getCorrelationId(), componentId, streamId, message);
break;
}
} catch (JsonProcessingException exception) {
logger.error("Could not serialize message: component={}, stream={}, message={}", componentId, streamId, message);
} finally {
logger.debug("Northbound-Reply message ack: component={}, stream={}, tuple={}, values={}", tuple.getSourceComponent(), tuple.getSourceStreamId(), tuple, values);
outputCollector.ack(tuple);
}
}
Aggregations