Back to index

nordugrid-arc-nox  1.1.0~rc6
Public Member Functions | Private Attributes
Paul::FileTransfer Class Reference
Collaboration diagram for Paul::FileTransfer:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ~FileTransfer ()
 FileTransfer (const std::string &_cache_path)
void create_cache (Job &j)
void download (const std::string &job_root, Job &j)
void upload (const std::string &job_root, Job &j)

Private Attributes

Arc::DataMovermover
Arc::FileCachecache
Arc::URLMap url_map
Arc::Logger logger_
unsigned long long int min_speed
time_t min_speed_time
unsigned long long int min_average_speed
time_t max_inactivity_time
std::string cache_path

Detailed Description

Definition at line 40 of file stage.cpp.


Constructor & Destructor Documentation

Definition at line 54 of file stage.cpp.

        {
            delete mover;
            delete cache;
        };
Paul::FileTransfer::FileTransfer ( const std::string &  _cache_path) [inline]

Definition at line 60 of file stage.cpp.

                                                  :logger_(Arc::Logger::rootLogger, "Paul-FileTransfer") {
            cache_path = _cache_path;
            logger_.msg(Arc::VERBOSE, "Filetransfer created");
    
        };

Here is the call graph for this function:


Member Function Documentation

void Paul::FileTransfer::create_cache ( Job j) [inline]

Definition at line 66 of file stage.cpp.

        {
            // Create cache
            Arc::User cache_user;
            std::string job_id = j.getID();
            std::string cache_dir = cache_path;
#ifndef WIN32
            cache = new Arc::FileCache (cache_dir, job_id, 
#else
            std::string cache_data_dir = cache_dir; 
            std::string cache_link_dir;
            cache = new Arc::FileCache (cache_dir, cache_data_dir,
                                        cache_link_dir, job_id,
#endif
                                        cache_user.get_uid(),
                                        cache_user.get_gid());
        }

Here is the call graph for this function:

Here is the caller graph for this function:

void Paul::FileTransfer::download ( const std::string &  job_root,
Job j 
) [inline]

Definition at line 84 of file stage.cpp.

        {
            // Create mover
            mover = new Arc::DataMover();
            mover->retry(true);
            mover->secure(false); // XXX what if I download form https url? 
            mover->passive(false);
            mover->verbose(true);
            min_speed = 0;
            min_speed_time = 300;
            min_average_speed = 0;
            max_inactivity_time = 300;
            if (min_speed != 0) {
                mover->set_default_min_speed(min_speed,min_speed_time);
            }
            if (min_average_speed != 0) {
                mover->set_default_min_average_speed(min_average_speed);
            }
            if(max_inactivity_time != 0) {
                mover->set_default_max_inactivity_time(max_inactivity_time);
            }
            create_cache(j);
            logger_.msg(Arc::VERBOSE, "download");
            Arc::XMLNode jd = j.getJSDL()["JobDescription"];
            std::string xml_str;
            j.getJSDL().GetXML(xml_str);
            logger_.msg(Arc::VERBOSE, xml_str);
            Arc::XMLNode ds;
            for (int i = 0; (ds = jd["DataStaging"][i]) != false; i++) {
                std::string dest = Glib::build_filename(Glib::build_filename(job_root, j.getID()), (std::string)ds["FileName"]);
                Arc::XMLNode s = ds["Source"];
                if (s == false) {
                    // it should not download
                    continue;
                }
                std::string src = (std::string)s["URI"];
                logger_.msg(Arc::VERBOSE, "%s -> %s", src, dest);
    
                std::string failure;
                Arc::UserConfig usercfg(true);
                PointPair *pair = new PointPair(src, dest, usercfg);
                if (pair->source == NULL) {
                    logger_.msg(Arc::ERROR, "Cannot accept source as URL");
                    delete pair;
                    continue;
                }
                if (pair->destination == NULL) {
                    logger_.msg(Arc::ERROR, "Cannot accept destination as URL");
                    delete pair;
                    continue;
                }
                Arc::DataStatus res = mover->Transfer(*(pair->source), *(pair->destination), 
                                                      *cache, url_map, 
                                                      min_speed, min_speed_time, 
                                                      min_average_speed, max_inactivity_time); 
                if (!res.Passed()) {
                    logger_.msg(Arc::ERROR, std::string(res));
                    delete pair;
                    continue;
                }
                delete pair;
            }
        };

Here is the call graph for this function:

Here is the caller graph for this function:

void Paul::FileTransfer::upload ( const std::string &  job_root,
Job j 
) [inline]

Definition at line 148 of file stage.cpp.

        {
            // Create mover
            mover = new Arc::DataMover();
            mover->retry(true);
            mover->secure(false); // XXX what if I download form https url? 
            mover->passive(false);
            mover->verbose(true);
            min_speed = 0;
            min_speed_time = 300;
            min_average_speed = 0;
            max_inactivity_time = 300;
            if (min_speed != 0) {
                mover->set_default_min_speed(min_speed,min_speed_time);
            }
            if (min_average_speed != 0) {
                mover->set_default_min_average_speed(min_average_speed);
            }
            if(max_inactivity_time != 0) {
                mover->set_default_max_inactivity_time(max_inactivity_time);
            }
            create_cache(j);
            Arc::XMLNode jd = j.getJSDL()["JobDescription"];
            Arc::XMLNode ds;
            for (int i = 0; (ds = jd["DataStaging"][i]) != false; i++) {
                std::string src = Glib::build_filename(Glib::build_filename(job_root, j.getID()), (std::string)ds["FileName"]);
                Arc::XMLNode d = ds["Target"];
                if (d == false) {
                    // it should not upload
                    continue;
                }
                std::string dest = (std::string)d["URI"];
                logger_.msg(Arc::VERBOSE, "%s -> %s", src, dest);
    
                std::string failure;
                Arc::UserConfig usercfg(true);
                PointPair *pair = new PointPair(src, dest, usercfg);
                if (pair->source == NULL) {
                    logger_.msg(Arc::ERROR, "Cannot accept source as URL");
                    delete pair;
                    continue;
                }
                if (pair->destination == NULL) {
                    logger_.msg(Arc::ERROR, "Cannot accept destination as URL");
                    delete pair;
                    continue;
                }
                Arc::DataStatus res = mover->Transfer(*(pair->source), *(pair->destination), 
                                                      *cache, url_map, 
                                                      min_speed, min_speed_time, 
                                                      min_average_speed, max_inactivity_time);
                if (!res.Passed()) {
                    logger_.msg(Arc::ERROR, std::string(res));
                    delete pair;
                    continue;
                }
                logger_.msg(Arc::VERBOSE, "Transfer completed");
                delete pair;
            }
        };

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 44 of file stage.cpp.

std::string Paul::FileTransfer::cache_path [private]

Definition at line 51 of file stage.cpp.

Definition at line 46 of file stage.cpp.

Definition at line 50 of file stage.cpp.

unsigned long long int Paul::FileTransfer::min_average_speed [private]

Definition at line 49 of file stage.cpp.

unsigned long long int Paul::FileTransfer::min_speed [private]

Definition at line 47 of file stage.cpp.

Definition at line 48 of file stage.cpp.

Definition at line 43 of file stage.cpp.

Definition at line 45 of file stage.cpp.


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