xrootd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
XrdBwmHandle.hh
Go to the documentation of this file.
1 #ifndef __BWM_HANDLE__
2 #define __BWM_HANDLE__
3 /******************************************************************************/
4 /* */
5 /* X r d B w m H a n d l e . h h */
6 /* */
7 /* (c) 2008 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 <cstdlib>
34 
35 #include "XrdBwm/XrdBwmPolicy.hh"
36 #include "XrdOuc/XrdOucErrInfo.hh"
37 #include "XrdSys/XrdSysPthread.hh"
38 
39 class XrdBwmLogger;
40 
42 {
43 public:
44 
46 
48 
49  int Activate(XrdOucErrInfo &einfo);
50 
51 static XrdBwmHandle *Alloc(const char *theUsr, const char *thePath,
52  const char *lclNode, const char *rmtNode,
53  int Incoming);
54 
55 static void *Dispatch();
56 
57 inline const char *Name() {return Parms.Lfn;}
58 
59  void Retire();
60 
61 static int setPolicy(XrdBwmPolicy *pP, XrdBwmLogger *lP);
62 
63  XrdBwmHandle() : Status(Idle), Next(0), qTime(0), rTime(0),
64  xSize(0), xTime(0)
65  {}
66 
68 
69 private:
70 static XrdBwmHandle *Alloc(XrdBwmHandle *oldHandle=0);
71 static XrdBwmHandle *refHandle(int refID, XrdBwmHandle *hP=0);
72 
75 static XrdBwmHandle *Free; // List of free handles
76 static unsigned int numQueued;
77 
82  unsigned long long ErrCBarg;
83  time_t qTime;
84  time_t rTime;
85  long long xSize;
86  long xTime;
87  int rHandle;
88 
89 class theEICB : public XrdOucEICB
90 {
91 public:
92 
93  void Done(int &Result, XrdOucErrInfo *eInfo, const char *Path=0)
94  {mySem.Post();}
95 
96  int Same(unsigned long long arg1, unsigned long long arg2)
97  {return arg1 == arg2;}
98 
99  void Wait() {mySem.Wait();}
100 
101  theEICB() : mySem(0) {}
102 
103 virtual ~theEICB() {}
104 
105 private:
107 } myEICB;
108 };
109 #endif
XrdSysMutex hMutex
Definition: XrdBwmHandle.hh:78
static XrdBwmHandle * Free
Definition: XrdBwmHandle.hh:75
const char * Name()
Definition: XrdBwmHandle.hh:57
time_t qTime
Definition: XrdBwmHandle.hh:83
static XrdBwmLogger * Logger
Definition: XrdBwmHandle.hh:74
void Done(int &Result, XrdOucErrInfo *eInfo, const char *Path=0)
Definition: XrdBwmHandle.hh:93
int rHandle
Definition: XrdBwmHandle.hh:87
XrdBwmPolicy::SchedParms Parms
Definition: XrdBwmHandle.hh:79
XrdBwmHandle::theEICB myEICB
XrdBwmHandle()
Definition: XrdBwmHandle.hh:63
void Wait()
Definition: XrdSysPthread.hh:509
Definition: XrdBwmHandle.hh:45
static unsigned int numQueued
Definition: XrdBwmHandle.hh:76
Definition: XrdBwmPolicy.hh:117
HandleState Status
Definition: XrdBwmHandle.hh:47
void Wait()
Definition: XrdBwmHandle.hh:99
Definition: XrdSysPthread.hh:164
unsigned long long ErrCBarg
Definition: XrdBwmHandle.hh:82
XrdBwmHandle * Next
Definition: XrdBwmHandle.hh:80
static XrdBwmPolicy * Policy
Definition: XrdBwmHandle.hh:73
Definition: XrdBwmHandle.hh:89
XrdOucEICB * ErrCB
Definition: XrdBwmHandle.hh:81
void Post()
Definition: XrdSysPthread.hh:505
Definition: XrdOucErrInfo.hh:100
Definition: XrdBwmPolicy.hh:33
Definition: XrdSysPthread.hh:493
Definition: XrdBwmHandle.hh:41
static XrdBwmHandle * refHandle(int refID, XrdBwmHandle *hP=0)
char * Lfn
Definition: XrdBwmPolicy.hh:120
HandleState
Definition: XrdBwmHandle.hh:45
Definition: XrdBwmHandle.hh:45
time_t rTime
Definition: XrdBwmHandle.hh:84
XrdSysSemaphore mySem
Definition: XrdBwmHandle.hh:106
static int setPolicy(XrdBwmPolicy *pP, XrdBwmLogger *lP)
virtual ~theEICB()
Definition: XrdBwmHandle.hh:103
Definition: XrdBwmLogger.hh:40
int Same(unsigned long long arg1, unsigned long long arg2)
Definition: XrdBwmHandle.hh:96
theEICB()
Definition: XrdBwmHandle.hh:101
long long xSize
Definition: XrdBwmHandle.hh:85
Definition: XrdBwmHandle.hh:45
static XrdBwmHandle * Alloc(const char *theUsr, const char *thePath, const char *lclNode, const char *rmtNode, int Incoming)
~XrdBwmHandle()
Definition: XrdBwmHandle.hh:67
int Activate(XrdOucErrInfo &einfo)
Definition: XrdOucErrInfo.hh:484
static void * Dispatch()
long xTime
Definition: XrdBwmHandle.hh:86