00001 #ifndef __CMS_PROTOCOL_H__
00002 #define __CMS_PROTOCOL_H__
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 #include "Xrd/XrdProtocol.hh"
00034 #include "XrdCms/XrdCmsParser.hh"
00035 #include "XrdCms/XrdCmsTypes.hh"
00036 #include "XrdSys/XrdSysPthread.hh"
00037
00038 class XrdLink;
00039 class XrdCmsManager;
00040 class XrdCmsNode;
00041 class XrdCmsRRData;
00042 class XrdCmsRouting;
00043
00044 class XrdCmsProtocol : public XrdProtocol
00045 {
00046 friend class XrdCmsJob;
00047 public:
00048
00049 static XrdCmsProtocol *Alloc(const char *theRole = "", XrdCmsManager *mP=0,
00050 const char *theMan = 0, int thePort=0);
00051
00052 void DoIt();
00053
00054 int Execute(XrdCmsRRData &Data);
00055
00056 XrdProtocol *Match(XrdLink *lp);
00057
00058 int Process(XrdLink *lp);
00059
00060 void Recycle(XrdLink *lp, int consec, const char *reason);
00061
00062 void Ref(int rcnt);
00063
00064 int Stats(char *buff, int blen, int do_sync=0);
00065
00066 XrdCmsProtocol() : XrdProtocol("cms protocol handler") {Init();}
00067 ~XrdCmsProtocol() {}
00068
00069 private:
00070
00071 XrdCmsRouting *Admit();
00072 XrdCmsRouting *Admit_DataServer(int);
00073 XrdCmsRouting *Admit_Redirector(int);
00074 XrdCmsRouting *Admit_Supervisor(int);
00075 SMask_t AddPath(XrdCmsNode *nP, const char *pType, const char *Path);
00076 int Authenticate();
00077 void ConfigCheck(unsigned char *theConfig);
00078 enum Bearing {isDown, isLateral, isUp};
00079 const char *Dispatch(Bearing cDir, int maxWait, int maxTries);
00080 void Init(const char *iRole="?", XrdCmsManager *uMan=0,
00081 const char *iMan="?", int iPort=0);
00082 XrdCmsRouting *Login_Failed(const char *Reason);
00083 void Pander(const char *manager, int mport);
00084 void Reissue(XrdCmsRRData &Data);
00085 void Reply_Delay(XrdCmsRRData &Data, kXR_unt32 theDelay);
00086 void Reply_Error(XrdCmsRRData &Data, int ecode, const char *etext);
00087 bool SendPing();
00088 void Sync();
00089
00090 static XrdSysMutex ProtMutex;
00091 static XrdCmsProtocol *ProtStack;
00092 static XrdCmsParser ProtArgs;
00093 XrdCmsProtocol *ProtLink;
00094
00095 XrdCmsRouting *Routing;
00096
00097 static const int maxReqSize = 16384;
00098 XrdSysMutex refMutex;
00099 XrdSysSemaphore *refWait;
00100 XrdLink *Link;
00101 static int readWait;
00102 const char *myRole;
00103 XrdCmsNode *myNode;
00104 XrdCmsManager *Manager;
00105 const char *myMan;
00106 int myManPort;
00107 int refCount;
00108 short RSlot;
00109 char loggedIn;
00110 bool isNBSQ;
00111 };
00112 #endif