16 package org.openkilda.floodlight.command.flow;
28 import net.floodlightcontroller.core.IOFSwitch;
29 import net.floodlightcontroller.core.internal.IOFSwitchService;
30 import net.floodlightcontroller.core.module.FloodlightModuleContext;
31 import net.floodlightcontroller.threadpool.IThreadPoolService;
32 import org.projectfloodlight.openflow.protocol.OFVersion;
33 import org.projectfloodlight.openflow.types.DatapathId;
34 import org.slf4j.Logger;
35 import org.slf4j.LoggerFactory;
37 import java.util.concurrent.TimeUnit;
45 private final IThreadPoolService scheduler;
49 super(context, verificationRequest);
55 scheduler = moduleContext.getServiceImpl(IThreadPoolService.class);
57 checkCapabilities(
new SwitchUtils(moduleContext.getServiceImpl(IOFSwitchService.class)));
64 TimeoutNotification notification =
new TimeoutNotification(
this);
65 scheduler.getScheduledExecutor().schedule(
66 notification, getVerificationRequest().getTimeout(), TimeUnit.MILLISECONDS);
73 if (! verificationData.
equals(payload)) {
79 "Receive flow VERIFICATION package - packetId: {}, latency: {}",
80 payload.
getPacketId(), measures.getNetworkLatency());
82 sendResponse(response);
87 private void timeout() {
88 log.error(
"Give up waiting for flow VERIFICATION packet (packetId: {})", verificationData.
getPacketId());
94 private void checkCapabilities(
SwitchUtils switchUtils)
throws InsufficientCapabilitiesException {
95 DatapathId switchId = DatapathId.of(getVerificationRequest().getDestSwitchId().toLong());
96 IOFSwitch sw = switchUtils.lookupSwitch(switchId);
98 if (0 < OFVersion.OF_13.compareTo(sw.getOFFactory().getVersion())) {
99 throw new InsufficientCapabilitiesException(
"Destination switch is unable to catch PING package");
103 static class TimeoutNotification
implements Runnable {
CommandContext getContext()
void unsubscribe(VerificationListenCommand handler)
boolean packetIn(IOFSwitch sw, VerificationData payload)
static VerificationData of(DecodedJWT token)
def command(payload, fields)
FloodlightModuleContext getModuleContext()
void subscribe(VerificationListenCommand handler)
VerificationMeasures produceMeasurements(long recipientLatency)
VerificationListenCommand(CommandContext context, UniFlowVerificationRequest verificationRequest)