xrootd
|
00001 #ifndef __CMS_PROTOCOL_H__ 00002 #define __CMS_PROTOCOL_H__ 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d C m s P r o t o c o l . 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$ 00014 00015 #include "Xrd/XrdProtocol.hh" 00016 #include "XrdCms/XrdCmsParser.hh" 00017 #include "XrdCms/XrdCmsTypes.hh" 00018 #include "XrdSys/XrdSysPthread.hh" 00019 00020 class XrdLink; 00021 class XrdCmsNode; 00022 class XrdCmsRRData; 00023 class XrdCmsRouting; 00024 00025 class XrdCmsProtocol : public XrdProtocol 00026 { 00027 friend class XrdCmsJob; 00028 public: 00029 00030 static XrdCmsProtocol *Alloc(const char *theRole = "", 00031 const char *theMan = 0, int thePort=0); 00032 00033 void DoIt(); 00034 00035 int Execute(XrdCmsRRData &Data); 00036 00037 XrdProtocol *Match(XrdLink *lp); // Upon accept 00038 00039 int Process(XrdLink *lp); // Initial entry 00040 00041 void Recycle(XrdLink *lp, int consec, const char *reason); 00042 00043 int Stats(char *buff, int blen, int do_sync=0) {return 0;} 00044 00045 XrdCmsProtocol() : XrdProtocol("cms protocol handler"), 00046 ProtLink(0), myRole("?"), myNode(0), RSlot(0) 00047 {} 00048 ~XrdCmsProtocol() {} 00049 00050 private: 00051 00052 XrdCmsRouting *Admit(); 00053 XrdCmsRouting *Admit_DataServer(int); 00054 XrdCmsRouting *Admit_Redirector(int); 00055 XrdCmsRouting *Admit_Supervisor(int); 00056 SMask_t AddPath(XrdCmsNode *nP, const char *pType, const char *Path); 00057 int Authenticate(); 00058 void ConfigCheck(unsigned char *theConfig); 00059 enum Bearing {isDown, isLateral, isUp}; 00060 const char *Dispatch(Bearing cDir, int maxWait, int maxTries); 00061 XrdCmsRouting *Login_Failed(const char *Reason); 00062 void Pander(const char *manager, int mport); 00063 void Reissue(XrdCmsRRData &Data); 00064 void Reply_Delay(XrdCmsRRData &Data, kXR_unt32 theDelay); 00065 void Reply_Error(XrdCmsRRData &Data, int ecode, const char *etext); 00066 00067 static XrdSysMutex ProtMutex; 00068 static XrdCmsProtocol *ProtStack; 00069 static XrdCmsParser ProtArgs; 00070 XrdCmsProtocol *ProtLink; 00071 00072 XrdCmsRouting *Routing; // Request routing for this instance 00073 00074 static const int maxReqSize = 16384; 00075 00076 XrdLink *Link; 00077 static int readWait; 00078 const char *myRole; 00079 const char *myMan; 00080 int myManPort; 00081 XrdCmsNode *myNode; 00082 short RSlot; // True only for redirectors 00083 char loggedIn; // True of login succeeded 00084 }; 00085 #endif