use of org.openkilda.server42.control.messaging.flowrtt.FlowRttControl.Flow in project open-kilda by telstra.
the class FlowCreateHubBolt method sendActivateFlowMonitoring.
@Override
public void sendActivateFlowMonitoring(@NonNull RequestedFlow flow) {
ActivateFlowMonitoringInfoData payload = RequestedFlowMapper.INSTANCE.toActivateFlowMonitoringInfoData(flow);
Message message = new InfoMessage(payload, getCommandContext().getCreateTime(), getCommandContext().getCorrelationId());
emitWithContext(HUB_TO_SERVER42_CONTROL_TOPOLOGY_SENDER.name(), getCurrentTuple(), new Values(flow.getFlowId(), message));
}
use of org.openkilda.server42.control.messaging.flowrtt.FlowRttControl.Flow in project open-kilda by telstra.
the class Router method handleInfoMessage.
private void handleInfoMessage(Tuple input, InfoData payload) throws PipelineException {
if (payload instanceof ActivateFlowMonitoringInfoData) {
ActivateFlowMonitoringInfoData data = (ActivateFlowMonitoringInfoData) payload;
emit(STREAM_FLOW_ID, input, makeTuple(new ActivateFlowMonitoringCommand(data, true)));
emit(STREAM_FLOW_ID, input, makeTuple(new ActivateFlowMonitoringCommand(data, false)));
} else if (payload instanceof DeactivateFlowMonitoringInfoData) {
DeactivateFlowMonitoringInfoData data = (DeactivateFlowMonitoringInfoData) payload;
for (SwitchId switchId : data.getSwitchIds()) {
emit(STREAM_FLOW_ID, input, makeTuple(new DeactivateFlowMonitoringCommand(switchId, data.getFlowId(), true)));
emit(STREAM_FLOW_ID, input, makeTuple(new DeactivateFlowMonitoringCommand(switchId, data.getFlowId(), false)));
}
} else if (payload instanceof ActivateFlowMonitoringOnSwitchInfoData) {
ActivateFlowMonitoringOnSwitchInfoData data = (ActivateFlowMonitoringOnSwitchInfoData) payload;
activateFlowMonitoringOnSwitch(data.getSwitchId());
} else if (payload instanceof DeactivateFlowMonitoringOnSwitchInfoData) {
DeactivateFlowMonitoringOnSwitchInfoData data = (DeactivateFlowMonitoringOnSwitchInfoData) payload;
deactivateFlowMonitoringOnSwitch(data.getSwitchId());
} else if (payload instanceof ActivateIslMonitoringOnSwitchInfoData) {
ActivateIslMonitoringOnSwitchInfoData data = (ActivateIslMonitoringOnSwitchInfoData) payload;
activateIslMonitoringOnSwitch(data.getSwitchId());
} else if (payload instanceof DeactivateIslMonitoringOnSwitchInfoData) {
DeactivateIslMonitoringOnSwitchInfoData data = (DeactivateIslMonitoringOnSwitchInfoData) payload;
deactivateIslMonitoringOnSwitch(data.getSwitchId());
} else if (payload instanceof FeatureTogglesUpdate) {
FeatureTogglesUpdate data = (FeatureTogglesUpdate) payload;
this.service.handleFlowRttFeatureToggle(data.getToggles().getServer42FlowRtt());
this.service.handleIslRttFeatureToggle(data.getToggles().getServer42IslRtt());
} else {
log.error("Do not proxy flow message - unexpected message payload \"{}\"", payload.getClass());
}
}
use of org.openkilda.server42.control.messaging.flowrtt.FlowRttControl.Flow in project open-kilda by telstra.
the class StatsServer method run.
/**
* Generate packet statistics.
*/
@Override
public void run() {
log.info("started");
try (ZContext context = new ZContext()) {
Socket server = context.createSocket(ZMQ.PUSH);
server.bind(bindEndpoint);
while (!isInterrupted()) {
LatencyPacketBucket.Builder bucketBuilder = LatencyPacketBucket.newBuilder();
long seconds = TimeUnit.MILLISECONDS.toSeconds(Instant.now().toEpochMilli());
long timestamp = seconds << 32;
synchronized (this) {
FlowLatencyPacket.Builder flowLatencyPacketBuilder = FlowLatencyPacket.newBuilder();
for (FlowStats flow : flows.values()) {
flowLatencyPacketBuilder.setFlowId(flow.flowId);
flowLatencyPacketBuilder.setDirection(flow.direction);
flowLatencyPacketBuilder.setT0(timestamp);
long generatedLatency = MIN_DELTA_LATENCY + (long) (Math.random() * (MAX_DELTA_LATENCY - MIN_DELTA_LATENCY));
flowLatencyPacketBuilder.setT1(timestamp + flow.baseLatency + generatedLatency);
bucketBuilder.addFlowLatencyPacket(flowLatencyPacketBuilder.build());
}
IslLatencyPacket.Builder islLatencyPacketBuilder = IslLatencyPacket.newBuilder();
for (Map.Entry<IslKey, Long> isl : isls.entrySet()) {
islLatencyPacketBuilder.setSwitchId(isl.getKey().getSwitchId());
islLatencyPacketBuilder.setPort(isl.getKey().getPort());
islLatencyPacketBuilder.setT0(timestamp);
long generatedLatency = MIN_DELTA_LATENCY + (long) (Math.random() * (MAX_DELTA_LATENCY - MIN_DELTA_LATENCY));
islLatencyPacketBuilder.setT1(timestamp + isl.getValue() + generatedLatency);
bucketBuilder.addIslLatencyPacket(islLatencyPacketBuilder.build());
}
}
server.send(bucketBuilder.build().toByteArray());
if (flows.isEmpty() && isls.isEmpty()) {
log.info("send ping");
} else {
log.info("send stats");
}
try {
sleep(tickSize);
} catch (InterruptedException e) {
log.info("received shutdown, exiting from server loop");
return;
}
}
}
}
use of org.openkilda.server42.control.messaging.flowrtt.FlowRttControl.Flow in project open-kilda by telstra.
the class GateTest method removeFlow.
@Test
public void removeFlow() throws Exception {
RemoveFlow removeFlow = RemoveFlow.builder().flowId("some-flow-id").build();
gate.listen(removeFlow);
CommandPacket commandPacket = getCommandPacket();
assertThat(commandPacket.getType()).isEqualTo(Type.REMOVE_FLOW);
assertThat(commandPacket.getCommandList()).hasSize(1);
Any command = commandPacket.getCommand(0);
assertThat(command.is(FlowRttControl.RemoveFlow.class)).isTrue();
FlowRttControl.RemoveFlow unpack = command.unpack(FlowRttControl.RemoveFlow.class);
assertThat(unpack.getFlow().getFlowId()).isEqualTo(removeFlow.getFlowId());
}
use of org.openkilda.server42.control.messaging.flowrtt.FlowRttControl.Flow in project open-kilda by telstra.
the class StubApplicationTests method deleteFlow.
@Test
public void deleteFlow() throws Exception {
pushFlow(testFlowVlan1001);
pushFlow(testFlowVxlan2002);
pushFlow(testFlowVxlan3003);
mockMvc.perform(delete("/kafka/flow/{id}", testFlowVxlan2002.getFlowId()).param("switchId", switchId)).andExpect(status().isOk());
MvcResult result = mockMvc.perform(get("/kafka/flow/").param("switchId", switchId)).andReturn();
ListFlowsPayload listFlowsPayload = new ListFlowsPayload();
listFlowsPayload.getFlowIds().add(testFlowVlan1001.getFlowId());
listFlowsPayload.getFlowIds().add(testFlowVxlan3003.getFlowId());
mockMvc.perform(asyncDispatch(result)).andExpect(status().isOk()).andExpect(content().json(objectWriter.writeValueAsString(listFlowsPayload)));
}
Aggregations