com.cloudtran.replicator.ssdStore
Class SSDWriteOperationIterator

java.lang.Object
  extended by com.cloudtran.replicator.ssdStore.SSDWriteOperationIterator
All Implemented Interfaces:
Iterator<SSDWriteOperationArea>

public class SSDWriteOperationIterator
extends Object
implements Iterator<SSDWriteOperationArea>


Field Summary
static int BLOCKS_PER_TX
           
 
Constructor Summary
SSDWriteOperationIterator(FileInputStream fis, boolean allData)
          The constructor for this iterator
 
Method Summary
 int getCurrentBlockNumber()
           
 SSDWriteOperationArea getNextArea()
          This reads the next section of the FileInputStream.
 boolean hasNext()
          The hasNext() and next() method in this iterator are closely tied As we are iterating over a FileInputStream it is not possible to see if there is more data without actually reading it.
 SSDWriteOperationArea next()
          The hasNext() and next() method in this iterator are closely tied As we are iterating over a FileInputStream it is not possible to see if there is more data without actually reading it.
 void remove()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BLOCKS_PER_TX

public static final int BLOCKS_PER_TX
Constructor Detail

SSDWriteOperationIterator

public SSDWriteOperationIterator(FileInputStream fis,
                                 boolean allData)
The constructor for this iterator

Parameters:
the - fileInputStream. This should be open.
the - flag to determine whether to return all the data
Method Detail

hasNext

public boolean hasNext()
The hasNext() and next() method in this iterator are closely tied As we are iterating over a FileInputStream it is not possible to see if there is more data without actually reading it. So when hasNext() is called the variable dataArea is checked. If it is null then the getNextArea() method is called to retrieve the next dataArea. If the call to getNextArea() results in an error ( NoSuchElementException ) then hasNext() returns false If the call to getNextArea() succeeds - i.e. the next dataArea has been read successfully - then the return value is stored in the dataArea variable and hasNext() returns true; If hasNext() is called subsequently the return value will be false - as dataArea != null. If next() is called the dataArea is returned. The next() method works in the same way, but of course having returned the dataArea to the caller it sets the dataArea == null.

Specified by:
hasNext in interface Iterator<SSDWriteOperationArea>
See Also:
Iterator.hasNext(), next()

next

public SSDWriteOperationArea next()
The hasNext() and next() method in this iterator are closely tied As we are iterating over a FileInputStream it is not possible to see if there is more data without actually reading it. So when hasNext() is called the variable dataArea is checked. If it is null then the getNextArea() method is called to retrieve the next dataArea. If the call to getNextArea() results in an error ( NoSuchElementException ) then hasNext() returns false If the call to getNextArea() succeeds - i.e. the next dataArea has been read successfully - then the return value is stored in the dataArea variable and hasNext() returns true; If hasNext() is called subsequently the return value will be false - as dataArea != null. If next() is called the dataArea is returned. The next() method works in the same way, but of course having returned the dataArea to the caller it sets the dataArea == null.

Specified by:
next in interface Iterator<SSDWriteOperationArea>
See Also:
Iterator.next(), hasNext()

getNextArea

public SSDWriteOperationArea getNextArea()
This reads the next section of the FileInputStream. If the allData flag is set 'false' the data returned is the 'length' and SSDWriteOperationHeader are returned. If the allData flag is set 'true' then the ReplicatorOutboundRequest and the SSDWriteOperationTrailer are also returned. A CRC check is also made. In both cases the SSDWriteOperationArea is returned


remove

public void remove()
Specified by:
remove in interface Iterator<SSDWriteOperationArea>

getCurrentBlockNumber

public int getCurrentBlockNumber()