diff --git a/scheduler/OStoreDB/QueueItor.cpp b/scheduler/OStoreDB/QueueItor.cpp index aa1f7eff1c73d4459d115ddc006a008af65f65de..80f80f5ed0c327787062fb22a67f08062f147a38 100644 --- a/scheduler/OStoreDB/QueueItor.cpp +++ b/scheduler/OStoreDB/QueueItor.cpp @@ -24,10 +24,11 @@ namespace cta { //------------------------------------------------------------------------------ -// QueueItor::getQueueJobs +// QueueItor::getQueueJobs (generic) //------------------------------------------------------------------------------ template<typename JobQueuesQueue, typename JobQueue> -void QueueItor<JobQueuesQueue, JobQueue>::getQueueJobs() +void QueueItor<JobQueuesQueue, JobQueue>:: +getQueueJobs() { // Behaviour is racy: it's possible that the queue can disappear before we read it. // In this case, we ignore the error and move on. @@ -44,6 +45,41 @@ void QueueItor<JobQueuesQueue, JobQueue>::getQueueJobs() } } +//------------------------------------------------------------------------------ +// QueueItor::QueueItor (Archive specialisation) +//------------------------------------------------------------------------------ +template<> +QueueItor<objectstore::RootEntry::ArchiveQueueDump, objectstore::ArchiveQueue>:: +QueueItor(objectstore::Backend &objectStore, const std::string &queue_id) : + m_objectStore(objectStore), + m_onlyThisQueueId(!queue_id.empty()), + m_jobQueueIt(m_jobQueue.begin()) +{ + objectstore::RootEntry re(m_objectStore); + objectstore::ScopedSharedLock rel(re); + re.fetch(); + m_jobQueuesQueue = re.dumpArchiveQueues(); + rel.release(); + + // Set queue iterator to the first queue in the list + m_jobQueuesQueueIt = m_jobQueuesQueue.begin(); + + // If we specified a tape pool, advance to the correct queue + if(m_onlyThisQueueId) { + for( ; m_jobQueuesQueueIt != m_jobQueuesQueue.end(); ++m_jobQueuesQueueIt) { + if(m_jobQueuesQueueIt->tapePool == queue_id) break; + } + if(m_jobQueuesQueueIt == m_jobQueuesQueue.end()) { + throw cta::exception::UserError("TapePool " + queue_id + " not found."); + } + } + + // Find the first job in the queue + if(m_jobQueuesQueueIt != m_jobQueuesQueue.end()) { + getQueueJobs(); + } +} + //------------------------------------------------------------------------------ // QueueItor::qid (Archive specialisation) //------------------------------------------------------------------------------ @@ -100,10 +136,10 @@ getJob() const } //------------------------------------------------------------------------------ -// QueueItor::QueueItor (Archive specialisation) +// QueueItor::QueueItor (Retrieve specialisation) //------------------------------------------------------------------------------ template<> -QueueItor<objectstore::RootEntry::ArchiveQueueDump, objectstore::ArchiveQueue>:: +QueueItor<objectstore::RootEntry::RetrieveQueueDump, objectstore::RetrieveQueue>:: QueueItor(objectstore::Backend &objectStore, const std::string &queue_id) : m_objectStore(objectStore), m_onlyThisQueueId(!queue_id.empty()), @@ -112,21 +148,22 @@ QueueItor(objectstore::Backend &objectStore, const std::string &queue_id) : objectstore::RootEntry re(m_objectStore); objectstore::ScopedSharedLock rel(re); re.fetch(); - m_jobQueuesQueue = re.dumpArchiveQueues(); + m_jobQueuesQueue = re.dumpRetrieveQueues(); rel.release(); - // Set queue iterator to the first queue in the list + // Find the first queue m_jobQueuesQueueIt = m_jobQueuesQueue.begin(); +#if 0 // If we specified a tape pool, advance to the correct queue if(m_onlyThisQueueId) { for( ; m_jobQueuesQueueIt != m_jobQueuesQueue.end(); ++m_jobQueuesQueueIt) { - if(m_jobQueuesQueueIt->tapePool == queue_id) break; - } - if(m_jobQueuesQueueIt == m_jobQueuesQueue.end()) { - throw cta::exception::UserError("TapePool " + queue_id + " not found."); + if(m_jobQueuesQueueIt->tapePool == queue_id) { + break; + } } } +#endif // Find the first job in the queue if(m_jobQueuesQueueIt != m_jobQueuesQueue.end()) { @@ -146,7 +183,7 @@ qid() const } //------------------------------------------------------------------------------ -// QueueItor::QueueItor (Retrieve specialisation) +// QueueItor::getJob (Retrieve specialisation) //------------------------------------------------------------------------------ template<> std::pair<bool,objectstore::RetrieveQueue::job_t> @@ -173,41 +210,4 @@ getJob() const } } -//------------------------------------------------------------------------------ -// QueueItor::QueueItor (Retrieve specialisation) -//------------------------------------------------------------------------------ -template<> -QueueItor<objectstore::RootEntry::RetrieveQueueDump, objectstore::RetrieveQueue>:: -QueueItor(objectstore::Backend &objectStore, const std::string &queue_id) : - m_objectStore(objectStore), - m_onlyThisQueueId(!queue_id.empty()), - m_jobQueueIt(m_jobQueue.begin()) -{ - objectstore::RootEntry re(m_objectStore); - objectstore::ScopedSharedLock rel(re); - re.fetch(); - m_jobQueuesQueue = re.dumpRetrieveQueues(); - rel.release(); - - // Find the first queue - m_jobQueuesQueueIt = m_jobQueuesQueue.begin(); - -#if 0 - // If we specified a tape pool, advance to the correct queue - if(m_onlyThisQueueId) { - for( ; m_jobQueuesQueueIt != m_jobQueuesQueue.end(); ++m_jobQueuesQueueIt) { - if(m_jobQueuesQueueIt->tapePool == queue_id) { - break; - } - } - } -#endif - - // Find the first job in the queue - if(m_jobQueuesQueueIt != m_jobQueuesQueue.end()) { - getQueueJobs(); - } -} - } // namespace cta -