This repository was archived by the owner on Feb 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathPyXRootDCopyProcess.cc
More file actions
154 lines (131 loc) · 6.25 KB
/
Copy pathPyXRootDCopyProcess.cc
File metadata and controls
154 lines (131 loc) · 6.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
//------------------------------------------------------------------------------
// Copyright (c) 2012-2014 by European Organization for Nuclear Research (CERN)
// Author: Justin Salmon <jsalmon@cern.ch>
// Author: Lukasz Janyst <ljanyst@cern.ch>
//------------------------------------------------------------------------------
// This file is part of the XRootD software suite.
//
// XRootD is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// XRootD is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with XRootD. If not, see <http://www.gnu.org/licenses/>.
//
// In applying this licence, CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
//------------------------------------------------------------------------------
#include "PyXRootDCopyProcess.hh"
#include "PyXRootDCopyProgressHandler.hh"
#include "XrdCl/XrdClConstants.hh"
#include "XrdCl/XrdClDefaultEnv.hh"
#include "Conversions.hh"
#include <XrdCl/XrdClDefaultEnv.hh>
#include <XrdCl/XrdClConstants.hh>
namespace PyXRootD
{
//----------------------------------------------------------------------------
// Add a job to the copy process
//----------------------------------------------------------------------------
PyObject* CopyProcess::AddJob( CopyProcess *self, PyObject *args, PyObject *kwds )
{
//--------------------------------------------------------------------------
// Initialize default parameters
//--------------------------------------------------------------------------
XrdCl::Env *env = XrdCl::DefaultEnv::GetEnv();
static const char *kwlist[]
= { "source", "target", "sourcelimit", "force", "posc", "coerce",
"mkdir", "thirdparty", "checksummode", "checksumtype",
"checksumpreset", "dynamicsource", "chunksize", "parallelchunks", "inittimeout",
"tpctimeout", NULL };
const char *source;
const char *target;
uint16_t sourceLimit = 1;
bool force = false;
bool posc = false;
bool coerce = false;
bool mkdir = false;
const char *thirdParty = "none";
const char *checkSumMode = "none";
const char *checkSumType = "";
const char *checkSumPreset = "";
bool dynamicSource = false;
int val = XrdCl::DefaultCPChunkSize;
env->GetInt( "CPChunkSize", val );
uint32_t chunkSize = val;
val = XrdCl::DefaultCPParallelChunks;
env->GetInt( "CPParallelChunks", val );
uint16_t parallelChunks = val;
val = XrdCl::DefaultCPInitTimeout;
env->GetInt( "CPInitTimeout", val );
uint16_t initTimeout = val;
val = XrdCl::DefaultCPTPCTimeout;
env->GetInt( "CPTPCTimeout", val );
uint16_t tpcTimeout = val;
if ( !PyArg_ParseTupleAndKeywords( args, kwds, "ss|HbbbbssssbIHHH:add_job",
(char**) kwlist, &source, &target, &sourceLimit, &force, &posc,
&coerce, &mkdir, &thirdParty, &checkSumMode, &checkSumType,
&checkSumPreset, &dynamicSource, &chunkSize, ¶llelChunks,
&initTimeout, &tpcTimeout) )
return NULL;
XrdCl::PropertyList properties;
self->results->push_back(XrdCl::PropertyList());
properties.Set( "source", source );
properties.Set( "target", target );
properties.Set( "force", force );
properties.Set( "posc", posc );
properties.Set( "coerce", coerce );
properties.Set( "makeDir", mkdir );
properties.Set( "dynamicSource", dynamicSource );
properties.Set( "thirdParty", thirdParty );
properties.Set( "checkSumMode", checkSumMode );
properties.Set( "checkSumType", checkSumType );
properties.Set( "checkSumPreset", checkSumPreset );
properties.Set( "chunkSize", chunkSize );
properties.Set( "parallelChunks", parallelChunks );
properties.Set( "initTimeout", initTimeout );
properties.Set( "tpcTimeout", tpcTimeout );
XrdCl::XRootDStatus status = self->process->AddJob(properties,
&self->results->back());
return ConvertType( &status );
}
//----------------------------------------------------------------------------
// Prepare the copy jobs
//----------------------------------------------------------------------------
PyObject* CopyProcess::Prepare( CopyProcess *self, PyObject *args, PyObject *kwds )
{
XrdCl::XRootDStatus status = self->process->Prepare();
return ConvertType( &status );
}
//----------------------------------------------------------------------------
// Run the copy jobs
//----------------------------------------------------------------------------
PyObject* CopyProcess::Run( CopyProcess *self, PyObject *args, PyObject *kwds )
{
(void) CopyProcessType; // Suppress unused variable warning
static const char *kwlist[] = { "handler", NULL };
PyObject *pyhandler = 0;
XrdCl::CopyProgressHandler *handler = 0;
if( !PyArg_ParseTupleAndKeywords( args, kwds, "|O", (char**) kwlist,
&pyhandler ) ) return NULL;
handler = new CopyProgressHandler( pyhandler );
XrdCl::XRootDStatus status;
//--------------------------------------------------------------------------
//! Allow other threads to acquire the GIL while the copy jobs are running
//--------------------------------------------------------------------------
Py_BEGIN_ALLOW_THREADS
status = self->process->Run( handler );
Py_END_ALLOW_THREADS
PyObject *tuple = PyTuple_New(2);
PyTuple_SetItem(tuple, 0, ConvertType(&status));
PyTuple_SetItem(tuple, 1, ConvertType(self->results));
return tuple;
}
}