XRootD
Loading...
Searching...
No Matches
XrdClTPFallBackCopyJob.cc
Go to the documentation of this file.
1//------------------------------------------------------------------------------
2// Copyright (c) 2014 by European Organization for Nuclear Research (CERN)
3// Author: Lukasz Janyst <ljanyst@cern.ch>
4//------------------------------------------------------------------------------
5// This file is part of the XRootD software suite.
6//
7// XRootD is free software: you can redistribute it and/or modify
8// it under the terms of the GNU Lesser General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// XRootD is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU Lesser General Public License
18// along with XRootD. If not, see <http://www.gnu.org/licenses/>.
19//
20// In applying this licence, CERN does not waive the privileges and immunities
21// granted to it by virtue of its status as an Intergovernmental Organization
22// or submit itself to any jurisdiction.
23//------------------------------------------------------------------------------
24
29#include "XrdCl/XrdClLog.hh"
31#include <string>
32
33namespace XrdCl
34{
35 //----------------------------------------------------------------------------
36 // Constructor
37 //----------------------------------------------------------------------------
39 PropertyList *jobProperties,
40 PropertyList *jobResults ):
41 CopyJob( jobId, jobProperties, jobResults ),
42 pJob( 0 )
43 {
44 Log *log = DefaultEnv::GetLog();
45 log->Debug( UtilityMsg, "Creating a third party fall back copy job, "
46 "from %s to %s", GetSource().GetObfuscatedURL().c_str(),
47 GetTarget().GetObfuscatedURL().c_str() );
48 }
49
50 //------------------------------------------------------------------------
51 // Destructor
52 //------------------------------------------------------------------------
54 {
55 delete pJob;
56 }
57
58 //----------------------------------------------------------------------------
59 // Run the copy job
60 //----------------------------------------------------------------------------
62 {
63 //--------------------------------------------------------------------------
64 // Set up the job
65 //--------------------------------------------------------------------------
66 std::string tmp;
67 bool tpcFallBack = false;
68
69 pProperties->Get( "thirdParty", tmp );
70 if( tmp == "first" )
71 tpcFallBack = true;
72
74 XRootDStatus st = pJob->Run( progress );
75 if( st.IsOK() ) return st; // we are done
76
77 // check if we can fall back to streaming
78 if( tpcFallBack && ( st.code == errNotSupported || st.code == errOperationExpired ) )
79 {
80 Log *log = DefaultEnv::GetLog();
81 log->Debug( UtilityMsg, "TPC is not supported, falling back to streaming mode." );
82
83 delete pJob;
85 return pJob->Run( progress );
86 }
87
88 return st;
89 }
90}
PropertyList * pResults
virtual XRootDStatus Run(CopyProgressHandler *progress=0)=0
const URL & GetSource() const
Get source.
const URL & GetTarget() const
Get target.
PropertyList * pProperties
Interface for copy progress notification.
static Log * GetLog()
Get default log.
Handle diagnostics.
Definition XrdClLog.hh:101
void Debug(uint64_t topic, const char *format,...)
Print a debug message.
Definition XrdClLog.cc:282
A key-value pair map storing both keys and values as strings.
bool Get(const std::string &name, Item &item) const
TPFallBackCopyJob(uint16_t jobId, PropertyList *jobProperties, PropertyList *jobResults)
Constructor.
virtual ~TPFallBackCopyJob()
Destructor.
virtual XRootDStatus Run(CopyProgressHandler *progress=0)
const uint16_t errOperationExpired
const uint64_t UtilityMsg
const uint16_t errNotSupported
uint16_t code
Error type, or additional hints on what to do.
bool IsOK() const
We're fine.