Trying to fix a state maintenance issue.

This commit is contained in:
Seth Hall 2013-04-11 09:42:46 -04:00
parent 94f39fee2a
commit a615601269
2 changed files with 19 additions and 15 deletions

View file

@ -142,12 +142,12 @@ type Thresholding: record {
threshold_series_index: count &default=0; threshold_series_index: count &default=0;
}; };
# Internal use only. For tracking thresholds per measurement and key.
global threshold_tracker: table[string] of table[Key] of Thresholding &optional;
redef record Measurement += { redef record Measurement += {
# Internal use only (mostly for cluster coherency). # Internal use only (mostly for cluster coherency).
id: string &optional; id: string &optional;
# Internal use only. For tracking tresholds per key.
threshold_tracker: table[Key] of Thresholding &optional;
}; };
# Store of measurements indexed on the measurement id. # Store of measurements indexed on the measurement id.
@ -249,6 +249,7 @@ function reset(m: Measurement)
delete result_store[m$id]; delete result_store[m$id];
result_store[m$id] = table(); result_store[m$id] = table();
threshold_tracker[m$id] = table();
} }
function create(m: Measurement) function create(m: Measurement)
@ -260,8 +261,7 @@ function create(m: Measurement)
if ( ! m?$id ) if ( ! m?$id )
m$id=unique_id(""); m$id=unique_id("");
local tmp: table[Key] of Thresholding = table(); threshold_tracker[m$id] = table();
m$threshold_tracker = tmp;
measurement_store[m$id] = m; measurement_store[m$id] = m;
for ( reducer in m$reducers ) for ( reducer in m$reducers )
@ -322,12 +322,6 @@ function check_thresholds(m: Measurement, key: Key, result: Result, modify_pct:
if ( ! (m?$threshold || m?$threshold_series) ) if ( ! (m?$threshold || m?$threshold_series) )
return F; return F;
if ( key !in m$threshold_tracker )
{
local tmp: Thresholding;
m$threshold_tracker[key] = tmp;
}
# Add in the extra ResultVals to make threshold_vals easier to write. # Add in the extra ResultVals to make threshold_vals easier to write.
if ( |m$reducers| != |result| ) if ( |m$reducers| != |result| )
{ {
@ -343,7 +337,17 @@ function check_thresholds(m: Measurement, key: Key, result: Result, modify_pct:
if ( modify_pct < 1.0 && modify_pct > 0.0 ) if ( modify_pct < 1.0 && modify_pct > 0.0 )
watch = double_to_count(floor(watch/modify_pct)); watch = double_to_count(floor(watch/modify_pct));
local tt = m$threshold_tracker[key]; if ( m$id !in threshold_tracker )
threshold_tracker[m$id] = table();
local t_tracker = threshold_tracker[m$id];
if ( key !in t_tracker )
{
local ttmp: Thresholding;
t_tracker[key] = ttmp;
}
local tt = threshold_tracker[m$id][key];
if ( m?$threshold && ! tt$is_threshold_crossed && watch >= m$threshold ) if ( m?$threshold && ! tt$is_threshold_crossed && watch >= m$threshold )
{ {
# Value crossed the threshold. # Value crossed the threshold.
@ -379,7 +383,7 @@ function threshold_crossed(m: Measurement, key: Key, result: Result)
} }
m$threshold_crossed(key, result); m$threshold_crossed(key, result);
local tt = m$threshold_tracker[key]; local tt = threshold_tracker[m$id][key];
tt$is_threshold_crossed = T; tt$is_threshold_crossed = T;
# Bump up to the next threshold series index if a threshold series is being used. # Bump up to the next threshold series index if a threshold series is being used.

View file

@ -21,14 +21,14 @@ export {
## Returns: An opaque queue record. ## Returns: An opaque queue record.
global init: function(s: Settings): Queue; global init: function(s: Settings): Queue;
## Push a string onto the top of a queue. ## Put a string onto the beginning of a queue.
## ##
## q: The queue to put the value into. ## q: The queue to put the value into.
## ##
## val: The value to insert into the queue. ## val: The value to insert into the queue.
global put: function(q: Queue, val: any); global put: function(q: Queue, val: any);
## Pop a string from the bottom of a queue. ## Get a string from the end of a queue.
## ##
## q: The queue to get the string from. ## q: The queue to get the string from.
## ##