xrootd
XrdCmsProtocol.hh
Go to the documentation of this file.
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 /* This file is part of the XRootD software suite.                            */
00013 /*                                                                            */
00014 /* XRootD is free software: you can redistribute it and/or modify it under    */
00015 /* the terms of the GNU Lesser General Public License as published by the     */
00016 /* Free Software Foundation, either version 3 of the License, or (at your     */
00017 /* option) any later version.                                                 */
00018 /*                                                                            */
00019 /* XRootD is distributed in the hope that it will be useful, but WITHOUT      */
00020 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or      */
00021 /* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public       */
00022 /* License for more details.                                                  */
00023 /*                                                                            */
00024 /* You should have received a copy of the GNU Lesser General Public License   */
00025 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file  */
00026 /* COPYING (GPL license).  If not, see <http://www.gnu.org/licenses/>.        */
00027 /*                                                                            */
00028 /* The copyright holder's institutional names and contributor's names may not */
00029 /* be used to endorse or promote products derived from this software without  */
00030 /* specific prior written permission of the institution or contributor.       */
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 XrdCmsNode;
00040 class XrdCmsRRData;
00041 class XrdCmsRouting;
00042 
00043 class XrdCmsProtocol : public XrdProtocol
00044 {
00045 friend class XrdCmsJob;
00046 public:
00047 
00048 static XrdCmsProtocol *Alloc(const char *theRole = "",
00049                              const char *theMan  = 0, int thePort=0);
00050 
00051        void            DoIt();
00052 
00053        int             Execute(XrdCmsRRData &Data);
00054 
00055        XrdProtocol    *Match(XrdLink *lp);   // Upon    accept
00056 
00057        int             Process(XrdLink *lp); // Initial entry
00058 
00059        void            Recycle(XrdLink *lp, int consec, const char *reason);
00060 
00061        int             Stats(char *buff, int blen, int do_sync=0);
00062 
00063               XrdCmsProtocol() : XrdProtocol("cms protocol handler"),
00064                                  ProtLink(0), myRole("?"), myNode(0), RSlot(0)
00065                                {}
00066              ~XrdCmsProtocol() {}
00067 
00068 private:
00069 
00070 XrdCmsRouting  *Admit();
00071 XrdCmsRouting  *Admit_DataServer(int);
00072 XrdCmsRouting  *Admit_Redirector(int);
00073 XrdCmsRouting  *Admit_Supervisor(int);
00074 SMask_t         AddPath(XrdCmsNode *nP, const char *pType, const char *Path);
00075 int             Authenticate();
00076 void            ConfigCheck(unsigned char *theConfig);
00077 enum Bearing    {isDown, isLateral, isUp};
00078 const char     *Dispatch(Bearing cDir, int maxWait, int maxTries);
00079 XrdCmsRouting  *Login_Failed(const char *Reason);
00080 void            Pander(const char *manager, int mport);
00081 void            Reissue(XrdCmsRRData &Data);
00082 void            Reply_Delay(XrdCmsRRData &Data, kXR_unt32 theDelay);
00083 void            Reply_Error(XrdCmsRRData &Data, int ecode, const char *etext);
00084 
00085 static XrdSysMutex     ProtMutex;
00086 static XrdCmsProtocol *ProtStack;
00087 static XrdCmsParser    ProtArgs;
00088        XrdCmsProtocol *ProtLink;
00089 
00090        XrdCmsRouting  *Routing;   // Request routing for this instance
00091 
00092 static const int       maxReqSize = 16384;
00093 
00094        XrdLink        *Link;
00095 static int             readWait;
00096 const  char           *myRole;
00097 const  char           *myMan;
00098        int             myManPort;
00099        XrdCmsNode     *myNode;
00100        short           RSlot;      // True only for redirectors
00101        char            loggedIn;   // True of login succeeded
00102 };
00103 #endif