Skip to content

Commit

Permalink
[XrdCl] Refactor TPC fall-back logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmichal committed Oct 17, 2018
1 parent 0d7c2a3 commit cc7ec36
Show file tree
Hide file tree
Showing 5 changed files with 350 additions and 250 deletions.
12 changes: 5 additions & 7 deletions src/XrdCl/XrdClCopy.cc
Expand Up @@ -31,8 +31,8 @@
#include "XrdCl/XrdClFileSystem.hh"
#include "XrdCl/XrdClUtils.hh"
#include "XrdCl/XrdClRedirectorRegistry.hh"
#include "XrdCl/XrdClDlgEnv.hh"
#include "XrdSys/XrdSysPthread.hh"
#include "XrdOuc/XrdOucEnv.hh"

#include <stdio.h>
#include <iostream>
Expand Down Expand Up @@ -548,15 +548,12 @@ int main( int argc, char **argv )
// inhere and we need the env var when we are establishing the
// connection and authenticating), but we are also setting a delegate
// parameter for CopyJob so it can be used on its own.
XrdOucEnv env;
env.Export( "XrdSecGSIDELEGPROXY", 1 );
DlgEnv::Instance().Enable();
delegate = true;
}
else
{
XrdOucEnv env;
env.Export( "XrdSecGSIDELEGPROXY", 0 );
}
DlgEnv::Instance().Disable();

if( config.Want( XrdCpConfig::DoRecurse ) ) makedir = true;
if( config.Want( XrdCpConfig::DoPath ) ) makedir = true;
if( config.Want( XrdCpConfig::DoDynaSrc ) ) dynSrc = true;
Expand Down Expand Up @@ -911,6 +908,7 @@ int main( int argc, char **argv )
return st.GetShellCode();
}
CleanUpResults( resultVect );

return 0;
}

80 changes: 80 additions & 0 deletions src/XrdCl/XrdClDlgEnv.hh
@@ -0,0 +1,80 @@
/*
* XrdClDlgEnv.hh
*
* Created on: Oct 17, 2018
* Author: simonm
*/

#ifndef SRC_XRDCL_XRDCLDLGENV_HH_
#define SRC_XRDCL_XRDCLDLGENV_HH_

#include <stdlib.h>


namespace XrdCl
{

//----------------------------------------------------------------------------
//! Helper class for setting and unsetting the 'XrdSecGSIDELEGPROXY'
//! environment variable.
//----------------------------------------------------------------------------
class DlgEnv
{
public:

//------------------------------------------------------------------------
//! @return : instance of DlgEnv
//------------------------------------------------------------------------
static DlgEnv& Instance()
{
static DlgEnv instance;
return instance;
}

//------------------------------------------------------------------------
//! Destructor
//!
//! Release the memory used to set environment
//------------------------------------------------------------------------
~DlgEnv()
{
unsetenv( "XrdSecGSIDELEGPROXY" );
}

//------------------------------------------------------------------------
//! Enable delegation in the environment
//------------------------------------------------------------------------
void Enable()
{
setenv( "XrdSecGSIDELEGPROXY", "1", 1 );
}

//------------------------------------------------------------------------
//! Disable delegation in the environment
//------------------------------------------------------------------------
void Disable()
{
setenv( "XrdSecGSIDELEGPROXY", "0", 1 );
}

private:

//------------------------------------------------------------------------
//! Default constructor
//------------------------------------------------------------------------
DlgEnv() { }

//------------------------------------------------------------------------
//! Copy constructor - deleted
//------------------------------------------------------------------------
DlgEnv( const DlgEnv& );

//------------------------------------------------------------------------
//! Assigment operator - deleted
//------------------------------------------------------------------------
DlgEnv& operator=( const DlgEnv& );
};

}

#endif /* SRC_XRDCL_XRDCLDLGENV_HH_ */
24 changes: 13 additions & 11 deletions src/XrdCl/XrdClTPFallBackCopyJob.cc
Expand Up @@ -70,19 +70,21 @@ namespace XrdCl
if( tmp == "first" )
tpcFallBack = true;

XRootDStatus st = ThirdPartyCopyJob::CanDo( GetSource(), GetTarget(),
pProperties );
pJob = new ThirdPartyCopyJob( pJobId, pProperties, pResults );
XRootDStatus st = pJob->Run( progress );
if( st.IsOK() ) return st; // we are done

if( st.IsOK() )
pJob = new ThirdPartyCopyJob( pJobId, pProperties, pResults );
else if( tpcFallBack && !st.IsFatal() )
// check if we can fall back to streaming
if( tpcFallBack && ( st.code == errNotSupported || st.code == errOperationExpired ) )
{
Log *log = DefaultEnv::GetLog();
log->Debug( UtilityMsg, "TPC is not supported, falling back to streaming mode." );

delete pJob;
pJob = new ClassicCopyJob( pJobId, pProperties, pResults );
else
return st;
return pJob->Run( progress );
}

//--------------------------------------------------------------------------
// Run the job
//--------------------------------------------------------------------------
return pJob->Run( progress );
return st;
}
}

0 comments on commit cc7ec36

Please sign in to comment.