org.asunder
Class AsunderCache

java.lang.Object
  extended by org.asunder.AsunderCache
All Implemented Interfaces:
DHTCache

public class AsunderCache
extends java.lang.Object
implements DHTCache

Author:
simms2k

Constructor Summary
AsunderCache(Id center, Environment env, java.lang.String rootDir, AsunderConfig config)
           
AsunderCache(Id center, Environment env, java.lang.String rootDir, AsunderConfig config, AsunderLogger logger)
          Creates a new instance of AsunderCache
 
Method Summary
 long capacity()
           
 int getAcceptanceFactor()
           
 boolean haveContent(DHTContentKey contentKey)
          Checks if the content for this key is already stored
 void loadContent(DHTContentKey contentKey, DHTContinuation cmd)
          Retrieve content from storage.
 void openContentStream(DHTContentKey contentKey, DHTContinuation cmd)
          TODO
 void setAcceptanceFactor(int factor)
           
 void storeContent(DHTContent content, DHTContinuation cmd)
          Non-forcing version of storeContent (follows policies)
 void storeContent(DHTContent content, DHTContinuation cmd, boolean force)
          Write the content to disk
 long usage()
           
 boolean wantContent(DHTContentKey contentKey)
          this is a non-deterministic method! Probability of returning true increases as contentKey approaches center
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AsunderCache

public AsunderCache(Id center,
                    Environment env,
                    java.lang.String rootDir,
                    AsunderConfig config)
             throws java.io.IOException
Throws:
java.io.IOException

AsunderCache

public AsunderCache(Id center,
                    Environment env,
                    java.lang.String rootDir,
                    AsunderConfig config,
                    AsunderLogger logger)
             throws java.io.IOException
Creates a new instance of AsunderCache

Throws:
java.io.IOException
Method Detail

setAcceptanceFactor

public void setAcceptanceFactor(int factor)

getAcceptanceFactor

public int getAcceptanceFactor()

capacity

public long capacity()

usage

public long usage()

wantContent

public boolean wantContent(DHTContentKey contentKey)
this is a non-deterministic method! Probability of returning true increases as contentKey approaches center

Specified by:
wantContent in interface DHTCache
Parameters:
contentKey - key for the content to potentially store
Returns:
whether the cache would like to store this content

haveContent

public boolean haveContent(DHTContentKey contentKey)
Checks if the content for this key is already stored

Parameters:
contentKey - the key to check for

storeContent

public void storeContent(DHTContent content,
                         DHTContinuation cmd,
                         boolean force)
Write the content to disk

Parameters:
content - the content to store
force - whether to save the content regardless of policies
cmd - command to run on completion

storeContent

public void storeContent(DHTContent content,
                         DHTContinuation cmd)
Non-forcing version of storeContent (follows policies)

Specified by:
storeContent in interface DHTCache

loadContent

public void loadContent(DHTContentKey contentKey,
                        DHTContinuation cmd)
Retrieve content from storage. Content is passed to cmd on success

Specified by:
loadContent in interface DHTCache
Parameters:
contenKey - the key of the content to retrieve
cmd - command to run on completion

openContentStream

public void openContentStream(DHTContentKey contentKey,
                              DHTContinuation cmd)
TODO

Specified by:
openContentStream in interface DHTCache