Skip to content

Commit

Permalink
[XrdCl] Expose --zip-mtln-cksum functionality through XRD_ZIPMTLNCKSU…
Browse files Browse the repository at this point in the history
…M envar.

Also, it's possible tto enable the functionallity from Python using:

  EnvPutInt( "ZipMtlnCksum", 1 )

for more details see:

  https://github.com/xrootd/xrootd/blob/master/bindings/python/libs/client/env.py
  • Loading branch information
simonmichal committed Apr 7, 2020
1 parent 1e561db commit 7d47317
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 14 deletions.
6 changes: 6 additions & 0 deletions docs/man/xrdcp.1
Expand Up @@ -517,6 +517,12 @@ If set to 1 XRootD client will preserve tired/triedrc cgi opaque info for kXR_lo
if set to 0 XRootD client will treat kXR_locate as any other passive request.
.RE

XRD_ZIPMTLNCKSUM
.RS 5
If set to 1, use the checksum available in a metalink file even if a file is being extracted from a ZIP archive.
By defaut set to 0;
.RE

.SH RETURN CODES
.RE
\fB50\fR : generic error (e.g. config, internal, data, OS, command line option)
Expand Down
18 changes: 8 additions & 10 deletions src/XrdCl/XrdClClassicCopyJob.cc
Expand Up @@ -756,12 +756,10 @@ namespace
const XrdCl::URL *archive,
uint32_t chunkSize,
uint8_t parallelChunks,
const std::string &ckSumType,
bool useMtlnCksum ):
const std::string &ckSumType ):
XRootDSource( archive, chunkSize, parallelChunks, ckSumType ),
pFilename( filename ),
pZipArchive( new XrdCl::ZipArchiveReader( *pFile ) ),
pUseMtlnCksum( useMtlnCksum )
pZipArchive( new XrdCl::ZipArchiveReader( *pFile ) )
{
}

Expand Down Expand Up @@ -835,7 +833,10 @@ namespace
if( checkSumType == "zcrc32" )
return pZipArchive->ZCRC32( checkSum );

if( pUseMtlnCksum && pUrl->IsMetalink() )
int useMtlnCksum = XrdCl::DefaultZipMtlnCksum;
XrdCl::Env *env = XrdCl::DefaultEnv::GetEnv();
env->GetInt( "ZipMtlnCksum", useMtlnCksum );
if( useMtlnCksum && pUrl->IsMetalink() )
{
XrdCl::RedirectorRegistry &registry = XrdCl::RedirectorRegistry::Instance();
XrdCl::VirtualRedirector *redirector = registry.Get( *pUrl );
Expand All @@ -858,7 +859,6 @@ namespace

const std::string pFilename;
XrdCl::ZipArchiveReader *pZipArchive;
bool pUseMtlnCksum;
};

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -1553,8 +1553,7 @@ namespace XrdCl
uint16_t parallelChunks;
uint32_t chunkSize;
uint64_t blockSize;
bool posc, force, coerce, makeDir, dynamicSource, zip, xcp,
zipMtlnCksum;
bool posc, force, coerce, makeDir, dynamicSource, zip, xcp;
int32_t nbXcpSources;
long long xRate;

Expand All @@ -1572,7 +1571,6 @@ namespace XrdCl
pProperties->Get( "xcp", xcp );
pProperties->Get( "xcpBlockSize", blockSize );
pProperties->Get( "xrate", xRate );
pProperties->Get( "zipMtlnCksum", zipMtlnCksum );

if( zip )
pProperties->Get( "zipSource", zipSource );
Expand All @@ -1587,7 +1585,7 @@ namespace XrdCl
if( xcp )
src.reset( new XRootDSourceXCp( &GetSource(), chunkSize, parallelChunks, nbXcpSources, blockSize ) );
else if( zip ) // TODO make zip work for xcp
src.reset( new XRootDSourceZip( zipSource, &GetSource(), chunkSize, parallelChunks, checkSumType, zipMtlnCksum ) );
src.reset( new XRootDSourceZip( zipSource, &GetSource(), chunkSize, parallelChunks, checkSumType ) );
else if( GetSource().GetProtocol() == "stdio" )
src.reset( new StdInSource( checkSumType, chunkSize ) );
else
Expand Down
1 change: 1 addition & 0 deletions src/XrdCl/XrdClConstants.hh
Expand Up @@ -74,6 +74,7 @@ namespace XrdCl
const int DefaultMaxMetalinkWait = 60;
const int DefaultPreserveLocateTried = 1;
const int DefaultNotAuthorizedRetryLimit = 3;
const int DefaultZipMtlnCksum = 0;

const char * const DefaultPollerPreference = "built-in";
const char * const DefaultNetworkStack = "IPAuto";
Expand Down
6 changes: 3 additions & 3 deletions src/XrdCl/XrdClCopy.cc
Expand Up @@ -489,7 +489,6 @@ int main( int argc, char **argv )
bool makedir = false;
bool dynSrc = false;
bool delegate = false;
bool zipMtlnCksum = false;
std::string thirdParty = "none";

if( config.Want( XrdCpConfig::DoPosc ) ) posc = true;
Expand All @@ -512,7 +511,6 @@ int main( int argc, char **argv )
if( config.Want( XrdCpConfig::DoRecurse ) ) makedir = true;
if( config.Want( XrdCpConfig::DoPath ) ) makedir = true;
if( config.Want( XrdCpConfig::DoDynaSrc ) ) dynSrc = true;
if( config.Want( XrdCpConfig::DoZipMtlnCksum ) ) zipMtlnCksum = true;

//----------------------------------------------------------------------------
// Checksums
Expand Down Expand Up @@ -585,6 +583,9 @@ int main( int argc, char **argv )
if( config.nStrm != 0 )
env->PutInt( "SubStreamsPerChannel", config.nStrm + 1 /*stands for the control stream*/ );

if( config.Want( XrdCpConfig::DoZipMtlnCksum ) )
env->PutInt( "ZipMtlnCksum", 1 );

int chunkSize = DefaultCPChunkSize;
env->GetInt( "CPChunkSize", chunkSize );

Expand Down Expand Up @@ -783,7 +784,6 @@ int main( int argc, char **argv )
properties.Set( "delegate", delegate );
properties.Set( "targetIsDir", targetIsDir );
properties.Set( "xrate", config.xRate );
properties.Set( "zipMtlnCksum", zipMtlnCksum );

if( zip )
properties.Set( "zipSource", zipFile );
Expand Down
2 changes: 1 addition & 1 deletion src/XrdCl/XrdClCopyProcess.cc
Expand Up @@ -169,7 +169,7 @@ namespace XrdCl
pJobProperties.push_back( properties );
PropertyList &p = pJobProperties.back();

const char *bools[] = {"target", "force", "posc", "coerce", "makeDir", "zipArchive", "xcp", "zipMtlnCksum", 0};
const char *bools[] = {"target", "force", "posc", "coerce", "makeDir", "zipArchive", "xcp", 0};
for( int i = 0; bools[i]; ++i )
if( !p.HasProperty( bools[i] ) )
p.Set( bools[i], false );
Expand Down
1 change: 1 addition & 0 deletions src/XrdCl/XrdClDefaultEnv.cc
Expand Up @@ -292,6 +292,7 @@ namespace XrdCl
REGISTER_VAR_INT( varsInt, "MaxMetalinkWait", DefaultMaxMetalinkWait );
REGISTER_VAR_INT( varsInt, "PreserveLocateTried", DefaultPreserveLocateTried );
REGISTER_VAR_INT( varsInt, "NotAuthorizedRetryLimit", DefaultNotAuthorizedRetryLimit );
REGISTER_VAR_INT( varsInt, "ZipMtlnCksum", DefaultZipMtlnCksum );

REGISTER_VAR_STR( varsStr, "PollerPreference", DefaultPollerPreference );
REGISTER_VAR_STR( varsStr, "ClientMonitor", DefaultClientMonitor );
Expand Down

0 comments on commit 7d47317

Please sign in to comment.