xrootd
Loading...
Searching...
No Matches
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>
36
37class XrdOfsEvsMsg;
38class XrdOucEnv;
39class XrdOucProg;
40class XrdSysError;
41
42/******************************************************************************/
43/* X r d O f s E v s I n f o */
44/******************************************************************************/
45
47{
48public:
49
51
52inline long long FSize() {return theFSize;}
53
54inline mode_t FMode() {return theFMode;}
55
56inline void Set(evArg aNum, const char *aVal) {Arg[aNum] = aVal;}
57
58inline 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
74private:
75
76const char *Arg[evARGS];
79long long theFSize;
80mode_t theFMode;
81};
82
83/******************************************************************************/
84/* X r d O f s E v s F o r m a t */
85/******************************************************************************/
86
88{
89public:
90
91enum evFlags {Null = 0, freeFmt = 1, cvtMode = 2, cvtFSize = 4};
92
93const 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{
122public:
123
124enum 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
136static const int minMsgSize = 1360; // (16+320+1024)
137static const int maxMsgSize = 2384; // (16+320+1024+1024);
138
139int Enabled(Event theEvents) {return theEvents & enEvents;}
140
141int maxSmsg() {return maxMin;}
142int maxLmsg() {return maxMax;}
143
144void Notify(Event eNum, XrdOfsEvsInfo &Info);
145
146static int Parse(XrdSysError &Eroute, Event eNum, char *mText);
147
148const char *Prog() {return theTarget;}
149
150void sendEvents(void);
151
153
154 XrdOfsEvs(Event theEvents, const char *Target, int minq=90, int maxq=10);
156
157private:
158const char *eName(int eNum);
159int Feed(const char *data, int dlen);
160XrdOfsEvsMsg *getMsg(int bigmsg);
161void retMsg(XrdOfsEvsMsg *tp);
162
164
165pthread_t tid;
172XrdOfsEvsMsg *msgFirst;
173XrdOfsEvsMsg *msgLast;
175XrdOfsEvsMsg *msgFreeMax;
176XrdOfsEvsMsg *msgFreeMin;
183};
184#endif
Definition XrdOfsEvs.hh:88
int SNP(XrdOfsEvsInfo &Info, char *buff, int blen)
Definition XrdOfsEvs.hh:97
XrdOfsEvsFormat()
Definition XrdOfsEvs.hh:112
XrdOfsEvsInfo::evArg Args[XrdOfsEvsInfo::evARGS]
Definition XrdOfsEvs.hh:95
void Def(evFlags theFlags, const char *Fmt,...)
const char * Format
Definition XrdOfsEvs.hh:93
evFlags Flags
Definition XrdOfsEvs.hh:94
~XrdOfsEvsFormat()
Definition XrdOfsEvs.hh:113
evFlags
Definition XrdOfsEvs.hh:91
@ cvtFSize
Definition XrdOfsEvs.hh:91
@ cvtMode
Definition XrdOfsEvs.hh:91
@ Null
Definition XrdOfsEvs.hh:91
@ freeFmt
Definition XrdOfsEvs.hh:91
void Set(evFlags theFlags, const char *Fmt, int *fullArgs)
Definition XrdOfsEvs.hh:106
Definition XrdOfsEvs.hh:47
long long FSize()
Definition XrdOfsEvs.hh:52
mode_t theFMode
Definition XrdOfsEvs.hh:80
const char * Arg[evARGS]
Definition XrdOfsEvs.hh:76
~XrdOfsEvsInfo()
Definition XrdOfsEvs.hh:72
mode_t FMode()
Definition XrdOfsEvs.hh:54
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
void Set(evArg aNum, const char *aVal)
Definition XrdOfsEvs.hh:56
evArg
Definition XrdOfsEvs.hh:50
@ evARGS
Definition XrdOfsEvs.hh:50
@ evLFN2
Definition XrdOfsEvs.hh:50
@ evLFN1
Definition XrdOfsEvs.hh:50
@ evTID
Definition XrdOfsEvs.hh:50
@ evFSIZE
Definition XrdOfsEvs.hh:50
@ evCGI1
Definition XrdOfsEvs.hh:50
@ evCGI2
Definition XrdOfsEvs.hh:50
@ evFMODE
Definition XrdOfsEvs.hh:50
long long theFSize
Definition XrdOfsEvs.hh:79
const char * Val(evArg aNum)
Definition XrdOfsEvs.hh:58
XrdOucEnv * Env2
Definition XrdOfsEvs.hh:78
XrdOucEnv * Env1
Definition XrdOfsEvs.hh:77
Definition XrdOfsEvs.hh:121
int maxSmsg()
Definition XrdOfsEvs.hh:141
XrdOfsEvs(Event theEvents, const char *Target, int minq=90, int maxq=10)
static const int maxMsgSize
Definition XrdOfsEvs.hh:137
XrdOfsEvsMsg * msgFreeMax
Definition XrdOfsEvs.hh:175
Event enEvents
Definition XrdOfsEvs.hh:167
XrdSysSemaphore qSem
Definition XrdOfsEvs.hh:171
static XrdOfsEvsFormat MsgFmt[XrdOfsEvs::nCount]
Definition XrdOfsEvs.hh:163
int Feed(const char *data, int dlen)
int maxMin
Definition XrdOfsEvs.hh:182
Event
Definition XrdOfsEvs.hh:124
@ All
Definition XrdOfsEvs.hh:124
@ Mask
Definition XrdOfsEvs.hh:133
@ Closer
Definition XrdOfsEvs.hh:125
@ Open
Definition XrdOfsEvs.hh:130
@ Mv
Definition XrdOfsEvs.hh:128
@ Mkdir
Definition XrdOfsEvs.hh:128
@ Rmdir
Definition XrdOfsEvs.hh:131
@ Closew
Definition XrdOfsEvs.hh:126
@ Rm
Definition XrdOfsEvs.hh:130
@ None
Definition XrdOfsEvs.hh:124
@ Close
Definition XrdOfsEvs.hh:126
@ Fwrite
Definition XrdOfsEvs.hh:127
@ nCount
Definition XrdOfsEvs.hh:132
@ Trunc
Definition XrdOfsEvs.hh:131
@ Openr
Definition XrdOfsEvs.hh:129
@ enMask
Definition XrdOfsEvs.hh:133
@ Openw
Definition XrdOfsEvs.hh:129
@ Create
Definition XrdOfsEvs.hh:127
@ Chmod
Definition XrdOfsEvs.hh:125
XrdOfsEvsMsg * getMsg(int bigmsg)
XrdSysMutex qMut
Definition XrdOfsEvs.hh:170
const char * eName(int eNum)
XrdOfsEvsMsg * msgFirst
Definition XrdOfsEvs.hh:172
char * theTarget
Definition XrdOfsEvs.hh:166
int numMin
Definition XrdOfsEvs.hh:181
XrdSysMutex fMut
Definition XrdOfsEvs.hh:174
int maxMax
Definition XrdOfsEvs.hh:180
int msgFD
Definition XrdOfsEvs.hh:178
void sendEvents(void)
pthread_t tid
Definition XrdOfsEvs.hh:165
XrdOfsEvsMsg * msgFreeMin
Definition XrdOfsEvs.hh:176
static int Parse(XrdSysError &Eroute, Event eNum, char *mText)
int maxLmsg()
Definition XrdOfsEvs.hh:142
int numMax
Definition XrdOfsEvs.hh:179
XrdOfsEvsMsg * msgLast
Definition XrdOfsEvs.hh:173
int Start(XrdSysError *eobj)
const char * Prog()
Definition XrdOfsEvs.hh:148
XrdSysError * eDest
Definition XrdOfsEvs.hh:168
int endIT
Definition XrdOfsEvs.hh:177
static const int minMsgSize
Definition XrdOfsEvs.hh:136
void Notify(Event eNum, XrdOfsEvsInfo &Info)
void retMsg(XrdOfsEvsMsg *tp)
XrdOucProg * theProg
Definition XrdOfsEvs.hh:169
int Enabled(Event theEvents)
Definition XrdOfsEvs.hh:139
Definition XrdOucEnv.hh:42
Definition XrdOucProg.hh:38
Definition XrdSysError.hh:90
Definition XrdSysPthread.hh:165
Definition XrdSysPthread.hh:494