|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.waveset.adapter.DblBufIterator
com.waveset.adapter.DblBufAcctIter
The DblBufAcctIter class is an abstract base class to provide a double buffering scheme for an account iterator. All the subclass needs to provide is a way to fill an array with users (subFillArray() method) and a way to handle a close in the middle (subClose() method). Below is a basic description of how the double buffering works. When instantiated, the first block of users is loaded. A thread is then started that loads the next block of users. It then waits for the the first block of users to be retrieved through calls to getNext(). Once all of the users in the first block are retrieved, additional calls to get next will retrieve users from the second block. Meanwhile, the thread will fill up the first block with additional users. Synchronization of the thread getting the users from the LDAP server (the producer) and the thread calling getNext() (the consumer) is done using Java's built in locking mechanisms on the 2 ArrayList instances containing the users. When the producer finishes filling up an ArrayList it does a notify on it. It then tries to get a lock on the other ArrayList. Once it does, it checks to see if it is empty. If it is not, it waits on the the ArrayList's lock. The consumer thread will do a notify when it finishes with that ArrayList and clears it. This will wake up the producer. If the array was empty when the producer checked it, it will proceed to fill it while maintaining the lock on the ArrayList. When the consumer attempts to access an ArrayList it waits until it can get a lock on it. If it contains any entries, then it gets one off the list and returns it. If there are no entries, it waits on the ArrayList (this gives the producer control, if it is waiting for the lock).
Supplier
,
BufferedAccountQueue
Field Summary | |
static java.lang.String |
code_id
Deprecated. |
Fields inherited from class com.waveset.adapter.DblBufIterator |
_trace |
Constructor Summary | |
DblBufAcctIter(int blockSize)
Deprecated. |
Method Summary | |
void |
close()
Deprecated. |
protected ObjectCache |
getCache()
Deprecated. |
boolean |
hasNext()
Deprecated. |
WSUser |
next()
Deprecated. |
protected void |
setCache(ObjectCache cache)
Deprecated. |
protected abstract void |
subClose()
Deprecated. |
protected abstract void |
subFillArray(java.util.ArrayList arrayList)
Deprecated. |
Methods inherited from class com.waveset.adapter.DblBufIterator |
finalize, getCurrentArray, getError, getFillArray, getNextArray, getNextIndex, hasError, isDone, isRun, nextObject, notifyArrays, run, setCurrentArray, setDone, setError, setRun, start |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String code_id
Constructor Detail |
public DblBufAcctIter(int blockSize) throws WavesetException
Method Detail |
protected void setCache(ObjectCache cache)
protected ObjectCache getCache()
protected abstract void subFillArray(java.util.ArrayList arrayList) throws java.lang.Exception
subFillArray
in class DblBufIterator
java.lang.Exception
protected abstract void subClose()
subClose
in class DblBufIterator
public boolean hasNext() throws WavesetException
hasNext
in interface AccountIterator
hasNext
in class DblBufIterator
WavesetException
public void close()
close
in interface AccountIterator
close
in class DblBufIterator
public WSUser next() throws java.util.NoSuchElementException, WavesetException
next
in interface AccountIterator
java.util.NoSuchElementException
WavesetException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |