Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
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
Alexandra Rogova
jio
Commits
669d28be
Commit
669d28be
authored
Aug 22, 2013
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
JIO JobRecovey enabled
parent
9eb9f121
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
8 deletions
+66
-8
src/jio/core/JIO.js
src/jio/core/JIO.js
+6
-8
src/jio/features/jobRecovery.js
src/jio/features/jobRecovery.js
+60
-0
No files found.
src/jio/core/JIO.js
View file @
669d28be
/*jslint indent: 2, maxlen: 80, nomen: true, sloppy: true, regexp: true */
/*global EventEmitter, deepClone, inherits, secureMethods, defineConstant,
exports */
/*global addBlobStorageUtilities, addClassesToStorageUtilities, enableRestAPI,
enableRestParamChecker, enableCommandMaker, enableCommandExecuter,
enableCommandTimeout, enableJobMaker, enableJobRetry, enableJobChecker,
enableJobQueue, enableJobRecoverer, enableJobExecuter, enableJobTimeout */
/*jslint indent: 2, maxlen: 80, nomen: true, sloppy: true */
/*global EventEmitter, deepClone, inherits, exports */
/*global enableRestAPI, enableRestParamChecker, enableJobMaker, enableJobRetry,
enableJobChecker, enableJobQueue, enableJobRecovery, enableJobTimeout,
enableJobExecuter */
function
JIO
(
storage_spec
,
options
)
{
JIO
.
super_
.
call
(
this
);
...
...
@@ -24,7 +22,7 @@ function JIO(storage_spec, options) {
enableJobRetry
(
that
,
shared
,
options
);
// enableJobChecker(that, shared, options);
enableJobQueue
(
that
,
shared
,
options
);
// enableJobRecoverer
(that, shared, options);
enableJobRecovery
(
that
,
shared
,
options
);
enableJobTimeout
(
that
,
shared
,
options
);
enableJobExecuter
(
that
,
shared
,
options
);
...
...
src/jio/features/jobRecovery.js
0 → 100644
View file @
669d28be
/*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true, unparam: true */
/*global setTimeout */
function
enableJobRecovery
(
jio
,
shared
,
options
)
{
// dependencies
// - JobQueue enabled and before this
// uses
// - shared.job_queue JobWorkspace
function
numberOrDefault
(
number
,
default_value
)
{
return
(
typeof
number
===
'
number
'
&&
isFinite
(
number
)
?
number
:
default_value
);
}
function
recoverJob
(
param
)
{
shared
.
emit
(
'
job
'
,
param
);
}
function
jobWaiter
(
id
,
modified
)
{
return
function
()
{
var
job
;
shared
.
job_queue
.
load
();
job
=
shared
.
job_queue
.
get
(
id
);
if
(
job
.
modified
===
modified
)
{
// job not modified, no one takes care of it
recoverJob
(
job
);
}
};
}
var
i
,
job_array
,
delay
,
deadline
;
if
(
options
.
job_management
!==
false
&&
options
.
job_recovery
!==
false
)
{
shared
.
job_queue
.
load
();
job_array
=
shared
.
job_queue
.
asArray
();
for
(
i
=
0
;
i
<
job_array
.
length
;
i
+=
1
)
{
if
(
job_array
[
i
].
state
===
'
ready
'
||
job_array
[
i
].
state
===
'
running
'
)
{
delay
=
numberOrDefault
(
job_array
[
i
].
timeout
+
10000
,
10000
);
deadline
=
new
Date
(
job_array
[
i
].
modified
).
getTime
()
+
delay
;
if
(
!
isFinite
(
delay
))
{
// 'modified' date is broken
recoverJob
(
job_array
[
i
]);
}
else
if
(
deadline
<=
Date
.
now
())
{
// deadline reached
recoverJob
(
job_array
[
i
]);
}
else
{
// deadline not reached yet
// wait until deadline is reached then check job again
setTimeout
(
jobWaiter
(
job_array
[
i
].
id
,
job_array
[
i
].
modified
),
deadline
-
delay
);
}
}
}
}
}
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