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));
}
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());
}
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);
}
}
}
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);
}
Aggregations