3
A brief file description
5
@section license License
7
Licensed to the Apache Software Foundation (ASF) under one
8
or more contributor license agreements. See the NOTICE file
9
distributed with this work for additional information
10
regarding copyright ownership. The ASF licenses this file
11
to you under the Apache License, Version 2.0 (the
12
"License"); you may not use this file except in compliance
13
with the License. You may obtain a copy of the License at
15
http://www.apache.org/licenses/LICENSE-2.0
17
Unless required by applicable law or agreed to in writing, software
18
distributed under the License is distributed on an "AS IS" BASIS,
19
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
See the License for the specific language governing permissions and
21
limitations under the License.
24
/***************************************/
25
/****************************************************************************
27
* StatType.h - Functions for computing node and cluster stat
31
****************************************************************************/
37
#include "Main.h" // Debug()
38
#include "WebMgmtUtils.h"
40
#define BYTES_TO_MBIT_SCALE (8/1000000.0)
42
#if defined MODULARIZED
45
#define StatDataT RecDataT
46
#define StatFloat RecFloat
47
#define StatInt RecInt
48
#define StatCounter RecCounter
49
#define StatString RecString
51
#define STAT_INT RECD_INT
52
#define STAT_FLOAT RECD_FLOAT
53
#define STAT_STRING RECD_STRING
54
#define STAT_COUNTER RECD_COUNTER
55
#define STAT_CONST RECD_STAT_CONST
56
#define STAT_FX RECD_STAT_FX
58
/* Structs used in Average Statistics calculations */
59
struct StatFloatSamples
61
ink_hrtime previous_time;
62
ink_hrtime current_time;
63
StatFloat previous_value;
64
StatFloat current_value;
66
StatFloat diff_value()
68
return (current_value - previous_value);
70
ink_hrtime diff_time()
72
return (current_time - previous_time);
79
#define ERROR_VALUE -9999.0
80
#define StatDataT MgmtType
81
#define StatFloat MgmtFloat
82
#define StatInt MgmtInt
83
#define StatCounter MgmtIntCounter
84
#define StatString MgmtString
86
#define STAT_INT INK_INT
87
#define STAT_FLOAT INK_FLOAT
88
#define STAT_STRING INK_STRING
89
#define STAT_COUNTER INK_COUNTER
90
#define STAT_CONST INK_STAT_CONST
91
#define STAT_FX INK_STAT_FX
93
#define StatFloatSamples StatTwoFloatSamples
96
// Urgly workaround -- no optimization in HPUX
101
#define MODULE "StatPro" // Statistics processor debug tag
102
#define MODULE_INIT "StatProInit" // Statistics processor debug tag
104
/***************************************************************
106
* a statistics expression token can either be a binary operator,
107
* name '+', '-', '*', '/', or parenthesis '(', ')' or a TS variable.
108
* In the former case, the arithSymbol stores the operator or
109
* paranthesis; otherwise arithSymbol is '/0';
110
***************************************************************/
118
StatDataT m_token_type;
119
StatFloat m_token_value;
120
StatFloat m_token_value_max;
121
StatFloat m_token_value_min;
122
StatFloatSamples *m_token_value_delta;
127
void assignTokenName(const char *);
128
bool assignTokenType();
129
void print(const char *);
131
void copy(const StatExprToken &);
133
LINK(StatExprToken, link);
135
inline ~ StatExprToken()
141
bool statVarSet(StatFloat);
147
* simply a list of StatExprToken.
155
inline ~ StatExprList()
161
void enqueue(StatExprToken *);
162
void push(StatExprToken *);
163
StatExprToken *dequeue();
164
StatExprToken *pop();
165
StatExprToken *top();
166
StatExprToken *first();
167
StatExprToken *next(StatExprToken *);
169
void print(const char *);
174
Queue<StatExprToken> m_tokenList;
177
/***************************************************************
179
* Each entry in the statistics XML file is represented by a
181
***************************************************************/
189
char *m_expr_string; /* for debugging using only */
190
StatExprToken *m_node_dest;
191
StatExprToken *m_cluster_dest;
192
StatExprList *m_expression;
193
StatExprList *m_postfix;
194
ink_hrtime m_last_update;
195
ink_hrtime m_current_time;
196
ink_hrtime m_update_interval;
197
StatFloat m_stats_max;
198
StatFloat m_stats_min;
200
LINK(StatObject, link);
204
StatObject(unsigned);
205
inline ~ StatObject()
210
void assignDst(const char *, bool, bool);
211
void assignExpr(const char *);
213
StatExprToken *StatBinaryEval(StatExprToken *, char, StatExprToken *, bool cluster = false);
214
StatFloat NodeStatEval(bool cluster);
215
StatFloat ClusterStatEval();
216
void setTokenValue(StatExprToken *, bool cluster = false);
220
void infix2postfix();
226
* simply a list of StatObject.
235
inline ~ StatObjectList()
240
void enqueue(StatObject * object);
242
StatObject *next(StatObject * current);
243
void print(const char *prefix = "");
244
short Eval(); // return the number of statistics object processed
250
Queue<StatObject> m_statList;