Back to index

nordugrid-arc-nox  1.1.0~rc6
Classes | Defines | Enumerations | Functions | Variables
job_request.cpp File Reference
#include <iostream>
#include <fstream>
#include <glibmm.h>
#include <arc/Logger.h>
#include <arc/StringConv.h>
#include <arc/URL.h>
#include <arc/client/JobDescription.h>
#include <arc/Utils.h>
#include "users.h"
#include "job.h"
#include "../files/info_files.h"
#include "../run/run_function.h"
#include "../conf/environment.h"
#include "job_request.h"

Go to the source code of this file.

Classes

struct  set_execs_t

Defines

#define istream_readline(__f, __s, __n)

Enumerations

enum  job_req_type_t { job_req_unknown, job_req_rsl, job_req_jsdl }

Functions

static int filter_rtes (const std::string &rte_root, const std::list< std::string > &rte)
bool parse_job_req_for_action (const char *fname, std::string &action, std::string &jobid, std::string &lrms, std::string &queue)
bool process_job_req (JobUser &user, const JobDescription &desc)
bool process_job_req (JobUser &user, const JobDescription &desc, JobLocalDescription &job_desc)
JobReqResult parse_job_req (const std::string &fname, JobLocalDescription &job_desc, std::string *acl, std::string *failure)
static int set_execs_callback (void *arg)
bool set_execs (const JobDescription &desc, const JobUser &user, const std::string &session_dir)
bool write_grami (const JobDescription &desc, const JobUser &user, const char *opt_add)
std::string read_grami (const JobId &job_id, const JobUser &user)

Variables

static Arc::Loggerlogger = Arc::Logger::getRootLogger()

Class Documentation

struct set_execs_t

Definition at line 132 of file job_request.cpp.

Collaboration diagram for set_execs_t:
Class Members
const JobDescription * arc_job_desc
const string * session_dir

Define Documentation

#define istream_readline (   __f,
  __s,
  __n 
)
Value:
{      \
   __f.get(__s,__n,'\n');         \
   if(__f.fail()) __f.clear();               \
   __f.ignore(INT_MAX,'\n'); \
}

Definition at line 36 of file job_request.cpp.


Enumeration Type Documentation

Enumerator:
job_req_unknown 
job_req_rsl 
job_req_jsdl 

Definition at line 47 of file job_request.cpp.

             {
  job_req_unknown,
  job_req_rsl,
// #ifndef JSDL_MISSING
  job_req_jsdl
// #endif
} job_req_type_t;

Function Documentation

static int filter_rtes ( const std::string &  rte_root,
const std::list< std::string > &  rte 
) [static]

Definition at line 56 of file job_request.cpp.

                                                                                {
  int rtes = 0;
  if(rte_root.empty()) return rte.size();
  for(std::list<std::string>::const_iterator r = rte.begin();r!=rte.end();++r) {
    std::string path = Glib::build_filename(rte_root,*r);
    if(Glib::file_test(path,Glib::FILE_TEST_IS_REGULAR)) continue;
    ++rtes;
  }
  return rtes;
}

Here is the caller graph for this function:

JobReqResult parse_job_req ( const std::string &  fname,
JobLocalDescription job_desc,
std::string *  acl,
std::string *  failure 
)

Definition at line 113 of file job_request.cpp.

                                                                                                                    {
  Arc::JobDescription arc_job_desc;
  if (!get_arc_job_description(fname, arc_job_desc)) {
    if (failure) *failure = "Unable to read or parse job description.";
    return JobReqInternalFailure;
  }

  if (!arc_job_desc.Resources.RunTimeEnvironment.isResolved()) {
    if (failure)
      *failure = "Runtime environments have not been resolved.";
    return JobReqInternalFailure;
  }

  job_desc = arc_job_desc;

  if (acl) return get_acl(arc_job_desc, *acl);
  return JobReqSuccess;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool parse_job_req_for_action ( const char *  fname,
std::string &  action,
std::string &  jobid,
std::string &  lrms,
std::string &  queue 
)

Definition at line 68 of file job_request.cpp.

                                                 {
  JobLocalDescription job_desc;
  std::string filename(fname);
  if(parse_job_req(filename,job_desc) == JobReqSuccess) {
    action=job_desc.action;
    jobid=job_desc.jobid;
    lrms=job_desc.lrms;
    queue=job_desc.queue;
    return true;
  };
  return false;
}

Here is the call graph for this function:

bool process_job_req ( JobUser user,
const JobDescription desc 
)

Definition at line 84 of file job_request.cpp.

                                                               {
  JobLocalDescription job_desc;
  return process_job_req(user,desc,job_desc);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool process_job_req ( JobUser user,
const JobDescription desc,
JobLocalDescription job_desc 
)

Definition at line 89 of file job_request.cpp.

                                                                                             {
  /* read local first to get some additional info pushed here by script */
  job_local_read_file(desc.get_id(),user,job_desc);
  /* some default values */
  job_desc.lrms=user.DefaultLRMS();
  job_desc.queue=user.DefaultQueue();
  job_desc.lifetime=Arc::tostring(user.KeepFinished());
  std::string filename;
  filename = user.ControlDir() + "/job." + desc.get_id() + ".description";
  if(parse_job_req(filename,job_desc) != JobReqSuccess) return false;
  if(job_desc.reruns>user.Reruns()) job_desc.reruns=user.Reruns();
  if((job_desc.diskspace>user.DiskSpace()) || (job_desc.diskspace==0)) {
    job_desc.diskspace=user.DiskSpace();
  };
  // Adjust number of rtes - exclude existing ones
  job_desc.rtes = filter_rtes(runtime_config_dir(),job_desc.rte);
  if(!job_local_write_file(desc,user,job_desc)) return false;
  if(!job_input_write_file(desc,user,job_desc.inputdata)) return false;
  if(!job_output_write_file(desc,user,job_desc.outputdata)) return false;
  if(!job_rte_write_file(desc,user,job_desc.rte)) return false;
  return true;
}

Here is the call graph for this function:

std::string read_grami ( const JobId job_id,
const JobUser user 
)

Definition at line 168 of file job_request.cpp.

                                                              {
  const char* local_id_param = "joboption_jobid=";
  int l = strlen(local_id_param);
  std::string id = "";
  char buf[256];
  std::string fgrami = user.ControlDir() + "/job." + job_id + ".grami";
  std::ifstream f(fgrami.c_str());
  if(!f.is_open()) return id;
  for(;!f.eof();) {
    istream_readline(f,buf,sizeof(buf));
    if(strncmp(local_id_param,buf,l)) continue;
    if(buf[0]=='\'') {
      l++; int ll = strlen(buf);
      if(buf[ll-1]=='\'') buf[ll-1]=0;
    };
    id=buf+l; break;
  };
  f.close();
  return id;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool set_execs ( const JobDescription desc,
const JobUser user,
const std::string &  session_dir 
)

Definition at line 145 of file job_request.cpp.

                                                                                            {
  std::string fname = user.ControlDir() + "/job." + desc.get_id() + ".description";
  Arc::JobDescription arc_job_desc;
  if (!get_arc_job_description(fname, arc_job_desc)) return false;

  if (user.StrictSession()) {
    JobUser tmp_user(user.get_uid()==0?desc.get_uid():user.get_uid());
    set_execs_t arg; arg.arc_job_desc=&arc_job_desc; arg.session_dir=&session_dir;
    return (RunFunction::run(tmp_user, "set_execs", &set_execs_callback, &arg, 20) == 0);
  }
  return set_execs(arc_job_desc, session_dir);
}

Here is the call graph for this function:

static int set_execs_callback ( void *  arg) [static]

Definition at line 137 of file job_request.cpp.

                                         {
  const Arc::JobDescription& arc_job_desc = *(((set_execs_t*)arg)->arc_job_desc);
  const std::string& session_dir = *(((set_execs_t*)arg)->session_dir);
  if (set_execs(arc_job_desc, session_dir)) return 0;
  return -1;
};

Here is the call graph for this function:

Here is the caller graph for this function:

bool write_grami ( const JobDescription desc,
const JobUser user,
const char *  opt_add 
)

Definition at line 158 of file job_request.cpp.

                                                                                     {
  const std::string fname = user.ControlDir() + "/job." + desc.get_id() + ".description";

  Arc::JobDescription arc_job_desc;
  if (!get_arc_job_description(fname, arc_job_desc)) return false;

  return write_grami(arc_job_desc, desc, user, opt_add);
}

Here is the call graph for this function:


Variable Documentation

Definition at line 45 of file job_request.cpp.