Java Code Examples for org.onosproject.net.device.DeviceService#addListener()

The following examples show how to use org.onosproject.net.device.DeviceService#addListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OFSwitchManager.java    From onos with Apache License 2.0 6 votes vote down vote up
private void processOFAgentStarted(OFAgent ofAgent) {
    devices(ofAgent.networkId()).forEach(deviceId -> {
        OFSwitch ofSwitch = ofSwitchMap.get(deviceId);
        if (ofSwitch != null) {
            connectController(ofSwitch, ofAgent.controllers());
        }
    });

    DeviceService deviceService = virtualNetService.get(
            ofAgent.networkId(),
            DeviceService.class);
    deviceService.addListener(deviceListener);

    PacketService packetService = virtualNetService.get(
            ofAgent.networkId(),
            PacketService.class);
    packetService.addProcessor(packetProcessor, PacketProcessor.director(0));

    FlowRuleService flowRuleService = virtualNetService.get(
            ofAgent.networkId(),
            FlowRuleService.class);
    flowRuleService.addListener(flowRuleListener);
}
 
Example 2
Source File: FlowRuleDriverProvider.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Initializes the provider with necessary supporting services.
 *
 * @param providerService   flow rule provider service
 * @param deviceService     device service
 * @param mastershipService mastership service
 * @param pollFrequency     flow entry poll frequency
 */
void init(FlowRuleProviderService providerService,
          DeviceService deviceService, MastershipService mastershipService,
          int pollFrequency) {
    this.providerService = providerService;
    this.deviceService = deviceService;
    this.mastershipService = mastershipService;

    deviceService.addListener(deviceListener);

    if (poller != null && !poller.isCancelled()) {
        poller.cancel(false);
    }

    poller = executor.scheduleAtFixedRate(this::pollFlowEntries, pollFrequency,
                                          pollFrequency, TimeUnit.SECONDS);
}
 
Example 3
Source File: GroupDriverProvider.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Initializes the provider with the necessary device service, group provider service,
 * mastership service and poll frequency.
 *
 * @param deviceService        device service
 * @param groupProviderService group provider service
 * @param mastershipService    mastership service
 * @param pollFrequency        group entry poll frequency
 */
void init(DeviceService deviceService, GroupProviderService groupProviderService,
          MastershipService mastershipService, int pollFrequency) {
    this.deviceService = deviceService;
    this.groupProviderService = groupProviderService;
    this.mastershipService = mastershipService;

    deviceService.addListener(deviceListener);

    if (poller != null && !poller.isCancelled()) {
        poller.cancel(false);
    }

    poller = executor.scheduleAtFixedRate(this::pollGroups, pollFrequency,
            pollFrequency, TimeUnit.SECONDS);

}
 
Example 4
Source File: MeterDriverProvider.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Initializes the provider with the necessary device service, meter provider service,
 * mastership service and poll frequency.
 *
 * @param deviceService        device service
 * @param meterProviderService meter provider service
 * @param mastershipService    mastership service
 * @param pollFrequency        meter entry poll frequency
 */
void init(DeviceService deviceService, MeterProviderService meterProviderService,
          MastershipService mastershipService, int pollFrequency) {
    this.deviceService = deviceService;
    this.meterProviderService = meterProviderService;
    this.mastershipService = mastershipService;
    this.pollFrequency = pollFrequency;

    deviceService.addListener(deviceListener);

    if (poller != null && !poller.isCancelled()) {
        poller.cancel(false);
    }

    poller = executor.scheduleAtFixedRate(this::pollMeters, pollFrequency,
            pollFrequency, TimeUnit.SECONDS);

}
 
Example 5
Source File: AsyncDeviceFetcher.java    From onos with Apache License 2.0 4 votes vote down vote up
private AsyncDeviceFetcher(DeviceService deviceService) {
    this.deviceService = checkNotNull(deviceService);
    deviceService.addListener(listener);
}