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());
}
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);
}
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);
}
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;
}
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();
}
Aggregations