예제 #1
0
void
JobQueue::add( const JobPtr& job )
{
    IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);

    if ( isQueueStopping_ )
        return;

    pendingJobs_.push_back( job );

    if ( job->isTracable_ || config_.traceAddEvents )
        tracer_.info( "Added "+job->toString()+" to the job queue" );

    if ( config_.queueSizeWarn>0 && pendingJobs_.size()>=(size_t)config_.queueSizeWarn ) {
        std::stringstream ss;
        ss << "Job queue size " << pendingJobs_.size() << " after adding "<<job->toString();
        tracer_.warning( ss.str() );
    }

    if ( config_.traceStalledJobs ) {
        std::string jobInfo;
        for ( size_t i=0; i<workerPool_.size(); ++i )
        {
            WorkerPtr w = WorkerPtr::dynamicCast( workerPool_[i] );
            if ( w->isJobStalled( jobInfo ) )
                tracer_.warning( jobInfo );
        }
    }

    notify();
}
예제 #2
0
std::string
JobQueue::toString()
{
    stringstream ss;

    IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);

    if ( activeJobCount_ )
        ss<<"ACTIVE JOBS (maybe out of sync):"<<endl;
    for ( size_t i=0; i<workerPool_.size(); ++i )
    {
        string s;
        if ( workerPool_[i] )
        {
            WorkerPtr w = WorkerPtr::dynamicCast( workerPool_[i] );
            s = w->toString();
            if ( !s.empty() )
                ss << "  " << w->toString() << endl;
        }
    }

    if ( !pendingJobs_.empty() )
        ss<<"PENDING JOBS:"<<endl;
    for ( std::list<JobPtr>::const_iterator it=pendingJobs_.begin(); it!=pendingJobs_.end(); ++it ) {
        const JobPtr job = *it;
        ss << "  " << job->toString() << endl;
    }

    return ss.str();
}