use of org.openkilda.floodlight.command.CommandContext in project open-kilda by telstra.
the class RecordHandler method parseRecord.
private void parseRecord(ConsumerRecord<String, String> record) {
if (handleSpeakerCommand()) {
return;
}
if (handleRuleManagerCommand()) {
return;
}
CommandMessage message;
try {
String value = record.value();
// TODO: Prior to Message changes, this MAPPER would read Message ..
// but, changed to BaseMessage and got an error wrt "timestamp" ..
// so, need to experiment with why CommandMessage can't be read as
// a BaseMessage
message = MAPPER.readValue(value, CommandMessage.class);
} catch (Exception exception) {
logger.error("error parsing record '{}'", record.value(), exception);
return;
}
// Process the message within the message correlation context.
try (CorrelationContextClosable closable = CorrelationContext.create(message.getCorrelationId())) {
if (logger.isDebugEnabled()) {
logger.debug("Receive command: key={}, payload={}", record.key(), message.getData());
}
CommandContext commandContext = new CommandContext(context.getModuleContext(), message.getCorrelationId(), record.key());
if (!dispatch(commandContext, message)) {
handleCommand(message);
}
} catch (Exception exception) {
logger.error("error processing message '{}'", message, exception);
}
}
use of org.openkilda.floodlight.command.CommandContext in project open-kilda by telstra.
the class PingRequestCommandWriteFailTest method expectFail.
private void expectFail(Ping ping, Ping.Errors errorCode) throws Exception {
final CommandContext context = commandContextFactory.produce();
final PingRequestCommand command = new PingRequestCommand(context, ping);
command.call();
verifySentErrorResponse(ping, errorCode);
}
use of org.openkilda.floodlight.command.CommandContext in project open-kilda by telstra.
the class CommandProcessorService method verifyPendingStatus.
private void verifyPendingStatus() {
LinkedList<ProcessorTask> checkList = rotatePendingCommands();
if (checkList.size() == 0) {
return;
}
try {
CommandContext context = commandContextFactory.produce();
VerifyBatch verifyBatch = new VerifyBatch(this, checkList);
PendingCommandSubmitter checkCommands = new PendingCommandSubmitter(context, verifyBatch);
processLazy(checkCommands);
} catch (Throwable e) {
synchronized (this) {
tasks.addAll(checkList);
}
throw e;
}
}
use of org.openkilda.floodlight.command.CommandContext in project open-kilda by telstra.
the class InputService method handle.
private void handle(OfInput input) {
final CommandContext commandContext = commandContextFactory.produce();
List<IInputTranslator> queue = translators.get(input.getType());
commandProcessor.processLazy(new InputDispatchCommand(commandContext, commandProcessor, queue, input));
}
use of org.openkilda.floodlight.command.CommandContext in project open-kilda by telstra.
the class BfdCommand method sendResponse.
protected void sendResponse() {
CommandContext context = getContext();
InfoMessage response = context.makeInfoMessage(assembleResponse());
kafkaProducer.sendMessageAndTrack(kafkaUtility.getKafkaChannel().getTopoDiscoTopic(), context.getRequestKey(), response);
}
Aggregations