add debugging. increase concurrency of request queue
This commit is contained in:
parent
c284078db6
commit
11449b77a9
|
@ -1,4 +1,4 @@
|
|||
var requestQueue = new Request.Queue( { concurrent: 2, stopOnFailure: false } );
|
||||
var requestQueue = new Request.Queue( { concurrent: monitorData.length, stopOnFailure: false } );
|
||||
|
||||
function Monitor( monitorData ) {
|
||||
this.id = monitorData.id;
|
||||
|
@ -7,15 +7,18 @@ function Monitor( monitorData ) {
|
|||
this.status = null;
|
||||
this.alarmState = STATE_IDLE;
|
||||
this.lastAlarmState = STATE_IDLE;
|
||||
this.streamCmdParms = 'view=request&request=stream&connkey='+this.connKey;
|
||||
this.streamCmdParms = this.server_url+'?view=request&request=stream&connkey='+this.connKey;
|
||||
this.onclick = monitorData.onclick;
|
||||
if ( auth_hash )
|
||||
this.streamCmdParms += '&auth='+auth_hash;
|
||||
this.streamCmdTimer = null;
|
||||
|
||||
this.start = function( delay ) {
|
||||
/*
|
||||
this.zm_startup = function( delay ) {
|
||||
console.log("Starting streamwatch for " + this.connKey );
|
||||
this.streamCmdTimer = this.streamCmdQuery.delay( delay, this );
|
||||
};
|
||||
*/
|
||||
|
||||
this.setStateClass = function( element, stateClass ) {
|
||||
if ( !element.hasClass( stateClass ) ) {
|
||||
|
@ -38,7 +41,10 @@ function Monitor( monitorData ) {
|
|||
this.onFailure = function( xhr ) {
|
||||
console.log('onFailure: ' + this.connKey);
|
||||
console.log(xhr );
|
||||
if ( ! requestQueue.hasNext("cmdReq"+this.id) ) {
|
||||
console.log("Not requeuing because there is one already");
|
||||
requestQueue.addRequest( "cmdReq"+this.id, this.streamCmdReq );
|
||||
}
|
||||
if ( 0 ) {
|
||||
// Requeue, but want to wait a while.
|
||||
if ( this.streamCmdTimer )
|
||||
|
@ -47,6 +53,7 @@ function Monitor( monitorData ) {
|
|||
this.streamCmdTimer = this.streamCmdQuery.delay( streamCmdTimeout, this, true );
|
||||
requestQueue.resume();
|
||||
}
|
||||
console.log("done failure");
|
||||
};
|
||||
|
||||
this.getStreamCmdResponse = function( respObj, respText ) {
|
||||
|
@ -134,6 +141,7 @@ function Monitor( monitorData ) {
|
|||
console.log( this.connKey+": Resending" );
|
||||
this.streamCmdReq.cancel();
|
||||
}
|
||||
console.log("Starting CmdQuery for " + this.connKey );
|
||||
this.streamCmdReq.send( this.streamCmdParms+"&command="+CMD_QUERY );
|
||||
};
|
||||
|
||||
|
@ -148,6 +156,7 @@ function Monitor( monitorData ) {
|
|||
link: 'cancel'
|
||||
} );
|
||||
|
||||
console.log("queueing for " + this.id + " " + this.connKey );
|
||||
requestQueue.addRequest( "cmdReq"+this.id, this.streamCmdReq );
|
||||
}
|
||||
|
||||
|
@ -375,7 +384,7 @@ function cancel_layout(button) {
|
|||
|
||||
var monitors = new Array();
|
||||
function initPage() {
|
||||
|
||||
console.log("initPage");
|
||||
for ( var i = 0; i < monitorData.length; i++ ) {
|
||||
monitors[i] = new Monitor(monitorData[i]);
|
||||
}
|
||||
|
@ -384,7 +393,8 @@ function initPage() {
|
|||
for ( var i = 0; i < monitorData.length; i++ ) {
|
||||
var delay = Math.round( (Math.random()+0.75)*statusRefreshTimeout );
|
||||
console.log("Delay for monitor " + monitorData[i].id + " is " + delay );
|
||||
monitors[i].start(delay);
|
||||
monitors[i].streamCmdQuery.delay( delay, monitors[i] );
|
||||
//monitors[i].zm_startup(delay);
|
||||
}
|
||||
}
|
||||
// Kick everything off
|
||||
|
|
Loading…
Reference in New Issue