Rice Pastry API

org.mpisws.p2p.transport.peerreview.commitment
Class AuthenticatorStoreImpl<Identifier extends RawSerializable>

java.lang.Object
  extended by org.mpisws.p2p.transport.peerreview.commitment.AuthenticatorStoreImpl<Identifier>
All Implemented Interfaces:
AuthenticatorStore<Identifier>

public class AuthenticatorStoreImpl<Identifier extends RawSerializable>
extends java.lang.Object
implements AuthenticatorStore<Identifier>


Field Summary
protected  boolean allowDuplicateSeqs
           
 
Constructor Summary
AuthenticatorStoreImpl(PeerReview<?,Identifier> peerreview)
           
AuthenticatorStoreImpl(PeerReview<?,Identifier> peerreview, boolean allowDuplicateSeqs)
           
 
Method Summary
 void addAuthenticator(Identifier id, Authenticator authenticator)
          Also writes it to disk.
protected  void addAuthenticatorToMemory(Identifier id, Authenticator authenticator)
          Add a new authenticator.
 void destroy()
           
 void disableMemoryBuffer()
           
protected  java.util.SortedSet<Authenticator> findSubject(Identifier id)
           
 void flush(Identifier id)
           
 void flushAll()
           
 void flushAuthenticatorsFor(Identifier id)
           
 void flushAuthenticatorsFor(Identifier id, long minseq, long maxseq)
           
protected  void flushAuthenticatorsFromMemory(Identifier id, long minseq, long maxseq)
          Discard the authenticators in a certain sequence range (presumably because we just checked them against the corresponding log segment, and they were okay)
 void garbageCollect()
          Commits the Authenticators in memory to disk, overwriting the old store.
 java.util.List<Authenticator> getAuthenticators(Identifier id)
           
 java.util.List<Authenticator> getAuthenticators(Identifier id, long minseq, long maxseq)
          Retrieve all the authenticators within a given range of sequence numbers
 int getAuthenticatorSizeBytes()
           
 Authenticator getLastAuthenticatorBefore(Identifier id, long seq)
           
 Authenticator getMostRecentAuthenticator(Identifier id)
           
 int getNumSubjects()
           
 Authenticator getOldestAuthenticator(Identifier id)
           
 java.util.List<Identifier> getSubjects()
           
 int numAuthenticatorsFor(Identifier id)
           
 int numAuthenticatorsFor(Identifier id, long minseq, long maxseq)
           
 void setFilename(java.io.File file)
          Read in the Authenticators from a file.
 Authenticator statAuthenticator(Identifier id, long seq)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

allowDuplicateSeqs

protected boolean allowDuplicateSeqs
Constructor Detail

AuthenticatorStoreImpl

public AuthenticatorStoreImpl(PeerReview<?,Identifier> peerreview)

AuthenticatorStoreImpl

public AuthenticatorStoreImpl(PeerReview<?,Identifier> peerreview,
                              boolean allowDuplicateSeqs)
Method Detail

destroy

public void destroy()

setFilename

public void setFilename(java.io.File file)
                 throws java.io.IOException
Read in the Authenticators from a file. Each instance of this class has just a single file in which to store authenticators. The file format is ( )*; authenticators from different peers can be mixed. This method sets the name of the file and reads its current contents into memory.

Specified by:
setFilename in interface AuthenticatorStore<Identifier extends RawSerializable>
Throws:
java.io.IOException

addAuthenticatorToMemory

protected void addAuthenticatorToMemory(Identifier id,
                                        Authenticator authenticator)
Add a new authenticator. Note that in memory, the authenticators are sorted by nodeID and by sequence number, whereas on disk, they are not sorted at all.


flushAuthenticatorsFromMemory

protected void flushAuthenticatorsFromMemory(Identifier id,
                                             long minseq,
                                             long maxseq)
Discard the authenticators in a certain sequence range (presumably because we just checked them against the corresponding log segment, and they were okay)


findSubject

protected java.util.SortedSet<Authenticator> findSubject(Identifier id)

addAuthenticator

public void addAuthenticator(Identifier id,
                             Authenticator authenticator)
Description copied from interface: AuthenticatorStore
Also writes it to disk.

Specified by:
addAuthenticator in interface AuthenticatorStore<Identifier extends RawSerializable>

flushAuthenticatorsFor

public void flushAuthenticatorsFor(Identifier id,
                                   long minseq,
                                   long maxseq)
Specified by:
flushAuthenticatorsFor in interface AuthenticatorStore<Identifier extends RawSerializable>

flushAuthenticatorsFor

public void flushAuthenticatorsFor(Identifier id)
Specified by:
flushAuthenticatorsFor in interface AuthenticatorStore<Identifier extends RawSerializable>

garbageCollect

public void garbageCollect()
                    throws java.io.IOException
Description copied from interface: AuthenticatorStore
Commits the Authenticators in memory to disk, overwriting the old store. Since the authenticator file on disk is append-only, we need to garbage collect it from time to time. When this becomes necessary, we clear the file and then write out the authenticators currently in memory.

Specified by:
garbageCollect in interface AuthenticatorStore<Identifier extends RawSerializable>
Throws:
java.io.IOException

getAuthenticatorSizeBytes

public int getAuthenticatorSizeBytes()
Specified by:
getAuthenticatorSizeBytes in interface AuthenticatorStore<Identifier extends RawSerializable>

getAuthenticators

public java.util.List<Authenticator> getAuthenticators(Identifier id,
                                                       long minseq,
                                                       long maxseq)
Description copied from interface: AuthenticatorStore
Retrieve all the authenticators within a given range of sequence numbers

Specified by:
getAuthenticators in interface AuthenticatorStore<Identifier extends RawSerializable>

getAuthenticators

public java.util.List<Authenticator> getAuthenticators(Identifier id)
Specified by:
getAuthenticators in interface AuthenticatorStore<Identifier extends RawSerializable>

getLastAuthenticatorBefore

public Authenticator getLastAuthenticatorBefore(Identifier id,
                                                long seq)
Specified by:
getLastAuthenticatorBefore in interface AuthenticatorStore<Identifier extends RawSerializable>

getMostRecentAuthenticator

public Authenticator getMostRecentAuthenticator(Identifier id)
Specified by:
getMostRecentAuthenticator in interface AuthenticatorStore<Identifier extends RawSerializable>

getNumSubjects

public int getNumSubjects()
Specified by:
getNumSubjects in interface AuthenticatorStore<Identifier extends RawSerializable>

getOldestAuthenticator

public Authenticator getOldestAuthenticator(Identifier id)
Specified by:
getOldestAuthenticator in interface AuthenticatorStore<Identifier extends RawSerializable>

getSubjects

public java.util.List<Identifier> getSubjects()
Specified by:
getSubjects in interface AuthenticatorStore<Identifier extends RawSerializable>

numAuthenticatorsFor

public int numAuthenticatorsFor(Identifier id)
Specified by:
numAuthenticatorsFor in interface AuthenticatorStore<Identifier extends RawSerializable>

numAuthenticatorsFor

public int numAuthenticatorsFor(Identifier id,
                                long minseq,
                                long maxseq)
Specified by:
numAuthenticatorsFor in interface AuthenticatorStore<Identifier extends RawSerializable>

statAuthenticator

public Authenticator statAuthenticator(Identifier id,
                                       long seq)
Specified by:
statAuthenticator in interface AuthenticatorStore<Identifier extends RawSerializable>

flush

public void flush(Identifier id)
Specified by:
flush in interface AuthenticatorStore<Identifier extends RawSerializable>

flushAll

public void flushAll()
Specified by:
flushAll in interface AuthenticatorStore<Identifier extends RawSerializable>

disableMemoryBuffer

public void disableMemoryBuffer()
Specified by:
disableMemoryBuffer in interface AuthenticatorStore<Identifier extends RawSerializable>

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.


Imprint-Dataprotection