XRootD
Loading...
Searching...
No Matches
XrdCmsPrepArgs.cc
Go to the documentation of this file.
1
/******************************************************************************/
2
/* */
3
/* X r d C m s P r e p A r g s . c c */
4
/* */
5
/* (c) 2007 by the Board of Trustees of the Leland Stanford, Jr., University */
6
/* All Rights Reserved */
7
/* Produced by Andrew Hanushevsky for Stanford University under contract */
8
/* DE-AC02-76-SFO0515 with the Department of Energy */
9
/* */
10
/* This file is part of the XRootD software suite. */
11
/* */
12
/* XRootD is free software: you can redistribute it and/or modify it under */
13
/* the terms of the GNU Lesser General Public License as published by the */
14
/* Free Software Foundation, either version 3 of the License, or (at your */
15
/* option) any later version. */
16
/* */
17
/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
18
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
19
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
20
/* License for more details. */
21
/* */
22
/* You should have received a copy of the GNU Lesser General Public License */
23
/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
24
/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
25
/* */
26
/* The copyright holder's institutional names and contributor's names may not */
27
/* be used to endorse or promote products derived from this software without */
28
/* specific prior written permission of the institution or contributor. */
29
/******************************************************************************/
30
31
#include <unistd.h>
32
#include <cstdlib>
33
#include <sys/types.h>
34
35
#include "
XrdCms/XrdCmsConfig.hh
"
36
#include "
XrdCms/XrdCmsPrepare.hh
"
37
#include "
XrdCms/XrdCmsPrepArgs.hh
"
38
39
using namespace
XrdCms
;
40
41
/******************************************************************************/
42
/* S t a t i c V a r i a b l e s */
43
/******************************************************************************/
44
45
XrdSysMutex
XrdCmsPrepArgs::PAQueue;
46
XrdSysSemaphore
XrdCmsPrepArgs::PAReady(0);
47
48
XrdCmsPrepArgs
*XrdCmsPrepArgs::First = 0;
49
XrdCmsPrepArgs
*XrdCmsPrepArgs::Last = 0;
50
int
XrdCmsPrepArgs::isIdle= 1;
51
52
/******************************************************************************/
53
/* C o n s t r u c t o r */
54
/******************************************************************************/
55
56
XrdCmsPrepArgs::XrdCmsPrepArgs
(
XrdCmsRRData
&Arg) :
XrdJob
(
"prepare"
)
57
{
58
59
// Copy variable pointers and steal the data buffer behind them
60
//
61
Request
= Arg.
Request
;
Request
.
streamid
= 0;
62
Ident
= Arg.
Ident
;
63
reqid
= Arg.
Reqid
;
64
notify
= Arg.
Notify
;
65
prty
= Arg.
Prty
;
66
mode
= Arg.
Mode
;
67
path
= Arg.
Path
;
68
pathlen
= Arg.
PathLen
;
69
opaque
= Arg.
Opaque
;
70
options
= Arg.
Request
.
modifier
;
71
Data = Arg.
Buff
; Arg.
Buff
= 0; Arg.
Blen
= 0;
72
73
// Fill out co-location information
74
//
75
if
(
options
&
CmsPrepAddRequest::kYR_stage
76
&&
options
&
CmsPrepAddRequest::kYR_coloc
&&
prty
)
77
{
clPath
=
prty
;
78
while
(*
clPath
&& *
clPath
!=
'/'
)
clPath
++;
79
if
(*
clPath
!=
'/'
)
clPath
= 0;
80
}
else
clPath
= 0;
81
82
// Fill out the iovec
83
//
84
ioV
[0].iov_base = (
char
*)&
Request
;
85
ioV
[0].iov_len =
sizeof
(
Request
);
86
ioV
[1].iov_base = Data;
87
ioV
[1].iov_len = Arg.
Dlen
;
88
}
89
90
/******************************************************************************/
91
/* g e t R e q u e s t */
92
/******************************************************************************/
93
94
XrdCmsPrepArgs
*
XrdCmsPrepArgs::getRequest
()
// Static
95
{
96
XrdCmsPrepArgs
*parg;
97
98
// Wait for a request
99
//
100
do
{PAQueue.
Lock
();
101
if
((parg = First))
102
if
(parg == Last) First = Last = 0;
103
else
First = parg->Next;
104
else
{isIdle = 1; PAQueue.
UnLock
(); PAReady.
Wait
();}
105
}
while
(parg == 0);
106
isIdle = 0;
107
PAQueue.
UnLock
();
108
return
parg;
109
}
110
111
/******************************************************************************/
112
/* P r o c e s s */
113
/*****************************************************************************/
114
115
// This static entry is started on a thread during configuration
116
//
117
void
XrdCmsPrepArgs::Process
()
118
{
119
XrdCmsPrepArgs
*aP;
120
121
// Process all queued prepare arguments. If we have data then we do this
122
// for real. Otherwise, simply do a server selection and, if need be, tell
123
// the server to stage the file.
124
//
125
if
(
Config
.
DiskOK
)
126
do
{aP =
getRequest
();
127
PrepQ
.
Prepare
(aP);
128
delete
aP;
129
}
while
(1);
130
else
131
do
{
getRequest
()->
DoIt
();
132
}
while
(1);
133
}
134
135
/******************************************************************************/
136
/* Q u e u e */
137
/******************************************************************************/
138
139
void
XrdCmsPrepArgs::Queue
()
140
{
141
142
// Lock the queue and add the element and post the waiter
143
//
144
PAQueue.
Lock
();
145
if
(First) Last->Next =
this
;
146
else
First =
this
;
147
Last =
this
;
148
if
(isIdle) PAReady.
Post
();
149
PAQueue.
UnLock
();
150
}
XrdCmsConfig.hh
XrdCmsPrepArgs.hh
XrdCmsPrepare.hh
XrdCmsConfig::DiskOK
bool DiskOK
Definition
XrdCmsConfig.hh:124
XrdCmsPrepArgs
Definition
XrdCmsPrepArgs.hh:41
XrdCmsPrepArgs::Queue
void Queue()
Definition
XrdCmsPrepArgs.cc:139
XrdCmsPrepArgs::Ident
char * Ident
Definition
XrdCmsPrepArgs.hh:46
XrdCmsPrepArgs::options
int options
Definition
XrdCmsPrepArgs.hh:54
XrdCmsPrepArgs::Process
static void Process()
Definition
XrdCmsPrepArgs.cc:117
XrdCmsPrepArgs::mode
char * mode
Definition
XrdCmsPrepArgs.hh:50
XrdCmsPrepArgs::notify
char * notify
Definition
XrdCmsPrepArgs.hh:48
XrdCmsPrepArgs::ioV
struct iovec ioV[iovNum]
Definition
XrdCmsPrepArgs.hh:57
XrdCmsPrepArgs::prty
char * prty
Definition
XrdCmsPrepArgs.hh:49
XrdCmsPrepArgs::DoIt
void DoIt()
Definition
XrdCmsPrepArgs.hh:59
XrdCmsPrepArgs::opaque
char * opaque
Definition
XrdCmsPrepArgs.hh:52
XrdCmsPrepArgs::path
char * path
Definition
XrdCmsPrepArgs.hh:51
XrdCmsPrepArgs::Request
XrdCms::CmsRRHdr Request
Definition
XrdCmsPrepArgs.hh:45
XrdCmsPrepArgs::XrdCmsPrepArgs
XrdCmsPrepArgs(XrdCmsRRData &Arg)
Definition
XrdCmsPrepArgs.cc:56
XrdCmsPrepArgs::reqid
char * reqid
Definition
XrdCmsPrepArgs.hh:47
XrdCmsPrepArgs::clPath
char * clPath
Definition
XrdCmsPrepArgs.hh:53
XrdCmsPrepArgs::getRequest
static XrdCmsPrepArgs * getRequest()
Definition
XrdCmsPrepArgs.cc:94
XrdCmsPrepArgs::pathlen
int pathlen
Definition
XrdCmsPrepArgs.hh:55
XrdCmsPrepare::Prepare
void Prepare(XrdCmsPrepArgs *pargs)
Definition
XrdCmsPrepare.cc:313
XrdCmsRRData
Definition
XrdCmsRRData.hh:52
XrdCmsRRData::Dlen
int Dlen
Definition
XrdCmsRRData.hh:73
XrdCmsRRData::Buff
char * Buff
Definition
XrdCmsRRData.hh:71
XrdCmsRRData::Blen
int Blen
Definition
XrdCmsRRData.hh:72
XrdCmsRRData::Path
char * Path
Definition
XrdCmsRRData.hh:55
XrdCmsRRData::Reqid
char * Reqid
Definition
XrdCmsRRData.hh:60
XrdCmsRRData::Opaque
char * Opaque
Definition
XrdCmsRRData.hh:56
XrdCmsRRData::PathLen
int PathLen
Definition
XrdCmsRRData.hh:66
XrdCmsRRData::Prty
char * Prty
Definition
XrdCmsRRData.hh:62
XrdCmsRRData::Ident
char * Ident
Definition
XrdCmsRRData.hh:64
XrdCmsRRData::Mode
char * Mode
Definition
XrdCmsRRData.hh:63
XrdCmsRRData::Notify
char * Notify
Definition
XrdCmsRRData.hh:61
XrdCmsRRData::Request
XrdCms::CmsRRHdr Request
Definition
XrdCmsRRData.hh:54
XrdJob
Definition
XrdJob.hh:43
XrdSysMutex
Definition
XrdSysPthread.hh:165
XrdSysMutex::Lock
void Lock()
Definition
XrdSysPthread.hh:222
XrdSysMutex::UnLock
void UnLock()
Definition
XrdSysPthread.hh:224
XrdSysSemaphore
Definition
XrdSysPthread.hh:494
XrdSysSemaphore::Wait
void Wait()
Definition
XrdSysPthread.hh:509
XrdSysSemaphore::Post
void Post()
Definition
XrdSysPthread.hh:505
XrdCms
Definition
YProtocol.hh:78
XrdCms::CmsRRHdr::modifier
kXR_char modifier
Definition
YProtocol.hh:85
XrdCms::PrepQ
XrdCmsPrepare PrepQ
Definition
XrdCmsPrepare.cc:54
XrdCms::CmsRRHdr::streamid
kXR_unt32 streamid
Definition
YProtocol.hh:83
XrdCms::Config
XrdCmsConfig Config
Definition
XrdCmsConfig.cc:108
XrdCms::CmsPrepAddRequest::kYR_coloc
@ kYR_coloc
Definition
YProtocol.hh:413
XrdCms::CmsPrepAddRequest::kYR_stage
@ kYR_stage
Definition
YProtocol.hh:411
XrdCms
XrdCmsPrepArgs.cc
Generated by
1.12.0