Exemplo n.º 1
0
void Peer::HandleTaskCancel(MessagePtr pMsg)
{
	bool status = true;
	JobPtr pJob = this->GetJob(pMsg->m_fromPeerId, pMsg->m_taskId);

	if(pJob == NULL) {
		Log(ERR, L"Peer::HandleTaskCancel- Task Cancel request received for Non-Existing Job from Peer: %d, taskid: %d\n", 
											pMsg->m_fromPeerId, pMsg->m_taskId);
		status = false;
	}
	else {
		Log(CONSOLE, L"Handling Task Cancel from Peer: %d, taskid: %d\n", pMsg->m_fromPeerId, pMsg->m_taskId);
		// cancel the job
		pJob->Stop();
		m_jobList.erase(pJob->GetJobId());
	}
}
Exemplo n.º 2
0
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();
}