• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

P_RecDefs.h

Go to the documentation of this file.
00001 /** @file
00002 
00003   Private record declarations
00004 
00005   @section license License
00006 
00007   Licensed to the Apache Software Foundation (ASF) under one
00008   or more contributor license agreements.  See the NOTICE file
00009   distributed with this work for additional information
00010   regarding copyright ownership.  The ASF licenses this file
00011   to you under the Apache License, Version 2.0 (the
00012   "License"); you may not use this file except in compliance
00013   with the License.  You may obtain a copy of the License at
00014 
00015       http://www.apache.org/licenses/LICENSE-2.0
00016 
00017   Unless required by applicable law or agreed to in writing, software
00018   distributed under the License is distributed on an "AS IS" BASIS,
00019   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00020   See the License for the specific language governing permissions and
00021   limitations under the License.
00022  */
00023 
00024 #ifndef _P_REC_DEFS_H_
00025 #define _P_REC_DEFS_H_
00026 
00027 #include "I_RecDefs.h"
00028 
00029 #define REC_CONFIG_FILE                "records.config"
00030 #define REC_SHADOW_EXT                 ".shadow"
00031 #define REC_RAW_STATS_FILE             "records.snap"
00032 #define REC_PIPE_NAME                  "librecords_pipe"
00033 
00034 #define REC_MESSAGE_ELE_MAGIC           0xF00DF00D
00035 
00036 // This is for the internal stats and configs, as well as API stats. We currently use
00037 // about 1600 stats + configs for the core, but we're allocating 2000 for some growth.
00038 // TODO: if/when we switch to a new config system, we should make this run-time dynamic.
00039 #define REC_MAX_RECORDS                 (2000 + TS_MAX_API_STATS)
00040 
00041 #define REC_CONFIG_UPDATE_INTERVAL_MS  3000
00042 #define REC_REMOTE_SYNC_INTERVAL_MS    5000
00043 
00044 #define REC_RAW_STAT_SYNC_INTERVAL_MS  5000
00045 #define REC_STAT_UPDATE_INTERVAL_MS    10000
00046 
00047 //-------------------------------------------------------------------------
00048 // Record Items
00049 //-------------------------------------------------------------------------
00050 
00051 #define REC_LOCAL_UPDATE_REQUIRED       1
00052 #define REC_PROCESS_UPDATE_REQUIRED     (REC_LOCAL_UPDATE_REQUIRED << 1)
00053 #define REC_UPDATE_REQUIRED             (REC_LOCAL_UPDATE_REQUIRED | REC_PROCESS_UPDATE_REQUIRED)
00054 
00055 #define REC_DISK_SYNC_REQUIRED          1
00056 #define REC_PEER_SYNC_REQUIRED          (REC_DISK_SYNC_REQUIRED << 1)
00057 #define REC_INC_CONFIG_VERSION          (REC_PEER_SYNC_REQUIRED << 1)
00058 #define REC_SYNC_REQUIRED               (REC_DISK_SYNC_REQUIRED | REC_PEER_SYNC_REQUIRED)
00059 
00060 enum RecEntryT
00061 {
00062   RECE_NULL,
00063   RECE_COMMENT,
00064   RECE_RECORD
00065 };
00066 
00067 struct RecConfigFileEntry
00068 {
00069   RecEntryT entry_type;
00070   char *entry;
00071 };
00072 
00073 typedef struct RecConfigCbList_t
00074 {
00075   RecConfigUpdateCb update_cb;
00076   void *update_cookie;
00077   struct RecConfigCbList_t *next;
00078 } RecConfigUpdateCbList;
00079 
00080 typedef struct RecStatUpdateFuncList_t
00081 {
00082   RecRawStatBlock *rsb;
00083   int id;
00084   RecStatUpdateFunc update_func;
00085   void *update_cookie;
00086   struct RecStatUpdateFuncList_t *next;
00087 } RecStatUpdateFuncList;
00088 
00089 struct RecStatMeta
00090 {
00091   RecRawStat data_raw;
00092   RecRawStatSyncCb sync_cb;
00093   RecRawStatBlock *sync_rsb;
00094   int sync_id;
00095   RecPersistT persist_type;
00096 };
00097 
00098 struct RecConfigMeta
00099 {
00100   unsigned char update_required;
00101   RecConfigUpdateCbList *update_cb_list;
00102   void *update_cookie;
00103   RecUpdateT update_type;
00104   RecCheckT check_type;
00105   char *check_expr;
00106   RecAccessT access_type;
00107 };
00108 
00109 struct RecRecord
00110 {
00111   RecT rec_type;
00112   const char *name;
00113   RecDataT data_type;
00114   RecData data;
00115   RecData data_default;
00116   RecMutex lock;
00117   unsigned char sync_required;
00118   uint32_t version;
00119   bool registered;
00120   union
00121   {
00122     RecStatMeta stat_meta;
00123     RecConfigMeta config_meta;
00124   };
00125   int order;
00126   int rsb_id;
00127 };
00128 
00129 // Used for cluster. TODO: Do we still need this?
00130 struct RecRecords
00131 {
00132   int num_recs;
00133   RecRecord *recs;
00134 };
00135 
00136 //-------------------------------------------------------------------------
00137 // Message Items
00138 //-------------------------------------------------------------------------
00139 
00140 enum RecMessageT
00141 {
00142   RECG_NULL,
00143   RECG_SET,
00144   RECG_REGISTER,
00145   RECG_PUSH,
00146   RECG_PULL_REQ,
00147   RECG_PULL_ACK,
00148   RECG_RESET
00149 };
00150 
00151 struct RecMessageHdr
00152 {
00153   RecMessageT msg_type;
00154   int o_start;
00155   int o_write;
00156   int o_end;
00157   int entries;
00158   int alignment;                //needs to be 8 byte aligned
00159 };
00160 
00161 struct RecMessageEleHdr
00162 {
00163   unsigned int magic;
00164   int o_next;
00165 };
00166 
00167 struct RecMessageItr
00168 {
00169   RecMessageEleHdr *ele_hdr;
00170   int next;
00171 };
00172 
00173 typedef RecMessageHdr RecMessage;
00174 
00175 typedef void (*RecDumpEntryCb) (RecT rec_type, void *edata, int registered, const char *name, int data_type, RecData *datum);
00176 
00177 typedef int (*RecMessageRecvCb) (RecMessage * msg, RecMessageT msg_type, void *cookie);
00178 
00179 #endif

Generated by  doxygen 1.7.1