~ps10gel/ubuntu/xenial/trafficserver/6.2.0

« back to all changes in this revision

Viewing changes to lib/records/P_RecDefs.h

  • Committer: Bazaar Package Importer
  • Author(s): Arno Toell
  • Date: 2011-01-13 11:49:18 UTC
  • Revision ID: james.westby@ubuntu.com-20110113114918-vu422h8dknrgkj15
Tags: upstream-2.1.5-unstable
ImportĀ upstreamĀ versionĀ 2.1.5-unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/** @file
 
2
 
 
3
  Private record declarations
 
4
 
 
5
  @section license License
 
6
 
 
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
 
14
 
 
15
      http://www.apache.org/licenses/LICENSE-2.0
 
16
 
 
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.
 
22
 */
 
23
 
 
24
#ifndef _P_REC_DEFS_H_
 
25
#define _P_REC_DEFS_H_
 
26
 
 
27
#include "ink_bool.h"
 
28
 
 
29
#include "I_RecDefs.h"
 
30
 
 
31
#define REC_CONFIG_FILE                "records.config"
 
32
#define REC_SHADOW_EXT                 ".shadow"
 
33
#define REC_RAW_STATS_FILE             "records.snap"
 
34
#define REC_PIPE_NAME                  "librecords_pipe"
 
35
 
 
36
#define REC_MESSAGE_ELE_MAGIC           0xF00DF00D
 
37
 
 
38
// This is for the internal stats and configs, as well as API stats. We currently use
 
39
// about 1600 stats + configs for the core, but we're allocating 2000 for some growth.
 
40
// TODO: if/when we switch to a new config system, we should make this run-time dynamic.
 
41
#define REC_MAX_RECORDS                 (2000 + TS_MAX_API_STATS)
 
42
 
 
43
#define REC_CONFIG_UPDATE_INTERVAL_SEC  3
 
44
#define REC_REMOTE_SYNC_INTERVAL_SEC    5
 
45
 
 
46
#define REC_RAW_STAT_SYNC_INTERVAL_SEC  5
 
47
#define REC_STAT_UPDATE_INTERVAL_SEC    10
 
48
 
 
49
//-------------------------------------------------------------------------
 
50
// Record Items
 
51
//-------------------------------------------------------------------------
 
52
 
 
53
#define REC_LOCAL_UPDATE_REQUIRED       1
 
54
#define REC_PROCESS_UPDATE_REQUIRED     (REC_LOCAL_UPDATE_REQUIRED << 1)
 
55
#define REC_UPDATE_REQUIRED             (REC_LOCAL_UPDATE_REQUIRED | REC_PROCESS_UPDATE_REQUIRED)
 
56
 
 
57
#define REC_DISK_SYNC_REQUIRED          1
 
58
#define REC_PEER_SYNC_REQUIRED          (REC_DISK_SYNC_REQUIRED << 1)
 
59
#define REC_SYNC_REQUIRED               (REC_DISK_SYNC_REQUIRED | REC_PEER_SYNC_REQUIRED)
 
60
 
 
61
enum RecEntryT
 
62
{
 
63
  RECE_NULL,
 
64
  RECE_COMMENT,
 
65
  RECE_RECORD
 
66
};
 
67
 
 
68
struct RecConfigFileEntry
 
69
{
 
70
  RecEntryT entry_type;
 
71
  char *entry;
 
72
};
 
73
 
 
74
typedef struct RecConfigCbList_t
 
75
{
 
76
  RecConfigUpdateCb update_cb;
 
77
  void *update_cookie;
 
78
  struct RecConfigCbList_t *next;
 
79
} RecConfigUpdateCbList;
 
80
 
 
81
typedef struct RecStatUpdateFuncList_t
 
82
{
 
83
  RecRawStatBlock *rsb;
 
84
  int id;
 
85
  RecStatUpdateFunc update_func;
 
86
  void *update_cookie;
 
87
  struct RecStatUpdateFuncList_t *next;
 
88
} RecStatUpdateFuncList;
 
89
 
 
90
struct RecStatMeta
 
91
{
 
92
  RecRawStat data_raw;
 
93
  RecRawStatSyncCb sync_cb;
 
94
  RecRawStatBlock *sync_rsb;
 
95
  int sync_id;
 
96
  RecPersistT persist_type;
 
97
};
 
98
 
 
99
struct RecConfigMeta
 
100
{
 
101
  unsigned char update_required;
 
102
  RecConfigUpdateCbList *update_cb_list;
 
103
  void *update_cookie;
 
104
  RecUpdateT update_type;
 
105
  RecCheckT check_type;
 
106
  char *check_expr;
 
107
  RecAccessT access_type;
 
108
};
 
109
 
 
110
struct RecRecord
 
111
{
 
112
  RecT rec_type;
 
113
  const char *name;
 
114
  RecDataT data_type;
 
115
  RecData data;
 
116
  RecData data_default;
 
117
  RecMutex lock;
 
118
  unsigned char sync_required;
 
119
  bool registered;
 
120
  union
 
121
  {
 
122
    RecStatMeta stat_meta;
 
123
    RecConfigMeta config_meta;
 
124
  };
 
125
  int order;
 
126
  int rsb_id;
 
127
};
 
128
 
 
129
// Used for cluster. TODO: Do we still need this?
 
130
struct RecRecords
 
131
{
 
132
  int num_recs;
 
133
  RecRecord *recs;
 
134
};
 
135
 
 
136
//-------------------------------------------------------------------------
 
137
// Message Items
 
138
//-------------------------------------------------------------------------
 
139
 
 
140
enum RecMessageT
 
141
{
 
142
  RECG_NULL,
 
143
  RECG_SET,
 
144
  RECG_REGISTER,
 
145
  RECG_PUSH,
 
146
  RECG_PULL_REQ,
 
147
  RECG_PULL_ACK
 
148
};
 
149
 
 
150
struct RecMessageHdr
 
151
{
 
152
  RecMessageT msg_type;
 
153
  int o_start;
 
154
  int o_write;
 
155
  int o_end;
 
156
  int entries;
 
157
  int alignment;                //needs to be 8 byte aligned
 
158
};
 
159
 
 
160
struct RecMessageEleHdr
 
161
{
 
162
  unsigned int magic;
 
163
  int o_next;
 
164
};
 
165
 
 
166
struct RecMessageItr
 
167
{
 
168
  RecMessageEleHdr *ele_hdr;
 
169
  int next;
 
170
};
 
171
 
 
172
typedef RecMessageHdr RecMessage;
 
173
 
 
174
typedef void (*RecDumpEntryCb) (RecT rec_type, void *edata, int registered, const char *name, int data_type, RecData *datum);
 
175
 
 
176
typedef int (*RecMessageRecvCb) (RecMessage * msg, RecMessageT msg_type, void *cookie);
 
177
 
 
178
#endif