xrootd
XrdCmsXmiReq.hh
Go to the documentation of this file.
00001 #ifndef _XRDCMSXMIREQ_H_
00002 #define _XRDCMSXMIREQ_H_
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                       X r d C m s X m i R e 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 /* 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 "XrdCms/XrdCmsReq.hh"
00034 #include "XrdCms/XrdCmsXmi.hh"
00035 #include "XrdSys/XrdSysPthread.hh"
00036   
00037 class XrdCmsXmiReq : XrdCmsXmi
00038 {
00039 public:
00040 
00041        enum ReqType {do_chmod, do_mkdir, do_mkpath,do_mv,
00042                      do_prep,  do_rm,    do_rmdir, do_stage, do_stat};
00043 
00044        int  Chmod (      XrdCmsReq      *Request,
00045                          mode_t          mode,
00046                    const char           *path,
00047                    const char           *opaque)
00048                   {return Qit(Request, do_chmod, (int)mode, path, opaque);}
00049 
00050        int  Mkdir (      XrdCmsReq      *Request,
00051                          mode_t          mode,
00052                    const char           *path,
00053                    const char           *opaque)
00054                   {return Qit(Request, do_mkdir, (int)mode, path, opaque);}
00055 
00056        int  Mkpath(      XrdCmsReq      *Request,
00057                          mode_t          mode,
00058                    const char           *path,
00059                    const char           *opaque)
00060                   {return Qit(Request, do_mkpath, (int)mode, path, opaque);}
00061 
00062        int  Prep  (const char           *ReqID,
00063                          int             opts,
00064                    const char           *path,
00065                    const char           *opaque)
00066                   {return Qit(0, do_prep, 0, path, opaque, ReqID);}
00067 
00068        int  Rename(      XrdCmsReq      *Request,
00069                    const char           *oldpath,
00070                    const char           *oldopaque,
00071                    const char           *newpath,
00072                    const char           *newopaque)
00073                   {return Qit(Request, do_mv, 0, oldpath, oldopaque,
00074                                                  newpath, newopaque);}
00075 
00076        int  Remdir(      XrdCmsReq      *Request,
00077                    const char           *path,
00078                    const char           *opaque)
00079                   {return Qit(Request, do_rmdir, 0, path, opaque);}
00080 
00081        int  Remove(      XrdCmsReq      *Request,
00082                    const char           *path,
00083                    const char           *opaque)
00084                   {return Qit(Request, do_rm, 0, path, opaque);}
00085 
00086        int  Select(      XrdCmsReq      *Request,
00087                          int             opts,
00088                    const char           *path,
00089                    const char           *opaque)
00090                   {return Qit(Request, do_stage, opts, path, opaque);}
00091 
00092        int  Stat  (      XrdCmsReq      *Request,
00093                    const char           *path,
00094                    const char           *opaque)
00095                   {return Qit(Request, do_stat, 0, path, opaque);}
00096 
00097 static void processPrpQ();
00098 
00099 static void processReqQ();
00100 
00101 static void processStgQ();
00102 
00103             XrdCmsXmiReq(XrdCmsXmi *xp);
00104 
00105             XrdCmsXmiReq(XrdCmsReq *reqp, ReqType rqtype, int parms,
00106                       const char *path,    const char *opaque,
00107                       const char *path2=0, const char *opaque2=0);
00108 
00109 virtual    ~XrdCmsXmiReq();
00110 
00111 private:
00112 void Start();
00113 int  Qit(XrdCmsReq *rp, ReqType, int parms, 
00114          const char *path,    const char *opaque,
00115          const char *path2=0, const char *opaque2=0);
00116 
00117 static XrdCmsXmi      *XmiP;
00118 static XrdSysMutex     prpMutex;
00119 static XrdSysSemaphore prpReady;
00120 static XrdCmsXmiReq   *prpFirst;
00121 static XrdCmsXmiReq   *prpLast;
00122 static XrdSysMutex     reqMutex;
00123 static XrdSysSemaphore reqReady;
00124 static XrdCmsXmiReq   *reqFirst;
00125 static XrdCmsXmiReq   *reqLast;
00126 static XrdSysMutex     stgMutex;
00127 static XrdSysSemaphore stgReady;
00128 static XrdCmsXmiReq   *stgFirst;
00129 static XrdCmsXmiReq   *stgLast;
00130        XrdCmsXmiReq   *Next;
00131        XrdCmsReq      *ReqP;
00132        int             Parms;
00133        ReqType         Rtype;
00134        char           *Path;
00135        char           *Opaque;
00136        char           *Path2;
00137        char           *Opaque2;
00138 };
00139 #endif