public class LLDPSpeaker implements AutoCloseable, NodeConnectorEventsObserver, Runnable {
private static final Logger LOG = LoggerFactory.getLogger(LLDPSpeaker.class);
private static final long LLDP_FLOOD_PERIOD = 5;
+ private long Current_Flood_Period = LLDP_FLOOD_PERIOD;
private final PacketProcessingService packetProcessingService;
private final ScheduledExecutorService scheduledExecutorService;
private final Map<InstanceIdentifier<NodeConnector>, TransmitPacketInput> nodeConnectorMap =
new ConcurrentHashMap<>();
- private final ScheduledFuture<?> scheduledSpeakerTask;
+ private ScheduledFuture<?> scheduledSpeakerTask;
private final MacAddress addressDestionation;
private volatile OperStatus operationalStatus = OperStatus.RUN;
return operationalStatus;
}
+ public void setLldpFloodInterval(long time) {
+ this.Current_Flood_Period = time;
+ scheduledSpeakerTask.cancel(false);
+ scheduledSpeakerTask = this.scheduledExecutorService
+ .scheduleAtFixedRate(this, time, time, TimeUnit.SECONDS);
+ LOG.info("LLDPSpeaker restarted, it will send LLDP frames each {} seconds", time);
+ }
+
+ public long getLldpFloodInterval() {
+ return Current_Flood_Period;
+ }
+
public LLDPSpeaker(final PacketProcessingService packetProcessingService,
final ScheduledExecutorService scheduledExecutorService,
final MacAddress addressDestionation) {
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.lldp.speaker.rev141023.ChangeOperationalStatusInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.lldp.speaker.rev141023.GetOperationalStatusOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.lldp.speaker.rev141023.GetOperationalStatusOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.lldp.speaker.rev141023.SetLldpFloodIntervalInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.lldp.speaker.rev141023.GetLldpFloodIntervalOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.lldp.speaker.rev141023.GetLldpFloodIntervalOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.lldp.speaker.rev141023.LldpSpeakerService;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
rpcResultBuilder.withResult(getOperationalStatusOutputBuilder.build());
return Futures.immediateFuture(rpcResultBuilder.build());
}
+
+ @Override
+ public Future<RpcResult<Void>> setLldpFloodInterval(final SetLldpFloodIntervalInput input) {
+ speakerInstance.setLldpFloodInterval(input.getInterval());
+ RpcResultBuilder<Void> rpcResultBuilder = RpcResultBuilder.success();
+ return Futures.immediateFuture(rpcResultBuilder.build());
+ }
+
+ @Override
+ public Future<RpcResult<GetLldpFloodIntervalOutput>> getLldpFloodInterval() {
+ RpcResultBuilder<GetLldpFloodIntervalOutput> rpcResultBuilder = RpcResultBuilder.success();
+ GetLldpFloodIntervalOutputBuilder getLldpFloodIntervalOutputBuilder = new GetLldpFloodIntervalOutputBuilder();
+ getLldpFloodIntervalOutputBuilder.setInterval(speakerInstance.getLldpFloodInterval());
+ rpcResultBuilder.withResult(getLldpFloodIntervalOutputBuilder.build());
+ return Futures.immediateFuture(rpcResultBuilder.build());
+ }
}
}
}
}
+ rpc set-lldp-flood-interval {
+ input {
+ leaf interval {
+ type int64;
+ description "Set LLDP_FLOOD_PERIOD";
+ }
+ }
+ }
+ rpc get-lldp-flood-interval {
+ output {
+ leaf interval {
+ type int64;
+ description "Get LLDP_FLOOD_PERIOD";
+ }
+ }
+ }
}