Topics

RunLevel Service with optional concurrency

hv@...
 

I'm using the HK2 RunLevel Service (https://javaee.github.io/hk2/runlevel.html) in fully-threaded mode. Sometimes I'd like to start a service with a higher concurrency, ideally indicated through an annotation parameter, e.g. @RunLevel(value = 3, concurrency = 5). The jobs should run within the threadpool of the runlevel controller. I'm not sure if there would be a clash with the default @Singleton scope of runlevel services though.

What do you think? Is this a popular request? Worthy of a feature request?

Thanks,
Henning

jwells131313@...
 

There is no feature like this however the building blocks are there for you to provide your own feature like this by using the setExecutor method of the RunLevelController service.  By using your own Executor you can ensure that certain jobs go to certain thread-pools or do whatever priority scheme you have in mind.

Hope this helps and is what you were asking for!

jwells131313@...
 

Actually after thinking about it for a second there is no way to figure out from the Runnable passed in which service is going to be executed with it.  This may call for a small mini-feature whereby the Runnable passed to the executors also implement some other interface from which the user can get some sort of indication of which RunLevel service is about to be started.  One issue with even such an interface as that is that not all RunLevel services are started via the executor, as they may also be started by dependency map.  Basically if B depends on A and the RunLevelService decides to start B then it will find the dependency A and start it as well without going through the executor.  So that's not quite the correct solution for that.

So this may need more thought, so perhaps you should enter in an enhancement request!

hv@...
 

Yes, that makes sense. I'm already using my own Executor (for other reasons), but as you said - it is unaware of what specifically it is supposed to be executing.

hk2-360 added. Thanks!