XrdCmsRRQ.hh

Go to the documentation of this file.
00001 #ifndef __XRDCMSRRQ_HH__
00002 #define __XRDCMSRRQ_HH__
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                          X r d C m s R R Q . h h                           */
00006 /*                                                                            */
00007 /* (c) 2007 by the Board of Trustees of the Leland Stanford, Jr., University  */
00008 /*                            All Rights Reserved                             */
00009 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
00010 /*              DE-AC02-76-SFO0515 with the Department of Energy              */
00011 /******************************************************************************/
00012 
00013 //         $Id: XrdCmsRRQ.hh 25932 2008-10-23 10:58:11Z ganis $
00014 
00015 #include <sys/uio.h>
00016 
00017 #include "XProtocol/XPtypes.hh"
00018 #include "XProtocol/YProtocol.hh"
00019 
00020 #include "XrdCms/XrdCmsTypes.hh"
00021 #include "XrdOuc/XrdOucDLlist.hh"
00022 #include "XrdSys/XrdSysPthread.hh"
00023   
00024 /******************************************************************************/
00025 /*                         X r d C m s R R Q I n f o                          */
00026 /******************************************************************************/
00027   
00028 class XrdCmsRRQInfo
00029 {
00030 public:
00031 void     *Key;     // Key link, which is the cache line address
00032 kXR_unt32 ID;      // Response link, which is the request ID
00033 int       Rinst;   // Redirector instance
00034 short     Rnum;    // Redirector number (RTable slot number)
00035 char      isRW;    // True if r/w access wanted
00036 char      isLU;    // True if locate response wanted
00037 SMask_t   rwVec;   // R/W servers for corresponding path (if isLU is true)
00038 
00039         XrdCmsRRQInfo() {isLU = 0;}
00040         XrdCmsRRQInfo(int rinst, short rnum, kXR_unt32 id)
00041                         {Key = 0; ID = id; 
00042                          Rinst = rinst; Rnum = rnum; isRW = isLU = 0;
00043                         }
00044        ~XrdCmsRRQInfo() {}
00045 };
00046 
00047 /******************************************************************************/
00048 /*                         X r d C m s R R Q S l o t                          */
00049 /******************************************************************************/
00050   
00051 class XrdCmsRRQSlot
00052 {
00053 friend class XrdCmsRRQ;
00054 
00055 static XrdCmsRRQSlot *Alloc(XrdCmsRRQInfo *Info);
00056 
00057        void           Recycle();
00058 
00059        XrdCmsRRQSlot();
00060       ~XrdCmsRRQSlot() {}
00061 
00062 private:
00063 
00064 static   XrdSysMutex                 myMutex;
00065 static   XrdCmsRRQSlot              *freeSlot;
00066 static   short                       initSlot;
00067 
00068          XrdOucDLlist<XrdCmsRRQSlot> Link;
00069          XrdCmsRRQSlot              *Cont;
00070          XrdCmsRRQSlot              *LkUp;
00071          XrdCmsRRQInfo               Info;
00072          SMask_t                     Arg1;
00073          SMask_t                     Arg2;
00074 unsigned int                         Expire;
00075          int                         slotNum;
00076 };
00077 
00078 /******************************************************************************/
00079 /*                             X r d C m s R R Q                              */
00080 /******************************************************************************/
00081   
00082 class XrdCmsRRQ
00083 {
00084 public:
00085 
00086 short Add(short Snum, XrdCmsRRQInfo *ip);
00087 
00088 void  Del(short Snum, const void *Key);
00089 
00090 int   Init(int Tint=0, int Tdly=0);
00091 
00092 void  Ready(int Snum, const void *Key, SMask_t mask1, SMask_t mask2);
00093 
00094 void *Respond();
00095 
00096 void *TimeOut();
00097 
00098       XrdCmsRRQ() : isWaiting(0), isReady(0), Tslice(178),
00099                     Tdelay(5),    myClock(0) {}
00100      ~XrdCmsRRQ() {}
00101 
00102 private:
00103 
00104 void sendLocResp(XrdCmsRRQSlot *lP);
00105 void sendResponse(XrdCmsRRQInfo *Info, int doredir, int totlen = 0);
00106 static const int numSlots = 1024;
00107 
00108          XrdSysMutex                   myMutex;
00109          XrdSysSemaphore               isWaiting;
00110          XrdSysSemaphore               isReady;
00111          XrdCmsRRQSlot                 Slot[numSlots];
00112          XrdOucDLlist<XrdCmsRRQSlot>   waitQ;
00113          XrdOucDLlist<XrdCmsRRQSlot>   readyQ;  // Redirect/Locate ready queue
00114 static   const int                     iov_cnt = 2;
00115          struct iovec                  data_iov[iov_cnt];
00116          struct iovec                  redr_iov[iov_cnt];
00117          XrdCms::CmsResponse           dataResp;
00118          XrdCms::CmsResponse           redrResp;
00119          XrdCms::CmsResponse           waitResp;
00120 union   {char                          hostbuff[288];
00121          char                          databuff[XrdCms::CmsLocateRequest::RILen
00122                                                *STMax];
00123         };
00124          int                           Tslice;
00125          int                           Tdelay;
00126 unsigned int                           myClock;
00127 };
00128 
00129 namespace XrdCms
00130 {
00131 extern    XrdCmsRRQ RRQ;
00132 }
00133 #endif

Generated on Tue Jul 5 14:46:31 2011 for ROOT_528-00b_version by  doxygen 1.5.1