File: I_RecProcess.h

package info (click to toggle)
trafficserver 9.2.5%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 53,008 kB
  • sloc: cpp: 345,484; ansic: 31,134; python: 24,200; sh: 7,271; makefile: 3,045; perl: 2,261; java: 277; pascal: 119; sql: 94; xml: 2
file content (156 lines) | stat: -rw-r--r-- 6,754 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/** @file

  Public RecProcess declarations

  @section license License

  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements.  See the NOTICE file
  distributed with this work for additional information
  regarding copyright ownership.  The ASF licenses this file
  to you under the Apache License, Version 2.0 (the
  "License"); you may not use this file except in compliance
  with the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
 */

#pragma once

#include "I_RecCore.h"
#include "I_EventSystem.h"

//-------------------------------------------------------------------------
// Initialization/Starting
//-------------------------------------------------------------------------
int RecProcessInit(RecModeT mode_type, Diags *diags = nullptr);
int RecProcessInitMessage(RecModeT mode_type);
int RecProcessStart();

//-------------------------------------------------------------------------
// Setters for manipulating internal sleep intervals
//-------------------------------------------------------------------------
void RecProcess_set_raw_stat_sync_interval_ms(int ms);
void RecProcess_set_config_update_interval_ms(int ms);
void RecProcess_set_remote_sync_interval_ms(int ms);

//-------------------------------------------------------------------------
// RawStat Registration
//-------------------------------------------------------------------------
RecRawStatBlock *RecAllocateRawStatBlock(int num_stats);

int _RecRegisterRawStat(RecRawStatBlock *rsb, RecT rec_type, const char *name, RecDataT data_type, RecPersistT persist_type, int id,
                        RecRawStatSyncCb sync_cb);
#define RecRegisterRawStat(rsb, rec_type, name, data_type, persist_type, id, sync_cb) \
  _RecRegisterRawStat((rsb), (rec_type), (name), (data_type), REC_PERSISTENCE_TYPE(persist_type), (id), (sync_cb))

// RecRawStatRange* RecAllocateRawStatRange (int num_buckets);

// int RecRegisterRawStatRange (RecRawStatRange *rsr,
//                           RecT rec_type,
//                           char *name,
//                           RecPersistT persist_type,
//                           int id,
//                           RecInt min,
//                           RecInt max);

//-------------------------------------------------------------------------
// Predefined RawStat Callbacks
//-------------------------------------------------------------------------
int RecRawStatSyncSum(const char *name, RecDataT data_type, RecData *data, RecRawStatBlock *rsb, int id);
int RecRawStatSyncCount(const char *name, RecDataT data_type, RecData *data, RecRawStatBlock *rsb, int id);
int RecRawStatSyncAvg(const char *name, RecDataT data_type, RecData *data, RecRawStatBlock *rsb, int id);
int RecRawStatSyncHrTimeAvg(const char *name, RecDataT data_type, RecData *data, RecRawStatBlock *rsb, int id);
int RecRawStatSyncIntMsecsToFloatSeconds(const char *name, RecDataT data_type, RecData *data, RecRawStatBlock *rsb, int id);

int RecRegisterRawStatSyncCb(const char *name, RecRawStatSyncCb sync_cb, RecRawStatBlock *rsb, int id);
int RecRawStatUpdateSum(RecRawStatBlock *rsb, int id);

//-------------------------------------------------------------------------
// RawStat Setting/Getting
//-------------------------------------------------------------------------

// Note: The following RecIncrRawStatXXX calls are fast and don't
// require any ink_atomic_xxx64()'s to be executed.  Use these RawStat
// functions over other RawStat functions whenever possible.
inline int RecIncrRawStat(RecRawStatBlock *rsb, EThread *ethread, int id, int64_t incr = 1);
inline int RecIncrRawStatSum(RecRawStatBlock *rsb, EThread *ethread, int id, int64_t incr = 1);
inline int RecIncrRawStatCount(RecRawStatBlock *rsb, EThread *ethread, int id, int64_t incr = 1);

int RecSetRawStatSum(RecRawStatBlock *rsb, int id, int64_t data);
int RecSetRawStatCount(RecRawStatBlock *rsb, int id, int64_t data);

int RecGetRawStatSum(RecRawStatBlock *rsb, int id, int64_t *data);
int RecGetRawStatCount(RecRawStatBlock *rsb, int id, int64_t *data);

//-------------------------------------------------------------------------
// Global RawStat Items (e.g. same as above, but no thread-local behavior)
//-------------------------------------------------------------------------
int RecIncrGlobalRawStat(RecRawStatBlock *rsb, int id, int64_t incr = 1);
int RecIncrGlobalRawStatSum(RecRawStatBlock *rsb, int id, int64_t incr = 1);
int RecIncrGlobalRawStatCount(RecRawStatBlock *rsb, int id, int64_t incr = 1);

int RecSetGlobalRawStatSum(RecRawStatBlock *rsb, int id, int64_t data);
int RecSetGlobalRawStatCount(RecRawStatBlock *rsb, int id, int64_t data);

int RecGetGlobalRawStatSum(RecRawStatBlock *rsb, int id, int64_t *data);
int RecGetGlobalRawStatCount(RecRawStatBlock *rsb, int id, int64_t *data);

RecRawStat *RecGetGlobalRawStatPtr(RecRawStatBlock *rsb, int id);
int64_t *RecGetGlobalRawStatSumPtr(RecRawStatBlock *rsb, int id);
int64_t *RecGetGlobalRawStatCountPtr(RecRawStatBlock *rsb, int id);

//-------------------------------------------------------------------------
// RecIncrRawStatXXX
//-------------------------------------------------------------------------
// inlined functions that are used very frequently.
// FIXME: move it to Inline.cc
inline RecRawStat *
raw_stat_get_tlp(RecRawStatBlock *rsb, int id, EThread *ethread)
{
  ink_assert((id >= 0) && (id < rsb->max_stats));
  if (ethread == nullptr) {
    ethread = this_ethread();
  }
  return (((RecRawStat *)((char *)(ethread) + rsb->ethr_stat_offset)) + id);
}

inline int
RecIncrRawStat(RecRawStatBlock *rsb, EThread *ethread, int id, int64_t incr)
{
  RecRawStat *tlp = raw_stat_get_tlp(rsb, id, ethread);
  tlp->sum += incr;
  tlp->count += 1;
  return REC_ERR_OKAY;
}

inline int
RecDecrRawStat(RecRawStatBlock *rsb, EThread *ethread, int id, int64_t decr)
{
  RecRawStat *tlp = raw_stat_get_tlp(rsb, id, ethread);
  tlp->sum -= decr;
  tlp->count += 1;
  return REC_ERR_OKAY;
}

inline int
RecIncrRawStatSum(RecRawStatBlock *rsb, EThread *ethread, int id, int64_t incr)
{
  RecRawStat *tlp = raw_stat_get_tlp(rsb, id, ethread);
  tlp->sum += incr;
  return REC_ERR_OKAY;
}

inline int
RecIncrRawStatCount(RecRawStatBlock *rsb, EThread *ethread, int id, int64_t incr)
{
  RecRawStat *tlp = raw_stat_get_tlp(rsb, id, ethread);
  tlp->count += incr;
  return REC_ERR_OKAY;
}