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

I_RecDefs.h

Go to the documentation of this file.
00001 /** @file
00002 
00003   Public Rec defines and types
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 _I_REC_DEFS_H_
00025 #define _I_REC_DEFS_H_
00026 
00027 #include "Compatability.h"
00028 #include "ink_mutex.h"
00029 #include "ink_rwlock.h"
00030 #include "I_RecMutex.h"
00031 
00032 #define STAT_PROCESSOR
00033 
00034 
00035 //-------------------------------------------------------------------------
00036 // Error Values
00037 //-------------------------------------------------------------------------
00038 enum RecErrT
00039 {
00040   REC_ERR_FAIL = -1,
00041   REC_ERR_OKAY = 0
00042 };
00043 
00044 
00045 //-------------------------------------------------------------------------
00046 // Types
00047 //-------------------------------------------------------------------------
00048 #define RecStringNull NULL
00049 
00050 typedef int64_t RecInt;
00051 typedef float RecFloat;
00052 typedef char *RecString;
00053 typedef const char *RecStringConst;
00054 typedef int64_t RecCounter;
00055 typedef int8_t RecByte;
00056 typedef bool RecBool;
00057 
00058 enum RecT
00059 {
00060   RECT_NULL     = 0x00,
00061   RECT_CONFIG   = 0x01,
00062   RECT_PROCESS  = 0x02,
00063   RECT_NODE     = 0x04,
00064   RECT_CLUSTER  = 0x08,
00065   RECT_LOCAL    = 0x10,
00066   RECT_PLUGIN   = 0x20,
00067   RECT_ALL      = 0x3F
00068 };
00069 
00070 enum RecDataT
00071 {
00072   RECD_NULL = 0,
00073   RECD_INT,
00074   RECD_FLOAT,
00075   RECD_STRING,
00076   RECD_COUNTER,
00077 
00078 #if defined(STAT_PROCESSOR)
00079   RECD_CONST,               // Added for the StatProcessor, store as RECD_FLOAT
00080   RECD_FX,                  // Added for the StatProcessor, store as RECD_INT
00081 #endif
00082   RECD_MAX
00083 };
00084 
00085 enum RecPersistT
00086 {
00087   RECP_NULL,
00088   RECP_PERSISTENT,
00089   RECP_NON_PERSISTENT
00090 };
00091 
00092 // RECP_NULL should never be used by callers of RecRegisterStat*(). You have to decide
00093 // whether to persist stats or not. The template goop below make sure that passing RECP_NULL
00094 // is a very ugle compile-time error.
00095 
00096 namespace rec {
00097 namespace detail {
00098 template <RecPersistT>
00099 struct is_valid_persistence;
00100 
00101 template<>
00102 struct is_valid_persistence<RECP_PERSISTENT>
00103 {
00104   static const RecPersistT value = RECP_PERSISTENT;
00105 };
00106 
00107 template<>
00108 struct is_valid_persistence<RECP_NON_PERSISTENT>
00109 {
00110   static const RecPersistT value = RECP_NON_PERSISTENT;
00111 };
00112 
00113 }}
00114 
00115 #define REC_PERSISTENCE_TYPE(P) rec::detail::is_valid_persistence<P>::value
00116 
00117 enum RecUpdateT
00118 {
00119   RECU_NULL,                    // default: don't know the behavior
00120   RECU_DYNAMIC,                 // config can be updated dynamically w/ traffic_line -x
00121   RECU_RESTART_TS,              // config requires TS to be restarted to take effect
00122   RECU_RESTART_TM,              // config requires TM/TS to be restarted to take effect
00123   RECU_RESTART_TC               // config requires TC/TM/TS to be restarted to take effect
00124 };
00125 
00126 enum RecCheckT
00127 {
00128   RECC_NULL,                    // default: no check type defined
00129   RECC_STR,                     // config is a string
00130   RECC_INT,                     // config is an integer with a range
00131   RECC_IP                       // config is an ip address
00132 };
00133 
00134 enum RecModeT
00135 {
00136   RECM_NULL,
00137   RECM_CLIENT,
00138   RECM_SERVER,
00139   RECM_STAND_ALONE
00140 };
00141 
00142 enum RecAccessT
00143 {
00144   RECA_NULL,
00145   RECA_NO_ACCESS,
00146   RECA_READ_ONLY
00147 };
00148 
00149 
00150 //-------------------------------------------------------------------------
00151 // Data Union
00152 //-------------------------------------------------------------------------
00153 union RecData
00154 {
00155   RecInt rec_int;
00156   RecFloat rec_float;
00157   RecString rec_string;
00158   RecCounter rec_counter;
00159 };
00160 
00161 
00162 //-------------------------------------------------------------------------
00163 // RawStat Structures
00164 //-------------------------------------------------------------------------
00165 struct RecRawStat
00166 {
00167   int64_t sum;
00168   int64_t count;
00169   // XXX - these will waist some space because they are only needed for the globals
00170   // this is a fix for bug TS-162, so I am trying to do as few code changes as
00171   // possible, this should be revisted -bcall
00172   int64_t last_sum; // value from the last global sync
00173   int64_t last_count; // value from the last global sync
00174   uint32_t version;
00175 };
00176 
00177 
00178 // WARNING!  It's advised that developers do not modify the contents of
00179 // the RecRawStatBlock.  ^_^
00180 struct RecRawStatBlock
00181 {
00182   off_t ethr_stat_offset;   // thread local raw-stat storage
00183   RecRawStat **global;      // global raw-stat storage (ptr to RecRecord)
00184   int num_stats;            // number of stats in this block
00185   int max_stats;            // maximum number of stats for this block
00186   ink_mutex mutex;
00187 };
00188 
00189 
00190 //-------------------------------------------------------------------------
00191 // RecCore Callback Types
00192 //-------------------------------------------------------------------------
00193 typedef int (*RecConfigUpdateCb) (const char *name, RecDataT data_type, RecData data, void *cookie);
00194 typedef int (*RecStatUpdateFunc) (const char *name, RecDataT data_type, RecData * data, RecRawStatBlock * rsb, int id, void *cookie);
00195 typedef int (*RecRawStatSyncCb) (const char *name, RecDataT data_type, RecData * data, RecRawStatBlock * rsb, int id);
00196 
00197 
00198 //-------------------------------------------------------------------------
00199 // RecTree Defines
00200 //-------------------------------------------------------------------------
00201 #define REC_VAR_NAME_DELIMITOR '.'
00202 #define REC_VAR_NAME_WILDCARD  '*'
00203 
00204 #endif

Generated by  doxygen 1.7.1