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 = 0x00010000, // Packed selection 00074 UseRef = 0x00020000 // Selection by reference count only 00075 }; 00076 00077 struct {SMask_t wf; // Out: Writable locations 00078 SMask_t hf; // Out: Existing locations 00079 SMask_t pf; // Out: Pending locations 00080 SMask_t bf; // Out: Bounced locations 00081 } Vec; 00082 00083 struct {int Port; // Out: Target node port number 00084 char Data[256]; // Out: Target node or error message 00085 int DLen; // Out: Length of Data including null byte 00086 } Resp; 00087 00088 XrdCmsSelect(int opts=0, char *thePath=0, int thePLen=0) 00089 : Path(thePath,thePLen), InfoP(0), smask(0), Opts(opts) 00090 {Resp.Port = 0; *Resp.Data = '\0'; Resp.DLen = 0;} 00091 ~XrdCmsSelect() {} 00092 }; 00093 00094 /******************************************************************************/ 00095 /* C l a s s X r d C m s S e l e c t e d */ 00096 /******************************************************************************/ 00097 00098 class XrdCmsSelected // Argument to List() after select or locate 00099 { 00100 public: 00101 00102 static const int IdentSize = 264; 00103 00104 XrdCmsSelected *next; 00105 SMask_t Mask; 00106 int Id; 00107 int IdentLen; // 12345678901234567890123456 00108 char Ident[IdentSize]; // [::123.123.123.123]:123456 00109 int Port; 00110 int RefTotW; 00111 int RefTotR; 00112 int Shrin; // Share intervals used 00113 char Share; // Share 00114 char RoleID; // Role Identifier 00115 char Rsvd[2]; 00116 int Status; // One of the following 00117 00118 enum {Disable = 0x0001, 00119 NoStage = 0x0002, 00120 Offline = 0x0004, 00121 Suspend = 0x0008, 00122 isRW = 0x0010, 00123 isMangr = 0x0100 00124 }; 00125 00126 XrdCmsSelected(XrdCmsSelected *np=0) : next(np) {} 00127 00128 ~XrdCmsSelected() {} 00129 }; 00130 00131 /******************************************************************************/ 00132 /* C l a s s X r d C m s S e l e c t o r */ 00133 /******************************************************************************/ 00134 00135 class XrdCmsSelector 00136 { 00137 public: 00138 const char *reason; 00139 int delay; 00140 short nPick; 00141 char needNet; 00142 char needSpace; 00143 bool selPack; 00144 bool xFull; 00145 bool xNoNet; 00146 bool xOff; 00147 bool xOvld; 00148 bool xSusp; 00149 00150 inline void Reset() {reason = 0; delay = 0; nPick = 0; 00151 xFull = xNoNet = xOff = xOvld = xSusp = false; 00152 } 00153 }; 00154 #endif