Rice Pastry API

org.mpisws.p2p.transport.peerreview.history
Interface SecureHistory

All Known Implementing Classes:
SecureHistoryImpl

public interface SecureHistory


Method Summary
 void appendEntry(short type, boolean storeFullEntry, java.nio.ByteBuffer... entry)
          Appends a new entry to the log.
 void appendHash(short type, Hash hash)
          Append a new hashed entry to the log.
 void close()
          The destructor.
 long findLastEntry(short[] types, long maxSeq)
          Find the most recent entry whose type is in the specified set.
 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
 boolean serializeRange(int idxFrom, int idxTo, HashPolicy hashPolicy, RandomAccessFileIOBuffer outfile)
          Serialize a given range of entries, and write the result to the specified file.
 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.
 

Method Detail

getNumEntries

long getNumEntries()

getBaseSeq

long getBaseSeq()

getLastSeq

long getLastSeq()

getTopLevelEntry

HashSeq getTopLevelEntry()
Returns the node hash and the sequence number of the most recent log entry


appendEntry

void appendEntry(short type,
                 boolean storeFullEntry,
                 java.nio.ByteBuffer... entry)
                 throws java.io.IOException
Appends a new entry to the log. If 'storeFullEntry' is false, only the hash of the entry is stored. If 'header' is not NULL, the log entry is formed by concatenating 'header' and 'entry'; otherwise, only 'entry' is used. Takes an ordered list of ByteBuffers to append

Throws:
java.io.IOException

appendHash

void appendHash(short type,
                Hash hash)
                throws java.io.IOException
Append a new hashed entry to the log. Unlike appendEntry(), this only keeps the content type, sequence number, and hash values. No entry is made in the data file.

Throws:
java.io.IOException

setNextSeq

boolean setNextSeq(long nextSeq)
Sets the next sequence number to be used. The PeerReview library typically uses the format , where X is a timestamp in microseconds and Y a sequence number. The sequence numbers need not be contigious (and usually aren't)


close

void close()
           throws java.io.IOException
The destructor. Closes the file handles.

Throws:
java.io.IOException

findSeqOrHigher

long findSeqOrHigher(long seq,
                     boolean allowHigher)
                     throws java.io.IOException
Look up a given sequence number, or the first sequence number that is not lower than a given number. The return value is the number of the corresponding record in the index file, or -1 if no matching record was found.

Throws:
java.io.IOException

serializeRange

boolean serializeRange(int idxFrom,
                       int idxTo,
                       HashPolicy hashPolicy,
                       RandomAccessFileIOBuffer outfile)
                       throws java.io.IOException
Serialize a given range of entries, and write the result to the specified file. This is used when we need to send a portion of our log to some other node, e.g. during an audit. The format of the serialized log segment is as follows: 1. base hash value (size depends on hash function) 2. entry type (1 byte) 3. entry size in bytes (1 byte); 0x00=entry is hashed; 0xFF=16-bit size follows 4. entry content (size as specified; omitted if entry is hashed) 5. difference to next sequence number (1 byte) 0x00: increment by one 0xFF: 64-bit sequence number follows Otherwise: Round down to nearest multiple of 1000, then add specified value times 1000 6. repeat 2-5 as often as necessary; 5 is omitted on last entry.4 Note that the idxFrom and idxTo arguments are record numbers, NOT sequence numbers. Use findSeqOrHigher() to get these if only sequence numbers are known.

Throws:
java.io.IOException

statEntry

IndexEntry statEntry(long idx)
                     throws java.io.IOException
Retrieve information about a given record

Parameters:
idx - the index you are interested in
Throws:
java.io.IOException

getEntry

byte[] getEntry(long idx,
                int maxSizeToRead)
                throws java.io.IOException
Get the content of a log entry, specified by its record number

Throws:
java.io.IOException

getEntry

byte[] getEntry(IndexEntry ie,
                int maxSizeToRead)
                throws java.io.IOException
Throws:
java.io.IOException

upgradeHashedEntry

boolean upgradeHashedEntry(int idx,
                           java.nio.ByteBuffer entry)
                           throws java.io.IOException
If the log already contains an entry in 'hashed' form and we learn the actual contents later, this function is called.

Throws:
java.io.IOException

findLastEntry

long findLastEntry(short[] types,
                   long maxSeq)
                   throws java.io.IOException
Find the most recent entry whose type is in the specified set. Useful e.g. for locating the last CHECKPOINT or INIT entry.

Throws:
java.io.IOException

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.


Imprint-Dataprotection