00001 #ifndef __XRDOUCCACHEDATA_HH__
00002 #define __XRDOUCCACHEDATA_HH__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #include "XrdOuc/XrdOucCache.hh"
00038 #include "XrdOuc/XrdOucCacheReal.hh"
00039 #include "XrdSys/XrdSysPthread.hh"
00040 #include "XrdSys/XrdSysXSLock.hh"
00041
00042
00043
00044
00045
00046 class XrdOucCacheData : public XrdOucCacheIO
00047 {
00048 public:
00049
00050 XrdOucCacheIO *Base() {return ioObj;}
00051
00052 XrdOucCacheIO *Detach();
00053
00054 long long FSize() {return (ioObj ? ioObj->FSize() : 0);}
00055
00056 const char *Path() {return ioObj->Path();}
00057
00058 void Preread();
00059
00060 void Preread(aprParms &Parms);
00061
00062 void Preread(long long Offs, int rLen, int Opts=0);
00063
00064 int Read (char *Buffer, long long Offset, int Length);
00065
00066 static int setAPR(aprParms &Dest, aprParms &Src, int pSize);
00067
00068 int Sync() {return 0;}
00069
00070 int Trunc(long long Offset);
00071
00072 int Write(char *Buffer, long long Offset, int Length);
00073
00074 XrdOucCacheData(XrdOucCacheReal *cP, XrdOucCacheIO *ioP,
00075 long long vn, int opts);
00076
00077 private:
00078 ~XrdOucCacheData() {}
00079 void QueuePR(long long SegOffs, int rLen, int prHow, int isAuto=0);
00080 int Read (XrdOucCacheStats &Now,
00081 char *Buffer, long long Offs, int Length);
00082
00083
00084
00085 class MrSw
00086 {
00087 public:
00088 inline void UnLock() {if (myLock) {myLock->UnLock(myUsage); myLock = 0;}}
00089
00090 MrSw(XrdSysXSLock *lP, XrdSysXS_Type usage) : myUsage(usage)
00091 {if ((myLock = lP)) lP->Lock(usage);}
00092 ~MrSw() {if (myLock) myLock->UnLock(myUsage);}
00093
00094 private:
00095 XrdSysXSLock *myLock;
00096 XrdSysXS_Type myUsage;
00097 };
00098
00099
00100
00101 XrdSysXSLock rwLock;
00102 XrdSysXSLock *pPLock;
00103 XrdSysXSLock *rPLock;
00104 XrdSysXSLock *wPLock;
00105 XrdSysXS_Type pPLopt;
00106 XrdSysXS_Type rPLopt;
00107
00108 XrdSysMutex DMutex;
00109 XrdOucCacheReal *Cache;
00110 XrdOucCacheIO *ioObj;
00111 long long VNum;
00112 long long SegSize;
00113 long long OffMask;
00114 long long SegShft;
00115 int maxCache;
00116 char isFIS;
00117 char isRW;
00118 char isADB;
00119 char Debug;
00120
00121 static const int okRW = 1;
00122 static const int xqRW = 2;
00123
00124
00125
00126 XrdOucCacheReal::prTask prReq;
00127 XrdSysSemaphore *prStop;
00128
00129 long long prNSS;
00130
00131 static const int prRRMax= 5;
00132 long long prRR[prRRMax];
00133 int prRRNow;
00134
00135 static const int prMax = 8;
00136 static const int prRun = 1;
00137 static const int prWait = 2;
00138
00139 static const int prLRU = 1;
00140 static const int prSUSE = 2;
00141 static const int prSKIP = 3;
00142
00143 aprParms Apr;
00144 long long prCalc;
00145 long long prBeg[prMax];
00146 long long prEnd[prMax];
00147 int prNext;
00148 int prFree;
00149 int prPerf;
00150 char prOpt[prMax];
00151 char prOK;
00152 char prActive;
00153 char prAuto;
00154 };
00155 #endif