Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio-main
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
Hardik Juneja
jio-main
Commits
89403981
Commit
89403981
authored
Aug 26, 2013
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
JIO recovers only writer jobs
parent
31f0324f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
21 deletions
+23
-21
src/jio/features/jobRecovery.js
src/jio/features/jobRecovery.js
+23
-21
No files found.
src/jio/features/jobRecovery.js
View file @
89403981
/*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true, unparam: true */
/*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true, unparam: true */
/*global setTimeout */
/*global setTimeout
, methodType
*/
function
enableJobRecovery
(
jio
,
shared
,
options
)
{
function
enableJobRecovery
(
jio
,
shared
,
options
)
{
...
@@ -16,8 +16,14 @@ function enableJobRecovery(jio, shared, options) {
...
@@ -16,8 +16,14 @@ function enableJobRecovery(jio, shared, options) {
function
recoverJob
(
param
)
{
function
recoverJob
(
param
)
{
shared
.
job_queue
.
remove
(
param
.
id
);
shared
.
job_queue
.
remove
(
param
.
id
);
shared
.
job_queue
.
save
();
delete
param
.
id
;
shared
.
emit
(
'
job
'
,
param
);
if
(
methodType
(
param
.
method
)
===
'
writer
'
||
param
.
state
===
'
ready
'
||
param
.
state
===
'
running
'
||
param
.
state
===
'
waiting
'
)
{
shared
.
job_queue
.
save
();
shared
.
emit
(
'
job
'
,
param
);
}
}
}
function
jobWaiter
(
id
,
modified
)
{
function
jobWaiter
(
id
,
modified
)
{
...
@@ -45,24 +51,20 @@ function enableJobRecovery(jio, shared, options) {
...
@@ -45,24 +51,20 @@ function enableJobRecovery(jio, shared, options) {
job_array
=
shared
.
job_queue
.
asArray
();
job_array
=
shared
.
job_queue
.
asArray
();
for
(
i
=
0
;
i
<
job_array
.
length
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
job_array
.
length
;
i
+=
1
)
{
if
(
job_array
[
i
].
state
===
'
ready
'
||
delay
=
numberOrDefault
(
job_array
[
i
].
timeout
+
recovery_delay
,
job_array
[
i
].
state
===
'
running
'
||
recovery_delay
);
job_array
[
i
].
state
===
'
waiting
'
)
{
deadline
=
new
Date
(
job_array
[
i
].
modified
).
getTime
()
+
delay
;
delay
=
numberOrDefault
(
job_array
[
i
].
timeout
+
recovery_delay
,
if
(
!
isFinite
(
delay
))
{
recovery_delay
);
// 'modified' date is broken
deadline
=
new
Date
(
job_array
[
i
].
modified
).
getTime
()
+
delay
;
recoverJob
(
job_array
[
i
]);
if
(
!
isFinite
(
delay
))
{
}
else
if
(
deadline
<=
Date
.
now
())
{
// 'modified' date is broken
// deadline reached
recoverJob
(
job_array
[
i
]);
recoverJob
(
job_array
[
i
]);
}
else
if
(
deadline
<=
Date
.
now
())
{
}
else
{
// deadline reached
// deadline not reached yet
recoverJob
(
job_array
[
i
]);
// wait until deadline is reached then check job again
}
else
{
setTimeout
(
jobWaiter
(
job_array
[
i
].
id
,
job_array
[
i
].
modified
),
// deadline not reached yet
deadline
-
Date
.
now
());
// wait until deadline is reached then check job again
setTimeout
(
jobWaiter
(
job_array
[
i
].
id
,
job_array
[
i
].
modified
),
deadline
-
Date
.
now
());
}
}
}
}
}
...
...
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