use of org.openkilda.messaging.command.CommandData in project open-kilda by telstra.
the class RerouteBolt method handleCommandMessage.
private void handleCommandMessage(CommandMessage commandMessage) {
CommandData commandData = commandMessage.getData();
String correlationId = getCommandContext().getCorrelationId();
if (commandData instanceof RerouteAffectedFlows) {
rerouteService.rerouteAffectedFlows(this, correlationId, (RerouteAffectedFlows) commandData);
} else if (commandData instanceof RerouteAffectedInactiveFlows) {
rerouteService.rerouteInactiveAffectedFlows(this, correlationId, ((RerouteAffectedInactiveFlows) commandData).getSwitchId());
} else if (commandData instanceof RerouteInactiveFlows) {
rerouteService.rerouteInactiveFlows(this, correlationId, (RerouteInactiveFlows) commandData);
} else if (commandData instanceof FlowRerouteRequest) {
rerouteService.processRerouteRequest(this, correlationId, (FlowRerouteRequest) commandData);
} else if (commandData instanceof YFlowRerouteRequest) {
rerouteService.processRerouteRequest(this, correlationId, (YFlowRerouteRequest) commandData);
} else {
unhandledInput(getCurrentTuple());
}
}
use of org.openkilda.messaging.command.CommandData in project open-kilda by telstra.
the class SwitchPortsSpout method nextTuple.
@Override
public void nextTuple() {
final long now = now();
if (now - lastTickTime > frequency) {
CommandData data = new PortsCommandData(REQUESTER);
logger.debug("emitting PortsCommandData: {}", data);
String correlationId = format("SwitchPortsSpout-%s", UUID.randomUUID().toString());
collector.emit(new Values(correlationId, data, correlationId));
if (now - lastTickTime > frequency * 2) {
logger.warn("long tick for PortsCommandData - {}ms", now - lastTickTime);
}
lastTickTime = now;
}
org.apache.storm.utils.Utils.sleep(1);
}
use of org.openkilda.messaging.command.CommandData in project open-kilda by telstra.
the class PingRequestTest method serializeLoop.
@Test
public void serializeLoop() throws Exception {
Ping ping = new Ping((short) 100, new NetworkEndpoint(new SwitchId("ff:fe:00:00:00:00:00:01"), 8), new NetworkEndpoint(new SwitchId("ff:fe:00:00:00:00:00:02"), 10));
PingRequest origin = new PingRequest(ping);
CommandMessage wrapper = new CommandMessage(origin, System.currentTimeMillis(), getClass().getSimpleName());
serializer.serialize(wrapper);
CommandMessage decodedWrapper = (CommandMessage) serializer.deserialize();
CommandData decoded = decodedWrapper.getData();
Assert.assertEquals(String.format("%s object have been mangled in serialisation/deserialization loop", origin.getClass().getName()), origin, decoded);
}
use of org.openkilda.messaging.command.CommandData in project open-kilda by telstra.
the class RouterBolt method handleInput.
@Override
protected void handleInput(Tuple input) throws PipelineException {
String key = input.getStringByField(MessageKafkaTranslator.FIELD_ID_KEY);
Message message = pullValue(input, FIELD_ID_PAYLOAD, Message.class);
if (message instanceof CommandMessage) {
if (active) {
log.debug("Received command message {}", message);
CommandMessage command = (CommandMessage) message;
CommandData data = command.getData();
if (data instanceof BaseRequest) {
BaseRequest baseRequest = (BaseRequest) data;
processRequest(input, key, baseRequest);
}
}
} else if (message instanceof InfoMessage || message instanceof ErrorMessage) {
log.debug("Received hub response message {}", message);
emitWithContext(SpeakerWorkerBolt.INCOME_STREAM, input, new Values(key, message));
} else {
unhandledInput(input);
}
}
use of org.openkilda.messaging.command.CommandData in project open-kilda by telstra.
the class SpeakerWorkerBolt method onRequestTimeout.
@Override
public void onRequestTimeout(Tuple request) throws PipelineException {
String key = pullKey(request);
CommandData commandData = pullValue(request, MessageKafkaTranslator.FIELD_ID_PAYLOAD, CommandData.class);
log.debug("Send timeout error to hub {}", key);
ErrorData errorData = new ErrorData(ErrorType.OPERATION_TIMED_OUT, String.format("Timeout for waiting response on command %s", commandData), "Error in SpeakerWorker");
ErrorMessage errorMessage = new ErrorMessage(errorData, System.currentTimeMillis(), key);
emitResponseToHub(request, new Values(key, errorMessage, pullContext(request)));
}
Aggregations