XRootD
XrdOfsConfigCP Class Reference

#include <XrdOfsConfigCP.hh>

+ Collaboration diagram for XrdOfsConfigCP:

Static Public Member Functions

static bool Init ()
 
static bool Parse (XrdOucStream &Config)
 

Static Public Attributes

static bool cprErrNA = true
 
static bool Enabled = true
 
static bool EnForce = false
 
static bool isProxy = false
 
static long long MaxSZ = 1024*1024
 
static int MaxVZ = 16
 
static char * Path = 0
 

Detailed Description

Definition at line 35 of file XrdOfsConfigCP.hh.

Member Function Documentation

◆ Init()

bool XrdOfsConfigCP::Init ( )
static

Definition at line 67 of file XrdOfsConfigCP.cc.

68 {
69  const int AMode = S_IRWXU|S_IRGRP|S_IXGRP;
70  const char *endMsg = "completed.";
71  char *aPath;
72  int rc;
73  bool autoDis = false;
74 
75 // If we are not enabled then do nothing
76 //
77  if (!Enabled || isProxy) return true;
78 
79 // Print warm-up message
80 //
81  OfsEroute.Say("++++++ Checkpoint initialization started.");
82 
83 // If there is no path then generate the default path
84 //
85  if (Path)
86  {aPath = XrdOucUtils::genPath(Path, XrdOucUtils::InstName(-1), "chkpnt/");
87  free(Path);
88  Path = aPath;
89  } else {
90  if (!(aPath = getenv("XRDADMINPATH")))
91  {OfsEroute.Emsg("Config",
92  "Unable to determine adminpath for chkpnt files.");
93  return false;
94  }
95  Path = XrdOucUtils::genPath(aPath, (char *)0, "chkpnt/");
96  }
97 
98 // Make sure directory path exists
99 //
100  if ((rc = XrdOucUtils::makePath(Path, AMode)))
101  {OfsEroute.Emsg("Config", rc, "create path for", Path);
102  return false;
103  }
104 
105 // We generally prohibit placing the checkpoint directory in /tmp unless
106 // "enable" has been specified.
107 //
108  if (!strncmp(Path, "/tmp/", 5))
109  {if (EnForce) OfsEroute.Say("Config warning: rooting the checkpoint "
110  "directory in '/tmp' is ill-advised!");
111  else autoDis = true;
112  }
113 
114 // Prepare to list contents of the directory
115 //
117  XrdOucNSWalk::NSEnt *nsX, *nsP = nsWalk.Index(rc);
118  if (rc)
119  {OfsEroute.Emsg("Config", rc, "list CKP path", Path);
120  return false;
121  }
122 
123 // Process all files
124 //
125  Stats stats;
126  while((nsX = nsP))
127  {Recover(nsX->Path, stats);
128  nsP = nsP->Next;
129  delete nsX;
130  }
131 
132 // Print message if we found anything
133 //
134  if (stats.numFiles)
135  {char mBuff[256];
136  snprintf(mBuff, sizeof(mBuff),
137  "%d of %d checkpoints restored, %d failed, and %d skipped.",
138  stats.numRecov, stats.numFiles, stats.numError, stats.numSkipd);
139  OfsEroute.Say("Config ", mBuff);
140  if (stats.numUnres)
141  {snprintf(mBuff, sizeof(mBuff), "%d", stats.numUnres);
142  OfsEroute.Say("Config warning: ", mBuff, " unresolved checkpoint "
143  "restore failures found!");
144  endMsg = "requires attention!";
145  }
146  }
147 
148 // Check if we need to disable checkpoint processing at this point
149 //
150  if (autoDis)
151  {OfsEroute.Say("Config warning: checkpoints disabled because the "
152  "checkpoint directory is rooted in '/tmp'!");
153  Enabled = false;
154  }
155 
156 // Print final mesage
157 //
158  OfsEroute.Say("++++++ Checkpoint initialization ", endMsg);
159  return true;
160 }
XrdSysError OfsEroute
static bool isProxy
static bool EnForce
static bool Enabled
static char * Path
static const int retFile
static char * genPath(const char *path, const char *inst, const char *psfx=0)
Definition: XrdOucUtils.cc:417
static const char * InstName(int TranOpt=0)
Definition: XrdOucUtils.cc:732
static int makePath(char *path, mode_t mode, bool reset=false)
Definition: XrdOucUtils.cc:917
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
Definition: XrdSysError.cc:95
void Say(const char *text1, const char *text2=0, const char *txt3=0, const char *text4=0, const char *text5=0, const char *txt6=0)
Definition: XrdSysError.cc:141
XrdPosixStats Stats
Definition: XrdPosixFile.cc:64
struct NSEnt * Next
Definition: XrdOucNSWalk.hh:48

References XrdSysError::Emsg(), Enabled, EnForce, XrdOucUtils::genPath(), XrdOucNSWalk::Index(), XrdOucUtils::InstName(), isProxy, XrdOucUtils::makePath(), XrdOucNSWalk::NSEnt::Next, OfsEroute, Path, XrdOucNSWalk::NSEnt::Path, XrdOucNSWalk::retFile, XrdSysError::Say(), and XrdPosixGlobals::Stats.

Referenced by XrdOfs::Configure().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Parse()

bool XrdOfsConfigCP::Parse ( XrdOucStream Config)
static

Definition at line 185 of file XrdOfsConfigCP.cc.

186 {
187  static const int minSZ = 1024*1024;
188  char *val;
189 
190 // Get the size
191 //
192  if (!(val = Config.GetWord()) || !val[0])
193  {OfsEroute.Emsg("Config", "chkpnt parameters not specified");
194  return false;
195  }
196 
197 // Process options
198 //
199 do{ if (!strcmp(val, "disable")) Enabled = EnForce = false;
200  else if (!strcmp(val, "enable")) Enabled = EnForce = true;
201  else if (!strcmp(val, "cprerr"))
202  { if (!strcmp(val, "makero")) cprErrNA = false;
203  else if (!strcmp(val, "stopio")) cprErrNA = true;
204  else {OfsEroute.Emsg("Config","invalid chkpnt cperr option -",val);
205  return false;
206  }
207  }
208  else if (!strcmp(val, "maxsz"))
209  {if (!(val = Config.GetWord()) || !val[0])
210  {OfsEroute.Emsg("Config", "chkpnt maxsz value not specified");
211  return false;
212  }
213  if (XrdOuca2x::a2sz(OfsEroute,"chkpnt maxsz", val, &MaxSZ, minSZ))
214  return false;
215  }
216  else if (!strcmp(val, "path"))
217  {if (!(val = Config.GetWord()) || !val[0])
218  {OfsEroute.Emsg("Config", "chkpnt path value not specified");
219  return false;
220  }
221  if (*val != '/')
222  {OfsEroute.Emsg("Config", "chkpnt path is not absolute");
223  return false;
224  }
225  if (Path) free(Path);
226  int n = strlen(val);
227  if (val[n-1] == '/') Path = strdup(val);
228  else {XrdOucString pstr(n+1);
229  pstr = val; pstr.append('/');
230  Path = strdup(pstr.c_str());
231  }
232  }
233  else {OfsEroute.Emsg("Config", "invalid chkpnt parameter -", val);
234  return false;
235  }
236 
237  } while((val = Config.GetWord()));
238 
239 // All done
240 //
241  return true;
242 }
static long long MaxSZ
static bool cprErrNA
static int a2sz(XrdSysError &, const char *emsg, const char *item, long long *val, long long minv=-1, long long maxv=-1)
Definition: XrdOuca2x.cc:257
XrdCmsConfig Config

References XrdOuca2x::a2sz(), XrdOucString::append(), XrdOucString::c_str(), XrdCms::Config, cprErrNA, XrdSysError::Emsg(), Enabled, EnForce, MaxSZ, OfsEroute, and Path.

Referenced by XrdOfs::ConfigXeq().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ cprErrNA

bool XrdOfsConfigCP::cprErrNA = true
static

Definition at line 42 of file XrdOfsConfigCP.hh.

Referenced by Parse().

◆ Enabled

bool XrdOfsConfigCP::Enabled = true
static

Definition at line 43 of file XrdOfsConfigCP.hh.

Referenced by XrdOfsFile::checkpoint(), Init(), and Parse().

◆ EnForce

bool XrdOfsConfigCP::EnForce = false
static

Definition at line 45 of file XrdOfsConfigCP.hh.

Referenced by Init(), and Parse().

◆ isProxy

bool XrdOfsConfigCP::isProxy = false
static

Definition at line 44 of file XrdOfsConfigCP.hh.

Referenced by Init().

◆ MaxSZ

long long XrdOfsConfigCP::MaxSZ = 1024*1024
static

◆ MaxVZ

int XrdOfsConfigCP::MaxVZ = 16
static

Definition at line 41 of file XrdOfsConfigCP.hh.

◆ Path

char * XrdOfsConfigCP::Path = 0
static

Definition at line 39 of file XrdOfsConfigCP.hh.

Referenced by Init(), and Parse().


The documentation for this class was generated from the following files: