XRootD
Loading...
Searching...
No Matches
XrdOssArcStopMon Class Reference

#include <XrdOssArcStopMon.hh>

Inheritance diagram for XrdOssArcStopMon:
Collaboration diagram for XrdOssArcStopMon:

Public Member Functions

 XrdOssArcStopMon (const char *apath, int chkT, bool &aOK)
 XrdOssArcStopMon (const XrdOssArcStopMon &other)=delete
 XrdOssArcStopMon (XrdOssArcStopMon *parent)
virtual ~XrdOssArcStopMon ()
void Activate ()
void Deactivate ()
virtual void DoIt () override
XrdOssArcStopMonoperator= (const XrdOssArcStopMon &)=delete
Public Member Functions inherited from XrdJob
 XrdJob (const char *desc="")
virtual ~XrdJob ()

Additional Inherited Members

Public Attributes inherited from XrdJob
const char * Comment
XrdJobNextJob

Detailed Description

Definition at line 42 of file XrdOssArcStopMon.hh.

Constructor & Destructor Documentation

◆ XrdOssArcStopMon() [1/3]

XrdOssArcStopMon::XrdOssArcStopMon ( const char * apath,
int chkT,
bool & aOK )

Definition at line 65 of file XrdOssArcStopMon.cc.

66 : XrdJob("StopMon"),
67 xsLock(*(new XrdSysXSLock())),
68 admPath(aPath), chkInterval(chkT)
69{
70// Tty to open the admin path. This is where the STOP file should appear and
71// where we plce the IDLE file once we have safely stopped all the archiving
72// and restores.
73//
74 if ((admDirFD = XrdSysFD_Open(aPath, O_DIRECTORY|O_RDONLY)) < 0)
75 {Elog.Emsg("Config", errno, "open admin path", aPath);
76 aOK = false;
77 return;
78 }
79
80// Remove any idle file left over from previous run
81//
82 if (unlinkat(admDirFD, IdleFN, 0) && errno != ENOENT)
83 {Elog.Emsg("Config", errno, "remove IDLE file in admin path", aPath);
84 aOK = false;
85 close(admDirFD);
86 admDirFD = -1;
87 return;
88 }
89
90// Now schedule ourselves to see if a stop file appears
91//
92 schedP->Schedule(this, time(0)+chkT);
93
94// All done
95//
96 aOK = true;
97}
#define close(a)
Definition XrdPosix.hh:48
XrdJob(const char *desc="")
Definition XrdJob.hh:51
void Schedule(XrdJob *jp)
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
static const char * IdleFN
XrdScheduler * schedP
Definition XrdOssArc.cc:66
XrdSysError Elog(0, "OssArc_")

References XrdJob::XrdJob(), close, XrdOssArcGlobals::Elog, XrdOssArcGlobals::IdleFN, and XrdOssArcGlobals::schedP.

Referenced by XrdOssArcStopMon(), XrdOssArcStopMon(), and operator=().

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

◆ XrdOssArcStopMon() [2/3]

XrdOssArcStopMon::XrdOssArcStopMon ( XrdOssArcStopMon * parent)
inline

Definition at line 68 of file XrdOssArcStopMon.hh.

68 : xsLock(parent->xsLock),
69 admPath(0), admDirFD(-1), isActive(true)
70 {xsLock.Lock(xs_Shared);}
static void parent()
@ xs_Shared

References XrdOssArcStopMon(), parent(), and xs_Shared.

Here is the call graph for this function:

◆ ~XrdOssArcStopMon()

XrdOssArcStopMon::~XrdOssArcStopMon ( )
virtual

Definition at line 103 of file XrdOssArcStopMon.cc.

104{
105// Parent instances of this class may not be destroyed. A parent instance
106// is indicated by admDirFD being non-negative.
107//
108 if (admDirFD >= 0)
109 {Elog.Emsg("StopMon", "Invalid deletion of StopMon parent instance for",
110 admPath);
111 std::abort();
112 }
113
114// We are not a parent, release the lock since the constructor obtained it.
115//
116 Deactivate();
117}

References Deactivate(), and XrdOssArcGlobals::Elog.

Here is the call graph for this function:

◆ XrdOssArcStopMon() [3/3]

XrdOssArcStopMon::XrdOssArcStopMon ( const XrdOssArcStopMon & other)
delete

References XrdOssArcStopMon().

Here is the call graph for this function:

Member Function Documentation

◆ Activate()

void XrdOssArcStopMon::Activate ( )
inline

Definition at line 53 of file XrdOssArcStopMon.hh.

53{if (!isActive.exchange(true)) xsLock.Lock(xs_Shared);}

References xs_Shared.

Referenced by XrdOssArcBackupTask::BkpXeq().

Here is the caller graph for this function:

◆ Deactivate()

void XrdOssArcStopMon::Deactivate ( )
inline

Definition at line 57 of file XrdOssArcStopMon.hh.

57 {if (isActive.exchange(false))
58 xsLock.UnLock(xs_Shared);
59 }

References xs_Shared.

Referenced by ~XrdOssArcStopMon(), and XrdOssArcBackupTask::BkpXeq().

Here is the caller graph for this function:

◆ DoIt()

void XrdOssArcStopMon::DoIt ( )
overridevirtual

Implements XrdJob.

Definition at line 123 of file XrdOssArcStopMon.cc.

124{
125 static const mode_t idleMode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
126 static const int idleOflg = O_CREAT | O_RDWR | O_CLOEXEC;
127 struct stat Stat;
128
129// This method is only valid for the parent class.
130//
131 if (admDirFD < 0)
132 {Elog.Emsg("StopMon","Invalid DoIt() call on child instance for",admPath);
133 return;
134 }
135
136// Check if a STOP file exists in the admpath. If it does, try to obtain a
137// write lock. Only one thread may it and when we get it we know no other
138// threads are actively executing a backup or restore. Once we have it,
139// Issue a message and create an IDLE file.
140//
141 if (fstatat(admDirFD, StopFN, &Stat, 0) == 0)
142 {Elog.Emsg("StopMon", "STOP file found in", admPath);
143 xsLock.Lock(xs_Exclusive);
144 Elog.Emsg("StopMon", "Drain complete; entering idle state...");
145 int iFD = openat(admDirFD, IdleFN, idleOflg, idleMode);
146 if (iFD < 0) Elog.Emsg("StopMon",errno,"create IDLE file in",admPath);
147 else close(iFD);
148 do {XrdSysTimer::Snooze(10);} while(!fstatat(admDirFD,StopFN,&Stat,0));
149 unlinkat(admDirFD, IdleFN, 0);
150 xsLock.UnLock(xs_Exclusive);
151 Elog.Emsg("StopMon", "Resuming execution; STOP file removed!");
152 }
153
154// Reschedule ourselves
155//
156 schedP->Schedule(this, time(0)+chkInterval);
157}
struct stat Stat
Definition XrdCks.cc:49
#define stat(a, b)
Definition XrdPosix.hh:101
@ xs_Exclusive
static void Snooze(int seconds)
static const char * StopFN

References close, XrdOssArcGlobals::Elog, XrdOssArcGlobals::IdleFN, XrdOssArcGlobals::schedP, XrdSysTimer::Snooze(), Stat, stat, XrdOssArcGlobals::StopFN, and xs_Exclusive.

Here is the call graph for this function:

◆ operator=()

XrdOssArcStopMon & XrdOssArcStopMon::operator= ( const XrdOssArcStopMon & )
delete

References XrdOssArcStopMon().

Here is the call graph for this function:

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