Back to index

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

#include <resource.h>

Collaboration diagram for GridScheduler::Resource:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Resource (void)
 Resource (const Resource &r)
 Resource (const std::string &url_str, std::map< std::string, std::string > &cli_config)
 ~Resource (void)
Arc::ClientSOAPgetSOAPClient (void)
const std::string CreateActivity (const Arc::XMLNode &jsdl)
const std::string GetActivityStatus (const std::string &arex_job_id)
bool TerminateActivity (const std::string &arex_job_id)
const std::string & getURL (void)
Resourceoperator= (const Resource &r)
bool refresh (void)

Private Attributes

std::string id
std::string url
Arc::ClientSOAPclient
Arc::NS ns
Arc::MCCConfig cfg

Detailed Description

Definition at line 11 of file resource.h.


Constructor & Destructor Documentation

Definition at line 14 of file resource.cpp.

{

}

Definition at line 182 of file resource.cpp.

{
    id = r.id;
    url = r.url;
    client = r.client;
    ns = r.ns;
    cfg = r.cfg;
}
GridScheduler::Resource::Resource ( const std::string &  url_str,
std::map< std::string, std::string > &  cli_config 
)

Definition at line 19 of file resource.cpp.

{
    url = url_str;
    ns["a-rex"]="http://www.nordugrid.org/schemas/a-rex";
    ns["bes-factory"]="http://schemas.ggf.org/bes/2006/08/bes-factory";
    ns["deleg"]="http://www.nordugrid.org/schemas/delegation";
    ns["wsa"]="http://www.w3.org/2005/08/addressing";
    ns["jsdl"]="http://schemas.ggf.org/jsdl/2005/11/jsdl";
    ns["wsrf-bf"]="http://docs.oasis-open.org/wsrf/bf-2";
    ns["wsrf-r"]="http://docs.oasis-open.org/wsrf/r-2";
    ns["wsrf-rw"]="http://docs.oasis-open.org/wsrf/rw-2";
    ns["ibes"]="http://www.nordugrid.org/schemas/ibes";
    ns["sched"]="http://www.nordugrid.org/schemas/sched";

    Arc::URL url(url_str);
    
    if (url.Protocol() == "https") {
        cfg.AddPrivateKey(cli_config["PrivateKey"]);
        cfg.AddCertificate(cli_config["CertificatePath"]);
        cfg.AddCAFile(cli_config["CACertificatePath"]);
    }
    
    client = new Arc::ClientSOAP(cfg, url, 60);
}

Here is the call graph for this function:

Definition at line 45 of file resource.cpp.

{
    //if (client) delete client;
}

Member Function Documentation

const std::string GridScheduler::Resource::CreateActivity ( const Arc::XMLNode jsdl)

Definition at line 64 of file resource.cpp.

{
    std::string jobid, faultstring;
    Arc::PayloadSOAP request(ns);
    request.NewChild("bes-factory:CreateActivity").NewChild("bes-factory:ActivityDocument").NewChild(jsdl);

    Arc::PayloadSOAP* response;
        
    Arc::MCC_Status status = client->process(&request, &response);

    if (!status) {
        std::cerr << "Request failed" << std::endl;
        if(response) {
           std::string str;
           response->GetXML(str);
           std::cout << str << std::endl;
           delete response;
        }
        return "";
     };

     if (!response) {
         std::cerr << "No response" << std::endl;
         return "";
     };

    Arc::XMLNode id, fs;
    (*response)["CreateActivityResponse"]["ActivityIdentifier"].New(id);
    (*response)["Fault"]["faultstring"].New(fs);
    id.GetDoc(jobid);
    faultstring=(std::string)fs;
    if (faultstring=="")
      return jobid;
    return "";
}

Here is the call graph for this function:

Here is the caller graph for this function:

const std::string GridScheduler::Resource::GetActivityStatus ( const std::string &  arex_job_id)

Definition at line 100 of file resource.cpp.

{
    std::string state, substate, faultstring;
    Arc::PayloadSOAP* response;

    // TODO: better error handling

    try {
        Arc::PayloadSOAP request(ns);
        request.NewChild("bes-factory:GetActivityStatuses").NewChild(Arc::XMLNode(arex_job_id));

        Arc::MCC_Status status = client->process(&request, &response);
        if (!status || !response) {
            return "Unknown";
        }
    } catch (...) { 
        return "Unknown";
    }

    Arc::XMLNode st, fs;
    (*response)["GetActivityStatusesResponse"]["Response"]["ActivityStatus"].New(st);
    state = (std::string)st.Attribute("state");
    Arc::XMLNode sst;
    (*response)["GetActivityStatusesResponse"]["Response"]["ActivityStatus"]["state"].New(sst);
    substate = (std::string)sst;

    faultstring=(std::string)fs;
    if (faultstring!="")
      std::cerr << "ERROR" << std::endl;
    else if (state=="")
      std::cerr << "The job status could not be retrieved." << std::endl;
    else {
      return substate;
    }
    return "";
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 23 of file resource.h.

{ return client; };
const std::string& GridScheduler::Resource::getURL ( void  ) [inline]

Definition at line 27 of file resource.h.

{ return url; };

Here is the caller graph for this function:

Resource & GridScheduler::Resource::operator= ( const Resource r)

Definition at line 169 of file resource.cpp.

{
   if ( this != &r ) {
      id = r.id;
      url = r.url;
      client = r.client;
      ns = r.ns;
      cfg = r.cfg;
   }

   return *this;
}

Definition at line 50 of file resource.cpp.

{
    // TODO ClientSOAP refresh if the connection is wrong
    //

    if (client) delete client;
    Arc::URL u(url);
    client = new Arc::ClientSOAP(cfg, u, 60);
    std::cout << "Resource refreshed: " << url << std::endl;

    return true;
}
bool GridScheduler::Resource::TerminateActivity ( const std::string &  arex_job_id)

Definition at line 137 of file resource.cpp.

{
    std::cout << "kill this job: " << arex_job_id << std::endl; 
    std::string state, substate, faultstring;
    Arc::PayloadSOAP* response;
      
    // TODO: better error handling

    try {
        Arc::PayloadSOAP request(ns);
        request.NewChild("bes-factory:TerminateActivities").NewChild(Arc::XMLNode(arex_job_id));

        Arc::MCC_Status status = client->process(&request, &response);
        if(!status || !response) {
            return false;
        }
    } catch (...) { 
        return false;
    }

    Arc::XMLNode cancelled, fs;
    (*response)["TerminateActivitiesResponse"]["Response"]["Terminated"].New(cancelled);
    std::string result = (std::string)cancelled;
    if (result=="true") {
        return true;
    }
    else {
        return false;
    }
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 17 of file resource.h.

Definition at line 15 of file resource.h.

std::string GridScheduler::Resource::id [private]

Definition at line 13 of file resource.h.

Definition at line 16 of file resource.h.

std::string GridScheduler::Resource::url [private]

Definition at line 14 of file resource.h.


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