public class ConcurrentComponentAccessUtil extends ComponentAccessUtil
ConcurrentComponentAccessUtil extends ComponentAccessUtil, allowing to
instantiate and release components concurrently.
The class owns a thread pool to execute the tasks concurrently. The size of the thread pool
can be set in the constructor; otherwise a default value of defaultThreadNumber
is used.
This class allows to release components in parallel by executing each release in one of the threads of the pool.
Life cycle:
| Modifier and Type | Class and Description |
|---|---|
class |
ConcurrentComponentAccessUtil.BenchmarkTreadPoolExecutor
The thread pool to add statistics to the FutureTask.
|
class |
ConcurrentComponentAccessUtil.InstrumentedFutureTask<T>
An instrumented future task contains fields useful for getting statistics.
|
ComponentAccessUtil.CompRefHelpercompName2Comp, contSrv, logger| Constructor and Description |
|---|
ConcurrentComponentAccessUtil(ContainerServices contSrv)
Constructor.
|
ConcurrentComponentAccessUtil(ContainerServices contSrv,
int threadPoolSize)
Constructor.
|
ConcurrentComponentAccessUtil(ContainerServices contSrv,
int threadPoolSize,
boolean prestartCoreThreads)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
<T extends ACSComponentOperations> |
getDynamicComponentConcurrent(ComponentSpec compSpec,
java.lang.Class<T> idlOpInterface)
The parallel version of
ComponentAccessUtil.getDynamicComponent(ComponentSpec, Class)
gets the dynamic component in a thread of the pool. |
java.util.concurrent.Future<java.lang.Void> |
releaseComponentConcurrent(java.lang.String name)
Releases a component in a dedicated thread of the pool.
|
void |
releaseComponents(java.util.Collection<java.lang.String> compNames,
boolean waitCompsTermination)
Concurrently releases the components with the passed names.
|
void |
start()
Life cycle method: this method must be called before using methods from this class
|
void |
stop()
Life cycle method: this method must be called when the object is not needed
anymore
|
getCachedComponentNames, getCachedComponents, getDynamicComponent, getDynamicComponentFromContainerServices, initCompImpl, logInfo, releaseAllComponents, releaseComponentpublic ConcurrentComponentAccessUtil(ContainerServices contSrv)
Build the ConcurrentComponentAccessUtil with a default number of threads
contSrv - The ContainerServicespublic ConcurrentComponentAccessUtil(ContainerServices contSrv, int threadPoolSize)
contSrv - The ContainerServicesthreadPoolSize - The number of threads in the thread poolpublic ConcurrentComponentAccessUtil(ContainerServices contSrv, int threadPoolSize, boolean prestartCoreThreads)
contSrv - The ContainerServicesthreadPoolSize - The number of threads in the thread poolprestartCoreThreads - public void start()
public void stop()
public java.util.concurrent.Future<java.lang.Void> releaseComponentConcurrent(java.lang.String name)
Note that ComponentAccessUtil#releaseComponent(compName, waitForCompRelease=false)
is very similar in the sense that it is also asynchronous, making an async call to the manager
instead of spawning a new thread already here in the client.
The main difference though is that in this method we can measure the time it takes to release a component,
which is important for performance tests.
name - The name of the component to deactivatepublic void releaseComponents(java.util.Collection<java.lang.String> compNames,
boolean waitCompsTermination)
This method overrides the base class version, bringing in a thread pool for parallel
component release, instead of sequentially releaseing every component.
Mostly makes sense for waitCompsTermination == true.
To avoid hanging tests, a generous timeout of 30 minutes gets applied.
releaseComponents in class ComponentAccessUtilcompNames - The names of the components to releasewaitCompsTermination - if true the method waits for all the threads to terminate before returning, otherwise
returns immediatelypublic <T extends ACSComponentOperations> java.util.concurrent.Future<T> getDynamicComponentConcurrent(ComponentSpec compSpec,
java.lang.Class<T> idlOpInterface)
ComponentAccessUtil.getDynamicComponent(ComponentSpec, Class)
gets the dynamic component in a thread of the pool.compSpec - The spec to start the dynamic componentidlOpInterface - The idl interface of the component