Search in sources :

Example 31 with Message

use of org.openkilda.messaging.Message in project open-kilda by telstra.

the class FlowServiceImpl method statusFlow.

/**
 * {@inheritDoc}
 */
@Override
public FlowIdStatusPayload statusFlow(final String id, final String correlationId) {
    LOGGER.debug("Flow status: {}={}", CORRELATION_ID, correlationId);
    FlowStatusRequest data = new FlowStatusRequest(new FlowIdStatusPayload(id, null));
    CommandMessage request = new CommandMessage(data, System.currentTimeMillis(), correlationId, Destination.WFM);
    messageConsumer.clear();
    messageProducer.send(topic, request);
    Message message = (Message) messageConsumer.poll(correlationId);
    FlowStatusResponse response = (FlowStatusResponse) validateInfoMessage(request, message, correlationId);
    return response.getPayload();
}
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) FlowIdStatusPayload(org.openkilda.messaging.payload.flow.FlowIdStatusPayload) FlowStatusRequest(org.openkilda.messaging.command.flow.FlowStatusRequest) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 32 with Message

use of org.openkilda.messaging.Message in project open-kilda by telstra.

the class FlowServiceImpl method createFlow.

/**
 * {@inheritDoc}
 */
@Override
public FlowPayload createFlow(final FlowPayload flow, final String correlationId) {
    LOGGER.debug("Create flow: {}={}", CORRELATION_ID, correlationId);
    FlowCreateRequest data = new FlowCreateRequest(Converter.buildFlowByFlowPayload(flow));
    CommandMessage request = new CommandMessage(data, System.currentTimeMillis(), correlationId, Destination.WFM);
    messageConsumer.clear();
    messageProducer.send(topic, request);
    Message message = (Message) messageConsumer.poll(correlationId);
    FlowResponse response = (FlowResponse) validateInfoMessage(request, message, correlationId);
    return Converter.buildFlowPayloadByFlow(response.getPayload());
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) FlowCreateRequest(org.openkilda.messaging.command.flow.FlowCreateRequest) FlowResponse(org.openkilda.messaging.info.flow.FlowResponse) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 33 with Message

use of org.openkilda.messaging.Message in project open-kilda by telstra.

the class FlowServiceImpl method getFlow.

/**
 * {@inheritDoc}
 */
@Override
public FlowPayload getFlow(final String id, final String correlationId) {
    LOGGER.debug("Get flow: {}={}", CORRELATION_ID, correlationId);
    FlowGetRequest data = new FlowGetRequest(new FlowIdStatusPayload(id, null));
    CommandMessage request = new CommandMessage(data, System.currentTimeMillis(), correlationId, Destination.WFM);
    messageConsumer.clear();
    messageProducer.send(topic, request);
    Message message = (Message) messageConsumer.poll(correlationId);
    FlowResponse response = (FlowResponse) validateInfoMessage(request, message, correlationId);
    return Converter.buildFlowPayloadByFlow(response.getPayload());
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) FlowIdStatusPayload(org.openkilda.messaging.payload.flow.FlowIdStatusPayload) FlowGetRequest(org.openkilda.messaging.command.flow.FlowGetRequest) FlowResponse(org.openkilda.messaging.info.flow.FlowResponse) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 34 with Message

use of org.openkilda.messaging.Message in project open-kilda by telstra.

the class FlowServiceImpl method _deleteFlowRespone.

/**
 * Blocking primitive .. waits for the response .. and then converts to FlowPayload.
 * @return the deleted flow.
 */
private FlowPayload _deleteFlowRespone(final String correlationId, CommandMessage request) {
    Message message = (Message) messageConsumer.poll(correlationId);
    FlowResponse response = (FlowResponse) validateInfoMessage(request, message, correlationId);
    return Converter.buildFlowPayloadByFlow(response.getPayload());
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) FlowResponse(org.openkilda.messaging.info.flow.FlowResponse)

Example 35 with Message

use of org.openkilda.messaging.Message in project open-kilda by telstra.

the class SwitchServiceImpl method syncRules.

@Override
public SyncRulesOutput syncRules(String switchId, String correlationId) {
    SyncRulesRequest request = new SyncRulesRequest(switchId);
    CommandWithReplyToMessage commandMessage = new CommandWithReplyToMessage(request, System.currentTimeMillis(), correlationId, Destination.TOPOLOGY_ENGINE, northboundTopic);
    messageProducer.send(topoEngTopic, commandMessage);
    Message message = messageConsumer.poll(correlationId);
    SyncRulesResponse response = (SyncRulesResponse) validateInfoMessage(commandMessage, message, correlationId);
    return switchMapper.toSuncRulesOutput(response);
}
Also used : SyncRulesResponse(org.openkilda.messaging.info.switches.SyncRulesResponse) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) CommandWithReplyToMessage(org.openkilda.messaging.command.CommandWithReplyToMessage) CommandWithReplyToMessage(org.openkilda.messaging.command.CommandWithReplyToMessage) SyncRulesRequest(org.openkilda.messaging.command.switches.SyncRulesRequest)

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