XRootD
XrdOssArcBackup Class Reference

#include <XrdOssArcBackup.hh>

+ Inheritance diagram for XrdOssArcBackup:
+ Collaboration diagram for XrdOssArcBackup:

Public Member Functions

 XrdOssArcBackup (const char *scp, bool &isOK)
 
 ~XrdOssArcBackup ()
 
bool Archive (const char *dsName, const char *dsDir)
 
const char * Arena ()
 
void DoIt () override
 
const char * theScope ()
 
- Public Member Functions inherited from XrdJob
 XrdJob (const char *desc="")
 
virtual ~XrdJob ()
 

Static Public Member Functions

static void StartWorkers (int maxw)
 

Friends

class XrdOssArcBackupTask
 

Additional Inherited Members

- Public Attributes inherited from XrdJob
const char * Comment
 
XrdJobNextJob
 

Detailed Description

Definition at line 69 of file XrdOssArcBackup.hh.

Constructor & Destructor Documentation

◆ XrdOssArcBackup()

XrdOssArcBackup::XrdOssArcBackup ( const char *  scp,
bool &  isOK 
)

Definition at line 342 of file XrdOssArcBackup.cc.

343  : XrdJob("Backup"), Scope(scp)
344 {
345  char abuff[1024];
346  int rc;
347 
348 // Construct the arena where our backups will be staged
349 //
350  snprintf(abuff, sizeof(abuff), "%s%s/",Config.dsetRepoPFN,scp);
351  rc = XrdOucUtils::makePath(abuff, S_IRWXU|S_IRGRP|S_IXGRP);
352  if (rc)
353  {Elog.Emsg("Backup", rc, "create arena", abuff);
354  isOK = false;
355  } else {
356  myArena = strdup(abuff);
357  isOK = true;
358  }
359 }
XrdJob(const char *desc="")
Definition: XrdJob.hh:51
static int makePath(char *path, mode_t mode, bool reset=false)
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
Definition: XrdSysError.cc:116
XrdCmsConfig Config
XrdSysError Elog(0, "OssArc_")

References XrdCms::Config, XrdOssArcGlobals::Elog, XrdSysError::Emsg(), and XrdOucUtils::makePath().

+ Here is the call graph for this function:

◆ ~XrdOssArcBackup()

XrdOssArcBackup::~XrdOssArcBackup ( )
inline

Definition at line 88 of file XrdOssArcBackup.hh.

88 {}

Member Function Documentation

◆ Archive()

bool XrdOssArcBackup::Archive ( const char *  dsName,
const char *  dsDir 
)

Definition at line 389 of file XrdOssArcBackup.cc.

390 {
391  TraceInfo("Archive",0);
392  XrdOucStream cmdOut;
393  char tapPath[MAXPATHLEN];
394  int n, rc;
395 
396 // All we need to do is launch the archive program to complete the steps:
397 // 1. Create the zip file of all files in the dataset.
398 // 2. Move the zip file to the <tape_dir>.
399 // 3. Do a recursvive delete starting at and including <src_dir>.
400 // 4. Delete file <trg_dir>/<zipfn>.
401 
402 // The calling parameters are:
403 // <src_dir> <tape_dir> <arcfn> [{<arcpy> | ""} [<arcdsp> <manifest>]]
404 //
405 // <src_dir>: The directory containing all of the files in the dataset.
406 // This is apssed as a PFN via dsDir parameter.
407 // <tape_dir>: The directory to hold the zip archive destined to tape.
408 // We need to build this using the dsName parameter.
409 // <arcfn>: The actual filename to be used for the archive. By convention
410 // the archive is created as '<src_dir>/../<arcfn>'.
411 //[<arcpy>] Optional parameter to drive remote mode backups.
412 // 0 1 2 3
413  const char* argV[] = {dsDir, tapPath, Config.arFName, Config.ArchiverSave};
414 // 4 5
415  if (Config.bkpLocal)
416  {n = snprintf(tapPath, sizeof(tapPath), "%s/%s/%s",
417  Config.tapePath, Scope, dsName);
418  argV[3] = "";
419  } else {
420  n = snprintf(tapPath, sizeof(tapPath), "%s/%s", Scope, dsName);
421  argV[3] = Config.ArchiverSave;
422  }
423 
424 
425 
426 // Verify we didn't truncate the path
427 //
428  if (n >= (int)sizeof(tapPath))
429  {rc = -ENAMETOOLONG;
430  snprintf(tapPath, sizeof(tapPath), "%s:%s", Scope, dsName);
431  Elog.Emsg("Archive", rc, "generate tape path for dataset", tapPath);
432  Elog.Emsg("Archive","Dataset",dsName,"needs manual intervention!!!");
433  return false;
434  }
435 
436 // Do some tracing
437 //
438  DEBUG("Running "<<Config.ArchiverName<<' '<<argV[0]<<' '
439  <<argV[1]<<' '<<argV[2]<<' '<<argV[3]);
440 
441 // Run the archive script.
442 //
443  n = sizeof(argV)/sizeof(char*);
444  if (!(rc = Config.ArchiverProg->Run(&cmdOut, argV, n)))
445  {char* lp;
446  while((lp = cmdOut.GetLine())) {} // Throw away stdout
447  rc = Config.ArchiverProg->RunDone(cmdOut);
448  }
449 
450 // Check for any failures
451 //
452  if (rc)
453  {char rcVal[32];
454  snprintf(rcVal, sizeof(rcVal),"%d",rc);
455  Elog.Emsg("Archive", "Archive script failed with rc=", rcVal);
456  Elog.Emsg("Archive", "Dataset", dsName, "needs manual intervention!!!");
457  return false;
458  }
459 
460  return true;
461 }
#define DEBUG(x)
Definition: XrdBwmTrace.hh:54
#define TraceInfo(x, y)
char * GetLine()

References XrdCms::Config, DEBUG, XrdOssArcGlobals::Elog, XrdSysError::Emsg(), XrdOucStream::GetLine(), and TraceInfo.

Referenced by XrdOssArcBackupTask::BkpXeq().

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

◆ Arena()

const char* XrdOssArcBackup::Arena ( )
inline

Definition at line 77 of file XrdOssArcBackup.hh.

77 {return myArena;}

Referenced by XrdOssArcBackupTask::BkpXeq().

+ Here is the caller graph for this function:

◆ DoIt()

void XrdOssArcBackup::DoIt ( )
overridevirtual

Implements XrdJob.

Definition at line 467 of file XrdOssArcBackup.cc.

468 {
469  // Do a backup round and then reschedule for the next one
470  //
471  GetManifest();
472 
473  schedP->Schedule(this, time(0)+Config.bkpPoll);
474 }
void Schedule(XrdJob *jp)
XrdScheduler * schedP

References XrdCms::Config, XrdOfsPrepGPIReal::schedP, and XrdScheduler::Schedule().

+ Here is the call graph for this function:

◆ StartWorkers()

void XrdOssArcBackup::StartWorkers ( int  maxw)
static

Definition at line 558 of file XrdOssArcBackup.cc.

559 {
560  TraceInfo("StartWorkers",0);
561  numRunning = maxRunning = maxw;
562 
563 // Start all of the workers, they will immediately go idle.
564 // This is a one time call from config.
565 //
566  for (int i = 0; i < maxw; i++)
567  {XrdJob* bJob = new BkpWorker();
568  schedP->Schedule(bJob);
569  }
570 
571 // Do some tracing
572 //
573  DEBUG("Started "<<maxw<<" backup workers.");
574 }
Definition: XrdJob.hh:43

References DEBUG, XrdOfsPrepGPIReal::schedP, XrdScheduler::Schedule(), and TraceInfo.

Referenced by XrdOssArcConfig::Configure().

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

◆ theScope()

const char* XrdOssArcBackup::theScope ( )
inline

Definition at line 85 of file XrdOssArcBackup.hh.

85 {return Scope;}

Friends And Related Function Documentation

◆ XrdOssArcBackupTask

friend class XrdOssArcBackupTask
friend

Definition at line 71 of file XrdOssArcBackup.hh.


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