use of org.openkilda.messaging.Message in project open-kilda by telstra.
the class AbstractSerializerTest method flowStatusResponseTest.
@Test
public void flowStatusResponseTest() throws IOException, ClassNotFoundException {
FlowStatusResponse data = new FlowStatusResponse(flowIdStatusResponse);
System.out.println(data);
InfoMessage info = new InfoMessage(data, System.currentTimeMillis(), CORRELATION_ID, DESTINATION);
serialize(info);
Message message = (Message) deserialize();
assertTrue(message instanceof InfoMessage);
InfoMessage resultInfo = (InfoMessage) message;
assertTrue(resultInfo.getData() instanceof FlowStatusResponse);
FlowStatusResponse resultData = (FlowStatusResponse) resultInfo.getData();
System.out.println(resultData);
assertEquals(data, resultData);
assertEquals(data.hashCode(), resultData.hashCode());
assertEquals(flowIdStatusResponse.hashCode(), resultData.getPayload().hashCode());
}
use of org.openkilda.messaging.Message in project open-kilda by telstra.
the class AbstractSerializerTest method flowsResponseTest.
@Test
public void flowsResponseTest() throws IOException, ClassNotFoundException {
FlowsResponse data = new FlowsResponse(Collections.singletonList(flowModel));
System.out.println(data);
InfoMessage info = new InfoMessage(data, System.currentTimeMillis(), CORRELATION_ID, DESTINATION);
serialize(info);
Message message = (Message) deserialize();
assertTrue(message instanceof InfoMessage);
InfoMessage resultInfo = (InfoMessage) message;
assertTrue(resultInfo.getData() instanceof FlowsResponse);
FlowsResponse resultData = (FlowsResponse) resultInfo.getData();
System.out.println(resultData);
assertEquals(data, resultData);
assertEquals(data.hashCode(), resultData.hashCode());
assertEquals(Collections.singletonList(flowModel).hashCode(), resultData.getPayload().hashCode());
}
use of org.openkilda.messaging.Message in project open-kilda by telstra.
the class KafkaHealthCheckMessageConsumer method receive.
/**
* Receives messages from WorkFlowManager queue.
*
* @param record the message object instance
*/
@KafkaListener(id = "northbound-listener-health-check", topics = Topic.HEALTH_CHECK)
public void receive(final String record) {
try {
logger.trace("message received");
Message message = MAPPER.readValue(record, Message.class);
if (Destination.NORTHBOUND.equals(message.getDestination())) {
logger.debug("message received: {}", record);
InfoMessage info = (InfoMessage) message;
HealthCheckInfoData healthCheck = (HealthCheckInfoData) info.getData();
messages.put(healthCheck.getId(), healthCheck);
} else {
logger.trace("Skip message: {}", message);
}
} catch (IOException exception) {
logger.error("Could not deserialize message: {}", record, exception);
}
}
use of org.openkilda.messaging.Message in project open-kilda by telstra.
the class FeatureTogglesServiceImpl method getFeatureTogglesState.
@Override
public FeatureTogglePayload getFeatureTogglesState() {
String correlationId = UUID.randomUUID().toString();
FeatureToggleStateRequest teRequest = new FeatureToggleStateRequest();
CommandMessage requestMessage = new CommandMessage(teRequest, System.currentTimeMillis(), correlationId, Destination.TOPOLOGY_ENGINE);
messageProducer.send(topoEngTopic, requestMessage);
Message result = messageConsumer.poll(requestMessage.getCorrelationId());
FeatureTogglesResponse response = (FeatureTogglesResponse) validateInfoMessage(requestMessage, result, correlationId);
return mapper.toDto(response);
}
use of org.openkilda.messaging.Message in project open-kilda by telstra.
the class FlowServiceImpl method getFlows.
/**
* {@inheritDoc}
*/
@Override
public List<FlowPayload> getFlows(final String correlationId) {
LOGGER.debug("\n\n\nGet flows: ENTER {}={}\n", CORRELATION_ID, correlationId);
// TODO: why does FlowsGetRequest use empty FlowIdStatusPayload? Delete if not needed.
FlowsGetRequest data = new FlowsGetRequest(new FlowIdStatusPayload());
CommandMessage request = new CommandMessage(data, System.currentTimeMillis(), correlationId, Destination.WFM);
messageConsumer.clear();
messageProducer.send(topic, request);
Message message = (Message) messageConsumer.poll(correlationId);
FlowsResponse response = (FlowsResponse) validateInfoMessage(request, message, correlationId);
List<FlowPayload> result = Converter.buildFlowsPayloadByFlows(response.getPayload());
logger.debug("\nGet flows: EXIT {}={}, num_flows {}\n\n\n", CORRELATION_ID, correlationId, result.size());
return result;
}
Aggregations