Back to index

nordugrid-arc-nox  1.1.0~rc6
info.cpp
Go to the documentation of this file.
00001 #ifdef HAVE_CONFIG_H
00002 #include <config.h>
00003 #endif
00004 
00005 #include <arc/DateTime.h> 
00006 #include <arc/GUID.h>
00007 #include "paul.h"
00008 #include "sysinfo.h"
00009 
00010 namespace Paul
00011 {
00012 
00013 bool PaulService::information_collector(Arc::XMLNode &doc)
00014 {
00015     // refresh dynamic system information
00016     sysinfo.refresh();
00017     // common variables
00018     std::string created = TimeStamp(Arc::UTCTime);
00019     std::string validity = Arc::tostring(configurator.getPeriod()*2);
00020     std::string id = "urn:nordugrid:paul:" + Arc::UUID(); 
00021     std::string ee_id = id + ":executionenvironment:0";
00022     // Set Domain
00023     doc.NewAttribute("CreationTime") = created;
00024     doc.NewAttribute("Validity") = validity;
00025     // Set AdminDomain
00026     Arc::XMLNode ad = doc.NewChild("AdminDomain");
00027     ad.NewAttribute("CreationTime") = created;
00028     ad.NewAttribute("Validity") = validity;
00029     ad.NewAttribute("BaseType") = "Domain";
00030     ad.NewChild("ID") = id;
00031     ad.NewChild("Distributed") = "False";
00032     // Set Computing Service
00033     //      Service Part
00034     Arc::XMLNode services = ad.NewChild("Services");
00035     Arc::XMLNode cs = services.NewChild("ComputingService");
00036     cs.NewAttribute("CreationTime") = created;
00037     cs.NewAttribute("Validity") = validity;
00038     cs.NewAttribute("BaseType") = "Service";
00039     cs.NewChild("ID") = id + ":computingservice:0";
00040     cs.NewChild("Name") = "Arc Paul Service";
00041     cs.NewChild("Type") = "org.nordugrid.paul";
00042     cs.NewChild("QualityLevel") = "production";
00043     // No endpont -> pull modell
00044     //      Computing Service part
00045     cs.NewChild("TotalJobs") = Arc::tostring(jobq.getTotalJobs());
00046     cs.NewChild("RunningJobs") = Arc::tostring(jobq.getRunningJobs());
00047     cs.NewChild("WaitingJobs") = Arc::tostring(jobq.getWaitingJobs());
00048     cs.NewChild("StagingJobs") = Arc::tostring(jobq.getStagingJobs());
00049     Arc::XMLNode sh = cs.NewChild("ComputingShares").NewChild("ComputingShare");
00050     sh.NewAttribute("CreationTime") = created;
00051     sh.NewAttribute("Validity") = validity;
00052     sh.NewAttribute("BaseType") = "Share";
00053     //      Share part
00054     sh.NewChild("LocalID") = "computingshare:0";
00055     //      Computing Share part
00056     sh.NewChild("MaxTotalJobs") = Arc::tostring(sysinfo.getLogicalCPUs());
00057     sh.NewChild("MaxMemory") = Arc::tostring((int)sysinfo.getMainMemorySize()); // in MB
00058     sh.NewChild("MaxDiskSpace") = Arc::tostring((int)(SysInfo::diskFree(configurator.getJobRoot())/1024)); // in GB
00059     sh.NewChild("ServingState") = "production";
00060     sh.NewChild("TotalJobs") = Arc::tostring(jobq.getTotalJobs());
00061     sh.NewChild("RunningJobs") = Arc::tostring(jobq.getRunningJobs());
00062     sh.NewChild("WaitingJobs") = Arc::tostring(jobq.getWaitingJobs());
00063     sh.NewChild("StagingJobs") = Arc::tostring(jobq.getStagingJobs());
00064     sh.NewChild("Associations").NewChild("ExecutionEnvironmentLocalID") = ee_id;
00065     //      Manager part
00066     Arc::XMLNode mg = cs.NewChild("ComputingManager");
00067     mg.NewAttribute("CreationTime") = created;
00068     mg.NewAttribute("Validity") = validity;
00069     mg.NewAttribute("BaseType") = "Manager";
00070     mg.NewChild("ID") = id + ":computingmanager:0";
00071     mg.NewChild("Name") = "Paul";
00072     //      Computing Manager part
00073     mg.NewChild("Type") = "fork";
00074     mg.NewChild("Version") = "1.0";
00075     mg.NewChild("TotalPhysicalCPUs") = Arc::tostring(sysinfo.getPhysicalCPUs());
00076     mg.NewChild("TotalLogicalCPUs") = Arc::tostring(sysinfo.getLogicalCPUs());
00077     mg.NewChild("Homogenety") = "True";
00078     mg.NewChild("WorkingAreaTotal") = Arc::tostring((int)(SysInfo::diskTotal(configurator.getJobRoot())/1024)); // in GB
00079     mg.NewChild("WorkingAreaFree") = Arc::tostring((int)(SysInfo::diskFree(configurator.getJobRoot())/1024)); // in GB
00080     // Application environment
00081     Arc::XMLNode appenvs = configurator.getApplicationEnvironments();
00082     Arc::XMLNode env;
00083     if (appenvs) {
00084         Arc::XMLNode ae = mg.NewChild("ApplicationEnvironments");
00085         for (int i = 0; (env = appenvs["ApplicationEnvironment"][i]) != false; i++) {
00086             Arc::XMLNode cr_time = env.Attribute("CreationTime");
00087             if (!cr_time) { 
00088                 cr_time = env.NewAttribute("CreationTime");
00089             }
00090             cr_time = created;
00091             Arc::XMLNode v_time = env.Attribute("Validity");
00092             if (!v_time) {
00093                 v_time = env.NewAttribute("Validity");
00094             }
00095             v_time = validity;
00096             Arc::XMLNode local_id = env["LocalID"];
00097             if (!local_id) {
00098                 env.NewChild("LocalID") = ("applicationenvironment:" + Arc::tostring(i));
00099             }
00100             Arc::XMLNode eid = env["Associations"]["ExecutionEnvironmentLocalID"];
00101             if (!eid) {
00102                 env.NewChild("Associations").NewChild("ExecutionEnvironmentLocalID") = ee_id;
00103             }
00104             ae.NewChild(env);
00105         }
00106     }
00107     //  Resource part
00108     Arc::XMLNode exec = mg.NewChild("ExecutionEnvironment");
00109     exec.NewAttribute("CreationTime") = created;
00110     exec.NewAttribute("Validity") = validity;
00111     exec.NewAttribute("BaseType") = "Resource";
00112     exec.NewChild("ID") = ee_id;
00113     //  ExecutionEnvironment part
00114     exec.NewChild("Platform") = sysinfo.getPlatform();
00115     exec.NewChild("PhysicalCPUs") = Arc::tostring(sysinfo.getPhysicalCPUs());
00116     exec.NewChild("LogicalCPUs") = Arc::tostring(sysinfo.getLogicalCPUs());
00117     exec.NewChild("MainMemorySize") = Arc::tostring(sysinfo.getMainMemorySize()); // in MB
00118     exec.NewChild("VirtualMemorySize") = Arc::tostring(sysinfo.getVirtualMemorySize()); // in MB
00119     exec.NewChild("OSFamily") = sysinfo.getOSFamily();
00120     exec.NewChild("OSName") = sysinfo.getOSName();
00121     exec.NewChild("OSVersion") = sysinfo.getOSVersion();
00122     return true;
00123 }
00124 
00125 bool PaulService::RegistrationCollector(Arc::XMLNode &doc) {
00126   logger_.msg(Arc::DEBUG,"Passing service's information from collector to registrator");
00127   Arc::XMLNode empty(ns_, "RegEntry");
00128   empty.New(doc);
00129 
00130   doc.NewChild("SrcAdv");
00131   doc.NewChild("MetaSrcAdv");
00132   doc["SrcAdv"].NewChild("Type") = "org.nordugrid.execution.paul";
00133   doc["SrcAdv"].NewChild("EPR").NewChild("Address") = configurator.getEndpoint();
00134 
00135   return true;
00136 }
00137 
00138 
00139 } // namespace