Back to index

nordugrid-arc-nox  1.1.0~rc6
Public Member Functions | Private Attributes
Paul::Job Class Reference

#include <job.h>

Collaboration diagram for Paul::Job:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Job (void)
 Job (const Job &j)
 Job (JobRequest &r)
 Job (JobRequest &r, JobSchedMetaData &m, int t, const std::string &db_path)
 Job (const std::string &job, const std::string &db_path)
 Job (std::istream &job, const std::string &db_path)
virtual ~Job (void)
void setJobRequest (JobRequest &r)
JobRequestgetJobRequest (void)
void setJobSchedMetaData (JobSchedMetaData &sched_meta)
JobSchedMetaDatagetSchedMetaData (void)
const std::string getFailure (void)
void setID (const std::string &id_)
const std::string & getID (void)
void setStatus (SchedStatusLevel s)
SchedStatusLevel getStatus (void)
 operator bool (void)
bool operator! (void)
Arc::XMLNodegetJSDL (void)
void setResourceJobID (const std::string &id)
const std::string & getResourceJobID (void)
void setResourceID (const std::string &id)
const std::string & getResourceID (void)
bool CheckTimeout (void)
bool Cancel (void)
bool save (void)
bool load (void)
bool remove (void)
void finishedReported (void)
bool isFinishedReported (void)
void clean (const std::string &jobroot)

Private Attributes

JobRequest request
JobSchedMetaData sched_meta
std::string failure
std::string id
std::string db
SchedStatusLevel status
int timeout
int check
bool finished_reported

Detailed Description

Definition at line 12 of file job.h.


Constructor & Destructor Documentation

Paul::Job::Job ( void  )

Definition at line 15 of file job.cpp.

{
    finished_reported = false;
    timeout = 5;
    check = 0;
}
Paul::Job::Job ( const Job j)

Definition at line 22 of file job.cpp.

{
    request = j.request;
    sched_meta = j.sched_meta;
    timeout = j.timeout;
    id = j.id;
    db = j.db;
    check = j.check;
    finished_reported = false;
}

Definition at line 33 of file job.cpp.

{
    request = r;
    finished_reported = false;
}
Paul::Job::Job ( JobRequest r,
JobSchedMetaData m,
int  t,
const std::string &  db_path 
)

Definition at line 39 of file job.cpp.

{
    request = r;
    sched_meta = m;
    timeout = t;
    id = Arc::UUID();
    db = db_path;
    check = 0;
    finished_reported = false;
}
Paul::Job::Job ( const std::string &  job,
const std::string &  db_path 
)

Definition at line 50 of file job.cpp.

{
    id = jobid;
    db = db_path;
    check = 0;
    timeout = 5;
    finished_reported = false;
}
Paul::Job::Job ( std::istream &  job,
const std::string &  db_path 
)

Definition at line 59 of file job.cpp.

{
    db = db_path;
    std::string xml_document;
    std::string xml_line;
    Arc::XMLNode tmp_xml;
    check = 0;
    timeout = 5;

    while (getline(job, xml_line)) {
        xml_document += xml_line;
    }
    (Arc::XMLNode (xml_document)).New(tmp_xml);
    JobRequest job_desc(tmp_xml);
    setJobRequest(job_desc);
}

Here is the call graph for this function:

Paul::Job::~Job ( void  ) [virtual]

Definition at line 76 of file job.cpp.

{
    // NOP
}

Member Function Documentation

bool Paul::Job::Cancel ( void  )

Definition at line 92 of file job.cpp.

{
    status = KILLED;
    return true;
}
bool Paul::Job::CheckTimeout ( void  )

Definition at line 81 of file job.cpp.

{
    check++;
    if (check < timeout) {
        return true;
    }
    
    check = 0;
    return false;
}
void Paul::Job::clean ( const std::string &  jobroot)

Definition at line 235 of file job.cpp.

{
    std::string wd = Glib::build_filename(jobroot, id);

    // TODO: clean should be delayed

    //Remove(wd);
}

Here is the caller graph for this function:

void Paul::Job::finishedReported ( void  ) [inline]

Definition at line 53 of file job.h.

{ finished_reported = true; };

Here is the caller graph for this function:

const std::string Paul::Job::getFailure ( void  )

Definition at line 244 of file job.cpp.

{
    return failure + "/" + sched_meta.getFailure();
}

Here is the call graph for this function:

const std::string& Paul::Job::getID ( void  ) [inline]

Definition at line 38 of file job.h.

{ return id; };

Here is the caller graph for this function:

JobRequest& Paul::Job::getJobRequest ( void  ) [inline]

Definition at line 33 of file job.h.

{ return request; };

Here is the caller graph for this function:

Arc::XMLNode& Paul::Job::getJSDL ( void  ) [inline]

Definition at line 43 of file job.h.

{ return request.getJSDL(); };

Here is the call graph for this function:

Here is the caller graph for this function:

const std::string& Paul::Job::getResourceID ( void  ) [inline]

Definition at line 47 of file job.h.

{ return sched_meta.getResourceID(); };

Here is the call graph for this function:

Here is the caller graph for this function:

const std::string& Paul::Job::getResourceJobID ( void  ) [inline]

Definition at line 45 of file job.h.

Here is the call graph for this function:

Definition at line 35 of file job.h.

{ return sched_meta; };

Definition at line 40 of file job.h.

{ return status; };

Here is the caller graph for this function:

bool Paul::Job::isFinishedReported ( void  ) [inline]

Definition at line 54 of file job.h.

{ return finished_reported; };

Here is the caller graph for this function:

bool Paul::Job::load ( void  )

Definition at line 154 of file job.cpp.

{
    char buf[250];
    std::string fname = db + "/" + id + ".metadata";
    std::ifstream f(fname.c_str());
    if (!f.is_open()) {
        return false;
    }
    for (;!f.eof();) {
        f.getline(buf, 250);
        std::string line(buf);
        std::string name;
        std::string value;
        if (!cut(line,name,value)) {
            continue;
        }
        if (name == "id") {
            id = value;
        } else if (name == "arex_id") {
            sched_meta.setResourceID(value);
        } else if (name == "status") {
            status = sched_status_from_string(value);
        }
    }
    f.close(); 

    // read jsdl
    std::string fname_jsdl = db + "/" + id + ".jsdl";
    std::ifstream f_jsdl(fname_jsdl.c_str());
    std::string xml_document;
    std::string xml_line;
    Arc::XMLNode tmp_xml;
    while (getline(f_jsdl, xml_line)) {
        xml_document += xml_line;
    }
    (Arc::XMLNode (xml_document)).New(tmp_xml);
    f_jsdl.close();
    JobRequest job_desc(tmp_xml);
    setJobRequest(job_desc);
    //read arex_job_id
    std::string a_id = db + "/" + id + ".arex_job_id";
    std::ifstream f_arex(a_id.c_str());
    std::string line, tmp;
    while (getline(f_arex, line)) {
        tmp += line;
    }
    sched_meta.setResourceID(tmp);

    f_arex.close();
    return true;
}

Here is the call graph for this function:

Paul::Job::operator bool ( void  ) [inline]

Definition at line 41 of file job.h.

{ return (id.empty() ? false : true ); };
bool Paul::Job::operator! ( void  ) [inline]

Definition at line 42 of file job.h.

{ return (id.empty() ? true : false ); };
bool Paul::Job::remove ( void  )

Definition at line 206 of file job.cpp.

{
    std::string file1 = db + "/" + id + ".metadata";
    std::string file2 = db + "/" + id + ".jsdl";
    std::string file3 = db + "/" + id + ".arex_job_id";
    std::remove(file1.c_str());
    std::remove(file2.c_str());
    std::remove(file3.c_str());

    return true;
}
bool Paul::Job::save ( void  )

Definition at line 103 of file job.cpp.

{ 
    // write out the jobrequest
    Arc::XMLNode jsdl = getJSDL();
    std::string jsdl_str;
    std::string fname = db + "/" + id + ".jsdl";
    jsdl.GetXML(jsdl_str);
    std::ofstream f1(fname.c_str(), std::ios::out | std::ios::trunc);
    if(!f1.is_open()) {
        return false; /* can't open file */
    }
    f1 << jsdl_str;
    f1.close();
    // write out job metadata
    fname = db + "/" + id + ".metadata";
    std::ofstream f2(fname.c_str(), std::ios::out | std::ios::trunc);
    if(!f2.is_open()) {
        return false; /* can't open file */
    }
    write_pair(f2, "id", id);
    std::string arex_id = getResourceID();
    write_pair(f2, "arex_id", arex_id);
    std::string status_str = sched_status_to_string(status);
    write_pair(f2, "status", status_str);
    f2.close();
    
    // write out arex_job_id
    fname = db + "/" + id + ".arex_job_id";
    jsdl.GetXML(jsdl_str);
    std::ofstream f3(fname.c_str(), std::ios::out | std::ios::trunc);
    if(!f3.is_open()) {
        return false; /* can't open file */
    }
    f3 << sched_meta.getResourceID();
    f3.close();

    return true;
}

Here is the call graph for this function:

void Paul::Job::setID ( const std::string &  id_) [inline]

Definition at line 37 of file job.h.

{ id = id_; };

Here is the caller graph for this function:

void Paul::Job::setJobRequest ( JobRequest r) [inline]

Definition at line 32 of file job.h.

{ request = r; };

Here is the caller graph for this function:

void Paul::Job::setResourceID ( const std::string &  id) [inline]

Definition at line 46 of file job.h.

Here is the call graph for this function:

Here is the caller graph for this function:

void Paul::Job::setResourceJobID ( const std::string &  id) [inline]

Definition at line 44 of file job.h.

Here is the call graph for this function:

void Paul::Job::setStatus ( SchedStatusLevel  s) [inline]

Definition at line 39 of file job.h.

{ status = s; };

Here is the caller graph for this function:


Member Data Documentation

int Paul::Job::check [private]

Definition at line 22 of file job.h.

std::string Paul::Job::db [private]

Definition at line 19 of file job.h.

std::string Paul::Job::failure [private]

Definition at line 17 of file job.h.

Definition at line 23 of file job.h.

std::string Paul::Job::id [private]

Definition at line 18 of file job.h.

Definition at line 15 of file job.h.

Definition at line 16 of file job.h.

Definition at line 20 of file job.h.

int Paul::Job::timeout [private]

Definition at line 21 of file job.h.


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