XRootD
XrdSsiSfsConfig Class Reference

#include <XrdSsiSfsConfig.hh>

+ Collaboration diagram for XrdSsiSfsConfig:

Public Member Functions

 XrdSsiSfsConfig (bool iscms=false)
 
 ~XrdSsiSfsConfig ()
 
bool Configure (const char *cFN, XrdOucEnv *envP)
 
bool Configure (XrdOucEnv *envP)
 

Public Attributes

bool isCms
 
bool isServer
 
const char * myHost
 
const char * myInsName
 
int myPort
 
const char * myProg
 
char * myRole
 
XrdVersionInfo * myVersion
 
XrdSsiClusterSsiCms
 

Detailed Description

Definition at line 38 of file XrdSsiSfsConfig.hh.

Constructor & Destructor Documentation

◆ XrdSsiSfsConfig()

XrdSsiSfsConfig::XrdSsiSfsConfig ( bool  iscms = false)

Definition at line 121 of file XrdSsiSfsConfig.cc.

122 {
123  static XrdVERSIONINFODEF(myVer, ssi, XrdVNUMBER, XrdVERSION);
124  char *bp;
125 
126 // Establish defaults
127 //
128  ConfigFN = 0;
129  CmsLib = 0;
130  CmsParms = 0;
131  SsiCms = 0;
132  SvcLib = 0;
133  SvcParms = 0;
134  myRole = 0;
135  respWT = 0x7fffffff;
136  isServer = true;
137  isCms = iscms;
138  myHost = getenv("XRDHOST");
139  myProg = getenv("XRDPROG");
141  myVersion = &myVer;
142  myPort = (bp = getenv("XRDPORT")) ? strtol(bp, (char **)NULL, 10) : 0;
143 }
static const char * InstName(int TranOpt=0)
Definition: XrdOucUtils.cc:732
const char * myHost
XrdVersionInfo * myVersion
const char * myInsName
const char * myProg
XrdSsiCluster * SsiCms
XrdVERSIONINFODEF(myVersion, cmsclient, XrdVNUMBER, XrdVERSION)

References XrdOucUtils::InstName(), XrdCms::myVersion, XrdSsi::respWT, XrdSsi::SsiCms, and XrdCms::XrdVERSIONINFODEF().

+ Here is the call graph for this function:

◆ ~XrdSsiSfsConfig()

XrdSsiSfsConfig::~XrdSsiSfsConfig ( )

Definition at line 149 of file XrdSsiSfsConfig.cc.

150 {
151  if (ConfigFN) free(ConfigFN);
152  if (CmsLib) free(CmsLib);
153  if (CmsParms) free(CmsParms);
154  if (SvcLib) free(SvcLib);
155  if (SvcParms) free(SvcParms);
156 }

Member Function Documentation

◆ Configure() [1/2]

bool XrdSsiSfsConfig::Configure ( const char *  cFN,
XrdOucEnv envP 
)

Definition at line 162 of file XrdSsiSfsConfig.cc.

163 {
164  char *var;
165  const char *tmp;
166  int cfgFD, retc, NoGo = 0;
167  XrdOucEnv myEnv;
168  XrdOucStream cStrm(&Log, getenv("XRDINSTANCE"), &myEnv, "=====> ");
169 
170 // Print warm-up message
171 //
172  Log.Say("++++++ ssi initialization started.");
173 
174 // Preset all variables with common defaults
175 //
176  if (getenv("XRDDEBUG") || getenv("XRDSSIDEBUG"))
178 
179 // If there is no config file, return with an error.
180 //
181  if( !cFN || !*cFN)
182  {Log.Emsg("Config", "Configuration file not specified.");
183  return false;
184  }
185 
186 // Try to open the configuration file.
187 //
188  ConfigFN = strdup(cFN);
189  if ( (cfgFD = open(cFN, O_RDONLY, 0)) < 0)
190  {Log.Emsg("Config", errno, "open config file", cFN);
191  return false;
192  }
193  cStrm.Attach(cfgFD);
194  static const char *cvec[] = { "*** ssi (sfs) plugin config:", 0 };
195  cStrm.Capture(cvec);
196 
197 // Now start reading records until eof.
198 //
199  cFile = &cStrm;
200  while((var = cFile->GetMyFirstWord()))
201  {if (!strncmp(var, "ssi.", 4)
202  || !strcmp(var, "all.role"))
203  {if (ConfigXeq(var+4)) {cFile->Echo(); NoGo=1;}}
204  }
205 
206 // Now check if any errors occurred during file i/o
207 //
208  if ((retc = cStrm.LastError()))
209  NoGo = Log.Emsg("Config", -retc, "read config file", cFN);
210  cStrm.Close();
211 
212 // Make sure we are configured as a server
213 //
214  if (!isServer)
215  {Log.Emsg("Config", "ssi only supports server roles but role is not "
216  "defined as 'server'.");
217  return false;
218  }
219 
220 // Configure filesystem callout as needed
221 //
222  if ((fsChk = FSPath.NotEmpty()))
223  {if (!theFS && !isCms)
224  {Log.Emsg("Config", "Specifying an fspath requires SSI to be stacked "
225  "with a file system!");
226  return false;
227  }
228  if (isServer && !theFS && !isCms) fsChk = false;
229  }
230 
231 // Perform historical phase 2 initialization
232 //
233  if (!NoGo) NoGo = !Configure(envP);
234 
235 // All done
236 //
237  tmp = (NoGo ? " failed." : " completed.");
238  Log.Say("------ ssi initialization", tmp);
239  return !NoGo;
240 }
int open(const char *path, int oflag,...)
#define TRACESSI_Debug
Definition: XrdSsiTrace.hh:34
#define TRACESSI_ALL
Definition: XrdSsiTrace.hh:33
char * GetMyFirstWord(int lowcase=0)
bool Configure(const char *cFN, XrdOucEnv *envP)
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
XrdSysTrace Trace("cms")
XrdSysError Log
Definition: XrdConfig.cc:112
XrdOucEnv * envP
Definition: XrdPss.cc:109
XrdSfsFileSystem * theFS
Definition: XrdSsiFile.cc:54
bool fsChk
Definition: XrdSsiFile.cc:56
XrdOucPListAnchor FSPath
Definition: XrdSsiFile.cc:55

References XrdOucStream::Attach(), XrdOucStream::Capture(), XrdOucStream::Close(), XrdOucStream::Echo(), XrdSysError::Emsg(), XrdProxy::envP, XrdSsi::fsChk, XrdSsi::FSPath, XrdOucStream::LastError(), XrdSsi::Log, XrdOucPListAnchor::NotEmpty(), open(), XrdSysError::Say(), XrdSsi::theFS, XrdSsi::Trace, TRACESSI_ALL, TRACESSI_Debug, and XrdSysTrace::What.

Referenced by XrdSfsGetFileSystem2().

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

◆ Configure() [2/2]

bool XrdSsiSfsConfig::Configure ( XrdOucEnv envP)

Definition at line 244 of file XrdSsiSfsConfig.cc.

245 {
246  static char theSSI[] = {'s', 's', 'i', 0};
247  static char **myArgv = 0, *dfltArgv[] = {0, 0};
248  XrdOucEnv *xrdEnvP;
249  int myArgc = 0, NoGo;
250 
251 // Now find the scheduler
252 //
253  if (envP && !(Sched = (XrdScheduler *)envP->GetPtr("XrdScheduler*")))
254  {Log.Emsg("Config", "Scheduler pointer is undefined!");
255  NoGo = 1;
256  } else NoGo = 0;
257 
258 // Find our arguments, if any
259 //
260  if ((xrdEnvP = (XrdOucEnv *)envP->GetPtr("xrdEnv*"))
261  && (myArgv = (char **)xrdEnvP->GetPtr("xrdssi.argv**")))
262  myArgc = xrdEnvP->GetInt("xrdssi.argc");
263 
264 // Verify that we have some and substitute if not
265 //
266  if (!myArgv || myArgc < 1)
267  {if (!(dfltArgv[0] = (char *)xrdEnvP->GetPtr("argv[0]")))
268  dfltArgv[0] = theSSI;
269  myArgv = dfltArgv;
270  myArgc = 1;
271  }
272 
273 // Establish the network interface that the caller must provide
274 //
275  if (!isCms && (!envP || !(myIF = (XrdNetIF *)envP->GetPtr("XrdNetIF*"))))
276  {Log.Emsg("Finder", "Network i/f undefined; unable to self-locate.");
277  NoGo = 1;
278  }
279 
280 // Now configure management functions and the cms if we are not the cms
281 //
282  if (!NoGo && !isCms && envP)
283  {if (ConfigObj() || ConfigCms(envP)) NoGo = 1;}
284 
285 // Now configure the server
286 //
287  if (!NoGo && ConfigSvc(myArgv, myArgc)) NoGo = 1;
288 
289 // All done
290 //
291  return !NoGo;
292 }
long GetInt(const char *varname)
Definition: XrdOucEnv.cc:253
void * GetPtr(const char *varname)
Definition: XrdOucEnv.cc:281
XrdScheduler Sched
Definition: XrdLinkCtl.cc:54
XrdNetIF * myIF

References XrdSysError::Emsg(), XrdProxy::envP, XrdOucEnv::GetInt(), XrdOucEnv::GetPtr(), XrdSsi::Log, XrdSsi::myIF, and XrdSsi::Sched.

+ Here is the call graph for this function:

Member Data Documentation

◆ isCms

bool XrdSsiSfsConfig::isCms

Definition at line 50 of file XrdSsiSfsConfig.hh.

◆ isServer

bool XrdSsiSfsConfig::isServer

Definition at line 49 of file XrdSsiSfsConfig.hh.

◆ myHost

const char* XrdSsiSfsConfig::myHost

Definition at line 43 of file XrdSsiSfsConfig.hh.

◆ myInsName

const char* XrdSsiSfsConfig::myInsName

Definition at line 45 of file XrdSsiSfsConfig.hh.

◆ myPort

int XrdSsiSfsConfig::myPort

Definition at line 48 of file XrdSsiSfsConfig.hh.

◆ myProg

const char* XrdSsiSfsConfig::myProg

Definition at line 44 of file XrdSsiSfsConfig.hh.

◆ myRole

char* XrdSsiSfsConfig::myRole

Definition at line 46 of file XrdSsiSfsConfig.hh.

◆ myVersion

XrdVersionInfo* XrdSsiSfsConfig::myVersion

Definition at line 42 of file XrdSsiSfsConfig.hh.

◆ SsiCms

XrdSsiCluster* XrdSsiSfsConfig::SsiCms

Definition at line 47 of file XrdSsiSfsConfig.hh.


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