xrootd
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;}
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
XrdOfsEvr::theEvent::aClient
theClient * aClient
Definition: XrdOfsEvr.hh:89
XrdOfsEvr::runQ
int runQ
Definition: XrdOfsEvr.hh:116
XrdOfsEvr::theClient::evtCB
XrdOucEICB * evtCB
Definition: XrdOfsEvr.hh:76
XrdOfsEvr::theClient::~theClient
~theClient()
Definition: XrdOfsEvr.hh:86
XrdSysMutex
Definition: XrdSysPthread.hh:166
XrdSysPthread.hh
XrdOfsEvr::eventFIFO
XrdOucStream eventFIFO
Definition: XrdOfsEvr.hh:112
XrdOfsEvr
Definition: XrdOfsEvr.hh:43
XrdCmsClient
Definition: XrdCmsClient.hh:116
XrdOucHash
Definition: XrdOucHash.hh:128
XrdOfsEvr::Balancer
XrdCmsClient * Balancer
Definition: XrdOfsEvr.hh:114
XrdOfsEvr::theClient::theClient
theClient(XrdOfsEvr *evr, XrdOucErrInfo *einfo, const char *path=0)
Definition: XrdOfsEvr.hh:79
XrdOucErrInfo.hh
XrdOfsEvr::theClient::Path
char * Path
Definition: XrdOfsEvr.hh:74
XrdOfsEvr::Wait4Event
void Wait4Event(const char *path, XrdOucErrInfo *einfo)
XrdOucStream
Definition: XrdOucStream.hh:46
XrdOfsEvr::theEvent::finalRC
int finalRC
Definition: XrdOfsEvr.hh:91
XrdOucHash.hh
XrdOfsEvr::theClient::EvrP
XrdOfsEvr * EvrP
Definition: XrdOfsEvr.hh:75
XrdOfsEvr::~XrdOfsEvr
~XrdOfsEvr()
XrdOfsEvr::theClient::Done
void Done(int &Result, XrdOucErrInfo *eInfo, const char *path=0)
Definition: XrdOfsEvr.hh:66
XrdOfsEvr::theClient::Next
theClient * Next
Definition: XrdOfsEvr.hh:72
XrdOucEICB
Definition: XrdOucErrInfo.hh:484
XrdOfsEvr::theEvent::~theEvent
~theEvent()
Definition: XrdOfsEvr.hh:98
XrdOfsEvr::flushEvents
void flushEvents()
XrdSysSemaphore
Definition: XrdSysPthread.hh:404
XrdOfsEvr::eDest
XrdSysError * eDest
Definition: XrdOfsEvr.hh:113
XrdOfsEvr::theClient::evtCBarg
unsigned long long evtCBarg
Definition: XrdOfsEvr.hh:77
XrdOucErrInfo::getErrCB
XrdOucEICB * getErrCB()
Definition: XrdOucErrInfo.hh:223
XrdOfsEvr::theClient
Definition: XrdOfsEvr.hh:63
XrdOfsEvr::deferQ
theClient * deferQ
Definition: XrdOfsEvr.hh:115
XrdOfsEvr::Init
int Init(XrdCmsClient *trg=0)
XrdOfsEvr::Work4Event
void Work4Event(theClient *Client)
XrdOfsEvr::theEvent::finalMsg
char * finalMsg
Definition: XrdOfsEvr.hh:90
XrdOfsEvr::theEvent::theEvent
theEvent(int rc, const char *emsg, theClient *cp=0)
Definition: XrdOfsEvr.hh:94
XrdOfsEvr::theEvent::Happened
char Happened
Definition: XrdOfsEvr.hh:92
XrdOfsEvr::theEvent
Definition: XrdOfsEvr.hh:89
XrdOfsEvr::recvEvents
void recvEvents()
XrdOfsEvr::maxLife
static const int maxLife
Definition: XrdOfsEvr.hh:109
XrdOfsEvr::mySem
XrdSysSemaphore mySem
Definition: XrdOfsEvr.hh:111
XrdOfsEvr::theClient::User
const char * User
Definition: XrdOfsEvr.hh:73
XrdOfsEvr::Init
int Init(XrdSysError *eObj)
XrdOfsEvr::msgFD
int msgFD
Definition: XrdOfsEvr.hh:117
XrdOucErrInfo
Definition: XrdOucErrInfo.hh:100
XrdOfsEvr::myMutex
XrdSysMutex myMutex
Definition: XrdOfsEvr.hh:110
XrdOucErrInfo::getErrUser
const char * getErrUser()
Definition: XrdOucErrInfo.hh:296
XrdSysError
Definition: XrdSysError.hh:90
XrdOfsEvr::Events
XrdOucHash< theEvent > Events
Definition: XrdOfsEvr.hh:119
XrdOucStream.hh
XrdOfsEvr::XrdOfsEvr
XrdOfsEvr()
Definition: XrdOfsEvr.hh:59
XrdOfsEvr::theClient::Same
int Same(unsigned long long arg1, unsigned long long arg2)
Definition: XrdOfsEvr.hh:69
XrdOfsEvr::sendEvent
void sendEvent(theEvent *ep)
XrdOfsEvr::eventStage
void eventStage()