Back to index

nordugrid-arc-nox  1.1.0~rc6
information_collector.cpp
Go to the documentation of this file.
00001 #ifdef HAVE_CONFIG_H
00002 #include <config.h>
00003 #endif
00004 
00005 #ifdef WIN32 
00006 #include <arc/win32.h>
00007 #endif
00008 
00009 #include "grid_sched.h"
00010 
00011 namespace GridScheduler {
00012 
00013 void GridSchedulerService::InformationCollector(void) {
00014    for(;;) {
00015 
00016     std::string xml_str = "\
00017 <arc:InfoRoot xmlns:glue=\"http://schemas.ogf.org/glue/2008/05/spec_2.0_d41_r01\" xmlns:arc=\"urn:knowarc\">\
00018   <Domains xmlns=\"http://schemas.ogf.org/glue/2008/05/spec_2.0_d41_r01\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://schemas.ogf.org/glue/2008/05/spec_2.0_d41_r01 pathto/GLUE2.xsd\">\
00019     <AdminDomain xmlns=\"http://schemas.ogf.org/glue/2008/05/spec_2.0_d41_r01\">\
00020       <Services xmlns=\"http://schemas.ogf.org/glue/2008/05/spec_2.0_d41_r01\">\
00021         <ComputingService BaseType=\"Service\" CreationTime=\"2009-07-16T07:55:47Z\" Validity=\"600\">\
00022           <Associations></Associations>\
00023           <Capability>executionmanagement.jobexecution</Capability>\
00024           <Complexity>endpoint=1,share=1,resource=1</Complexity>\
00025           <ComputingEndpoint BaseType=\"Endpoint\" CreationTime=\"2009-07-16T07:55:47Z\" Validity=\"600\">\
00026             <Associations>\
00027               <ComputingShareID>urn:ogsa:ComputingShare:knowarc1:2811:knowarc</ComputingShareID>\
00028             </Associations>\
00029             <HealthState>ok</HealthState>\
00030             <ID>urn:ogsa:ComputingEndpoint:knowarc1:2811</ID>\
00031             <ImplementationName>ARC1</ImplementationName>\
00032             <ImplementationVersion>0.9</ImplementationVersion>\
00033             <Implementor>NorduGrid</Implementor>\
00034             <Interface>OGSA-BES</Interface>\
00035             <JobDescription>ogf:jsdl:1.0</JobDescription>\
00036             <PreLRMSWaitingJobs>0</PreLRMSWaitingJobs>\
00037             <QualityLevel>development</QualityLevel>\
00038             <RunningJobs>0</RunningJobs>\
00039             <Semantics>http://svn.nordugrid.org/trac/nordugrid/browser/arc1/trunk/src/services/sched/README</Semantics>\
00040             <ServingState>production</ServingState>\
00041             <Staging>staginginout</Staging>\
00042             <StagingJobs>0</StagingJobs>\
00043             <SupportedProfile>WS-I 1.0</SupportedProfile>\
00044             <SupportedProfile>HPC-BP</SupportedProfile>\
00045             <SuspendedJobs>0</SuspendedJobs>\
00046             <Technology>webservice</Technology>\
00047             <TotalJobs>0</TotalJobs>\
00048             <ComputingActivities>\
00049             </ComputingActivities>\
00050           </ComputingEndpoint>\
00051           <ComputingShares>\
00052             <ComputingShare BaseType=\"Share\" CreationTime=\"2009-07-16T08:46:43Z\" Validity=\"600\">\
00053               <Associations>\
00054                 <ComputingEndpointID>urn:ogsa:ComputingEndpoint:knowarc1:2811</ComputingEndpointID>\
00055               </Associations>\
00056               <Description>Job scheduler service. It speaks BES and iBES as well. It implements a job queue and schedules job to other BES services like A-REX or iBES clients like Paul.</Description>\
00057               <FreeSlots>2000</FreeSlots>\
00058               <FreeSlotsWithDuration>1:6483600</FreeSlotsWithDuration>\
00059               <ID>urn:ogsa:ComputingShare:knowarc1:2811:knowarc</ID>\
00060               <LocalRunningJobs>0</LocalRunningJobs>\
00061               <LocalSuspendedJobs>0</LocalSuspendedJobs>\
00062               <LocalWaitingJobs>0</LocalWaitingJobs>\
00063               <MappingQueue>knowarc</MappingQueue>\
00064               <MaxCPUTime>100860</MaxCPUTime>\
00065               <MaxMultiSlotWallTime>108060</MaxMultiSlotWallTime>\
00066               <MaxRunningJobs>4</MaxRunningJobs>\
00067               <MaxSlotsPerJob>1</MaxSlotsPerJob>\
00068               <MaxWallTime>108060</MaxWallTime>\
00069               <MinCPUTime>0</MinCPUTime>\
00070               <MinWallTime>0</MinWallTime>\
00071               <Name>knowarc</Name>\
00072               <PreLRMSWaitingJobs>0</PreLRMSWaitingJobs>\
00073               <RequestedSlots>0</RequestedSlots>\
00074               <RunningJobs>0</RunningJobs>\
00075               <ServingState>draining</ServingState>\
00076               <StagingJobs>0</StagingJobs>\
00077               <SuspendedJobs>0</SuspendedJobs>\
00078               <TotalJobs>0</TotalJobs>\
00079               <UsedSlots>0</UsedSlots>\
00080               <WaitingJobs>0</WaitingJobs>\
00081             </ComputingShare>\
00082           </ComputingShares>\
00083           <ID>urn:ogsa:ComputingService:knowarc1:2811</ID>\
00084           <Name>ARC1, Sched service</Name>\
00085           <PreLRMSWaitingJobs>0</PreLRMSWaitingJobs>\
00086           <QualityLevel>development</QualityLevel>\
00087           <RunningJobs>0</RunningJobs>\
00088           <StagingJobs>0</StagingJobs>\
00089           <SuspendedJobs>0</SuspendedJobs>\
00090           <TotalJobs>0</TotalJobs>\
00091           <Type>org.nordugrid.execution.sched</Type>\
00092           <WaitingJobs>0</WaitingJobs>\
00093         </ComputingService>\
00094       </Services>\
00095     </AdminDomain>\
00096   </Domains>\
00097   <n:nordugrid xmlns:M0=\"urn:Mds\" xmlns:n=\"urn:nordugrid\" xmlns:nc0=\"urn:nordugrid-cluster\">\
00098     <M0:validfrom>20090716075547Z</M0:validfrom>\
00099     <M0:validto>20090716080547Z</M0:validto>\
00100     <nc0:aliasname>ARC1, Sched service</nc0:aliasname>\
00101     <nc0:architecture>i686</nc0:architecture>\
00102   </n:nordugrid>\
00103 </arc:InfoRoot>";
00104     
00105 
00106     Arc::XMLNode root(xml_str);
00107 
00108     for (Arc::JobQueueIterator jobs = jobq.getAll(); jobs.hasMore(); jobs++) {
00109        Arc::Job *j = *jobs;
00110        Arc::XMLNode jobs = root["Domains"]["AdminDomain"]["Services"]["ComputingService"]["ComputingEndpoint"]["ComputingActivities"];
00111        Arc::XMLNode job = jobs.NewChild("glue:ComputingActivity");
00112        job.NewChild("glue:ID") =  "urn:ogsa:ComputingActivity:sched:" + j->getID();
00113        switch (j->getStatus()) {
00114          case Arc::JOB_STATUS_SCHED_NEW:
00115              job.NewChild("glue:State") = "bes:Pending";
00116              job.NewChild("glue:State") = "nordugrid:ACCEPTED";
00117              break; 
00118          case Arc::JOB_STATUS_SCHED_RESCHEDULED:
00119              job.NewChild("glue:State") = "bes:Pending";
00120              job.NewChild("glue:State") = "nordugrid:ACCEPTED";
00121              break; 
00122          case Arc::JOB_STATUS_SCHED_STARTING:
00123              job.NewChild("glue:State") = "bes:Pending";
00124              job.NewChild("glue:State") = "nordugrid:PREPARING";
00125              break; 
00126          case Arc::JOB_STATUS_SCHED_RUNNING:
00127              job.NewChild("glue:State") = "bes:Running";
00128              job.NewChild("glue:State") = "nordugrid:INLRMS:R";
00129              break; 
00130          case Arc::JOB_STATUS_SCHED_CANCELLED:
00131              job.NewChild("glue:State") = "bes:Cancelled";
00132              job.NewChild("glue:State") = "nordugrid:KILLED";
00133              break; 
00134          case Arc::JOB_STATUS_SCHED_FAILED:
00135              job.NewChild("glue:State") = "bes:Failed";
00136              job.NewChild("glue:State") = "nordugrid:FAILED";
00137              break; 
00138          case Arc::JOB_STATUS_SCHED_FINISHED:
00139              job.NewChild("glue:State") = "bes:Finished";
00140              job.NewChild("glue:State") = "nordugrid:FINISHED";
00141              break; 
00142          case Arc::JOB_STATUS_SCHED_KILLED:
00143              job.NewChild("glue:State") = "bes:Cancelled";
00144              job.NewChild("glue:State") = "nordugrid:KILLED";
00145              break; 
00146          case Arc::JOB_STATUS_SCHED_KILLING:
00147              job.NewChild("glue:State") = "bes:Cancelled";
00148              job.NewChild("glue:State") = "nordugrid:KILLED";
00149              break; 
00150          case Arc::JOB_STATUS_SCHED_UNKNOWN:
00151              job.NewChild("glue:State") = "bes:Unknown";
00152              job.NewChild("glue:State") = "nordugrid:UNKNOWN";
00153              break; 
00154        }
00155     }
00156 
00157     if(root) {
00158       // Put result into container
00159       infodoc_.Assign(root,true);
00160 
00161       std::string s;
00162 
00163       root.GetDoc(s, true);
00164 
00165       logger_.msg(Arc::VERBOSE,"Assigned new informational document");
00166     } else {
00167       logger_.msg(Arc::ERROR,"Failed to create informational document");
00168     };
00169   
00170     sleep(5); 
00171 
00172    } // end of the for loop
00173   
00174 }
00175 
00176 bool GridSchedulerService::RegistrationCollector(Arc::XMLNode &doc) {
00177   logger_.msg(Arc::DEBUG,"Passing service's information from collector to registrator");
00178   Arc::XMLNode empty(ns_, "RegEntry");
00179   empty.New(doc);
00180 
00181   doc.NewChild("SrcAdv");
00182   doc.NewChild("MetaSrcAdv");
00183   doc["SrcAdv"].NewChild("Type") = "org.nordugrid.execution.sched";
00184   doc["SrcAdv"].NewChild("EPR").NewChild("Address") = endpoint;
00185   return true;
00186 }
00187 
00188 } // end of the namespace
00189 
00190 
00191