Search in sources :

Example 31 with CommandMessage

use of org.openkilda.messaging.command.CommandMessage 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 CommandMessage

use of org.openkilda.messaging.command.CommandMessage 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 CommandMessage

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

the class FlowServiceImpl method deleteFlow.

/**
 * {@inheritDoc}
 */
@Override
public FlowPayload deleteFlow(final String id, final String correlationId) {
    LOGGER.debug("Delete flow: {}={}", CORRELATION_ID, correlationId);
    messageConsumer.clear();
    CommandMessage request = _sendDeleteFlow(id, correlationId);
    return _deleteFlowRespone(correlationId, request);
}
Also used : CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 34 with CommandMessage

use of org.openkilda.messaging.command.CommandMessage 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 35 with CommandMessage

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

the class FlowServiceImpl method _sendDeleteFlow.

/**
 * Non-blocking primitive .. just create and send delete request
 * @return the request
 */
private CommandMessage _sendDeleteFlow(final String id, final String correlationId) {
    Flow flow = new Flow();
    flow.setFlowId(id);
    FlowDeleteRequest data = new FlowDeleteRequest(flow);
    CommandMessage request = new CommandMessage(data, System.currentTimeMillis(), correlationId, Destination.WFM);
    messageProducer.send(topic, request);
    return request;
}
Also used : FlowDeleteRequest(org.openkilda.messaging.command.flow.FlowDeleteRequest) Flow(org.openkilda.messaging.model.Flow) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Aggregations

CommandMessage (org.openkilda.messaging.command.CommandMessage)70 Message (org.openkilda.messaging.Message)36 InfoMessage (org.openkilda.messaging.info.InfoMessage)32 Test (org.junit.Test)19 ErrorMessage (org.openkilda.messaging.error.ErrorMessage)18 Values (org.apache.storm.tuple.Values)11 FlowIdStatusPayload (org.openkilda.messaging.payload.flow.FlowIdStatusPayload)11 RemoveFlow (org.openkilda.messaging.command.flow.RemoveFlow)8 Flow (org.openkilda.messaging.model.Flow)8 IOException (java.io.IOException)7 CommandData (org.openkilda.messaging.command.CommandData)7 AbstractStormTest (org.openkilda.wfm.AbstractStormTest)7 HashSet (java.util.HashSet)6 SwitchInfoData (org.openkilda.messaging.info.event.SwitchInfoData)6 CommandWithReplyToMessage (org.openkilda.messaging.command.CommandWithReplyToMessage)5 NetworkCommandData (org.openkilda.messaging.command.discovery.NetworkCommandData)5 InstallOneSwitchFlow (org.openkilda.messaging.command.flow.InstallOneSwitchFlow)5 FlowDeleteRequest (org.openkilda.messaging.command.flow.FlowDeleteRequest)4 FlowPathRequest (org.openkilda.messaging.command.flow.FlowPathRequest)4 FlowRerouteRequest (org.openkilda.messaging.command.flow.FlowRerouteRequest)4