Last active
October 29, 2017 11:32
-
-
Save bamedro/283d25c78aba357d1c27e31dac05c6cd to your computer and use it in GitHub Desktop.
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
<?xml version="1.0" encoding="UTF-8"?> | |
<job | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns="urn:proactive:jobdescriptor:3.8" | |
xsi:schemaLocation="urn:proactive:jobdescriptor:3.8 http://www.activeeon.com/public_content/schemas/proactive/jobdescriptor/3.8/schedulerjob.xsd" | |
name="EP" | |
priority="normal" | |
onTaskError="cancelJob" | |
maxNumberOfExecution="1" | |
> | |
<variables> | |
<variable name="count" value="100" /> | |
</variables> | |
<genericInformation> | |
<info name="bucketName" value="Examples"/> | |
<info name="group" value="public-objects"/> | |
</genericInformation> | |
<taskFlow> | |
<task name="Split"> | |
<description> | |
<![CDATA[ This task defines some input, here strings to be processed. ]]> | |
</description> | |
<scriptExecutable> | |
<script> | |
<code language="groovy"> | |
<![CDATA[ | |
result = [:] | |
Random randomSeeds = new Random(); | |
randomSeeds.setSeed(42); | |
int[] finalResults = new int[Integer.valueOf(variables.get("count"))]; | |
for(int i = 0; i<finalResults.length; i++) { | |
int seed = randomSeeds.nextInt(); | |
result.put(i, seed); | |
Random taskRandom = new Random(); | |
taskRandom.setSeed(seed); | |
finalResults[i] = taskRandom.nextInt(); | |
} | |
Arrays.sort(finalResults); | |
int preComputedResultHash = Arrays.hashCode(finalResults); | |
variables.put("preComputedResultHash", preComputedResultHash); | |
println "preComputedResultHash=" + preComputedResultHash | |
]]> | |
</code> | |
</script> | |
</scriptExecutable> | |
<controlFlow > | |
<replicate> | |
<script> | |
<code language="groovy"> | |
<![CDATA[ | |
runs=variables.get("count") | |
]]> | |
</code> | |
</script> | |
</replicate> | |
</controlFlow> | |
</task> | |
<task name="Process"> | |
<description> | |
<![CDATA[ This task will be replicated according to the 'runs' value specified in the replication script. The replication index is used in each task's instance to select the input. ]]> | |
</description> | |
<depends> | |
<task ref="Split"/> | |
</depends> | |
<scriptExecutable> | |
<script> | |
<code language="groovy"> | |
<![CDATA[ | |
int replication = variables.get('PA_TASK_REPLICATION'); | |
int seed = results[0].value()[replication]; | |
Random random = new Random(); | |
random.setSeed(seed); | |
Thread.sleep(5*60*1000); | |
result = random.nextInt(); | |
]]> | |
</code> | |
</script> | |
</scriptExecutable> | |
</task> | |
<task name="Merge"> | |
<description> | |
<![CDATA[ As a merge operation, we simply print the results from previous tasks. ]]> | |
</description> | |
<depends> | |
<task ref="Process"/> | |
</depends> | |
<scriptExecutable> | |
<script> | |
<code language="groovy"> | |
<![CDATA[ | |
if( results.length != Integer.valueOf(variables.get("count")) ) { | |
throw new RuntimeException("Incorrect number of results: " + results.length); | |
} | |
int[] randoms = new int[results.length]; | |
for( int i=0; i<results.length; i++) { | |
randoms[i] = results[i].value(); | |
} | |
Arrays.sort(randoms); | |
int finalResultHash = Arrays.hashCode(randoms); | |
println "finalResultHash=" + finalResultHash; | |
if( finalResultHash != Integer.valueOf(variables.get("preComputedResultHash")) ) { | |
throw new RuntimeException("Incorrect hash for results: " + finalResultHash); | |
} | |
]]> | |
</code> | |
</script> | |
</scriptExecutable> | |
</task> | |
</taskFlow> | |
</job> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment