Back to index

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

% JobSupervisor class More...

#include <JobSupervisor.h>

Collaboration diagram for Arc::JobSupervisor:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 JobSupervisor (const UserConfig &usercfg, const std::list< std::string > &jobs)
 Create a JobSupervisor object.
 ~JobSupervisor ()
const std::list< JobController * > & GetJobControllers ()
 Get list of JobControllers.
bool JobsFound () const

Private Attributes

JobControllerLoader loader
bool jobsFound

Static Private Attributes

static Logger logger

Detailed Description

% JobSupervisor class

The JobSupervisor class is tool for loading JobController plugins for managing Grid jobs.

Definition at line 23 of file JobSupervisor.h.


Constructor & Destructor Documentation

Arc::JobSupervisor::JobSupervisor ( const UserConfig usercfg,
const std::list< std::string > &  jobs 
)

Create a JobSupervisor object.

Default constructor to create a JobSupervisor. Automatically loads JobController plugins based upon the input jobids.

Parameters:
usercfgReference to UserConfig object with information about user credentials and joblistfile.
jobsList of jobs(jobid or job name) to be managed.

Definition at line 24 of file JobSupervisor.cpp.

    : jobsFound(false) {
    URLListMap jobids;

    Config jobstorage;
    if (!usercfg.JobListFile().empty()) {
      FileLock lock(usercfg.JobListFile());
      jobstorage.ReadFromFile(usercfg.JobListFile());
    }

    std::list<std::string> controllers;

    if (!jobs.empty()) {

      logger.msg(VERBOSE, "Identifying needed job controllers according to "
                 "specified jobs");

      for (std::list<std::string>::const_iterator it = jobs.begin();
           it != jobs.end(); it++) {
        std::string strJobID = *it;
        // Remove trailing slashes '/'.
        const std::string::size_type pos = strJobID.find_last_not_of("/");
        if (pos != std::string::npos)
          strJobID = strJobID.substr(0, pos + 1);

        XMLNodeList xmljobs =
          jobstorage.XPathLookup("//Job[JobID='" + strJobID + "' or "
                                 "Name='" + *it + "']", NS());

        if (xmljobs.empty()) {
          logger.msg(WARNING, "Job not found in job list: %s", *it);
          continue;
        }
        else
          jobsFound = true;

        for (XMLNodeList::iterator xit = xmljobs.begin();
             xit != xmljobs.end(); xit++) {
          const std::string flavour = (std::string)(*xit)["Flavour"];
          jobids[flavour].push_back((std::string)(*xit)["JobID"]);

          if (std::find(controllers.begin(), controllers.end(),
                        flavour) == controllers.end()) {
            logger.msg(VERBOSE, "Need job controller for grid flavour %s",
                       flavour);
            controllers.push_back(flavour);
          }
        }
      }
    }

    if (!usercfg.GetSelectedServices(COMPUTING).empty()) {

      logger.msg(VERBOSE, "Identifying needed job controllers according to "
                 "specified clusters");

      for (URLListMap::const_iterator it = usercfg.GetSelectedServices(COMPUTING).begin();
           it != usercfg.GetSelectedServices(COMPUTING).end(); it++) {
        if (std::find(controllers.begin(), controllers.end(),
                      it->first) == controllers.end()) {
          std::list<URL>::const_iterator itCluster = it->second.begin();
          for (; itCluster != it->second.end(); itCluster++)
            if (jobstorage.XPathLookup("//Job[Cluster='" + itCluster->str() + "']", NS()).size() > 0)
              break;

          if (itCluster == it->second.end()) // No jobs found at the specified cluster.
            break;

          jobsFound = true;
          logger.msg(VERBOSE, "Need job controller for grid flavour %s",
                     it->first);
          controllers.push_back(it->first);
        }
      }
    }

    if (jobs.empty() && usercfg.GetSelectedServices(COMPUTING).empty()) {

      logger.msg(VERBOSE, "Identifying needed job controllers according to "
                 "all jobs present in job list");

      XMLNodeList xmljobs = jobstorage.Path("Job");

      if (xmljobs.empty())
        return;

      jobsFound = true;

      for (XMLNodeList::iterator it = xmljobs.begin();
           it != xmljobs.end(); it++)
        if (std::find(controllers.begin(), controllers.end(),
                      (std::string)(*it)["Flavour"]) == controllers.end()) {
          std::string flavour = (*it)["Flavour"];
          logger.msg(VERBOSE, "Need job controller for grid flavour %s",
                     flavour);
          controllers.push_back(flavour);
        }
    }

    for (std::list<std::string>::iterator it = controllers.begin();
         it != controllers.end(); it++) {
      JobController *JC = loader.load(*it, usercfg);
      if (JC)
        JC->FillJobStore(jobids[*it]);
    }
  }

Here is the call graph for this function:

Definition at line 132 of file JobSupervisor.cpp.

{}

Member Function Documentation

const std::list<JobController*>& Arc::JobSupervisor::GetJobControllers ( ) [inline]

Get list of JobControllers.

Method to get the list of JobControllers loaded by constructor.

Definition at line 46 of file JobSupervisor.h.

                                                       {
      return loader.GetJobControllers();
    }

Here is the call graph for this function:

Here is the caller graph for this function:

bool Arc::JobSupervisor::JobsFound ( ) const [inline]

Definition at line 50 of file JobSupervisor.h.

{ return jobsFound; }

Here is the caller graph for this function:


Member Data Documentation

Definition at line 55 of file JobSupervisor.h.

Definition at line 54 of file JobSupervisor.h.

Definition at line 53 of file JobSupervisor.h.


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