/** * Returns a thread factory that produces threads named according to the * supplied name pattern and from the specified thread-group. The thread * group name is expected to be specified in slash-delimited format, e.g. * {@code onos/intent}. The thread names will be produced by converting * the thread group name into dash-delimited format and pre-pended to the * specified pattern. * * @param groupName group name in slash-delimited format to indicate hierarchy * @param pattern name pattern * @return thread factory */ public static ThreadFactory groupedThreads(String groupName, String pattern) { return groupedThreads(groupName, pattern, log); }
/** * Creates an executor that will be used for synchronization tasks. * <p> * Can be overridden to change the type of executor used. * </p> * * @return executor service */ protected ExecutorService createExecutor() { return newSingleThreadExecutor(groupedThreads("onos/" + appId, "sync", log)); }
DispatchLoop(String name) { this.name = name; executor = newSingleThreadExecutor( groupedThreads("onos/event", "dispatch-" + name + "%d", log)); eventsQueue = new LinkedBlockingQueue<>(); }
@Activate private void activate() { components = Collections.newSetFromMap(new ConcurrentHashMap<>()); executor = newScheduledThreadPool(NUM_THREADS, groupedThreads("onos/component", "%d", log)); executor.scheduleAtFixedRate(() -> components.forEach(this::enableComponent), 0, POLLING_PERIOD_MS, TimeUnit.MILLISECONDS); log.info("Started"); }
@Activate public void activate() { worker = newSingleThreadExecutor(groupedThreads("onos/protection", "installer", log)); networkConfigService.addListener(listener); factories.forEach(cfgRegistry::registerConfigFactory); log.info("Started"); }
/** * Sets the shared thread pool size. * * @param poolSize new pool size */ public static void setPoolSize(int poolSize) { checkArgument(poolSize > 0, "Shared pool size size must be greater than 0"); poolThreadExecutor.setBackingExecutor( newFixedThreadPool(poolSize, groupedThreads("onos/shared", "onos-pool-executor-%d"))); }
/** * Configures the shared scheduled thread pool size. * * @param poolSize new pool size */ public static void setPoolSize(int poolSize) { checkArgument(poolSize > 0, "Shared pool size size must be greater than 0"); poolThreadExecutor.setBackingExecutor( newScheduledThreadPool(poolSize, groupedThreads("onos/shared/scheduled", "onos-pool-executor-%d"))); }
/** * Creates a new sliding window counter with the given total number of * window slots. * * @param windowSlots total number of window slots */ public SlidingWindowCounter(int windowSlots) { checkArgument(windowSlots > 0, "Window size must be a positive integer"); this.windowSlots = windowSlots; this.headSlot = 0; // Initialize each item in the list to an AtomicLong of 0 this.counters = Collections.nCopies(windowSlots, 0) .stream() .map(AtomicLong::new) .collect(Collectors.toCollection(ArrayList::new)); background = newSingleThreadScheduledExecutor(groupedThreads("SlidingWindowCounter", "bg-%d")); background.scheduleWithFixedDelay(this::advanceHead, 0, SLIDE_WINDOW_PERIOD_SECONDS, TimeUnit.SECONDS); }
private ServerBootstrap createServerBootStrap() { if (workerThreads == 0) { execFactory = new NioServerSocketChannelFactory( Executors.newCachedThreadPool(groupedThreads("onos/of", "boss-%d", log)), Executors.newCachedThreadPool(groupedThreads("onos/of", "worker-%d", log))); return new ServerBootstrap(execFactory); } else { execFactory = new NioServerSocketChannelFactory( Executors.newCachedThreadPool(groupedThreads("onos/of", "boss-%d", log)), Executors.newCachedThreadPool(groupedThreads("onos/of", "worker-%d", log)), workerThreads); return new ServerBootstrap(execFactory); } }
@Activate public void activate() { intentExtensionService.registerInstaller(FlowRuleIntent.class, this); nonDisruptiveIntentInstaller = newSingleThreadScheduledExecutor(groupedThreads("onos/intent", "non-disruptive-installer", log)); configService.registerProperties(getClass()); }
@Activate public void activate() { worker = newSingleThreadExecutor(groupedThreads("onos/inject", "worker", log)); providerService = deviceProviderRegistry.register(deviceProvider); netcfgService.addListener(listener); factories.forEach(netcfgRegistry::registerConfigFactory); log.info("Started"); }
/** * Creates peer boot strap. * * @return client bootstrap instance */ private ClientBootstrap createPeerBootStrap() { if (peerWorkerThreads == 0) { peerExecFactory = new NioClientSocketChannelFactory( Executors.newCachedThreadPool(groupedThreads("onos/isis", "boss-%d")), Executors.newCachedThreadPool(groupedThreads("onos/isis", "worker-%d"))); return new ClientBootstrap(peerExecFactory); } else { peerExecFactory = new NioClientSocketChannelFactory( Executors.newCachedThreadPool(groupedThreads("onos/isis", "boss-%d")), Executors.newCachedThreadPool(groupedThreads("onos/isis", "worker-%d")), peerWorkerThreads); return new ClientBootstrap(peerExecFactory); } }
/** * Creates peer boot strap. * * @return client bootstrap instance */ private ClientBootstrap createPeerBootStrap() { if (peerWorkerThreads == 0) { peerExecFactory = new NioClientSocketChannelFactory( Executors.newCachedThreadPool(groupedThreads("onos/isis", "boss-%d")), Executors.newCachedThreadPool(groupedThreads("onos/isis", "worker-%d"))); return new ClientBootstrap(peerExecFactory); } else { peerExecFactory = new NioClientSocketChannelFactory( Executors.newCachedThreadPool(groupedThreads("onos/isis", "boss-%d")), Executors.newCachedThreadPool(groupedThreads("onos/isis", "worker-%d")), peerWorkerThreads); return new ClientBootstrap(peerExecFactory); } }
@Activate public void activate(ComponentContext context) { appId = coreService.registerApplication("org.onosproject.snmp"); eventHandlingExecutor = Executors.newSingleThreadExecutor( groupedThreads("onos/alarms", "event-handler")); deviceService.addListener(internalDeviceListener); log.info("activated SNMP provider with appId = {} and context props {}", appId, context.getProperties()); modified(context); log.info("Started"); }
@Activate public void activate() { cfgService.registerProperties(getClass()); executor = newSingleThreadExecutor(groupedThreads("onos/intent", "cleanup", log)); timer = new Timer("onos-intent-cleanup-timer"); service.addListener(this); adjustRate(); log.info("Started"); }
@Activate protected void activate() { cfgService.registerProperties(getClass()); executorService = newFixedThreadPool(numThreads, groupedThreads(GROUP_THREAD_NAME, WORKER_PATTERN, log)); flowObjectiveStore.setDelegate(delegate); deviceService.addListener(deviceListener); driverService.addListener(driverListener); log.info("Started"); }
@Activate public void activate(ComponentContext context) { eventExecutor = Executors.newSingleThreadExecutor(groupedThreads("onos/group", "event")); store.setDelegate(delegate); eventDispatcher.addSink(GroupEvent.class, listenerRegistry); deviceService.addListener(deviceListener); cfgService.registerProperties(getClass()); modified(context); log.info("Started"); }
@Activate protected void activate() { executorService = newFixedThreadPool(4, groupedThreads("onos/objective-installer", "%d", log)); flowObjectiveStore.setDelegate(delegate); mastershipService.addListener(mastershipListener); deviceService.addListener(deviceListener); deviceService.getDevices().forEach(device -> setupPipelineHandler(device.id())); deviceCompositionTreeMap = Maps.newConcurrentMap(); log.info("Started"); }
@Activate public void activate(ComponentContext context) { eventExecutor = newSingleThreadScheduledExecutor(groupedThreads("onos/linkevents", "events-%d", log)); shuttingDown = false; cfgService.registerProperties(getClass()); appId = coreService.registerApplication(PROVIDER_NAME); cfgRegistry.addListener(cfgListener); factories.forEach(cfgRegistry::registerConfigFactory); SuppressionConfig cfg = cfgRegistry.getConfig(appId, SuppressionConfig.class); if (cfg == null) { // If no configuration is found, register default. cfg = this.setDefaultSuppressionConfig(); } cfgListener.reconfigureSuppressionRules(cfg); modified(context); log.info("Started"); }
@Activate public synchronized void activate(ComponentContext context) { cfgService.registerProperties(DefaultTopologyProvider.class); executor = newFixedThreadPool(MAX_THREADS, groupedThreads("onos/topo", "build-%d", log)); accumulator = new TopologyChangeAccumulator(); logConfig("Configured"); modified(context); providerService = providerRegistry.register(this); deviceService.addListener(deviceListener); linkService.addListener(linkListener); isStarted = true; triggerRecompute(); log.info("Started"); }