Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parallel jobs in Ant using a list

I'm trying to run parallel tasks on Ant.
User provide a list of server (-Drhosts="rhost1,rhost2,...") and the system should start the same target only using a different host each time.
<ac:for> and <ac:foreach> only support <sequential>, not <parallel>

Any idea?

like image 968
Assaf Avatar asked Jan 16 '23 16:01

Assaf


1 Answers

It supports parallel running by specifying an property.

Parameters of Ant-contrib's <for> task:

parallel
If true, all iterations of the nested will execute in parallel. Defaults to false, which forces sequential execution of the iterations. It is up to the caller to ensure that parallel execution is safe.

threadCount
The maximum number of allowable threads when executing in parallel.

So if you can set parallel="true". Please note that there is nothing to do with the nested <sequential> element, because the tasks inside <sequential> are still executed sequentially; by setting parallel parameter, you tell <for> tasks to execute multiple <sequential>s at the same time -- how many? It depends on the number of elements in your list, as well as the value of threadCount.

Please check

http://ant-contrib.sourceforge.net/tasks/tasks/for.html

to see all the parameters.


And for <foreach> task, it executes the specified target for each element in your list, or each file in the nested fileset. You can also use parallel property to make the execution parallel.

Check

http://ant-contrib.sourceforge.net/tasks/tasks/foreach.html

like image 79
Dante WWWW Avatar answered Jan 22 '23 20:01

Dante WWWW