|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mpisws.p2p.transport.peerreview.history.SecureHistoryImpl
public class SecureHistoryImpl
The following class implements PeerReview's log. A log entry consists of a sequence number, a type, and a string of bytes. On disk, the log is stored as two files: An index file and a data file.
| Field Summary | |
|---|---|
protected long |
baseSeq
|
protected RandomAccessFileIOBuffer |
dataFile
|
protected HashProvider |
hashProv
|
protected IndexEntryFactory |
indexFactory
|
protected RandomAccessFileIOBuffer |
indexFile
|
protected Logger |
logger
|
protected long |
nextSeq
|
protected long |
numEntries
|
protected boolean |
pointerAtEnd
|
protected boolean |
readOnly
|
protected IndexEntry |
topEntry
|
| Fields inherited from interface org.mpisws.p2p.transport.peerreview.StatusConstants |
|---|
STATUS_EXPOSED, STATUS_SUSPECTED, STATUS_TRUSTED |
| Constructor Summary | |
|---|---|
SecureHistoryImpl(RandomAccessFileIOBuffer indexFile,
RandomAccessFileIOBuffer dataFile,
boolean readOnly,
HashProvider hashProv,
IndexEntryFactory indexFactory,
Logger logger)
|
|
| Method Summary | |
|---|---|
void |
appendEntry(short type,
boolean storeFullEntry,
ByteBuffer... entry)
Appends a new entry to the log. |
void |
appendHash(short type,
byte[] hash)
Append a new hashed entry to the log. |
void |
appendSnippetToHistory(LogSnippet snippet)
|
void |
close()
The destructor. |
long |
findLastEntry(short[] types,
long maxSeq)
Find the most recent entry whose type is in the specified set. |
long |
findSeq(long seq)
|
long |
findSeqOrHigher(long seq,
boolean allowHigher)
Look up a given sequence number, or the first sequence number that is not lower than a given number. |
long |
getBaseSeq()
|
byte[] |
getEntry(IndexEntry ie,
int maxSizeToRead)
|
byte[] |
getEntry(long idx,
int maxSizeToRead)
Get the content of a log entry, specified by its record number |
long |
getLastSeq()
|
long |
getNumEntries()
|
HashSeq |
getTopLevelEntry()
Returns the node hash and the sequence number of the most recent log entry |
LogSnippet |
serializeRange(long idxFrom,
long idxTo,
HashPolicy hashPolicy)
Serialize a given range of entries, and write the result to the specified file. |
boolean |
serializeRange2(long idxFrom,
long idxTo,
HashPolicy hashPolicy,
OutputBuffer outfile)
|
boolean |
setNextSeq(long nextSeq)
Sets the next sequence number to be used. |
IndexEntry |
statEntry(long idx)
Retrieve information about a given record |
boolean |
upgradeHashedEntry(int idx,
ByteBuffer entry)
If the log already contains an entry in 'hashed' form and we learn the actual contents later, this function is called. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Logger logger
protected HashProvider hashProv
protected boolean pointerAtEnd
protected IndexEntry topEntry
protected long baseSeq
protected long nextSeq
protected long numEntries
protected RandomAccessFileIOBuffer indexFile
protected RandomAccessFileIOBuffer dataFile
protected boolean readOnly
protected IndexEntryFactory indexFactory
| Constructor Detail |
|---|
public SecureHistoryImpl(RandomAccessFileIOBuffer indexFile,
RandomAccessFileIOBuffer dataFile,
boolean readOnly,
HashProvider hashProv,
IndexEntryFactory indexFactory,
Logger logger)
throws IOException
IOException| Method Detail |
|---|
public long getBaseSeq()
getBaseSeq in interface SecureHistorypublic long getLastSeq()
getLastSeq in interface SecureHistorypublic long getNumEntries()
getNumEntries in interface SecureHistorypublic HashSeq getTopLevelEntry()
getTopLevelEntry in interface SecureHistory
public void appendEntry(short type,
boolean storeFullEntry,
ByteBuffer... entry)
throws IOException
appendEntry in interface SecureHistoryIOException
public void appendHash(short type,
byte[] hash)
throws IOException
appendHash in interface SecureHistoryIOExceptionpublic boolean setNextSeq(long nextSeq)
setNextSeq in interface SecureHistory
public void close()
throws IOException
close in interface SecureHistoryIOException
public long findSeq(long seq)
throws IOException
findSeq in interface SecureHistoryIOException
public long findSeqOrHigher(long seq,
boolean allowHigher)
throws IOException
findSeqOrHigher in interface SecureHistoryIOException
public LogSnippet serializeRange(long idxFrom,
long idxTo,
HashPolicy hashPolicy)
throws IOException
serializeRange in interface SecureHistoryIOException
public boolean serializeRange2(long idxFrom,
long idxTo,
HashPolicy hashPolicy,
OutputBuffer outfile)
throws IOException
IOException
public IndexEntry statEntry(long idx)
throws IOException
statEntry in interface SecureHistoryidx - the index you are interested in
IOException
public byte[] getEntry(long idx,
int maxSizeToRead)
throws IOException
getEntry in interface SecureHistoryIOException
public byte[] getEntry(IndexEntry ie,
int maxSizeToRead)
throws IOException
getEntry in interface SecureHistoryIOException
public boolean upgradeHashedEntry(int idx,
ByteBuffer entry)
throws IOException
upgradeHashedEntry in interface SecureHistoryIOException
public long findLastEntry(short[] types,
long maxSeq)
throws IOException
findLastEntry in interface SecureHistoryIOException
public void appendSnippetToHistory(LogSnippet snippet)
throws IOException
appendSnippetToHistory in interface SecureHistoryIOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||