Search in sources :

Example 26 with CommandMessage

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

the class AbstractSerializerTest method flowCreateRequestTest.

@Test
public void flowCreateRequestTest() throws IOException, ClassNotFoundException {
    FlowCreateRequest data = new FlowCreateRequest(flowModel);
    System.out.println(data);
    CommandMessage command = new CommandMessage(data, System.currentTimeMillis(), CORRELATION_ID, DESTINATION);
    serialize(command);
    Message message = (Message) deserialize();
    assertTrue(message instanceof CommandMessage);
    CommandMessage resultCommand = (CommandMessage) message;
    assertTrue(resultCommand.getData() instanceof FlowCreateRequest);
    FlowCreateRequest resultData = (FlowCreateRequest) resultCommand.getData();
    System.out.println(resultData);
    assertEquals(data, resultData);
    assertEquals(data.hashCode(), resultData.hashCode());
    assertEquals(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) CommandMessage(org.openkilda.messaging.command.CommandMessage) Test(org.junit.Test)

Example 27 with CommandMessage

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

the class AbstractSerializerTest method flowUpdateRequestTest.

@Test
public void flowUpdateRequestTest() throws IOException, ClassNotFoundException {
    FlowUpdateRequest data = new FlowUpdateRequest(flowModel);
    System.out.println(data);
    CommandMessage command = new CommandMessage(data, System.currentTimeMillis(), CORRELATION_ID, DESTINATION);
    serialize(command);
    Message message = (Message) deserialize();
    assertTrue(message instanceof CommandMessage);
    CommandMessage resultCommand = (CommandMessage) message;
    assertTrue(resultCommand.getData() instanceof FlowUpdateRequest);
    FlowUpdateRequest resultData = (FlowUpdateRequest) resultCommand.getData();
    System.out.println(resultData);
    assertEquals(data, resultData);
    assertEquals(data.hashCode(), resultData.hashCode());
    assertEquals(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) CommandMessage(org.openkilda.messaging.command.CommandMessage) Test(org.junit.Test)

Example 28 with CommandMessage

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

the class AbstractSerializerTest method flowDeleteRequestTest.

@Test
public void flowDeleteRequestTest() throws IOException, ClassNotFoundException {
    Flow deleteFlow = new Flow();
    deleteFlow.setFlowId(flowName);
    FlowDeleteRequest data = new FlowDeleteRequest(deleteFlow);
    System.out.println(data);
    CommandMessage command = new CommandMessage(data, System.currentTimeMillis(), CORRELATION_ID, DESTINATION);
    serialize(command);
    Message message = (Message) deserialize();
    assertTrue(message instanceof CommandMessage);
    CommandMessage resultCommand = (CommandMessage) message;
    assertTrue(resultCommand.getData() instanceof FlowDeleteRequest);
    FlowDeleteRequest resultData = (FlowDeleteRequest) resultCommand.getData();
    System.out.println(resultData);
    assertEquals(data, resultData);
    assertEquals(data.hashCode(), resultData.hashCode());
    assertEquals(deleteFlow.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) Flow(org.openkilda.messaging.model.Flow) CommandMessage(org.openkilda.messaging.command.CommandMessage) Test(org.junit.Test)

Example 29 with CommandMessage

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

the class FlowServiceImpl method updateFlow.

/**
 * {@inheritDoc}
 */
@Override
public FlowPayload updateFlow(final FlowPayload flow, final String correlationId) {
    LOGGER.debug("Update flow: {}={}", CORRELATION_ID, correlationId);
    FlowUpdateRequest data = new FlowUpdateRequest(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 : FlowUpdateRequest(org.openkilda.messaging.command.flow.FlowUpdateRequest) InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) FlowResponse(org.openkilda.messaging.info.flow.FlowResponse) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 30 with CommandMessage

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

the class FlowServiceImpl method pathFlow.

/**
 * {@inheritDoc}
 */
@Override
public FlowPathPayload pathFlow(final String id, final String correlationId) {
    LOGGER.debug("Flow path: {}={}", CORRELATION_ID, correlationId);
    FlowPathRequest data = new FlowPathRequest(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);
    FlowPathResponse response = (FlowPathResponse) validateInfoMessage(request, message, correlationId);
    return Converter.buildFlowPathPayloadByFlowPath(id, response.getPayload());
}
Also used : FlowPathResponse(org.openkilda.messaging.info.flow.FlowPathResponse) InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) FlowIdStatusPayload(org.openkilda.messaging.payload.flow.FlowIdStatusPayload) FlowPathRequest(org.openkilda.messaging.command.flow.FlowPathRequest) 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