Back to index

nordugrid-arc-nox  1.1.0~rc6
Public Member Functions | Protected Member Functions | Private Attributes | Friends
Arc::JobQueueIterator Class Reference

#include <job_queue.h>

Collaboration diagram for Arc::JobQueueIterator:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 JobQueueIterator ()
 ~JobQueueIterator ()
bool hasMore (void) const
Joboperator* () const
const JobQueueIteratoroperator++ ()
const JobQueueIteratoroperator++ (int)
bool refresh (void)
void remove (void)
void finish (void)

Protected Member Functions

 JobQueueIterator (DbTxn *tid_, Dbc *cursor)
 JobQueueIterator (DbTxn *tid_, Dbc *cursor, JobSelector *selector_)
void next (void)

Private Attributes

DbTxn * tid_
Dbc * cursor_
bool has_more_
Jobjob_
bool have_status_
JobSelectorselector_

Friends

class JobQueue

Detailed Description

Definition at line 27 of file job_queue.h.


Constructor & Destructor Documentation

Arc::JobQueueIterator::JobQueueIterator ( DbTxn *  tid_,
Dbc *  cursor 
) [protected]

Definition at line 60 of file job_queue.cpp.

{
    has_more_ = true;
    tid_ = tid;
    cursor_ = cursor;
    have_status_ = false;
    job_ = NULL;
    selector_ = default_selector;
    next();
}

Here is the call graph for this function:

Arc::JobQueueIterator::JobQueueIterator ( DbTxn *  tid_,
Dbc *  cursor,
JobSelector selector_ 
) [protected]

Definition at line 71 of file job_queue.cpp.

{
    has_more_ = true;
    tid_ = tid;
    cursor_ = cursor;
    have_status_ = true;
    job_ = NULL;
    selector_ = selector;
    next();
}

Here is the call graph for this function:

Definition at line 13 of file job_queue.cpp.

{
    tid_ = NULL;
    cursor_ = NULL;
    job_ = NULL;
    has_more_ = false; 
    have_status_ = false;
    selector_ = default_selector;
}

Definition at line 138 of file job_queue.cpp.

{
    finish();
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 98 of file job_queue.cpp.

{
    if (job_ != NULL) {
        delete job_;
        job_ = NULL;
    }
    if (cursor_ != NULL) {
        cursor_->close();
        cursor_ = NULL;
    }
    if (tid_ != NULL) {
        tid_->commit(0);
        tid_ = NULL;
    }
}

Here is the caller graph for this function:

bool Arc::JobQueueIterator::hasMore ( void  ) const [inline]

Definition at line 44 of file job_queue.h.

{ return has_more_; };

Here is the caller graph for this function:

void Arc::JobQueueIterator::next ( void  ) [protected]

Definition at line 23 of file job_queue.cpp.

{
    int ret;
    Dbt key, value;
    key.set_flags(0);
    value.set_flags(0);
    for (;;) {
        try {
            ret = cursor_->get(&key, &value, DB_NEXT); 
            if (ret == DB_NOTFOUND) {
                has_more_ = false;
                break;
            }
        } catch (DbDeadlockException &de) {
            has_more_ = false;
            break;
        }
        // free(key.get_data());
        ByteArray a(value.get_data(), value.get_size());
        // free(value.get_data());
        job_ = new Job(a);
        if (have_status_ == false) {
            // only one query
            break;
        } else {
            if (selector_->match(job_) == true) {
                // query until found job right by selector
                break;
            } else {
                delete job_;
                job_ = NULL;
            }
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Job* Arc::JobQueueIterator::operator* ( void  ) const [inline]

Definition at line 45 of file job_queue.h.

{ return job_; };
const JobQueueIterator & Arc::JobQueueIterator::operator++ ( void  )

Definition at line 82 of file job_queue.cpp.

{
    delete job_;
    job_ = NULL;
    next();
    return *this;
}

Here is the call graph for this function:

const JobQueueIterator & Arc::JobQueueIterator::operator++ ( int  )

Definition at line 90 of file job_queue.cpp.

{
    delete job_;
    job_ = NULL;
    next();
    return *this;
}

Here is the call graph for this function:

Definition at line 114 of file job_queue.cpp.

{
    // generate key
    void *buf = (void *)job_->getID().c_str();
    int size = job_->getID().size() + 1;
    Dbt key(buf, size);
    // generate data
    ByteArray &a = job_->serialize();
    Dbt data(a.data(), a.size());
    try {
        cursor_->put(&key, &data, DB_KEYFIRST);
        return true;
    } catch (DbDeadlockException &de) {
        return false;        
    } catch (DbException &e) {
        return false;
    }
}

Here is the call graph for this function:

Definition at line 133 of file job_queue.cpp.

{
    cursor_->del(0);
}

Friends And Related Function Documentation

friend class JobQueue [friend]

Definition at line 29 of file job_queue.h.


Member Data Documentation

Definition at line 32 of file job_queue.h.

Definition at line 33 of file job_queue.h.

Definition at line 35 of file job_queue.h.

Definition at line 34 of file job_queue.h.

Definition at line 36 of file job_queue.h.

DbTxn* Arc::JobQueueIterator::tid_ [private]

Definition at line 31 of file job_queue.h.


The documentation for this class was generated from the following files: