|
Rice Pastry API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.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,
java.nio.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,
java.nio.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 java.io.IOException
java.io.IOException
Method Detail |
---|
public long getBaseSeq()
getBaseSeq
in interface SecureHistory
public long getLastSeq()
getLastSeq
in interface SecureHistory
public long getNumEntries()
getNumEntries
in interface SecureHistory
public HashSeq getTopLevelEntry()
getTopLevelEntry
in interface SecureHistory
public void appendEntry(short type, boolean storeFullEntry, java.nio.ByteBuffer... entry) throws java.io.IOException
appendEntry
in interface SecureHistory
java.io.IOException
public void appendHash(short type, byte[] hash) throws java.io.IOException
appendHash
in interface SecureHistory
java.io.IOException
public boolean setNextSeq(long nextSeq)
setNextSeq
in interface SecureHistory
public void close() throws java.io.IOException
close
in interface SecureHistory
java.io.IOException
public long findSeq(long seq) throws java.io.IOException
findSeq
in interface SecureHistory
java.io.IOException
public long findSeqOrHigher(long seq, boolean allowHigher) throws java.io.IOException
findSeqOrHigher
in interface SecureHistory
java.io.IOException
public LogSnippet serializeRange(long idxFrom, long idxTo, HashPolicy hashPolicy) throws java.io.IOException
serializeRange
in interface SecureHistory
java.io.IOException
public boolean serializeRange2(long idxFrom, long idxTo, HashPolicy hashPolicy, OutputBuffer outfile) throws java.io.IOException
java.io.IOException
public IndexEntry statEntry(long idx) throws java.io.IOException
statEntry
in interface SecureHistory
idx
- the index you are interested in
java.io.IOException
public byte[] getEntry(long idx, int maxSizeToRead) throws java.io.IOException
getEntry
in interface SecureHistory
java.io.IOException
public byte[] getEntry(IndexEntry ie, int maxSizeToRead) throws java.io.IOException
getEntry
in interface SecureHistory
java.io.IOException
public boolean upgradeHashedEntry(int idx, java.nio.ByteBuffer entry) throws java.io.IOException
upgradeHashedEntry
in interface SecureHistory
java.io.IOException
public long findLastEntry(short[] types, long maxSeq) throws java.io.IOException
findLastEntry
in interface SecureHistory
java.io.IOException
public void appendSnippetToHistory(LogSnippet snippet) throws java.io.IOException
appendSnippetToHistory
in interface SecureHistory
java.io.IOException
|
Rice Pastry API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |