Back to index

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

Target generation class More...

#include <TargetGenerator.h>

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

List of all members.

Public Member Functions

 TargetGenerator (const UserConfig &usercfg)
 Create a TargetGenerator object.
 ~TargetGenerator ()
void GetTargets (int targetType, int detailLevel)
 Find available targets.
const std::list
< ExecutionTarget > & 
FoundTargets () const
 Return targets found by GetTargets.
std::list< ExecutionTarget > & ModifyFoundTargets ()
 Return targets found by GetTargets.
const std::list< XMLNode * > & FoundJobs () const
 Return Grid jobs found by GetTargets.
bool AddService (const URL &url)
 Add a new computing service to the foundServices list.
bool AddIndexServer (const URL &url)
 Add a new index server to the foundIndexServers list.
void AddTarget (const ExecutionTarget &target)
 Add a new ExecutionTarget to the foundTargets list.
void AddJob (const XMLNode &job)
 Add a new Job to the foundJobs list.
void RetrieverDone ()
 Decrement the threadCounter by 1.
void PrintTargetInfo (bool longlist) const
 Prints target information.

Private Attributes

TargetRetrieverLoader loader
const UserConfigusercfg
std::list< URLfoundServices
std::list< URLfoundIndexServers
std::list< ExecutionTargetfoundTargets
std::list< XMLNode * > foundJobs
Glib::Mutex serviceMutex
Glib::Mutex indexServerMutex
Glib::Mutex targetMutex
Glib::Mutex jobMutex
int threadCounter
Glib::Mutex threadMutex
Glib::Cond threadCond

Static Private Attributes

static Logger logger

Detailed Description

Target generation class

The TargetGenerator class is the umbrella class for resource discovery and information retrieval (index servers and computing clusters). It can also be used to locate user Grid jobs but does not collect the job details (see the arcsync CLI)). The TargetGenerator loads TargetRetriever plugins (which implements the actual information retrieval) from URL objects found in the UserConfig object passed to its constructor using the custem TargetRetrieverLoader. E.g. if an URL pointing to an ARC1 computing resource is found in the UserConfig object the TargetRetrieverARC1 is loaded.

Definition at line 36 of file TargetGenerator.h.


Constructor & Destructor Documentation

Create a TargetGenerator object.

Default constructor to create a TargeGenerator. The constructor reads the computing and index service URL objects from the passed UserConfig object using the UserConfig:GetSelectedServices method. From each URL a matching specialized TargetRetriever plugin is loaded using the TargetRetrieverLoader.

Parameters:
usercfgReference to UserConfig object with URL objects to computing and/or index services and paths to user credentials.

Definition at line 23 of file TargetGenerator.cpp.

    : threadCounter(0), usercfg(usercfg) {

    /* When loading a specific middleware plugin fails, subsequent loads
     * should fail aswell. Therefore it should be unecessary to load the
     * same plugin multiple times, if it failed the first time.
     */
    std::map<std::string, bool> pluginLoaded;
    for (URLListMap::const_iterator it = usercfg.GetSelectedServices(COMPUTING).begin();
         it != usercfg.GetSelectedServices(COMPUTING).end(); it++)
      for (std::list<URL>::const_iterator it2 = it->second.begin();
           it2 != it->second.end(); it2++) {
        if (pluginLoaded[it->first] = (loader.load(it->first, usercfg, *it2, COMPUTING) != NULL))
          break;
      }

    for (URLListMap::const_iterator it = usercfg.GetSelectedServices(INDEX).begin();
         it != usercfg.GetSelectedServices(INDEX).end(); it++) {
      if (pluginLoaded.find(it->first) != pluginLoaded.end() && !pluginLoaded[it->first]) // Do not try to load if it failed above.
        continue;
      for (std::list<URL>::const_iterator it2 = it->second.begin();
           it2 != it->second.end(); it2++) {
        if (loader.load(it->first, usercfg, *it2, INDEX) == NULL)
          break;
      }
    }
  }

Here is the call graph for this function:

Definition at line 51 of file TargetGenerator.cpp.

                                    {

    if (foundJobs.size() > 0)
      for (std::list<XMLNode*>::iterator it = foundJobs.begin();
           it != foundJobs.end(); it++)
        delete *it;
  }

Member Function Documentation

Add a new index server to the foundIndexServers list.

Method to add a new index server to the list of foundIndexServers in a thread secure way. Compares the argument URL against the servers returned by UserConfig::GetRejectedServices and only allows to add the service if not specifically rejected.

Parameters:
urlURL pointing to the index server.

Definition at line 118 of file TargetGenerator.cpp.

                                                     {

    for (URLListMap::const_iterator it = usercfg.GetRejectedServices(INDEX).begin();
         it != usercfg.GetRejectedServices(INDEX).end(); it++)
      if (std::find(it->second.begin(), it->second.end(), url) !=
          it->second.end()) {
        logger.msg(INFO, "Rejecting service: %s", url.str());
        return false;
      }

    bool added = false;
    Glib::Mutex::Lock indexServerLock(indexServerMutex);
    if (std::find(foundIndexServers.begin(), foundIndexServers.end(), url) ==
        foundIndexServers.end()) {
      foundIndexServers.push_back(url);
      added = true;
      Glib::Mutex::Lock threadLock(threadMutex);
      threadCounter++;
    }
    return added;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void Arc::TargetGenerator::AddJob ( const XMLNode job)

Add a new Job to the foundJobs list.

Method to add a new Job (usually discovered by a TargetRetriever) to the list of foundJobs in a thread secure way.

Parameters:
jobXMLNode describing the job.

Definition at line 146 of file TargetGenerator.cpp.

                                                 {
    Glib::Mutex::Lock jobLock(jobMutex);
    NS ns;
    XMLNode *j = new XMLNode(ns, "");
    j->Replace(job);
    foundJobs.push_back(j);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

bool Arc::TargetGenerator::AddService ( const URL url)

Add a new computing service to the foundServices list.

Method to add a new service to the list of foundServices in a thread secure way. Compares the argument URL against the services returned by UserConfig::GetRejectedServices and only allows to add the service if not specifically rejected.

Parameters:
urlURL pointing to the information system of the computing service.

Definition at line 96 of file TargetGenerator.cpp.

                                                 {

    for (URLListMap::const_iterator it = usercfg.GetRejectedServices(COMPUTING).begin();
         it != usercfg.GetRejectedServices(COMPUTING).end(); it++)
      if (std::find(it->second.begin(), it->second.end(), url) !=
          it->second.end()) {
        logger.msg(INFO, "Rejecting service: %s", url.str());
        return false;
      }

    bool added = false;
    Glib::Mutex::Lock serviceLock(serviceMutex);
    if (std::find(foundServices.begin(), foundServices.end(), url) ==
        foundServices.end()) {
      foundServices.push_back(url);
      added = true;
      Glib::Mutex::Lock threadLock(threadMutex);
      threadCounter++;
    }
    return added;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Add a new ExecutionTarget to the foundTargets list.

Method to add a new ExecutionTarget (usually discovered by a TargetRetriever) to the list of foundTargets in a thread secure way.

Parameters:
targetExecutionTarget to be added.

Definition at line 140 of file TargetGenerator.cpp.

                                                               {
    Glib::Mutex::Lock targetLock(targetMutex);
    foundTargets.push_back(target);
  }

Here is the caller graph for this function:

const std::list< XMLNode * > & Arc::TargetGenerator::FoundJobs ( ) const

Return Grid jobs found by GetTargets.

Method to return the list of Grid jobs found by a call to the GetTargets method.

Definition at line 92 of file TargetGenerator.cpp.

                                                            {
    return foundJobs;
  }

Here is the caller graph for this function:

const std::list< ExecutionTarget > & Arc::TargetGenerator::FoundTargets ( ) const

Return targets found by GetTargets.

Method to return a const list of ExecutionTarget objects (currently only supported Target type) found by the GetTarget method.

Definition at line 84 of file TargetGenerator.cpp.

                                                                      {
    return foundTargets;
  }

Here is the caller graph for this function:

void Arc::TargetGenerator::GetTargets ( int  targetType,
int  detailLevel 
)

Find available targets.

Method to prepare a list of chosen Targets with a specified detail level. Current implementation supports finding computing clusters (ExecutionTarget) with full detail level and Grid jobs with limited detail level.

Parameters:
targetType0 = ExecutionTarget, 1 = Grid jobs
detailLevel1 = All details, 2 = Limited details (not implemented)

Definition at line 59 of file TargetGenerator.cpp.

                                                                  {

    logger.msg(VERBOSE, "Running resource (target) discovery");

    for (std::list<TargetRetriever*>::const_iterator it =
           loader.GetTargetRetrievers().begin();
         it != loader.GetTargetRetrievers().end(); it++)
      (*it)->GetTargets(*this, targetType, detailLevel);

    {
      Glib::Mutex::Lock threadLock(threadMutex);
      while (threadCounter > 0)
        threadCond.wait(threadMutex);
    }

    logger.msg(INFO, "Found %ld targets", foundTargets.size());

    for (std::list<ExecutionTarget>::iterator iter = foundTargets.begin();
         iter != foundTargets.end(); iter++) {
      logger.msg(VERBOSE, "Cluster: %s", iter->DomainName);
      logger.msg(VERBOSE, "Health State: %s", iter->HealthState);
    }

  }

Here is the call graph for this function:

Here is the caller graph for this function:

Return targets found by GetTargets.

Method to return the list of ExecutionTarget objects (currently only supported Target type) found by the GetTarget method.

Definition at line 88 of file TargetGenerator.cpp.

                                                                {
    return foundTargets;
  }

Here is the caller graph for this function:

void Arc::TargetGenerator::PrintTargetInfo ( bool  longlist) const

Prints target information.

Method to print information of the found targets to std::cout.

Parameters:
longlistfalse for minimal information, true for detailed information

Definition at line 161 of file TargetGenerator.cpp.

                                                           {
    for (std::list<ExecutionTarget>::const_iterator cli = foundTargets.begin();
         cli != foundTargets.end(); cli++)
      cli->Print(longlist);
  }

Here is the caller graph for this function:

Decrement the threadCounter by 1.

Method to decrement the threadCounter by 1 in a thread secure way.

Definition at line 154 of file TargetGenerator.cpp.

                                      {
    Glib::Mutex::Lock threadLock(threadMutex);
    threadCounter--;
    if (threadCounter == 0)
      threadCond.signal();
  }

Here is the caller graph for this function:


Member Data Documentation

Definition at line 156 of file TargetGenerator.h.

Definition at line 158 of file TargetGenerator.h.

Definition at line 155 of file TargetGenerator.h.

Definition at line 157 of file TargetGenerator.h.

Definition at line 161 of file TargetGenerator.h.

Glib::Mutex Arc::TargetGenerator::jobMutex [private]

Definition at line 163 of file TargetGenerator.h.

Definition at line 151 of file TargetGenerator.h.

Definition at line 169 of file TargetGenerator.h.

Glib::Mutex Arc::TargetGenerator::serviceMutex [private]

Definition at line 160 of file TargetGenerator.h.

Glib::Mutex Arc::TargetGenerator::targetMutex [private]

Definition at line 162 of file TargetGenerator.h.

Glib::Cond Arc::TargetGenerator::threadCond [private]

Definition at line 167 of file TargetGenerator.h.

Definition at line 165 of file TargetGenerator.h.

Glib::Mutex Arc::TargetGenerator::threadMutex [private]

Definition at line 166 of file TargetGenerator.h.

Definition at line 153 of file TargetGenerator.h.


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