Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Xiaowu Zhang
slapos.core
Commits
9083228c
Commit
9083228c
authored
Aug 29, 2016
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_monitoring: correctly manage jio_storage on sync, prevent start of two sync at same time
parent
5ef80d01
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
13 deletions
+52
-13
master/bt5/slapos_monitoring/PathTemplateItem/web_page_module/gadget_monitoring_sync_js.html
...mplateItem/web_page_module/gadget_monitoring_sync_js.html
+50
-11
master/bt5/slapos_monitoring/PathTemplateItem/web_page_module/gadget_monitoring_sync_js.xml
...emplateItem/web_page_module/gadget_monitoring_sync_js.xml
+2
-2
No files found.
master/bt5/slapos_monitoring/PathTemplateItem/web_page_module/gadget_monitoring_sync_js.html
View file @
9083228c
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
gadget_klass
gadget_klass
.ready(function (g) {
.ready(function (g) {
g.props = {};
g.props = {};
g.props.jio_storage_dict = {};
return g.getDeclaredGadget('jio_gadget')
return g.getDeclaredGadget('jio_gadget')
.push(function (jio_gadget) {
.push(function (jio_gadget) {
g.props.jio_gadget = jio_gadget;
g.props.jio_gadget = jio_gadget;
...
@@ -67,9 +68,36 @@
...
@@ -67,9 +68,36 @@
return error_message;
return error_message;
}
}
function getJioGadget(gadget, hash) {
return new RSVP.Queue()
.push(function () {
if (gadget.props.jio_storage_dict.hasOwnProperty(hash)) {
return gadget.props.jio_storage_dict[hash];
} else {
return gadget.declareGadget("gadget_monitoring_jio.html",
{
scope: hash
}
)
.push(function (jio_declared_gadget) {
gadget.props.jio_storage_dict[hash] = jio_declared_gadget;
return jio_declared_gadget;
});
}
});
}
function syncStorage(gadget, storage_dict, query) {
function syncStorage(gadget, storage_dict, query) {
gadget.props.jio_gadget.createJio(storage_dict, true, query);
var hash;
return gadget.props.jio_gadget.repair()
//gadget.props.jio_gadget.createJio(storage_dict, true, query);
hash = rusha.digestFromString(storage_dict.title.replace(/\s*/g, "") +
'_' + storage_dict.sub_storage.type);
return getJioGadget(gadget, hash)
.push(function (jio_declared_gadget) {
jio_declared_gadget.createJio(storage_dict, true, query);
return jio_declared_gadget.repair();
})
.push(undefined, function (error) {
.push(undefined, function (error) {
gadget.props.error_list.push({
gadget.props.error_list.push({
storage_dict: storage_dict,
storage_dict: storage_dict,
...
@@ -82,8 +110,12 @@
...
@@ -82,8 +110,12 @@
function updateStatus(gadget, storage_dict, status) {
function updateStatus(gadget, storage_dict, status) {
var promise_list = [],
var promise_list = [],
jio_gadget,
jio_gadget,
hash,
i;
i;
return gadget.declareGadget("gadget_monitoring_jio.html")
hash = rusha.digestFromString(storage_dict.title.replace(/\s*/g, "") +
'_' + storage_dict.sub_storage.type);
return getJioGadget(gadget, hash)
.push(function (jio_declared_gadget) {
.push(function (jio_declared_gadget) {
jio_gadget = jio_declared_gadget;
jio_gadget = jio_declared_gadget;
jio_gadget.createJio(storage_dict);
jio_gadget.createJio(storage_dict);
...
@@ -210,9 +242,7 @@
...
@@ -210,9 +242,7 @@
last_sync_time
;
last_sync_time
;
return
new
RSVP
.
Queue
()
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
.
push
(
function
()
{
if
(
options
.
now
)
{
return
gadget
.
setSetting
('
sync_start_time
',
new
Date
().
getTime
());
return
gadget
.
setSetting
('
manual_sync_time
',
new
Date
().
getTime
());
}
})
})
.
push
(
function
()
{
.
push
(
function
()
{
$(".
notifyjs-wrapper
").
remove
();
$(".
notifyjs-wrapper
").
remove
();
...
@@ -226,6 +256,7 @@
...
@@ -226,6 +256,7 @@
);
);
})
})
.
push
(
function
()
{
.
push
(
function
()
{
//
Get
all
configured
credentials
return
gadget
.
props
.
login_gadget
.
getUrlDict
();
return
gadget
.
props
.
login_gadget
.
getUrlDict
();
})
})
.
push
(
undefined
,
function
()
{
.
push
(
undefined
,
function
()
{
...
@@ -270,6 +301,10 @@
...
@@ -270,6 +301,10 @@
console
.
log
("
Sync
monitoring
data
...");
console
.
log
("
Sync
monitoring
data
...");
return
RSVP
.
all
(
promise_list
);
return
RSVP
.
all
(
promise_list
);
})
})
.
push
(
undefined
,
function
(
error
)
{
console
.
log
(
error
);
return
;
})
.
push
(
function
()
{
.
push
(
function
()
{
//
Check
if
there
was
errors
and
retry
them
if
possible
//
Check
if
there
was
errors
and
retry
them
if
possible
var
error_size =
gadget.props.error_list.length,
var
error_size =
gadget.props.error_list.length,
...
@@ -298,6 +333,10 @@
...
@@ -298,6 +333,10 @@
}
}
return
RSVP
.
all
(
promise_list
);
return
RSVP
.
all
(
promise_list
);
})
})
.
push
(
undefined
,
function
(
error
)
{
console
.
log
(
error
);
return
;
})
.
push
(
function
()
{
.
push
(
function
()
{
last_sync_time =
new
Date
().
getTime
();
last_sync_time =
new
Date
().
getTime
();
return
gadget
.
setSetting
('
latest_sync_time
',
last_sync_time
);
return
gadget
.
setSetting
('
latest_sync_time
',
last_sync_time
);
...
@@ -367,13 +406,13 @@
...
@@ -367,13 +406,13 @@
gadget.props.timer =
setTimeout(function(){
gadget.props.timer =
setTimeout(function(){
return
new
RSVP
.
Queue
()
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
.
push
(
function
()
{
return
gadget
.
getSetting
('
manual_sync
_time
');
return
gadget
.
getSetting
('
sync_start
_time
');
})
})
.
push
(
function
(
manual
_timestamp
)
{
.
push
(
function
(
start
_timestamp
)
{
var
current_time =
new
Date
().
getTime
();
var
current_time =
new
Date
().
getTime
();
if
(
manual
_timestamp
!==
undefined
&&
if
(
start
_timestamp
!==
undefined
&&
current_time
-
gadget
.
props
.
timer_interval
<=
manual
_timestamp
)
{
current_time
-
gadget
.
props
.
timer_interval
<=
start
_timestamp
)
{
//
There
was
a
manual
sync
don
'
t
start
a
new
sync
again
!
//
There
was
a
recent
sync
don
'
t
start
a
new
sync
before
the
time_interval
!
return
;
return
;
}
}
return
syncAllStorage
();
return
syncAllStorage
();
...
...
master/bt5/slapos_monitoring/PathTemplateItem/web_page_module/gadget_monitoring_sync_js.xml
View file @
9083228c
...
@@ -242,7 +242,7 @@
...
@@ -242,7 +242,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
95
2.63467.50835.5744
6
</string>
</value>
<value>
<string>
95
3.32835.32275.4080
6
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -260,7 +260,7 @@
...
@@ -260,7 +260,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
147
0152500.12
</float>
<float>
147
2247230.79
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
...
...
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