xrootd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
XrdOfsEvr.hh
Go to the documentation of this file.
1 #ifndef __XRDOFSEVR_H__
2 #define __XRDOFSEVR_H__
3 /******************************************************************************/
4 /* */
5 /* X r d O f s E v r . h h */
6 /* */
7 /* (c) 2006 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 /******************************************************************************/
32 
33 #include <strings.h>
34 #include "XrdOuc/XrdOucHash.hh"
35 #include "XrdOuc/XrdOucErrInfo.hh"
36 #include "XrdSys/XrdSysPthread.hh"
37 #include "XrdOuc/XrdOucStream.hh"
38 
39 class XrdSysError;
40 class XrdCmsClient;
41 
42 class XrdOfsEvr
43 {
44 public:
45 class theClient;
46 
47 void flushEvents();
48 
49 int Init(XrdSysError *eObj);
50 
51 int Init(XrdCmsClient *trg=0);
52 
53 void recvEvents();
54 
55 void Wait4Event(const char *path, XrdOucErrInfo *einfo);
56 
57 void Work4Event(theClient *Client);
58 
59  XrdOfsEvr() : mySem(0), eDest(0), Balancer(0) {runQ = 0; deferQ = 0;}
60  ~XrdOfsEvr();
61 
63 {
64 public:
65 
66 void Done(int &Result, XrdOucErrInfo *eInfo, const char *path=0)
67  { (void)Result; (void)eInfo; (void)path; EvrP->Work4Event(this);}
68 
69 int Same(unsigned long long arg1, unsigned long long arg2)
70 { (void)arg1; (void)arg2; return 0;}
71 
73 const char *User;
74 char *Path;
77 unsigned long long evtCBarg;
78 
79  theClient(XrdOfsEvr *evr, XrdOucErrInfo *einfo, const char *path=0)
80  {evtCB = einfo->getErrCB(evtCBarg);
81  User = einfo->getErrUser();
82  Path = (path ? strdup(path) : 0);
83  EvrP = evr;
84  Next = 0;
85  }
86  ~theClient() {if (Path) free(Path);}
87  };
88 
90  char *finalMsg;
91  int finalRC;
92  char Happened;
93 
94  theEvent(int rc, const char *emsg, theClient *cp=0)
95  {aClient = cp; finalRC = rc; Happened = 0;
96  finalMsg = (emsg ? strdup(emsg) : 0);
97  }
99  {if (finalMsg) free(finalMsg);
100  if (aClient) delete aClient;
101  }
102  };
103 
104 private:
105 
106 void eventStage();
107 void sendEvent(theEvent *ep);
108 
109 static const int maxLife = (8*60*60); // Eight hours
116 int runQ;
117 int msgFD;
118 
120 };
121 #endif
theEvent(int rc, const char *emsg, theClient *cp=0)
Definition: XrdOfsEvr.hh:94
Definition: XrdOfsEvr.hh:62
~theEvent()
Definition: XrdOfsEvr.hh:98
Definition: XrdOucStream.hh:46
static const int maxLife
Definition: XrdOfsEvr.hh:109
XrdCmsClient * Balancer
Definition: XrdOfsEvr.hh:114
Definition: XrdOfsEvr.hh:42
theClient * deferQ
Definition: XrdOfsEvr.hh:115
Definition: XrdCmsClient.hh:115
const char * User
Definition: XrdOfsEvr.hh:73
void eventStage()
int Same(unsigned long long arg1, unsigned long long arg2)
Definition: XrdOfsEvr.hh:69
void Work4Event(theClient *Client)
int Init(XrdSysError *eObj)
Definition: XrdSysError.hh:89
theClient * aClient
Definition: XrdOfsEvr.hh:89
Definition: XrdSysPthread.hh:164
void recvEvents()
XrdOucHash< theEvent > Events
Definition: XrdOfsEvr.hh:119
Definition: XrdOucErrInfo.hh:100
Definition: XrdSysPthread.hh:493
XrdOucEICB * evtCB
Definition: XrdOfsEvr.hh:76
j template void())
Definition: XrdOucJson.hh:4121
void sendEvent(theEvent *ep)
~theClient()
Definition: XrdOfsEvr.hh:86
int finalRC
Definition: XrdOfsEvr.hh:91
char Happened
Definition: XrdOfsEvr.hh:92
void Wait4Event(const char *path, XrdOucErrInfo *einfo)
XrdOfsEvr * EvrP
Definition: XrdOfsEvr.hh:75
XrdOucStream eventFIFO
Definition: XrdOfsEvr.hh:112
XrdSysMutex myMutex
Definition: XrdOfsEvr.hh:110
void Done(int &Result, XrdOucErrInfo *eInfo, const char *path=0)
Definition: XrdOfsEvr.hh:66
const char * getErrUser()
Definition: XrdOucErrInfo.hh:297
Definition: XrdOucHash.hh:127
theClient(XrdOfsEvr *evr, XrdOucErrInfo *einfo, const char *path=0)
Definition: XrdOfsEvr.hh:79
XrdSysSemaphore mySem
Definition: XrdOfsEvr.hh:111
void flushEvents()
unsigned long long evtCBarg
Definition: XrdOfsEvr.hh:77
int runQ
Definition: XrdOfsEvr.hh:116
XrdSysError * eDest
Definition: XrdOfsEvr.hh:113
int msgFD
Definition: XrdOfsEvr.hh:117
Definition: XrdOfsEvr.hh:89
Definition: XrdOucErrInfo.hh:484
char * Path
Definition: XrdOfsEvr.hh:74
theClient * Next
Definition: XrdOfsEvr.hh:72
XrdOucEICB * getErrCB()
Definition: XrdOucErrInfo.hh:224
XrdOfsEvr()
Definition: XrdOfsEvr.hh:59
char * finalMsg
Definition: XrdOfsEvr.hh:90