-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow custom thread pool executors to be wired in. (#3075)
* Allow custom thread pool executors to be wired in. Closes #3066 Following should be done. * Implement `org.testng.IExecutorServiceFactory` * plugin the fully qualified class name of the above implementation via the configuration parameter "-threadpoolfactoryclass" If using Maven surefire plugin then it can be wired in as below: <configuration> <properties> <property> <name>threadpoolfactoryclass</name> <value>test.thread.MyExecutorServiceFactory</value> </property> </properties> </configuration> If using TestNG API, then it can be wired in as below: ```java TestNG testng = new TestNG(); testng.setExecutorServiceFactory(new MyExecutorServiceFactory()); ```
- Loading branch information
1 parent
38910de
commit 2cc332d
Showing
22 changed files
with
298 additions
and
326 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
testng-core-api/src/main/java/org/testng/IExecutorServiceFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.testng; | ||
|
||
import java.util.concurrent.BlockingQueue; | ||
import java.util.concurrent.ExecutorService; | ||
import java.util.concurrent.ThreadFactory; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
/** | ||
* Represents the capability to create a custom {@link ExecutorService} by downstream consumers. The | ||
* implementation can be plugged in via the configuration parameter <code>-threadpoolfactoryclass | ||
* </code> | ||
*/ | ||
@FunctionalInterface | ||
public interface IExecutorServiceFactory { | ||
|
||
/** | ||
* @param corePoolSize the number of threads to keep in the pool, even if they are idle, unless | ||
* {@code allowCoreThreadTimeOut} is set | ||
* @param maximumPoolSize the maximum number of threads to allow in the pool | ||
* @param keepAliveTime when the number of threads is greater than the core, this is the maximum | ||
* time that excess idle threads will wait for new tasks before terminating. | ||
* @param unit the time unit for the {@code keepAliveTime} argument | ||
* @param workQueue the queue to use for holding tasks before they are executed. This queue will | ||
* hold only the {@code Runnable} tasks submitted by the {@code execute} method. | ||
* @param threadFactory the factory to use when the executor creates a new thread * | ||
* @return - An implementation of {@link ExecutorService} | ||
*/ | ||
ExecutorService create( | ||
int corePoolSize, | ||
int maximumPoolSize, | ||
long keepAliveTime, | ||
TimeUnit unit, | ||
BlockingQueue<Runnable> workQueue, | ||
ThreadFactory threadFactory); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.