Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ProActive
scheduling
Commits
de9bfda9
Unverified
Commit
de9bfda9
authored
Sep 03, 2020
by
Fabien Viale
Committed by
GitHub
Sep 03, 2020
Browse files
Merge pull request #3797 from fviale/master
Fix variables order
parents
3e59f7be
4c72f889
Changes
3
Hide whitespace changes
Inline
Side-by-side
scheduler/scheduler-api/src/main/java/org/ow2/proactive/scheduler/common/job/factories/StaxJobFactory.java
View file @
de9bfda9
...
...
@@ -257,7 +257,7 @@ public class StaxJobFactory extends JobFactory {
validate
(
jobInputStreamForValidation
);
}
long
t2
=
System
.
currentTimeMillis
();
Map
<
String
,
ArrayList
<
String
>>
dependencies
=
new
HashMap
<>();
Map
<
String
,
ArrayList
<
String
>>
dependencies
=
new
Linked
HashMap
<>();
Job
job
;
try
(
ByteArrayInputStream
jobInpoutStreamForParsing
=
new
ByteArrayInputStream
(
bytes
))
{
XMLStreamReader
xmlsr
=
xmlInputFactory
.
createXMLStreamReader
(
jobInpoutStreamForParsing
,
FILE_ENCODING
);
...
...
@@ -417,7 +417,7 @@ public class StaxJobFactory extends JobFactory {
};
// To allow variable replacements on the job attributes, store them until job variables are parsed
Map
<
String
,
String
>
delayedJobAttributes
=
new
HashMap
<>();
Map
<
String
,
String
>
delayedJobAttributes
=
new
Linked
HashMap
<>();
int
attrLen
=
cursorJob
.
getAttributeCount
();
int
i
=
0
;
for
(;
i
<
attrLen
;
i
++)
{
...
...
@@ -710,8 +710,8 @@ public class StaxJobFactory extends JobFactory {
protected
Map
<
String
,
JobVariable
>
replaceVariablesInJobVariablesMap
(
Map
<
String
,
JobVariable
>
variablesMap
,
Map
<
String
,
String
>
replacementVariables
)
throws
JobCreationException
{
HashMap
<
String
,
String
>
updatedReplacementVariables
=
new
HashMap
<>();
HashMap
<
String
,
JobVariable
>
updatedVariablesMap
=
new
HashMap
<>(
variablesMap
);
Linked
HashMap
<
String
,
String
>
updatedReplacementVariables
=
new
Linked
HashMap
<>();
Linked
HashMap
<
String
,
JobVariable
>
updatedVariablesMap
=
new
Linked
HashMap
<>(
variablesMap
);
// replacements will include at first variables defined in the job
for
(
JobVariable
variable
:
updatedVariablesMap
.
values
())
{
...
...
@@ -759,7 +759,7 @@ public class StaxJobFactory extends JobFactory {
*/
private
Map
<
String
,
TaskVariable
>
createUnresolvedTaskVariables
(
XMLStreamReader
cursorVariables
)
throws
JobCreationException
{
HashMap
<
String
,
TaskVariable
>
unresolvedVariablesMap
=
new
LinkedHashMap
<>();
Linked
HashMap
<
String
,
TaskVariable
>
unresolvedVariablesMap
=
new
LinkedHashMap
<>();
try
{
int
eventType
;
while
(
cursorVariables
.
hasNext
())
{
...
...
@@ -806,8 +806,8 @@ public class StaxJobFactory extends JobFactory {
protected
Map
<
String
,
TaskVariable
>
replaceVariablesInTaskVariablesMap
(
Map
<
String
,
TaskVariable
>
variablesMap
,
Map
<
String
,
String
>
replacementVariables
)
throws
JobCreationException
{
HashMap
<
String
,
String
>
updatedReplacementVariables
=
new
HashMap
<>();
HashMap
<
String
,
TaskVariable
>
updatedVariablesMap
=
new
HashMap
<>(
variablesMap
);
Linked
HashMap
<
String
,
String
>
updatedReplacementVariables
=
new
Linked
HashMap
<>();
Linked
HashMap
<
String
,
TaskVariable
>
updatedVariablesMap
=
new
Linked
HashMap
<>(
variablesMap
);
// replacements will include at first variables defined in the job
for
(
TaskVariable
variable
:
updatedVariablesMap
.
values
())
{
...
...
@@ -924,9 +924,10 @@ public class StaxJobFactory extends JobFactory {
*
* @return the list of generic information as a hashMap.
*/
private
HashMap
<
String
,
String
>
getResolvedGenericInformations
(
Map
<
String
,
String
>
unresolvedGenericInformations
,
Map
<
String
,
String
>
variables
)
throws
JobCreationException
{
HashMap
<
String
,
String
>
infos
=
new
HashMap
<>();
private
LinkedHashMap
<
String
,
String
>
getResolvedGenericInformations
(
Map
<
String
,
String
>
unresolvedGenericInformations
,
Map
<
String
,
String
>
variables
)
throws
JobCreationException
{
LinkedHashMap
<
String
,
String
>
infos
=
new
LinkedHashMap
<>();
for
(
Map
.
Entry
<
String
,
String
>
unresolvedGenericInformationValue
:
unresolvedGenericInformations
.
entrySet
())
{
infos
.
put
(
unresolvedGenericInformationValue
.
getKey
(),
replace
(
unresolvedGenericInformationValue
.
getValue
(),
variables
));
...
...
@@ -1087,7 +1088,7 @@ public class StaxJobFactory extends JobFactory {
};
// To allow variable replacements on the task attributes, store them until task variables are parsed
Map
<
String
,
String
>
delayedTaskAttributes
=
new
HashMap
<>();
Map
<
String
,
String
>
delayedTaskAttributes
=
new
Linked
HashMap
<>();
int
attrLen
=
cursorTask
.
getAttributeCount
();
for
(;
i
<
attrLen
;
i
++)
{
...
...
@@ -1371,7 +1372,7 @@ public class StaxJobFactory extends JobFactory {
private
Map
<
String
,
ArrayList
<
String
>>
createDependences
(
XMLStreamReader
cursorDepends
,
Task
t
)
throws
JobCreationException
{
try
{
Map
<
String
,
ArrayList
<
String
>>
dependencies
=
new
HashMap
<>();
Map
<
String
,
ArrayList
<
String
>>
dependencies
=
new
Linked
HashMap
<>();
ArrayList
<
String
>
depends
=
new
ArrayList
<>(
0
);
int
eventType
;
...
...
@@ -2057,7 +2058,7 @@ public class StaxJobFactory extends JobFactory {
private
static
String
replace
(
String
str
,
Map
<
String
,
String
>
variables
)
throws
JobCreationException
{
// Include System Variables
Map
<
String
,
String
>
replacements
=
new
HashMap
<>();
Map
<
String
,
String
>
replacements
=
new
Linked
HashMap
<>();
for
(
Map
.
Entry
<
Object
,
Object
>
o
:
System
.
getProperties
().
entrySet
())
{
replacements
.
put
(
o
.
getKey
().
toString
(),
o
.
getValue
().
toString
());
}
...
...
scheduler/scheduler-api/src/test/java/org/ow2/proactive/scheduler/common/job/factories/TestStaxJobFactory.java
View file @
de9bfda9
...
...
@@ -85,6 +85,8 @@ public class TestStaxJobFactory {
private
static
URI
jobDescriptorTaskVariable
;
private
static
URI
jobDescriptorVariableOrder
;
private
StaxJobFactory
factory
;
@BeforeClass
...
...
@@ -119,6 +121,8 @@ public class TestStaxJobFactory {
jobDescriptorTaskVariable
=
TestStaxJobFactory
.
class
.
getResource
(
"task_variables.xml"
).
toURI
();
jobDescriptorVariableOrder
=
TestStaxJobFactory
.
class
.
getResource
(
"job_variables_order.xml"
).
toURI
();
BasicConfigurator
.
resetConfiguration
();
BasicConfigurator
.
configure
();
}
...
...
@@ -152,6 +156,16 @@ public class TestStaxJobFactory {
factory
.
createJob
(
jobDescriptorWithEmptyMetadata
);
}
@Test
public
void
testCreateJobShouldPreserveVariablesOrder
()
throws
Exception
{
Job
job
=
factory
.
createJob
(
jobDescriptorVariableOrder
);
int
index
=
1
;
for
(
String
variable
:
job
.
getVariables
().
keySet
())
{
assertEquals
(
"var_"
+
index
,
variable
);
index
++;
}
}
@Test
public
void
testCreateJobWithNoVariablesShouldReferenceGlobalVariablesAndGenericInfo
()
throws
Exception
{
factory
.
globalVariables
.
put
(
"globalVar"
,
new
JobVariable
(
"globalVar"
,
"globalValue"
));
...
...
scheduler/scheduler-api/src/test/resources/org/ow2/proactive/scheduler/common/job/factories/job_variables_order.xml
0 → 100644
View file @
de9bfda9
<?xml version="1.0" encoding="UTF-8"?>
<job
xmlns=
"urn:proactive:jobdescriptor:dev"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"urn:proactive:jobdescriptor:dev ../../../src/org/ow2/proactive/scheduler/common/xml/schemas/jobdescriptor/dev/schedulerjob.xsd"
name=
"VariablesOrder"
onTaskError=
"continueJobExecution"
priority=
"normal"
>
<variables>
<variable
name=
"var_1"
value=
"value_1"
/>
<variable
name=
"var_2"
value=
"value_2"
/>
<variable
name=
"var_3"
value=
"value_3"
/>
<variable
name=
"var_4"
value=
"value_4"
/>
<variable
name=
"var_5"
value=
"value_5"
/>
<variable
name=
"var_6"
value=
"value_6"
/>
</variables>
<description>
NoVariablesTestJob
</description>
<taskFlow>
<task
name=
"Linux_Bash_Task"
>
<description>
<![CDATA[ The simplest task, ran by a bash engine. ]]>
</description>
<scriptExecutable>
<script>
<code
language=
"bash"
>
<![CDATA[
ls -la
]]>
</code>
</script>
</scriptExecutable>
</task>
</taskFlow>
</job>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment