Back to index

nordugrid-arc-nox  1.1.0~rc6
JobControllerUNICORE.cpp
Go to the documentation of this file.
00001 // -*- indent-tabs-mode: nil -*-
00002 
00003 #ifdef HAVE_CONFIG_H
00004 #include <config.h>
00005 #endif
00006 
00007 #include <arc/StringConv.h>
00008 #include <arc/UserConfig.h>
00009 #include <arc/XMLNode.h>
00010 #include <arc/client/ClientInterface.h>
00011 #include <arc/message/MCC.h>
00012 #include <arc/ws-addressing/WSA.h>
00013 
00014 #include "UNICOREClient.h"
00015 #include "JobStateUNICORE.h"
00016 #include "JobControllerUNICORE.h"
00017 
00018 namespace Arc {
00019 
00020   Logger JobControllerUNICORE::logger(JobController::logger, "UNICORE");
00021 
00022   JobControllerUNICORE::JobControllerUNICORE(const UserConfig& usercfg)
00023     : JobController(usercfg, "UNICORE") {}
00024 
00025   JobControllerUNICORE::~JobControllerUNICORE() {}
00026 
00027   Plugin* JobControllerUNICORE::Instance(PluginArgument *arg) {
00028     JobControllerPluginArgument *jcarg =
00029       dynamic_cast<JobControllerPluginArgument*>(arg);
00030     if (!jcarg)
00031       return NULL;
00032     return new JobControllerUNICORE(*jcarg);
00033   }
00034 
00035   void JobControllerUNICORE::GetJobInformation() {
00036     MCCConfig cfg;
00037     usercfg.ApplyToConfig(cfg);
00038 
00039     for (std::list<Job>::iterator iter = jobstore.begin();
00040          iter != jobstore.end(); iter++) {
00041       URL url(iter->Cluster);
00042       XMLNode id(iter->AuxInfo);
00043       ClientSOAP client(cfg, url, usercfg.Timeout());
00044       logger.msg(INFO, "Creating and sending a status request");
00045       NS ns;
00046       ns["bes-factory"] = "http://schemas.ggf.org/bes/2006/08/bes-factory";
00047       ns["wsa"] = "http://www.w3.org/2005/08/addressing";
00048       ns["jsdl"] = "http://schemas.ggf.org/jsdl/2005/11/jsdl";
00049       PayloadSOAP req(ns);
00050       XMLNode jobref =
00051         req.NewChild("bes-factory:GetActivityStatuses").
00052         NewChild(id);
00053       WSAHeader(req).Action("http://schemas.ggf.org/bes/2006/08/bes-factory/BESFactoryPortType/GetActivityStatuses");
00054       WSAHeader(req).To(url.str());
00055       // Send status request
00056       PayloadSOAP *resp = NULL;
00057       MCC_Status status =
00058         client.process("http://schemas.ggf.org/bes/2006/08/bes-factory/"
00059                        "BESFactoryPortType/GetActivityStatuses", &req, &resp);
00060       if (resp == NULL) {
00061         logger.msg(ERROR, "There was no SOAP response");
00062         continue;
00063       }
00064       XMLNode st, fs;
00065       (*resp)["GetActivityStatusesResponse"]["Response"]
00066       ["ActivityStatus"].New(st);
00067       std::string state = (std::string)st.Attribute("state");
00068       (*resp)["Fault"]["faultstring"].New(fs);
00069       std::string faultstring = (std::string)fs;
00070       // delete resp;
00071       if (!faultstring.empty()) {
00072         logger.msg(ERROR, faultstring);
00073         continue;
00074       }
00075       if (state.empty()) {
00076         logger.msg(ERROR, "Failed retrieving job status information");
00077         continue;
00078       }
00079       iter->State = JobStateUNICORE(state);
00080     }
00081 
00082 
00083   }
00084 
00085   bool JobControllerUNICORE::GetJob(const Job& job,
00086                                     const std::string& downloaddir) {
00087     /*
00088         logger.msg(VERBOSE, "Downloading job: %s", job.JobID.str());
00089 
00090         std::string path = job.JobID.Path();
00091         std::string::size_type pos = path.rfind('/');
00092         std::string jobidnum = path.substr(pos + 1);
00093 
00094         std::list<std::string> files = GetDownloadFiles(job.JobID);
00095 
00096         URL src(job.JobID);
00097         URL dst(downloaddir.empty() ? jobidnum : downloaddir + G_DIR_SEPARATOR_S + jobidnum);
00098 
00099 
00100         std::string srcpath = src.Path();
00101         std::string dstpath = dst.Path();
00102 
00103         if (srcpath.empty() || (srcpath[srcpath.size() - 1] != '/'))
00104           srcpath += '/';
00105         if (dstpath.empty() || (dstpath[dstpath.size() - 1] != G_DIR_SEPARATOR))
00106           dstpath += G_DIR_SEPARATOR_S;
00107 
00108         bool ok = true;
00109 
00110         for (std::list<std::string>::iterator it = files.begin();
00111              it != files.end(); it++) {
00112           src.ChangePath(srcpath + *it);
00113           dst.ChangePath(dstpath + *it);
00114           if (!ARCCopyFile(src, dst)) {
00115             logger.msg(ERROR, "Failed dowloading %s to %s", src.str(), dst.str());
00116             ok = false;
00117           }
00118         }
00119 
00120         return ok;*/
00121   }
00122 
00123   bool JobControllerUNICORE::CleanJob(const Job& job, bool force) {
00124     //     MCCConfig cfg;
00125     //     usercfg.ApplyToConfig(cfg);
00126     //     PathIterator pi(job.JobID.Path(), true);
00127     //     URL url(job.JobID);
00128     //     url.ChangePath(*pi);
00129     //     AREXClient ac(url, cfg);
00130     //     NS ns;
00131     //     ns["a-rex"] = "http://www.nordugrid.org/schemas/a-rex";
00132     //     ns["bes-factory"] = "http://schemas.ggf.org/bes/2006/08/bes-factory";
00133     //     ns["wsa"] = "http://www.w3.org/2005/08/addressing";
00134     //     ns["jsdl"] = "http://schemas.ggf.org/jsdl/2005/11/jsdl";
00135     //     ns["jsdl-posix"] = "http://schemas.ggf.org/jsdl/2005/11/jsdl-posix";
00136     //     ns["jsdl-arc"] = "http://www.nordugrid.org/ws/schemas/jsdl-arc";
00137     //     ns["jsdl-hpcpa"] = "http://schemas.ggf.org/jsdl/2006/07/jsdl-hpcpa";
00138     //     XMLNode id(ns, "ActivityIdentifier");
00139     //     id.NewChild("wsa:Address") = url.str();
00140     //     id.NewChild("wsa:ReferenceParameters").NewChild("a-rex:JobID") = pi.Rest();
00141     //     std::string idstr;
00142     //     id.GetXML(idstr);
00143     //     return ac.clean(idstr);
00144   }
00145 
00146   bool JobControllerUNICORE::CancelJob(const Job& job) {
00147     //     MCCConfig cfg;
00148     //     usercfg.ApplyToConfig(cfg);
00149     //     PathIterator pi(job.JobID.Path(), true);
00150     //     URL url(job.JobID);
00151     //     url.ChangePath(*pi);
00152     //     AREXClient ac(url, cfg);
00153     //     NS ns;
00154     //     ns["a-rex"] = "http://www.nordugrid.org/schemas/a-rex";
00155     //     ns["bes-factory"] = "http://schemas.ggf.org/bes/2006/08/bes-factory";
00156     //     ns["wsa"] = "http://www.w3.org/2005/08/addressing";
00157     //     ns["jsdl"] = "http://schemas.ggf.org/jsdl/2005/11/jsdl";
00158     //     ns["jsdl-posix"] = "http://schemas.ggf.org/jsdl/2005/11/jsdl-posix";
00159     //     ns["jsdl-arc"] = "http://www.nordugrid.org/ws/schemas/jsdl-arc";
00160     //     ns["jsdl-hpcpa"] = "http://schemas.ggf.org/jsdl/2006/07/jsdl-hpcpa";
00161     //     XMLNode id(ns, "ActivityIdentifier");
00162     //     id.NewChild("wsa:Address") = url.str();
00163     //     id.NewChild("wsa:ReferenceParameters").NewChild("a-rex:JobID") = pi.Rest();
00164     //     std::string idstr;
00165     //     id.GetXML(idstr);
00166     //     return ac.kill(idstr);
00167   }
00168 
00169   bool JobControllerUNICORE::RenewJob(const Job& job) {
00170     logger.msg(ERROR, "Renewal of UNICORE jobs is not supported");
00171     return false;
00172   }
00173 
00174   bool JobControllerUNICORE::ResumeJob(const Job& job) {
00175     logger.msg(ERROR, "Resumation of UNICORE jobs is not supported");
00176     return false;
00177   }
00178 
00179   URL JobControllerUNICORE::GetFileUrlForJob(const Job& job,
00180                                              const std::string& whichfile) { return URL(); }
00181 
00182   bool JobControllerUNICORE::GetJobDescription(const Job& job, std::string& desc_str) {}
00183 
00184 } // namespace Arc