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];
77XrdOucEnv *Env1;
78XrdOucEnv *Env2;
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
152int Start(XrdSysError *eobj);
153
154 XrdOfsEvs(Event theEvents, const char *Target, int minq=90, int maxq=10);
155 ~XrdOfsEvs();
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;
166char *theTarget;
167Event enEvents;
168XrdSysError *eDest;
169XrdOucProg *theProg;
170XrdSysMutex qMut;
171XrdSysSemaphore qSem;
172XrdOfsEvsMsg *msgFirst;
173XrdOfsEvsMsg *msgLast;
174XrdSysMutex fMut;
175XrdOfsEvsMsg *msgFreeMax;
176XrdOfsEvsMsg *msgFreeMin;
177int endIT;
178int msgFD;
179int numMax;
180int maxMax;
181int numMin;
182int maxMin;
183};
184#endif
int SNP(XrdOfsEvsInfo &Info, char *buff, int blen)
Definition XrdOfsEvs.hh:97
XrdOfsEvsInfo::evArg Args[XrdOfsEvsInfo::evARGS]
Definition XrdOfsEvs.hh:95
void Def(evFlags theFlags, const char *Fmt,...)
Definition XrdOfsEvs.cc:91
const char * Format
Definition XrdOfsEvs.hh:93
void Set(evFlags theFlags, const char *Fmt, int *fullArgs)
Definition XrdOfsEvs.hh:106
long long FSize()
Definition XrdOfsEvs.hh:52
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
const char * Val(evArg aNum)
Definition XrdOfsEvs.hh:58
static int Parse(XrdSysError &Eroute, Event eNum, char *mText)
Definition XrdOfsEvs.cc:287
int maxSmsg()
Definition XrdOfsEvs.hh:141
XrdOfsEvs(Event theEvents, const char *Target, int minq=90, int maxq=10)
Definition XrdOfsEvs.cc:118
static const int maxMsgSize
Definition XrdOfsEvs.hh:137
void sendEvents(void)
Definition XrdOfsEvs.cc:363
int maxLmsg()
Definition XrdOfsEvs.hh:142
int Start(XrdSysError *eobj)
Definition XrdOfsEvs.cc:394
const char * Prog()
Definition XrdOfsEvs.hh:148
static const int minMsgSize
Definition XrdOfsEvs.hh:136
void Notify(Event eNum, XrdOfsEvsInfo &Info)
Definition XrdOfsEvs.cc:234
int Enabled(Event theEvents)
Definition XrdOfsEvs.hh:139