com.caucho.server.distcache
Class DataStore

java.lang.Object
  extended by com.caucho.server.distcache.DataStore
Direct Known Subclasses:
JdbcDataStore

public class DataStore
extends java.lang.Object

Manages the backing for the file database objects


Constructor Summary
DataStore(java.lang.String serverName, MnodeStore mnodeStore)
           
 
Method Summary
 void addOrphanListener(MnodeOrphanListener listener)
           
 void destroy()
           
 long getCount()
           
protected  void init()
           
 boolean isDataAvailable(HashKey id)
          Checks if we have the data
 boolean load(HashKey id, LoadDataCallback cb)
          Reads the object from the data store.
 boolean load(HashKey id, WriteStream os)
          Reads the object from the data store.
 java.sql.Blob loadBlob(HashKey id)
          Reads the object from the data store.
 java.io.InputStream openInputStream(HashKey id)
          Reads the object from the data store.
 void removeExpiredData()
          Clears the expired data
 void removeOrphanListener(MnodeOrphanListener listener)
           
 boolean save(HashKey id, java.io.InputStream is, int length)
          Saves the data, returning true on success.
 boolean save(HashKey id, StreamSource source, int length)
          Saves the data, returning true on success.
 java.lang.String toString()
           
 boolean updateExpires(HashKey id)
          Updates the expires time for the data.
 void validateDatabase()
          Clears the expired data
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataStore

public DataStore(java.lang.String serverName,
                 MnodeStore mnodeStore)
          throws java.lang.Exception
Throws:
java.lang.Exception
Method Detail

init

protected void init()
             throws java.lang.Exception
Throws:
java.lang.Exception

addOrphanListener

public void addOrphanListener(MnodeOrphanListener listener)

removeOrphanListener

public void removeOrphanListener(MnodeOrphanListener listener)

load

public boolean load(HashKey id,
                    WriteStream os)
Reads the object from the data store.

Parameters:
id - the hash identifier for the data
os - the WriteStream to hold the data
Returns:
true on successful load

loadBlob

public java.sql.Blob loadBlob(HashKey id)
Reads the object from the data store.

Parameters:
id - the hash identifier for the data
os - the WriteStream to hold the data
Returns:
true on successful load

load

public boolean load(HashKey id,
                    LoadDataCallback cb)
Reads the object from the data store.

Parameters:
id - the hash identifier for the data
os - the WriteStream to hold the data
Returns:
true on successful load

isDataAvailable

public boolean isDataAvailable(HashKey id)
Checks if we have the data

Parameters:
id - the hash identifier for the data
Returns:
true on successful load

openInputStream

public java.io.InputStream openInputStream(HashKey id)
Reads the object from the data store.

Parameters:
id - the hash identifier for the data
os - the WriteStream to hold the data
Returns:
true on successful load

save

public boolean save(HashKey id,
                    StreamSource source,
                    int length)
             throws java.io.IOException
Saves the data, returning true on success.

Parameters:
id - the object's unique id.
is - the input stream to the serialized object
length - the length object the serialized object
Throws:
java.io.IOException

save

public boolean save(HashKey id,
                    java.io.InputStream is,
                    int length)
             throws java.io.IOException
Saves the data, returning true on success.

Parameters:
id - the object's unique id.
is - the input stream to the serialized object
length - the length object the serialized object
Throws:
java.io.IOException

updateExpires

public boolean updateExpires(HashKey id)
Updates the expires time for the data.

Parameters:
id - the hash identifier for the data
Returns:
true if the database contains the id

removeExpiredData

public void removeExpiredData()
Clears the expired data


validateDatabase

public void validateDatabase()
Clears the expired data


getCount

public long getCount()

destroy

public void destroy()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object