Back to index

nordugrid-arc-nox  1.1.0~rc6
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Attributes
Arc::SubmitterUNICORE Class Reference

#include <SubmitterUNICORE.h>

Inheritance diagram for Arc::SubmitterUNICORE:
Inheritance graph
[legend]
Collaboration diagram for Arc::SubmitterUNICORE:
Collaboration graph
[legend]

List of all members.

Public Member Functions

URL Submit (const JobDescription &jobdesc, const ExecutionTarget &et) const
 This virtual method should be overridden by plugins which should be capable of submitting jobs, defined in the JobDescription jobdesc, to the ExecutionTarget et.
URL Migrate (const URL &jobid, const JobDescription &jobdesc, const ExecutionTarget &et, bool forcemigration) const
 This virtual method should be overridden by plugins which should be capable of migrating jobs.
bool ModifyJobDescription (JobDescription &jobdesc, const ExecutionTarget &et) const
std::string GetCksum (const std::string &file) const

Static Public Member Functions

static PluginInstance (PluginArgument *arg)
static std::string GetCksum (const std::string &file, const UserConfig &usercfg)

Protected Member Functions

bool PutFiles (const JobDescription &jobdesc, const URL &url) const
void AddJob (const JobDescription &job, const URL &jobid, const URL &cluster, const URL &infoendpoint) const
void AddJob (const JobDescription &job, const URL &jobid, const URL &cluster, const URL &infoendpoint, const std::map< std::string, std::string > &additionalInfo) const

Protected Attributes

const std::string flavour
const UserConfigusercfg

Private Member Functions

 SubmitterUNICORE (const UserConfig &usercfg)
 ~SubmitterUNICORE ()

Static Private Attributes

static Logger logger

Detailed Description

Definition at line 15 of file SubmitterUNICORE.h.


Constructor & Destructor Documentation

Arc::SubmitterUNICORE::SubmitterUNICORE ( const UserConfig usercfg) [private]

Definition at line 23 of file SubmitterUNICORE.cpp.

    : Submitter(usercfg, "UNICORE") {}

Here is the caller graph for this function:

Definition at line 26 of file SubmitterUNICORE.cpp.

{}

Member Function Documentation

void Arc::Submitter::AddJob ( const JobDescription job,
const URL jobid,
const URL cluster,
const URL infoendpoint 
) const [inline, protected, inherited]

Definition at line 69 of file Submitter.h.

                                               {
      std::map<std::string, std::string> additionalInfo;
      AddJob(job, jobid, cluster, infoendpoint, additionalInfo);
    }

Here is the caller graph for this function:

void Arc::Submitter::AddJob ( const JobDescription job,
const URL jobid,
const URL cluster,
const URL infoendpoint,
const std::map< std::string, std::string > &  additionalInfo 
) const [protected, inherited]

Definition at line 72 of file Submitter.cpp.

                                                                                   {
    NS ns;
    XMLNode info(ns, "Job");
    info.NewChild("JobID") = jobid.str();
    if (!job.Identification.JobName.empty())
      info.NewChild("Name") = job.Identification.JobName;
    info.NewChild("Flavour") = flavour;
    info.NewChild("Cluster") = cluster.str();
    info.NewChild("InfoEndpoint") = infoendpoint.str();
    info.NewChild("LocalSubmissionTime") = (std::string)Arc::Time();

    for (std::map<std::string, std::string>::const_iterator it = additionalInfo.begin();
         it != additionalInfo.end(); it++)
      info.NewChild(it->first) = it->second;

    for (std::list<std::string>::const_iterator
           it = job.Identification.ActivityOldId.begin();
         it != job.Identification.ActivityOldId.end(); it++)
      info.NewChild("OldJobID") = *it;

    std::string rep = job.UnParse("arcjsdl");
    info.NewChild("JobDescription") = (std::string)rep;

    for (std::list<FileType>::const_iterator it = job.DataStaging.File.begin();
         it != job.DataStaging.File.end(); it++)
      if (!it->Source.empty())
        if (it->Source.begin()->URI.Protocol() == "file") {
          if (!info["LocalInputFiles"])
            info.NewChild("LocalInputFiles");
          XMLNode File = info["LocalInputFiles"].NewChild("File");
          File.NewChild("Source") = it->Name;
          File.NewChild("CheckSum") = GetCksum(it->Source.begin()->URI.Path());
        }

    FileLock lock(usercfg.JobListFile());
    Config jobstorage;
    jobstorage.ReadFromFile(usercfg.JobListFile());
    jobstorage.NewChild(info);
    jobstorage.SaveToFile(usercfg.JobListFile());
  }

Here is the call graph for this function:

std::string Arc::Submitter::GetCksum ( const std::string &  file) const [inline, inherited]

Definition at line 65 of file Submitter.h.

{ return GetCksum(file, usercfg); }

Here is the call graph for this function:

Here is the caller graph for this function:

std::string Arc::Submitter::GetCksum ( const std::string &  file,
const UserConfig usercfg 
) [static, inherited]

Definition at line 116 of file Submitter.cpp.

                                                                                {
    DataHandle source(file, usercfg);
    DataBuffer buffer;

    MD5Sum md5sum;
    buffer.set(&md5sum);

    if (!source->StartReading(buffer))
      return "";

    int handle;
    unsigned int length;
    unsigned long long int offset;

    while (buffer.for_write() || !buffer.eof_read())
      if (buffer.for_write(handle, length, offset, true))
        buffer.is_written(handle);

    if (!source->StopReading())
      return "";

    if (!buffer.checksum_valid())
      return "";

    char buf[100];
    md5sum.print(buf, 100);
    return buf;
  }

Here is the call graph for this function:

Definition at line 28 of file SubmitterUNICORE.cpp.

                                                        {
    SubmitterPluginArgument *subarg =
      dynamic_cast<SubmitterPluginArgument*>(arg);
    if (!subarg)
      return NULL;
    return new SubmitterUNICORE(*subarg);
  }

Here is the call graph for this function:

URL Arc::SubmitterUNICORE::Migrate ( const URL jobid,
const JobDescription jobdesc,
const ExecutionTarget et,
bool  forcemigration 
) const [virtual]

This virtual method should be overridden by plugins which should be capable of migrating jobs.

The active job which should be migrated is pointed to by the URL jobid, and is represented by the JobDescription jobdesc. The forcemigration boolean specifies if the migration should succeed if the active job cannot be terminated. The protected method AddJob can be used to save job information. This method should return the URL of the migrated job. In case migration fails an empty URL should be returned.

Implements Arc::Submitter.

Definition at line 128 of file SubmitterUNICORE.cpp.

                                                           {
    logger.msg(INFO, "Trying to migrate to %s: Migration to a UNICORE cluster is not supported.", et.url.str());
    return URL();
  }

Here is the call graph for this function:

bool Arc::SubmitterUNICORE::ModifyJobDescription ( JobDescription jobdesc,
const ExecutionTarget et 
) const [virtual]

Implements Arc::Submitter.

Definition at line 136 of file SubmitterUNICORE.cpp.

                                                                                                      {
    return true;
  }
bool Arc::Submitter::PutFiles ( const JobDescription jobdesc,
const URL url 
) const [protected, inherited]

Definition at line 35 of file Submitter.cpp.

                                                                          {

    FileCache cache;
    DataMover mover;
    mover.retry(true);
    mover.secure(false);
    mover.passive(true);
    mover.verbose(false);

    for (std::list<FileType>::const_iterator it = job.DataStaging.File.begin();
         it != job.DataStaging.File.end(); it++)
      if (!it->Source.empty()) {
        const URL& src = it->Source.begin()->URI;
        if (src.Protocol() == "file") {
          URL dst(std::string(url.str() + '/' + it->Name));
          DataHandle source(src, usercfg);
          DataHandle destination(dst, usercfg);
          DataStatus res =
            mover.Transfer(*source, *destination, cache, URLMap(), 0, 0, 0,
                           usercfg.Timeout());
          if (!res.Passed()) {
            if (!res.GetDesc().empty())
              logger.msg(ERROR, "Failed uploading file: %s - %s",
                         std::string(res), res.GetDesc());
            else
              logger.msg(ERROR, "Failed uploading file: %s", std::string(res));
            return false;
          }
        }
      }

    return true;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

URL Arc::SubmitterUNICORE::Submit ( const JobDescription jobdesc,
const ExecutionTarget et 
) const [virtual]

This virtual method should be overridden by plugins which should be capable of submitting jobs, defined in the JobDescription jobdesc, to the ExecutionTarget et.

The protected convenience method AddJob can be used to save job information. This method should return the URL of the submitted job. In case submission fails an empty URL should be returned.

Implements Arc::Submitter.

Definition at line 36 of file SubmitterUNICORE.cpp.

                                                                {
    MCCConfig cfg;
    usercfg.ApplyToConfig(cfg);

    //new code to use the UNICOREClient
    UNICOREClient uc(et.url, cfg, usercfg.Timeout());

    XMLNode id;

    if (uc.submit(jobdesc, id)){
    }
    else {
      return URL();
    }
    //end new code


/*
    logger.msg(INFO, "Creating client chain for UNICORE BES service");
    ClientSOAP client(cfg, submissionEndpoint);
    //if((!client) || (!(*client))) {
    //   logger.msg(ERROR,"Failed to create client for SOAP exchange");
    //   return URL();
    //}

    // Prepare BES request
    logger.msg(INFO, "Creating and sending request");

    // Create job request

    //   bes-factory:CreateActivity
    //     bes-factory:ActivityDocument
    //       jsdl:JobDefinition

    NS ns;
    ns["bes-factory"] = "http://schemas.ggf.org/bes/2006/08/bes-factory";
    ns["wsa"] = "http://www.w3.org/2005/08/addressing";
    ns["jsdl"] = "http://schemas.ggf.org/jsdl/2005/11/jsdl";
    PayloadSOAP req(ns);
    XMLNode op = req.NewChild("bes-factory:CreateActivity");
    XMLNode act_doc = op.NewChild("bes-factory:ActivityDocument");
    WSAHeader(req).Action("http://schemas.ggf.org/bes/2006/08/bes-factory/BESFactoryPortType/CreateActivity");
    WSAHeader(req).To(submissionEndpoint.str());
    std::string jsdl_str = jobdesc.UnParse("ARCJSDL");
    act_doc.NewChild(XMLNode(jsdl_str));
    //act_doc.Child(0).Namespaces(arex_ns); // Unify namespaces
    PayloadSOAP *resp = NULL;
    act_doc.GetXML(jsdl_str);
    logger.msg(DEBUG, "Job description to be sent: %s", jsdl_str);
    MCC_Status status =
      client.process("http://schemas.ggf.org/bes/2006/08/bes-factory/"
                     "BESFactoryPortType/CreateActivity", &req, &resp);
    if (!status) {
      logger.msg(ERROR, "Submission request failed");
      return URL();
    }
    if (resp == NULL) {
      logger.msg(ERROR, "There was no SOAP response");
      return URL();
    }

    SOAPFault fs(*resp);
    if (fs) {
      std::string faultstring = fs.Reason();
      std::string s;
      resp->GetXML(s);
      // delete resp;
      logger.msg(DEBUG, "Submission returned failure: %s", s);
      logger.msg(ERROR, "Submission failed, service returned: %s", faultstring);
      return URL();
    }
    XMLNode id;
    (*resp)["CreateActivityResponse"]["ActivityIdentifier"].New(id);
    std::string jobid;
    id.GetDoc(jobid);
    // delete resp;
    if (jobid.empty()) {
      logger.msg(ERROR, "Service returned no job identifier");
      return URL();
    }*/

    std::string jobid;
    id.GetDoc(jobid);

    std::map<std::string, std::string> additional_info;
    additional_info["AuxInfo"] = jobid;
    AddJob(jobdesc, (std::string)id["Address"], et.Cluster, et.url, additional_info);

    return (std::string)id["Address"];
  }

Here is the call graph for this function:


Member Data Documentation

const std::string Arc::Submitter::flavour [protected, inherited]

Definition at line 82 of file Submitter.h.

Reimplemented from Arc::Submitter.

Definition at line 19 of file SubmitterUNICORE.h.

const UserConfig& Arc::Submitter::usercfg [protected, inherited]

Definition at line 83 of file Submitter.h.


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