00001 #ifndef __CMS_SELECT_HH 00002 #define __CMS_SELECT_HH 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d C m s S e l e c t . 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 <netinet/in.h> 00034 00035 #include "XrdCms/XrdCmsKey.hh" 00036 00037 /******************************************************************************/ 00038 /* C l a s s X r d C m s S e l e c t */ 00039 /******************************************************************************/ 00040 00041 class XrdCmsRRQInfo; 00042 00043 class XrdCmsSelect 00044 { 00045 public: 00046 XrdCmsKey Path; // In: Path to select or lookup in the cache 00047 XrdCmsRRQInfo *InfoP; // In: Fast redirect routing 00048 SMask_t nmask; // In: Nodes to avoid 00049 SMask_t smask; // Out: Nodes selected 00050 struct iovec *iovP; // In: Prepare notification I/O vector 00051 int iovN; // In: Prepare notification I/O vector count 00052 int Opts; // In: One or more of the following enums 00053 00054 enum {Write = 0x00010, // File will be open in write mode (select & cache) 00055 NewFile = 0x00020, // File will be created may not exist (select) 00056 Online = 0x00040, // Only consider online files (select & prep) 00057 Trunc = 0x00080, // File will be truncated (Select only) 00058 Create = 0x000A0, // Create file, truncate if exists 00059 Defer = 0x00100, // Do not select a server now (prep only) 00060 Peers = 0x00200, // Peer clusters may be selected (select only) 00061 Refresh = 0x00400, // Cache should be refreshed (all) 00062 Asap = 0x00800, // Respond as soon as possible (locate only) 00063 noBind = 0x01000, // Do not new bind file to a server (select only) 00064 isMeta = 0x02000, // Only inode information being changed(select only) 00065 Freshen = 0x04000, // Freshen access times (prep only) 00066 Replica = 0x08000, // File will be replicated (w/ Create) (select only) 00067 NoTryLim= 0x10000, // Do not apply the retry limit 00068 MWFiles = 0x20000, // Multiwrite files allowed (select only) 00069 Advisory= 0x40000, // Cache A/D is advisory (no delay) (have & cache) 00070 Pending = 0x80000, // File being staged (have & cache) 00071 ifWant = 0x0000f, // XrdNetIF::ifType encoding location 00072 00073 Pack = 0x00100000, // Packed selection 00074 UseRef = 0x00200000, // Selection by reference count only 00075 isDir = 0x00400000 // This selection is for a directory 00076 }; 00077 00078 struct {SMask_t wf; // Out: Writable locations 00079 SMask_t hf; // Out: Existing locations 00080 SMask_t pf; // Out: Pending locations 00081 SMask_t bf; // Out: Bounced locations 00082 } Vec; 00083 00084 static const int SelDSZ = 256; 00085 00086 struct {int Port; // Out: Target node port number 00087 char Data[SelDSZ]; // Out: Target node or error message 00088 int DLen; // Out: Length of Data including null byte 00089 } Resp; 00090 00091 XrdCmsSelect(int opts=0, char *thePath=0, int thePLen=0) 00092 : Path(thePath,thePLen), InfoP(0), smask(0), Opts(opts) 00093 {Resp.Port = 0; *Resp.Data = '\0'; Resp.DLen = 0;} 00094 ~XrdCmsSelect() {} 00095 }; 00096 00097 /******************************************************************************/ 00098 /* C l a s s X r d C m s S e l e c t e d */ 00099 /******************************************************************************/ 00100 00101 class XrdCmsSelected // Argument to List() after select or locate 00102 { 00103 public: 00104 00105 static const int IdentSize = 264; 00106 00107 XrdCmsSelected *next; 00108 SMask_t Mask; 00109 int Id; 00110 int IdentLen; // 12345678901234567890123456 00111 char Ident[IdentSize]; // [::123.123.123.123]:123456 00112 int Port; 00113 int RefTotW; 00114 int RefTotR; 00115 int Shrin; // Share intervals used 00116 char Share; // Share 00117 char RoleID; // Role Identifier 00118 char Rsvd[2]; 00119 int Status; // One of the following 00120 00121 enum {Disable = 0x0001, 00122 NoStage = 0x0002, 00123 Offline = 0x0004, 00124 Suspend = 0x0008, 00125 isRW = 0x0010, 00126 isMangr = 0x0100 00127 }; 00128 00129 XrdCmsSelected(XrdCmsSelected *np=0) : next(np) {} 00130 00131 ~XrdCmsSelected() {} 00132 }; 00133 00134 /******************************************************************************/ 00135 /* C l a s s X r d C m s S e l e c t o r */ 00136 /******************************************************************************/ 00137 00138 class XrdCmsSelector 00139 { 00140 public: 00141 const char *reason; 00142 int delay; 00143 short nPick; 00144 char needNet; 00145 char needSpace; 00146 bool selPack; 00147 bool xFull; 00148 bool xNoNet; 00149 bool xOff; 00150 bool xOvld; 00151 bool xSusp; 00152 00153 inline void Reset() {reason = 0; delay = 0; nPick = 0; 00154 xFull = xNoNet = xOff = xOvld = xSusp = false; 00155 } 00156 }; 00157 #endif