void AllJobInfo::Visit( Scheduler &scheduler ) { const ScheduledJobs &schedJobs = scheduler.GetScheduledJobs(); for( auto it = schedJobs.GetJobQueueBegin(); it != schedJobs.GetJobQueueEnd(); ++it ) { const JobState &jobState = it->first; const JobPtr &job = jobState.GetJob(); std::string jobInfo; JobInfo::PrintJobInfo( jobInfo, scheduler, job->GetJobId() ); info_ += jobInfo + '\n'; } }
void Statistics::Visit( Scheduler &scheduler ) { std::ostringstream ss; const ScheduledJobs &schedJobs = scheduler.GetScheduledJobs(); const FailedWorkers &failedWorkers = scheduler.GetFailedWorkers(); IWorkerManager *workerManager = common::GetService< IWorkerManager >(); ss << "================" << std::endl << "busy workers = " << GetNumBusyWorkers( scheduler ) << std::endl << "free workers = " << GetNumFreeWorkers( scheduler ) << std::endl << "failed jobs = " << failedWorkers.GetFailedJobsCnt() << std::endl << "busy cpu's = " << GetNumBusyCPU( scheduler ) << std::endl << "total cpu's = " << workerManager->GetTotalCPU() << std::endl; const Scheduler::TaskList &needReschedule = scheduler.GetNeedReschedule(); ss << "jobs = " << schedJobs.GetNumJobs() << std::endl << "need reschedule = " << needReschedule.size() << std::endl; ss << "executing jobs: {"; for( auto it = schedJobs.GetJobQueueBegin(); it != schedJobs.GetJobQueueEnd(); ++it ) { const JobState &jobState = it->first; const JobPtr &job = jobState.GetJob(); if ( it != schedJobs.GetJobQueueBegin() ) ss << ", "; ss << job->GetJobId(); } ss << "}" << std::endl; ss << "================"; info_ = ss.str(); }
void JobInfo::PrintJobInfo( std::string &info, Scheduler &scheduler, int64_t jobId ) { std::ostringstream ss; ScheduledJobs &jobs = scheduler.GetScheduledJobs(); JobPtr job; if ( !jobs.FindJobByJobId( jobId, job ) ) { ss << "job isn't executing now, jobId = " << jobId; info = ss.str(); return; } ss << "================" << std::endl << "Job info, jobId = " << job->GetJobId() << std::endl; if ( job->GetGroupId() >= 0 ) { ss << "group id = " << job->GetGroupId() << std::endl; } if ( job->GetJobGroup() ) { const std::string &metaJobName = job->GetJobGroup()->GetName(); if ( !metaJobName.empty() ) { ss << "meta job name = '" << metaJobName << '\'' << std::endl; } } if ( !job->GetAlias().empty() ) { ss << "job alias = '" << job->GetAlias() << '\'' << std::endl; } else { ss << "job path = '" << job->GetFilePath() << '\'' << std::endl; } if ( !job->GetName().empty() ) { ss << "job name = '" << job->GetName() << '\'' << std::endl; } ss << "----------------" << std::endl; { int totalExec = job->GetNumPlannedExec(); int numExec = totalExec - jobs.GetNumExec( jobId ); ss << "job executions = " << numExec << std::endl << "total planned executions = " << totalExec << std::endl; } { int numWorkers = 0; int numCPU = 0; const Scheduler::IPToNodeState &nodeState = scheduler.GetNodeState(); for( auto it = nodeState.cbegin(); it != nodeState.cend(); ++it ) { const NodeState &nodeState = it->second; const WorkerPtr &worker = nodeState.GetWorker(); if ( !worker ) continue; const WorkerJob &workerJob = worker->GetJob(); if ( workerJob.HasJob( jobId ) ) { ++numWorkers; numCPU += workerJob.GetNumTasks( jobId ); } } ss << "busy workers = " << numWorkers << std::endl; ss << "busy cpu's = " << numCPU << std::endl; } ss << "================"; info = ss.str(); }