xrootd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
XrdOfsEvs.hh
Go to the documentation of this file.
1 #ifndef __XRDOFSEVS_H__
2 #define __XRDOFSEVS_H__
3 /******************************************************************************/
4 /* */
5 /* X r d O f s E v s . h h */
6 /* */
7 /* (c) 2005 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* All Rights Reserved */
9 /* Produced by Andrew Hanushevsky for Stanford University under contract */
10 /* DE-AC02-76-SFO0515 with the Department of Energy */
11 /* */
12 /* This file is part of the XRootD software suite. */
13 /* */
14 /* XRootD is free software: you can redistribute it and/or modify it under */
15 /* the terms of the GNU Lesser General Public License as published by the */
16 /* Free Software Foundation, either version 3 of the License, or (at your */
17 /* option) any later version. */
18 /* */
19 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22 /* License for more details. */
23 /* */
24 /* You should have received a copy of the GNU Lesser General Public License */
25 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27 /* */
28 /* The copyright holder's institutional names and contributor's names may not */
29 /* be used to endorse or promote products derived from this software without */
30 /* specific prior written permission of the institution or contributor. */
31 /* Based on code developed by Derek Feichtinger, CERN. */
32 /******************************************************************************/
33 
34 #include <strings.h>
35 #include "XrdSys/XrdSysPthread.hh"
36 
37 class XrdOfsEvsMsg;
38 class XrdOucEnv;
39 class XrdOucProg;
40 class XrdSysError;
41 
42 /******************************************************************************/
43 /* X r d O f s E v s I n f o */
44 /******************************************************************************/
45 
47 {
48 public:
49 
51 
52 inline long long FSize() {return theFSize;}
53 
54 inline mode_t FMode() {return theFMode;}
55 
56 inline void Set(evArg aNum, const char *aVal) {Arg[aNum] = aVal;}
57 
58 inline const char *Val(evArg aNum) {return Arg[aNum];}
59 
60  XrdOfsEvsInfo(const char *tid,
61  const char *lfn1, const char *cgi1="", XrdOucEnv *env1=0,
62  mode_t mode=0, long long fsize=0,
63  const char *lfn2="$LFN2", const char *cgi2="", XrdOucEnv *env2=0)
64  {Arg[evTID] = tid;
65  Arg[evLFN1] = lfn1;
66  Arg[evCGI1] = (cgi1 ? cgi1 : ""); Env1 = env1;
67  Arg[evLFN2] = (lfn2 ? lfn2 : "$LFN2");
68  Arg[evCGI2] = (cgi2 ? cgi2 : ""); Env2 = env2;
69  theFMode = mode; theFSize = fsize;
70  }
71 
73 
74 private:
75 
76 const char *Arg[evARGS];
79 long long theFSize;
80 mode_t theFMode;
81 };
82 
83 /******************************************************************************/
84 /* X r d O f s E v s F o r m a t */
85 /******************************************************************************/
86 
88 {
89 public:
90 
91 enum evFlags {Null = 0, freeFmt = 1, cvtMode = 2, cvtFSize = 4};
92 
93 const char *Format;
96 
97  int SNP(XrdOfsEvsInfo &Info, char *buff, int blen)
98  {return snprintf(buff,blen,Format, Info.Val(Args[0]),
99  Info.Val(Args[1]), Info.Val(Args[2]),
100  Info.Val(Args[3]), Info.Val(Args[4]),
101  Info.Val(Args[5]), Info.Val(Args[6]));
102  }
103 
104  void Def(evFlags theFlags, const char *Fmt, ...);
105 
106  void Set(evFlags theFlags, const char *Fmt, int *fullArgs)
107  {if (Format && Flags & freeFmt) free((char *)Format);
108  Format = Fmt; Flags = theFlags;
109  memcpy(Args, fullArgs, sizeof(Args));
110  }
111 
114 };
115 
116 /******************************************************************************/
117 /* X r d O f s E v s */
118 /******************************************************************************/
119 
121 {
122 public:
123 
124 enum Event {All = 0x7fffff00, None = 0x00000000,
125  Chmod = 0x00000100, Closer = 0x00000201,
126  Closew = 0x00000402, Close = 0x00000600,
127  Create = 0x00000803, Fwrite = 0x00001004,
128  Mkdir = 0x00002005, Mv = 0x00004006,
129  Openr = 0x00008007, Openw = 0x00010008,
130  Open = 0x00018000, Rm = 0x00020009,
131  Rmdir = 0x0004000a, Trunc = 0x0008000b,
132  nCount = 12,
133  Mask = 0X000000ff, enMask = 0x7fffff00
134  };
135 
136 static const int minMsgSize = 1360; // (16+320+1024)
137 static const int maxMsgSize = 2384; // (16+320+1024+1024);
138 
139 int Enabled(Event theEvents) {return theEvents & enEvents;}
140 
141 int maxSmsg() {return maxMin;}
142 int maxLmsg() {return maxMax;}
143 
144 void Notify(Event eNum, XrdOfsEvsInfo &Info);
145 
146 static int Parse(XrdSysError &Eroute, Event eNum, char *mText);
147 
148 const char *Prog() {return theTarget;}
149 
150 void sendEvents(void);
151 
152 int Start(XrdSysError *eobj);
153 
154  XrdOfsEvs(Event theEvents, const char *Target, int minq=90, int maxq=10);
155  ~XrdOfsEvs();
156 
157 private:
158 const char *eName(int eNum);
159 int Feed(const char *data, int dlen);
160 XrdOfsEvsMsg *getMsg(int bigmsg);
161 void retMsg(XrdOfsEvsMsg *tp);
162 
164 
165 pthread_t tid;
166 char *theTarget;
172 XrdOfsEvsMsg *msgFirst;
173 XrdOfsEvsMsg *msgLast;
175 XrdOfsEvsMsg *msgFreeMax;
176 XrdOfsEvsMsg *msgFreeMin;
177 int endIT;
178 int msgFD;
179 int numMax;
180 int maxMax;
181 int numMin;
182 int maxMin;
183 };
184 #endif
Definition: XrdOfsEvs.hh:125
int Feed(const char *data, int dlen)
XrdOfsEvsMsg * msgLast
Definition: XrdOfsEvs.hh:173
XrdOfsEvs(Event theEvents, const char *Target, int minq=90, int maxq=10)
Definition: XrdOfsEvs.hh:124
Definition: XrdOfsEvs.hh:133
XrdOucProg * theProg
Definition: XrdOfsEvs.hh:169
evFlags
Definition: XrdOfsEvs.hh:91
XrdOfsEvsInfo(const char *tid, const char *lfn1, const char *cgi1="", XrdOucEnv *env1=0, mode_t mode=0, long long fsize=0, const char *lfn2="$LFN2", const char *cgi2="", XrdOucEnv *env2=0)
Definition: XrdOfsEvs.hh:60
mode_t FMode()
Definition: XrdOfsEvs.hh:54
XrdSysSemaphore qSem
Definition: XrdOfsEvs.hh:171
XrdOfsEvsMsg * msgFreeMax
Definition: XrdOfsEvs.hh:175
Definition: XrdOfsEvs.hh:50
Definition: XrdOfsEvs.hh:120
static const int minMsgSize
Definition: XrdOfsEvs.hh:136
const char * eName(int eNum)
XrdOucEnv * Env2
Definition: XrdOfsEvs.hh:78
const char * Val(evArg aNum)
Definition: XrdOfsEvs.hh:58
Definition: XrdOfsEvs.hh:50
Definition: XrdOfsEvs.hh:87
Event
Definition: XrdOfsEvs.hh:124
Definition: XrdOfsEvs.hh:50
Definition: XrdOfsEvs.hh:50
Definition: XrdOfsEvs.hh:129
Event enEvents
Definition: XrdOfsEvs.hh:167
const char * Arg[evARGS]
Definition: XrdOfsEvs.hh:76
~XrdOfsEvsInfo()
Definition: XrdOfsEvs.hh:72
void Set(evFlags theFlags, const char *Fmt, int *fullArgs)
Definition: XrdOfsEvs.hh:106
Definition: XrdOfsEvs.hh:124
~XrdOfsEvsFormat()
Definition: XrdOfsEvs.hh:113
const char * Prog()
Definition: XrdOfsEvs.hh:148
Definition: XrdOfsEvs.hh:126
Definition: XrdOfsEvs.hh:50
Definition: XrdOfsEvs.hh:130
XrdSysError * eDest
Definition: XrdOfsEvs.hh:168
const char * Format
Definition: XrdOfsEvs.hh:93
Definition: XrdOfsEvs.hh:50
Definition: XrdOfsEvs.hh:128
Definition: XrdOfsEvs.hh:50
Definition: XrdSysError.hh:89
int maxLmsg()
Definition: XrdOfsEvs.hh:142
Definition: XrdOfsEvs.hh:132
void Def(evFlags theFlags, const char *Fmt,...)
Definition: XrdOfsEvs.hh:131
int msgFD
Definition: XrdOfsEvs.hh:178
int maxMin
Definition: XrdOfsEvs.hh:182
Definition: XrdSysPthread.hh:164
static int Parse(XrdSysError &Eroute, Event eNum, char *mText)
XrdOfsEvsMsg * msgFreeMin
Definition: XrdOfsEvs.hh:176
long long theFSize
Definition: XrdOfsEvs.hh:79
int endIT
Definition: XrdOfsEvs.hh:177
Definition: XrdOfsEvs.hh:130
XrdOfsEvsMsg * msgFirst
Definition: XrdOfsEvs.hh:172
Definition: XrdOfsEvs.hh:91
Definition: XrdOucProg.hh:37
Definition: XrdSysPthread.hh:493
XrdSysMutex qMut
Definition: XrdOfsEvs.hh:170
void Notify(Event eNum, XrdOfsEvsInfo &Info)
Definition: XrdOucEnv.hh:41
Definition: XrdOfsEvs.hh:129
XrdOfsEvsFormat()
Definition: XrdOfsEvs.hh:112
int numMax
Definition: XrdOfsEvs.hh:179
int Start(XrdSysError *eobj)
Definition: XrdOfsEvs.hh:131
Definition: XrdOfsEvs.hh:91
XrdOfsEvsMsg * getMsg(int bigmsg)
XrdOucEnv * Env1
Definition: XrdOfsEvs.hh:77
Definition: XrdOfsEvs.hh:50
static XrdOfsEvsFormat MsgFmt[XrdOfsEvs::nCount]
Definition: XrdOfsEvs.hh:163
long long FSize()
Definition: XrdOfsEvs.hh:52
Definition: XrdOfsEvs.hh:91
mode_t theFMode
Definition: XrdOfsEvs.hh:80
Definition: XrdOfsEvs.hh:46
int SNP(XrdOfsEvsInfo &Info, char *buff, int blen)
Definition: XrdOfsEvs.hh:97
evArg
Definition: XrdOfsEvs.hh:50
Definition: XrdOfsEvs.hh:91
Fmt
Definition: XrdSysTrace.hh:42
Definition: XrdOfsEvs.hh:127
void sendEvents(void)
Definition: XrdOfsEvs.hh:128
Definition: XrdOfsEvs.hh:125
Definition: XrdMacaroonsHandler.hh:18
XrdSysMutex fMut
Definition: XrdOfsEvs.hh:174
int maxSmsg()
Definition: XrdOfsEvs.hh:141
static const int maxMsgSize
Definition: XrdOfsEvs.hh:137
XrdOfsEvsInfo::evArg Args[XrdOfsEvsInfo::evARGS]
Definition: XrdOfsEvs.hh:95
int Enabled(Event theEvents)
Definition: XrdOfsEvs.hh:139
pthread_t tid
Definition: XrdOfsEvs.hh:165
Definition: XrdOfsEvs.hh:133
void retMsg(XrdOfsEvsMsg *tp)
char * theTarget
Definition: XrdOfsEvs.hh:166
void Set(evArg aNum, const char *aVal)
Definition: XrdOfsEvs.hh:56
int maxMax
Definition: XrdOfsEvs.hh:180
int numMin
Definition: XrdOfsEvs.hh:181
Definition: XrdOfsEvs.hh:127
Definition: XrdOfsEvs.hh:126
evFlags Flags
Definition: XrdOfsEvs.hh:94