Search in sources :

Example 61 with CommandMessage

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

the class AbstractSerializerTest method removeCommandTest.

@Test
public void removeCommandTest() throws IOException, ClassNotFoundException {
    RemoveFlow data = new RemoveFlow(TIMESTAMP, FLOW_NAME, COOKIE, SWITCH_ID, METER_ID);
    System.out.println(data);
    CommandMessage command = new CommandMessage(data, System.currentTimeMillis(), CORRELATION_ID, DESTINATION);
    command.setData(data);
    serialize(command);
    Message message = (Message) deserialize();
    assertTrue(message instanceof CommandMessage);
    CommandMessage resultCommand = (CommandMessage) message;
    assertTrue(resultCommand.getData() != null);
    RemoveFlow resultData = (RemoveFlow) resultCommand.getData();
    System.out.println(resultData);
    assertEquals(data, resultData);
    assertEquals(data.hashCode(), resultData.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 62 with CommandMessage

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

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

the class FeatureTogglesServiceImpl method toggleFeatures.

@Override
public void toggleFeatures(FeatureTogglePayload dto) {
    LOGGER.debug("Processing request to toggle features, new properties are {}", dto);
    FeatureToggleRequest request = mapper.toRequest(dto);
    CommandMessage message = new CommandMessage(request, System.currentTimeMillis(), UUID.randomUUID().toString(), Destination.TOPOLOGY_ENGINE);
    messageProducer.send(topoEngTopic, message);
}
Also used : FeatureToggleRequest(org.openkilda.messaging.command.system.FeatureToggleRequest) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 64 with CommandMessage

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

Example 65 with CommandMessage

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

the class FlowServiceImpl method syncFlowCache.

/**
 * {@inheritDoc}
 */
@Override
public FlowCacheSyncResults syncFlowCache(final String correlationId) {
    LOGGER.debug("Flow cache sync: {}={}", CORRELATION_ID, correlationId);
    FlowCacheSyncRequest data = new FlowCacheSyncRequest();
    CommandMessage request = new CommandMessage(data, System.currentTimeMillis(), correlationId, Destination.WFM);
    messageConsumer.clear();
    messageProducer.send(topic, request);
    Message message = (Message) messageConsumer.poll(correlationId);
    FlowCacheSyncResponse response = (FlowCacheSyncResponse) validateInfoMessage(request, message, correlationId);
    return response.getPayload();
}
Also used : FlowCacheSyncResponse(org.openkilda.messaging.info.flow.FlowCacheSyncResponse) InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) FlowCacheSyncRequest(org.openkilda.messaging.command.flow.FlowCacheSyncRequest) 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