Back to index

nordugrid-arc-nox  1.1.0~rc6
Public Member Functions | Static Public Member Functions | Protected Attributes | Static Protected Attributes
SRMClient Class Reference

A client interface to the SRM protocol. More...

#include <SRMClient.h>

Inheritance diagram for SRMClient:
Inheritance graph
[legend]
Collaboration diagram for SRMClient:
Collaboration graph
[legend]

List of all members.

Public Member Functions

SRMReturnCode connect (void)
 Establish a connection to the service.
bool disconnect (void)
 Disconnect from the service and destroy the connection.
virtual ~SRMClient ()
 empty destructor
void Timeout (int t)
 set the request timeout
std::string getVersion ()
 Returns the version of the SRM protocol used by this instance.
virtual SRMReturnCode ping (std::string &version, bool report_error=true)=0
 Find out the version supported by the server this client is connected to.
virtual SRMReturnCode getSpaceTokens (std::list< std::string > &tokens, std::string description="")=0
 Find the space tokens available to write to which correspond to the space token description, if given.
virtual SRMReturnCode getRequestTokens (std::list< std::string > &tokens, std::string description="")=0
 Returns a list of request tokens for the user calling the method which are still active requests, or the tokens corresponding to the token description, if given.
virtual SRMReturnCode getTURLs (SRMClientRequest &req, std::list< std::string > &urls)=0
 If the user wishes to copy a file from somewhere, getTURLs() is called to retrieve the transport URL to copy the file from.
virtual SRMReturnCode requestBringOnline (SRMClientRequest &req)=0
 Submit a request to bring online files.
virtual SRMReturnCode requestBringOnlineStatus (SRMClientRequest &req)=0
 Query the status of a request to bring files online.
virtual SRMReturnCode putTURLs (SRMClientRequest &req, std::list< std::string > &urls, unsigned long long size=0)=0
 If the user wishes to copy a file to somewhere, putTURLs() is called to retrieve the transport URL to copy the file to.
virtual SRMReturnCode releaseGet (SRMClientRequest &req)=0
 Should be called after a successful copy from SRM storage.
virtual SRMReturnCode releasePut (SRMClientRequest &req)=0
 Should be called after a successful copy to SRM storage.
virtual SRMReturnCode release (SRMClientRequest &req)=0
 Used in SRM v1 only.
virtual SRMReturnCode abort (SRMClientRequest &req)=0
 Called in the case of failure during transfer or releasePut.
virtual SRMReturnCode info (SRMClientRequest &req, std::list< struct SRMFileMetaData > &metadata, const int recursive=0, bool report_error=true)=0
 Returns information on a file or files (v2.2 and higher) stored in an SRM, such as file size, checksum and estimated access latency.
virtual SRMReturnCode remove (SRMClientRequest &req)=0
 Delete a file physically from storage and the SRM namespace.
virtual SRMReturnCode copy (SRMClientRequest &req, const std::string &source)=0
 Copy a file between two SRM storages.
virtual SRMReturnCode mkDir (SRMClientRequest &req)=0
 Make required directories for the SURL in the request.
 operator bool (void)
bool operator! (void)

Static Public Member Functions

static SRMClientgetInstance (std::string url, bool &timedout, std::string utils_dir, time_t timeout=300)
 Returns an SRMClient instance with the required protocol version.

Protected Attributes

std::string service_endpoint
 The URL of the service endpoint, eg httpg://srm.ndgf.org:8443/srm/managerv2 All SURLs passed to methods must correspond to this endpoint.
Arc::HTTPSClientSOAPcsoap
 SOAP client object.
SRMImplementation implementation
 The implementation of the server.
std::string version
 The version of the SRM protocol used.

Static Protected Attributes

static time_t request_timeout = 300
 Timeout for requests to the SRM service.
static Arc::Logger logger
 Logger.

Detailed Description

A client interface to the SRM protocol.

Instances of SRM clients are created by calling the getInstance() factory method. One client instance can be used to make many requests to the same server (with the same protocol version), but not multiple servers.

Definition at line 294 of file SRMClient.h.


Constructor & Destructor Documentation

virtual SRMClient::~SRMClient ( ) [inline, virtual]

empty destructor

Definition at line 361 of file SRMClient.h.

{};

Member Function Documentation

virtual SRMReturnCode SRMClient::abort ( SRMClientRequest req) [pure virtual]

Called in the case of failure during transfer or releasePut.

Releases all TURLs involved in the transfer.

Parameters:
reqThe request object
Returns:
SRMReturnCode specifying outcome of operation

Implemented in SRM22Client, and SRM1Client.

Here is the caller graph for this function:

Establish a connection to the service.

Returns:
SRMReturnCode specifying outcome of operation

Definition at line 14 of file SRMClient.cpp.

                                       {
    if(!csoap) return SRM_ERROR_OTHER;
    int r = csoap->connect();
    if (r == 1) return SRM_ERROR_TEMPORARY;
    if (r != 0) return SRM_ERROR_CONNECTION;
    return SRM_OK;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

virtual SRMReturnCode SRMClient::copy ( SRMClientRequest req,
const std::string &  source 
) [pure virtual]

Copy a file between two SRM storages.

Parameters:
reqThe request object
sourceThe source SURL
Returns:
SRMReturnCode specifying outcome of operation

Implemented in SRM22Client, and SRM1Client.

bool SRMClient::disconnect ( void  ) [inline]

Disconnect from the service and destroy the connection.

Definition at line 340 of file SRMClient.h.

{ if(!csoap) return true; return (csoap->disconnect() == 0);};

Here is the call graph for this function:

Here is the caller graph for this function:

SRMClient * SRMClient::getInstance ( std::string  url,
bool &  timedout,
std::string  utils_dir,
time_t  timeout = 300 
) [static]

Returns an SRMClient instance with the required protocol version.

This must be used to create SRMClient instances. Specifying a version explicitly forces creation of a client with that version.

Parameters:
urlA SURL. A client connects to the service host derived from this SURL. All operations with a client instance must use SURLs with the same host as this one.
timedoutWhether the connection timed out
utils_dirPath to a directory contining files with SRM info
timeoutConnection timeout. is returned.

Definition at line 22 of file SRMClient.cpp.

                                                    {
    request_timeout = timeout;
    SRMURL srm_url(url);
    if (!srm_url) return NULL;
  
    // can't use ping with srmv1 so just return
    if (srm_url.SRMVersion() == SRMURL::SRM_URL_VERSION_1)
      return new SRM1Client(srm_url);
  
    if (utils_dir.empty()) {
      if (srm_url.SRMVersion() == SRMURL::SRM_URL_VERSION_2_2) return new SRM22Client(srm_url);
      return NULL;
    }
      
    SRMReturnCode srm_error;
    std::string version;
  
    SRMInfo info(utils_dir);
    SRMFileInfo srm_file_info;
    // lists of ports and protocols in the order to try them
    std::vector<int> ports;
    ports.push_back(srm_url.Port());
    if (srm_url.Port() != 8443) ports.push_back(8443);
    if (srm_url.Port() != 8446) ports.push_back(8446);
    if (srm_url.Port() != 8444) ports.push_back(8444);
    std::vector<std::string> protocols;
    if (srm_url.GSSAPI()) {
      protocols.push_back("gssapi");
      protocols.push_back("gsi");
    }
    else {
      protocols.push_back("gsi");
      protocols.push_back("gssapi");
    }    
    
    srm_file_info.host = srm_url.Host();
    srm_file_info.version = srm_url.SRMVersion();
    
    // no info
    if (!info.getSRMFileInfo(srm_file_info)) {
      for (std::vector<std::string>::iterator protocol = protocols.begin(); protocol != protocols.end(); protocol++) {
        srm_url.GSSAPI((*protocol == "gssapi") ? true : false);
        for (std::vector<int>::iterator port = ports.begin(); port != ports.end(); port++) {
          logger.msg(Arc::VERBOSE, "Attempting to contact %s on port %i using protocol %s", srm_url.Host(), *port, *protocol);
          srm_url.SetPort(*port);
          SRMClient * client = new SRM22Client(srm_url);
      
          if ((srm_error = client->ping(version, false)) == SRM_OK) {
            srm_file_info.port = *port;
            srm_file_info.protocol = *protocol;
            logger.msg(Arc::VERBOSE, "Storing port %i and protocol %s for %s", *port, *protocol, srm_url.Host());
            info.putSRMFileInfo(srm_file_info);
            return client;
          }
          delete client;
          if (srm_error == SRM_ERROR_TEMPORARY) {
            // probably correct port and protocol and service is down
            // but don't want to risk storing incorrect info
            timedout = true;
            return NULL;
          }
        }
      }
      // if we get here no combination has worked
      logger.msg(Arc::VERBOSE, "No combination of port and protocol succeeded for %s", srm_url.Host());
      return NULL;
    }
    // url agrees with file info
    else if (srm_file_info == srm_url) {
      srm_url.SetPort(srm_file_info.port);
      srm_url.GSSAPI((srm_file_info.protocol == "gssapi") ? true : false);
      return new SRM22Client(srm_url);
    }
    // url disagrees with file info
    else {
      // ping and if ok, replace file info
      logger.msg(Arc::VERBOSE, "URL %s disagrees with stored SRM info, testing new info", srm_url.ShortURL());
      SRMClient * client = new SRM22Client(srm_url);
  
      if ((srm_error = client->ping(version, false)) == SRM_OK) {
        srm_file_info.port = srm_url.Port();
        srm_file_info.protocol = srm_url.GSSAPI()? "gssapi" : "gsi";
        logger.msg(Arc::VERBOSE, "Replacing old SRM info with new for URL %s", srm_url.ShortURL());
        info.putSRMFileInfo(srm_file_info);
        return client;
      }
      delete client;
      if (srm_error == SRM_ERROR_TEMPORARY) {
        // probably correct port and protocol and service is down
        // but don't want to risk storing incorrect info
        timedout = true;
      }
      return NULL;
    }
 }

Here is the call graph for this function:

Here is the caller graph for this function:

virtual SRMReturnCode SRMClient::getRequestTokens ( std::list< std::string > &  tokens,
std::string  description = "" 
) [pure virtual]

Returns a list of request tokens for the user calling the method which are still active requests, or the tokens corresponding to the token description, if given.

Parameters:
tokensThe list filled by the service
descriptionThe user request description, which can be specified when the request is created
Returns:
SRMReturnCode specifying outcome of operation

Implemented in SRM22Client, and SRM1Client.

virtual SRMReturnCode SRMClient::getSpaceTokens ( std::list< std::string > &  tokens,
std::string  description = "" 
) [pure virtual]

Find the space tokens available to write to which correspond to the space token description, if given.

The list of tokens is a list of numbers referring to the SRM internal definition of the spaces, not user-readable strings.

Parameters:
tokensThe list filled by the service
descriptionThe space token description
Returns:
SRMReturnCode specifying outcome of operation

Implemented in SRM22Client, and SRM1Client.

Here is the caller graph for this function:

virtual SRMReturnCode SRMClient::getTURLs ( SRMClientRequest req,
std::list< std::string > &  urls 
) [pure virtual]

If the user wishes to copy a file from somewhere, getTURLs() is called to retrieve the transport URL to copy the file from.

Parameters:
reqThe request object
urlsA list of TURLs filled by the method
Returns:
SRMReturnCode specifying outcome of operation

Implemented in SRM22Client, and SRM1Client.

Here is the caller graph for this function:

std::string SRMClient::getVersion ( ) [inline]

Returns the version of the SRM protocol used by this instance.

Definition at line 371 of file SRMClient.h.

{return version;};

Here is the caller graph for this function:

virtual SRMReturnCode SRMClient::info ( SRMClientRequest req,
std::list< struct SRMFileMetaData > &  metadata,
const int  recursive = 0,
bool  report_error = true 
) [pure virtual]

Returns information on a file or files (v2.2 and higher) stored in an SRM, such as file size, checksum and estimated access latency.

Parameters:
reqThe request object
metadataA list of structs filled with file information
recursiveThe level of recursion into sub directories
report_errorDetermines if errors should be reported
Returns:
SRMReturnCode specifying outcome of operation
See also:
SRMFileMetaData

Implemented in SRM22Client, and SRM1Client.

Here is the caller graph for this function:

virtual SRMReturnCode SRMClient::mkDir ( SRMClientRequest req) [pure virtual]

Make required directories for the SURL in the request.

Parameters:
reqThe request object
Returns:
SRMReturnCode specifying outcome of operation

Implemented in SRM22Client, and SRM1Client.

SRMClient::operator bool ( void  ) [inline]

Definition at line 519 of file SRMClient.h.

{ return csoap; };
bool SRMClient::operator! ( void  ) [inline]

Definition at line 520 of file SRMClient.h.

{ return !csoap; };
virtual SRMReturnCode SRMClient::ping ( std::string &  version,
bool  report_error = true 
) [pure virtual]

Find out the version supported by the server this client is connected to.

Since this method is used to determine which client version to instantiate, we may not want to report an error to the user, so setting report_error to false supresses the error message.

Parameters:
versionThe version returned by the server
report_errorWhether an error should be reported
Returns:
SRMReturnCode specifying outcome of operation

Implemented in SRM22Client, and SRM1Client.

Here is the caller graph for this function:

virtual SRMReturnCode SRMClient::putTURLs ( SRMClientRequest req,
std::list< std::string > &  urls,
unsigned long long  size = 0 
) [pure virtual]

If the user wishes to copy a file to somewhere, putTURLs() is called to retrieve the transport URL to copy the file to.

Parameters:
reqThe request object
urlsA list of TURLs filled by the method
sizeThe size of the file
Returns:
SRMReturnCode specifying outcome of operation

Implemented in SRM22Client, and SRM1Client.

Here is the caller graph for this function:

virtual SRMReturnCode SRMClient::release ( SRMClientRequest req) [pure virtual]

Used in SRM v1 only.

Called to release files after successful transfer.

Parameters:
reqThe request object
Returns:
SRMReturnCode specifying outcome of operation

Implemented in SRM22Client, and SRM1Client.

virtual SRMReturnCode SRMClient::releaseGet ( SRMClientRequest req) [pure virtual]

Should be called after a successful copy from SRM storage.

Parameters:
reqThe request object
Returns:
SRMReturnCode specifying outcome of operation

Implemented in SRM22Client, and SRM1Client.

Here is the caller graph for this function:

virtual SRMReturnCode SRMClient::releasePut ( SRMClientRequest req) [pure virtual]

Should be called after a successful copy to SRM storage.

Parameters:
reqThe request object
Returns:
SRMReturnCode specifying outcome of operation

Implemented in SRM22Client, and SRM1Client.

Here is the caller graph for this function:

virtual SRMReturnCode SRMClient::remove ( SRMClientRequest req) [pure virtual]

Delete a file physically from storage and the SRM namespace.

Parameters:
reqThe request object
Returns:
SRMReturnCode specifying outcome of operation

Implemented in SRM22Client, and SRM1Client.

Here is the caller graph for this function:

Submit a request to bring online files.

This operation is asynchronous and the status of the request can be checked by calling requestBringOnlineStatus() with the request token in req which is assigned by this method.

Parameters:
reqThe request object
Returns:
SRMReturnCode specifying outcome of operation

Implemented in SRM22Client, and SRM1Client.

Query the status of a request to bring files online.

The SURLs map is updated if the status of any files in the request has changed.

Parameters:
reqThe request object to query the status of
Returns:
SRMReturnCode specifying outcome of operation

Implemented in SRM22Client, and SRM1Client.

void SRMClient::Timeout ( int  t) [inline]

set the request timeout

Definition at line 366 of file SRMClient.h.


Member Data Documentation

SOAP client object.

Definition at line 307 of file SRMClient.h.

The implementation of the server.

Definition at line 312 of file SRMClient.h.

Arc::Logger SRMClient::logger [static, protected]

Logger.

Definition at line 327 of file SRMClient.h.

time_t SRMClient::request_timeout = 300 [static, protected]

Timeout for requests to the SRM service.

Definition at line 317 of file SRMClient.h.

std::string SRMClient::service_endpoint [protected]

The URL of the service endpoint, eg httpg://srm.ndgf.org:8443/srm/managerv2 All SURLs passed to methods must correspond to this endpoint.

Definition at line 302 of file SRMClient.h.

std::string SRMClient::version [protected]

The version of the SRM protocol used.

Definition at line 322 of file SRMClient.h.


The documentation for this class was generated from the following files: