use of org.openkilda.messaging.command.CommandMessage in project open-kilda by telstra.
the class FlowTopologyTest method removeFlowTopologyEngineSpeakerBoltTest.
@Test
public void removeFlowTopologyEngineSpeakerBoltTest() throws Exception {
String flowId = UUID.randomUUID().toString();
ConsumerRecord<String, String> ofsRecord;
ConsumerRecord<String, String> record;
createFlow(flowId);
record = cacheConsumer.pollMessage();
assertNotNull(record);
assertNotNull(record.value());
record = nbConsumer.pollMessage();
assertNotNull(record);
assertNotNull(record.value());
statusFlow(flowId);
record = nbConsumer.pollMessage();
assertNotNull(record);
assertNotNull(record.value());
InfoMessage infoMessage = objectMapper.readValue(record.value(), InfoMessage.class);
assertNotNull(infoMessage);
FlowStatusResponse infoData = (FlowStatusResponse) infoMessage.getData();
assertNotNull(infoData);
FlowIdStatusPayload flowNbPayload = infoData.getPayload();
assertNotNull(flowNbPayload);
assertEquals(flowId, flowNbPayload.getId());
assertEquals(FlowState.ALLOCATED, flowNbPayload.getStatus());
RemoveFlow data = removeFlowCommand(flowId);
ofsRecord = ofsConsumer.pollMessage();
assertNotNull(ofsRecord);
assertNotNull(ofsRecord.value());
CommandMessage response = objectMapper.readValue(ofsRecord.value(), CommandMessage.class);
assertNotNull(response);
RemoveFlow responseData = (RemoveFlow) response.getData();
Long transactionId = responseData.getTransactionId();
responseData.setTransactionId(0L);
assertEquals(data, responseData);
responseData.setTransactionId(transactionId);
statusFlow(flowId);
record = nbConsumer.pollMessage();
assertNotNull(record);
assertNotNull(record.value());
infoMessage = objectMapper.readValue(record.value(), InfoMessage.class);
assertNotNull(infoMessage);
infoData = (FlowStatusResponse) infoMessage.getData();
assertNotNull(infoData);
flowNbPayload = infoData.getPayload();
assertNotNull(flowNbPayload);
assertEquals(flowId, flowNbPayload.getId());
assertEquals(FlowState.IN_PROGRESS, flowNbPayload.getStatus());
response.setDestination(Destination.WFM_TRANSACTION);
removeRuleCommand(response);
statusFlow(flowId);
record = nbConsumer.pollMessage();
assertNotNull(record);
assertNotNull(record.value());
infoMessage = objectMapper.readValue(record.value(), InfoMessage.class);
assertNotNull(infoMessage);
infoData = (FlowStatusResponse) infoMessage.getData();
assertNotNull(infoData);
flowNbPayload = infoData.getPayload();
assertNotNull(flowNbPayload);
assertEquals(flowId, flowNbPayload.getId());
assertEquals(FlowState.UP, flowNbPayload.getStatus());
}
use of org.openkilda.messaging.command.CommandMessage in project open-kilda by telstra.
the class FlowTopologyTest method deleteFlow.
private Flow deleteFlow(final String flowId) throws IOException {
System.out.println("NORTHBOUND: Delete flow");
Flow payload = new Flow();
payload.setFlowId(flowId);
FlowDeleteRequest commandData = new FlowDeleteRequest(payload);
CommandMessage message = new CommandMessage(commandData, 0, "delete-flow", Destination.WFM);
// sendNorthboundMessage(message);
// sendTopologyEngineMessage(message);
sendFlowMessage(message);
return payload;
}
use of org.openkilda.messaging.command.CommandMessage in project open-kilda by telstra.
the class FlowTopologyTest method pathFlow.
private PathInfoData pathFlow(final String flowId) throws IOException {
System.out.println("NORTHBOUND: Path flow");
FlowIdStatusPayload payload = new FlowIdStatusPayload(flowId);
FlowPathRequest commandData = new FlowPathRequest(payload);
CommandMessage message = new CommandMessage(commandData, 0, "path-flow", Destination.WFM);
// sendNorthboundMessage(message);
sendFlowMessage(message);
return new PathInfoData(0L, Collections.emptyList());
}
use of org.openkilda.messaging.command.CommandMessage in project open-kilda by telstra.
the class FlowTopologyTest method dumpFlows.
private FlowIdStatusPayload dumpFlows(final String flowId) throws IOException {
System.out.println("NORTHBOUND: Get flows");
FlowIdStatusPayload payload = new FlowIdStatusPayload(flowId);
FlowsGetRequest commandData = new FlowsGetRequest(payload);
CommandMessage message = new CommandMessage(commandData, 0, "get-flows", Destination.WFM);
// sendNorthboundMessage(message);
sendFlowMessage(message);
return payload;
}
use of org.openkilda.messaging.command.CommandMessage in project open-kilda by telstra.
the class RecordHandler method parseRecord.
private void parseRecord(ConsumerRecord<String, String> record) {
try {
String value = (String) record.value();
// TODO: Prior to Message changes, this MAPPER would read Message ..
// but, changed to BaseMessage and got an error wrt "timestamp" ..
// so, need to experiment with why CommandMessage can't be read as
// a BaseMessage
CommandMessage message = MAPPER.readValue(value, CommandMessage.class);
doControllerMsg(message);
} catch (Exception exception) {
logger.error("error parsing record={}", record.value(), exception);
}
}
Aggregations