use of org.openkilda.messaging.info.InfoMessage in project open-kilda by telstra.
the class FlowServiceImpl method pathFlow.
/**
* {@inheritDoc}
*/
@Override
public InfoMessage pathFlow(final FlowIdStatusPayload payload, final String correlationId) {
Set<Flow> flows = flowRepository.findByFlowId(payload.getId());
FlowPathPayload flowPathPayload = null;
for (Flow flow : flows) {
if ((flow.getCookie() & DIRECT_FLOW_COOKIE) == DIRECT_FLOW_COOKIE) {
flowPathPayload = new FlowPathPayload(flow.getFlowId(), flow.getFlowPath());
}
}
logger.debug("Flow with id={} path: {}", payload.getId(), flowPathPayload);
return new InfoMessage(new FlowPathResponse(flowPathPayload), System.currentTimeMillis(), correlationId, Destination.WFM);
}
use of org.openkilda.messaging.info.InfoMessage in project open-kilda by telstra.
the class FlowServiceImpl method getFlow.
/**
* {@inheritDoc}
*/
@Override
public InfoMessage getFlow(final FlowIdStatusPayload payload, final String correlationId) {
Set<Flow> flows = flowRepository.findByFlowId(payload.getId());
if (flows == null || flows.isEmpty()) {
logger.error("Flow with id={} not found", payload.getId());
throw new MessageException(ErrorType.NOT_FOUND, System.currentTimeMillis());
}
FlowResponse response = null;
for (Flow flow : flows) {
if ((flow.getCookie() & DIRECT_FLOW_COOKIE) == DIRECT_FLOW_COOKIE) {
response = new FlowResponse(getFlowPayloadByFlow(flow));
}
}
logger.debug("Flow with id={} get: {}", payload.getId(), response);
return new InfoMessage(response, System.currentTimeMillis(), correlationId, Destination.WFM);
}
use of org.openkilda.messaging.info.InfoMessage in project open-kilda by telstra.
the class AbstractSerializerTest method eventPathInfoTest.
@Test
public void eventPathInfoTest() throws IOException, ClassNotFoundException {
PathInfoData data = new PathInfoData();
System.out.println(data);
InfoMessage info = new InfoMessage(data, System.currentTimeMillis(), CORRELATION_ID, DESTINATION);
serialize(info);
Message message = (Message) deserialize();
assertTrue(message instanceof InfoMessage);
InfoMessage resultInfo = (InfoMessage) message;
assertTrue(resultInfo.getData() instanceof PathInfoData);
PathInfoData resultData = (PathInfoData) resultInfo.getData();
System.out.println(resultData);
assertEquals(data, resultData);
assertEquals(data.hashCode(), resultData.hashCode());
}
use of org.openkilda.messaging.info.InfoMessage in project open-kilda by telstra.
the class AbstractSerializerTest method eventPortInfoTest.
@Test
public void eventPortInfoTest() throws IOException, ClassNotFoundException {
PortInfoData data = new PortInfoData(SWITCH_ID, INPUT_PORT, 0, PORT_CHANGE);
System.out.println(data);
InfoMessage info = new InfoMessage(data, System.currentTimeMillis(), CORRELATION_ID, DESTINATION);
serialize(info);
Message message = (Message) deserialize();
assertTrue(message instanceof InfoMessage);
InfoMessage resultInfo = (InfoMessage) message;
assertTrue(resultInfo.getData() instanceof PortInfoData);
PortInfoData resultData = (PortInfoData) resultInfo.getData();
System.out.println(resultData);
assertEquals(data, resultData);
assertEquals(data.hashCode(), resultData.hashCode());
}
use of org.openkilda.messaging.info.InfoMessage in project open-kilda by telstra.
the class AbstractSerializerTest method flowPathResponseTest.
@Test
public void flowPathResponseTest() throws IOException, ClassNotFoundException {
FlowPathResponse data = new FlowPathResponse(path);
System.out.println(data);
InfoMessage info = new InfoMessage(data, System.currentTimeMillis(), CORRELATION_ID, DESTINATION);
serialize(info);
Message message = (Message) deserialize();
assertTrue(message instanceof InfoMessage);
InfoMessage resultInfo = (InfoMessage) message;
assertTrue(resultInfo.getData() instanceof FlowPathResponse);
FlowPathResponse resultData = (FlowPathResponse) resultInfo.getData();
System.out.println(resultData);
assertEquals(data, resultData);
assertEquals(data.hashCode(), resultData.hashCode());
assertEquals(path.hashCode(), resultData.getPayload().hashCode());
}
Aggregations