Search in sources :

Example 1 with PredictableExecutor

use of org.onlab.util.PredictableExecutor in project onos by opennetworkinglab.

the class RouteManager method activate.

@Activate
protected void activate() {
    routeMonitor = new RouteMonitor(this, clusterService, storageService);
    routeResolver = new RouteResolver(this, hostService);
    threadFactory = groupedThreads("onos/route", "listener-%d", log);
    hostEventExecutors = new PredictableExecutor(DEFAULT_BUCKETS, groupedThreads("onos/route-manager", "event-host-%d", log));
    resolvedRouteStore = new DefaultResolvedRouteStore();
    routeStore.setDelegate(delegate);
    hostService.addListener(hostListener);
    routeStore.getRouteTables().stream().flatMap(id -> routeStore.getRoutes(id).stream()).forEach(routeSet -> routeResolver.resolve(routeSet));
}
Also used : Route(org.onosproject.routeservice.Route) Host(org.onosproject.net.Host) RouteStore(org.onosproject.routeservice.RouteStore) PredictableExecutor(org.onlab.util.PredictableExecutor) LoggerFactory(org.slf4j.LoggerFactory) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) RouteEvent(org.onosproject.routeservice.RouteEvent) HostListener(org.onosproject.net.host.HostListener) HostService(org.onosproject.net.host.HostService) RouteStoreDelegate(org.onosproject.routeservice.RouteStoreDelegate) Component(org.osgi.service.component.annotations.Component) StorageService(org.onosproject.store.service.StorageService) ImmutableList(com.google.common.collect.ImmutableList) RouteAdminService(org.onosproject.routeservice.RouteAdminService) Map(java.util.Map) HostEvent(org.onosproject.net.host.HostEvent) Activate(org.osgi.service.component.annotations.Activate) ThreadFactory(java.util.concurrent.ThreadFactory) ExecutorService(java.util.concurrent.ExecutorService) IpAddress(org.onlab.packet.IpAddress) RouteService(org.onosproject.routeservice.RouteService) Logger(org.slf4j.Logger) Deactivate(org.osgi.service.component.annotations.Deactivate) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) BlockingQueue(java.util.concurrent.BlockingQueue) Executors.newSingleThreadExecutor(java.util.concurrent.Executors.newSingleThreadExecutor) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) Collectors(java.util.stream.Collectors) RouteListener(org.onosproject.routeservice.RouteListener) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) InternalRouteEvent(org.onosproject.routeservice.InternalRouteEvent) RouteInfo(org.onosproject.routeservice.RouteInfo) Optional(java.util.Optional) ClusterService(org.onosproject.cluster.ClusterService) RouteTableId(org.onosproject.routeservice.RouteTableId) ResolvedRoute(org.onosproject.routeservice.ResolvedRoute) Reference(org.osgi.service.component.annotations.Reference) IpPrefix(org.onlab.packet.IpPrefix) PredictableExecutor(org.onlab.util.PredictableExecutor) Activate(org.osgi.service.component.annotations.Activate)

Example 2 with PredictableExecutor

use of org.onlab.util.PredictableExecutor in project onos by opennetworkinglab.

the class HostLocationProvider method activate.

@Activate
public void activate(ComponentContext context) {
    cfgService.registerProperties(getClass());
    appId = coreService.registerApplication("org.onosproject.provider.host");
    deviceEventHandler = newSingleThreadScheduledExecutor(groupedThreads("onos/host-loc-provider", "device-event-handler", log));
    probeEventHandler = newSingleThreadScheduledExecutor(groupedThreads("onos/host-loc-provider", "probe-event-handler", log));
    packetWorkers = new PredictableExecutor(DEFAULT_THREADS, groupedThreads("onos/host-loc-provider", "packet-worker-%d", log));
    providerService = providerRegistry.register(this);
    packetService.addProcessor(processor, PacketProcessor.advisor(1));
    deviceService.addListener(deviceListener);
    registry.registerConfigFactory(hostLearningConfig);
    modified(context);
    netcfgService.addListener(cfgListener);
    log.info("Started with Application ID {}", appId.id());
}
Also used : PredictableExecutor(org.onlab.util.PredictableExecutor) Activate(org.osgi.service.component.annotations.Activate)

Example 3 with PredictableExecutor

use of org.onlab.util.PredictableExecutor in project onos by opennetworkinglab.

the class P4RuntimePacketProvider method modified.

@Modified
protected void modified(ComponentContext context) {
    if (context != null) {
        Dictionary<?, ?> properties = context.getProperties();
        int newWorkers;
        try {
            String s = get(properties, P4RUNTIME_PACKET_PROVIDER_WORKERS);
            newWorkers = isNullOrEmpty(s) ? workers : Integer.parseInt(s.trim());
        } catch (NumberFormatException | ClassCastException e) {
            newWorkers = workers;
        }
        // OR during the start up of the service
        if (newWorkers != workers || packetWorkers == null) {
            workers = newWorkers;
            stopWorkersIfNeeded();
            packetWorkers = new PredictableExecutor(workers, groupedThreads("onos/p4rt", "packet-worker-%d", log));
            log.info("Settings: p4RuntimePacketProviderWorkers={}", workers);
        }
    }
}
Also used : PredictableExecutor(org.onlab.util.PredictableExecutor) Modified(org.osgi.service.component.annotations.Modified)

Example 4 with PredictableExecutor

use of org.onlab.util.PredictableExecutor in project onos by opennetworkinglab.

the class RouteManagerTest method setUp.

@Before
public void setUp() throws Exception {
    setUpHostService();
    routeListener = createMock(RouteListener.class);
    routeManager = new TestRouteManager();
    routeManager.hostService = hostService;
    routeManager.clusterService = createNiceMock(ClusterService.class);
    replay(routeManager.clusterService);
    routeManager.storageService = createNiceMock(StorageService.class);
    AsyncDistributedLock adl = createNiceMock(AsyncDistributedLock.class);
    expect(adl.asLock()).andReturn(createNiceMock(DistributedLock.class));
    replay(adl);
    DistributedLockBuilder dlb = createNiceMock(DistributedLockBuilder.class);
    expect(dlb.withName(anyString())).andReturn(dlb);
    expect(dlb.build()).andReturn(adl);
    replay(dlb);
    expect(routeManager.storageService.lockBuilder()).andReturn(dlb);
    expect(routeManager.storageService.getWorkQueue(anyString(), anyObject())).andReturn(createNiceMock(WorkQueue.class));
    replay(routeManager.storageService);
    LocalRouteStore routeStore = new LocalRouteStore();
    routeStore.activate();
    routeManager.routeStore = routeStore;
    routeManager.activate();
    routeManager.hostEventExecutors = new PredictableExecutor(0, groupedThreads("onos/route-manager-test", "event-host-%d"), true);
    routeManager.routeResolver.routeResolvers = new PredictableExecutor(0, groupedThreads("onos/route-resolver-test", "route-resolver-%d"), true);
    routeManager.addListener(routeListener);
}
Also used : AsyncDistributedLock(org.onosproject.store.service.AsyncDistributedLock) DistributedLock(org.onosproject.store.service.DistributedLock) ClusterService(org.onosproject.cluster.ClusterService) DistributedLockBuilder(org.onosproject.store.service.DistributedLockBuilder) LocalRouteStore(org.onosproject.routeservice.store.LocalRouteStore) AsyncDistributedLock(org.onosproject.store.service.AsyncDistributedLock) PredictableExecutor(org.onlab.util.PredictableExecutor) WorkQueue(org.onosproject.store.service.WorkQueue) RouteListener(org.onosproject.routeservice.RouteListener) StorageService(org.onosproject.store.service.StorageService) Before(org.junit.Before)

Aggregations

PredictableExecutor (org.onlab.util.PredictableExecutor)4 ClusterService (org.onosproject.cluster.ClusterService)2 RouteListener (org.onosproject.routeservice.RouteListener)2 StorageService (org.onosproject.store.service.StorageService)2 Activate (org.osgi.service.component.annotations.Activate)2 ImmutableList (com.google.common.collect.ImmutableList)1 Collection (java.util.Collection)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 BlockingQueue (java.util.concurrent.BlockingQueue)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ExecutorService (java.util.concurrent.ExecutorService)1 Executors.newSingleThreadExecutor (java.util.concurrent.Executors.newSingleThreadExecutor)1 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)1 ThreadFactory (java.util.concurrent.ThreadFactory)1 Collectors (java.util.stream.Collectors)1 Before (org.junit.Before)1 IpAddress (org.onlab.packet.IpAddress)1 IpPrefix (org.onlab.packet.IpPrefix)1