Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
preetwinder
jio
Commits
d73a4045
Commit
d73a4045
authored
Aug 26, 2013
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jobChecker upgraded to manage job updates
parent
569e96ea
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
9 deletions
+76
-9
src/jio/features/jobChecker.js
src/jio/features/jobChecker.js
+76
-9
No files found.
src/jio/features/jobChecker.js
View file @
d73a4045
/*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true, unparam: true */
/*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true, unparam: true */
/*global arrayInsert, indexOf, deepClone */
/*global arrayInsert, indexOf, deepClone
, defaults
*/
// creates
// creates
// - some defaults job rule actions
// - some defaults job rule actions
...
@@ -7,14 +7,43 @@
...
@@ -7,14 +7,43 @@
function
enableJobChecker
(
jio
,
shared
,
options
)
{
function
enableJobChecker
(
jio
,
shared
,
options
)
{
// dependencies
// dependencies
// - shared.job
_queue JobWorkspace
// - shared.job
s Object Array
// creates
// creates
// - shared.job_rules Array
// - shared.job_rules Array
// uses 'job' events
// uses 'job' events
shared
.
job_check_method_names
=
[
undefined
,
"
ok
"
,
"
wait
"
,
"
update
"
,
"
deny
"
];
var
i
;
shared
.
job_rule_action_names
=
[
undefined
,
"
ok
"
,
"
wait
"
,
"
update
"
,
"
deny
"
];
shared
.
job_rule_actions
=
{
wait
:
function
(
original_job
,
new_job
)
{
// XXX
return
;
},
update
:
function
(
original_job
,
new_job
)
{
if
(
!
new_job
.
deferred
)
{
// promise associated to the job
new_job
.
state
=
'
done
'
;
shared
.
emit
(
'
jobDone
'
,
new_job
);
}
else
{
if
(
!
original_job
.
deferred
)
{
original_job
.
deferred
=
new_job
.
deferred
;
}
else
{
original_job
.
deferred
.
promise
().
done
(
new_job
.
command
.
resolve
).
fail
(
new_job
.
command
.
reject
);
}
}
new_job
.
state
=
'
running
'
;
},
deny
:
function
(
original_job
,
new_job
)
{
// XXX
return
;
}
};
function
addJobRule
(
job_rule
)
{
function
addJobRule
(
job_rule
)
{
var
i
,
old_position
,
before_position
,
after_position
;
var
i
,
old_position
,
before_position
,
after_position
;
...
@@ -37,7 +66,7 @@ function enableJobChecker(jio, shared, options) {
...
@@ -37,7 +66,7 @@ function enableJobChecker(jio, shared, options) {
// wrong conditions
// wrong conditions
return
;
return
;
}
}
if
(
indexOf
(
job_rule
.
action
,
shared
.
job_
check_method
_names
)
===
-
1
)
{
if
(
indexOf
(
job_rule
.
action
,
shared
.
job_
rule_action
_names
)
===
-
1
)
{
// wrong action
// wrong action
return
;
return
;
}
}
...
@@ -84,6 +113,48 @@ function enableJobChecker(jio, shared, options) {
...
@@ -84,6 +113,48 @@ function enableJobChecker(jio, shared, options) {
}
}
}
}
function
jobsRespectConditions
(
original_job
,
new_job
,
conditions
)
{
var
j
;
// browsing conditions
for
(
j
=
0
;
j
<
conditions
.
length
;
j
+=
1
)
{
if
(
defaults
.
job_rule_conditions
[
conditions
[
j
]])
{
if
(
!
defaults
.
job_rule_conditions
[
conditions
[
j
]](
original_job
,
new_job
)
)
{
return
false
;
}
}
}
return
true
;
}
function
checkJob
(
job
)
{
var
i
,
j
;
if
(
job
.
state
===
'
ready
'
)
{
// browsing rules
for
(
i
=
0
;
i
<
shared
.
job_rules
.
length
;
i
+=
1
)
{
// browsing jobs
for
(
j
=
0
;
j
<
shared
.
jobs
.
length
;
j
+=
1
)
{
if
(
shared
.
jobs
[
j
]
!==
job
)
{
if
(
jobsRespectConditions
(
shared
.
jobs
[
j
],
job
,
shared
.
job_rules
[
i
].
conditions
)
)
{
shared
.
job_rule_actions
[
shared
.
job_rules
[
i
].
action
](
shared
.
jobs
[
j
],
job
);
return
;
}
}
}
}
}
}
if
(
options
.
job_management
!==
false
)
{
if
(
options
.
job_management
!==
false
)
{
shared
.
job_rules
=
[{
shared
.
job_rules
=
[{
...
@@ -115,17 +186,13 @@ function enableJobChecker(jio, shared, options) {
...
@@ -115,17 +186,13 @@ function enableJobChecker(jio, shared, options) {
"
action
"
:
"
wait
"
"
action
"
:
"
wait
"
}];
}];
var
i
;
if
(
Array
.
isArray
(
options
.
job_rules
))
{
if
(
Array
.
isArray
(
options
.
job_rules
))
{
for
(
i
=
0
;
i
<
options
.
job_rules
.
length
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
options
.
job_rules
.
length
;
i
+=
1
)
{
addJobRule
(
deepClone
(
options
.
job_rules
[
i
]));
addJobRule
(
deepClone
(
options
.
job_rules
[
i
]));
}
}
}
}
shared
.
on
(
'
job
'
,
function
(
param
)
{
shared
.
on
(
'
job
'
,
checkJob
);
// XXX
return
;
});
}
}
...
...
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