Search in sources :

Example 61 with Message

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());
}
Also used : FlowStatusResponse(org.openkilda.messaging.info.flow.FlowStatusResponse) InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) InfoMessage(org.openkilda.messaging.info.InfoMessage) Test(org.junit.Test)

Example 62 with Message

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());
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) InfoMessage(org.openkilda.messaging.info.InfoMessage) FlowsResponse(org.openkilda.messaging.info.flow.FlowsResponse) Test(org.junit.Test)

Example 63 with Message

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);
    }
}
Also used : HealthCheckInfoData(org.openkilda.messaging.info.discovery.HealthCheckInfoData) InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) InfoMessage(org.openkilda.messaging.info.InfoMessage) IOException(java.io.IOException) KafkaListener(org.springframework.kafka.annotation.KafkaListener)

Example 64 with Message

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);
}
Also used : Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) FeatureTogglesResponse(org.openkilda.messaging.info.system.FeatureTogglesResponse) FeatureToggleStateRequest(org.openkilda.messaging.command.system.FeatureToggleStateRequest) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 65 with Message

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;
}
Also used : FlowsGetRequest(org.openkilda.messaging.command.flow.FlowsGetRequest) FlowPayload(org.openkilda.messaging.payload.flow.FlowPayload) InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) FlowIdStatusPayload(org.openkilda.messaging.payload.flow.FlowIdStatusPayload) FlowsResponse(org.openkilda.messaging.info.flow.FlowsResponse) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Aggregations

Message (org.openkilda.messaging.Message)71 CommandMessage (org.openkilda.messaging.command.CommandMessage)55 InfoMessage (org.openkilda.messaging.info.InfoMessage)55 ErrorMessage (org.openkilda.messaging.error.ErrorMessage)29 Test (org.junit.Test)25 IOException (java.io.IOException)11 Values (org.apache.storm.tuple.Values)10 CtrlRequest (org.openkilda.messaging.ctrl.CtrlRequest)6 CtrlResponse (org.openkilda.messaging.ctrl.CtrlResponse)6 FlowIdStatusPayload (org.openkilda.messaging.payload.flow.FlowIdStatusPayload)6 CommandData (org.openkilda.messaging.command.CommandData)5 RequestData (org.openkilda.messaging.ctrl.RequestData)5 FlowResponse (org.openkilda.messaging.info.flow.FlowResponse)5 CommandWithReplyToMessage (org.openkilda.messaging.command.CommandWithReplyToMessage)4 DumpStateResponseData (org.openkilda.messaging.ctrl.DumpStateResponseData)4 IslInfoData (org.openkilda.messaging.info.event.IslInfoData)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 BaseInstallFlow (org.openkilda.messaging.command.flow.BaseInstallFlow)3 FlowCreateRequest (org.openkilda.messaging.command.flow.FlowCreateRequest)3 FlowGetRequest (org.openkilda.messaging.command.flow.FlowGetRequest)3