com.caucho.server.cluster
Class FileBacking

java.lang.Object
  extended by com.caucho.server.cluster.FileBacking

public class FileBacking
extends java.lang.Object

Manages the backing for the file objectStore.


Constructor Summary
FileBacking()
           
FileBacking(java.lang.String name)
           
 
Method Summary
 void clearOldObjects(long maxIdleTime)
          Clears the old objects.
 void destroy()
           
 javax.sql.DataSource getDataSource()
          Returns the data source.
 long getObjectCount()
           
 Path getPath()
          Returns the path to the directory.
 boolean init(int clusterLength)
           
 boolean load(ClusterObject clusterObj, java.lang.Object obj)
          Load the session from the jdbc objectStore.
 boolean loadIfVersion(ClusterObject clusterObj, java.lang.Object obj)
          Load the session from the jdbc objectStore.
 byte[] read(HashKey id, WriteStream os)
          Reads from the objectStore.
 void remove(HashKey id)
          Removes the named object from the objectStore.
 java.lang.String serverNameToTableName(java.lang.String serverName)
           
 void setExpireInterval(HashKey id, long expireInterval)
          Sets the object's expire_interval.
 void setPath(Path path)
          Sets the path to the saved file.
 void setTableName(java.lang.String table)
          Sets the table name
 long start()
           
 void store(HashKey id, HashKey storeId, java.io.InputStream is, int length, byte[] dataHash, byte[] oldDataHash, long expireInterval, int primary, int secondary, int tertiary)
          Stores the cluster object on the local objectStore.
 boolean storeData(HashKey id, byte[] dataHash, java.io.InputStream is, int length)
          Stores the cluster object on the local objectStore using an updateImpl query.
 java.lang.String toString()
           
 void updateAccess(HashKey id)
          Updates the object's objectAccess time.
 boolean updateMetadata(HashKey id, HashKey storeId, byte[] dataHash, long expireInterval, int primary, int secondary, int tertiary, boolean isDead)
          Updates the metadata from a cluster peer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileBacking

public FileBacking()

FileBacking

public FileBacking(java.lang.String name)
Method Detail

getPath

public Path getPath()
Returns the path to the directory.


setPath

public void setPath(Path path)
Sets the path to the saved file.


setTableName

public void setTableName(java.lang.String table)
Sets the table name


init

public boolean init(int clusterLength)
             throws java.lang.Exception
Throws:
java.lang.Exception

getDataSource

public javax.sql.DataSource getDataSource()
Returns the data source.


start

public long start()
           throws java.lang.Exception
Throws:
java.lang.Exception

clearOldObjects

public void clearOldObjects(long maxIdleTime)
                     throws java.sql.SQLException
Clears the old objects.

Throws:
java.sql.SQLException

load

public boolean load(ClusterObject clusterObj,
                    java.lang.Object obj)
             throws java.lang.Exception
Load the session from the jdbc objectStore.

Parameters:
session - the session to fill.
Returns:
true if the loadImpl was valid.
Throws:
java.lang.Exception

loadIfVersion

public boolean loadIfVersion(ClusterObject clusterObj,
                             java.lang.Object obj)
                      throws java.lang.Exception
Load the session from the jdbc objectStore.

Parameters:
session - the session to fill.
Returns:
true if the loadImpl was valid.
Throws:
java.lang.Exception

updateAccess

public void updateAccess(HashKey id)
                  throws java.lang.Exception
Updates the object's objectAccess time.

Parameters:
obj - the object to objectStore.
Throws:
java.lang.Exception

setExpireInterval

public void setExpireInterval(HashKey id,
                              long expireInterval)
                       throws java.lang.Exception
Sets the object's expire_interval.

Parameters:
obj - the object to objectStore.
Throws:
java.lang.Exception

remove

public void remove(HashKey id)
            throws java.lang.Exception
Removes the named object from the objectStore.

Throws:
java.lang.Exception

read

public byte[] read(HashKey id,
                   WriteStream os)
            throws java.io.IOException
Reads from the objectStore.

Throws:
java.io.IOException

store

public void store(HashKey id,
                  HashKey storeId,
                  java.io.InputStream is,
                  int length,
                  byte[] dataHash,
                  byte[] oldDataHash,
                  long expireInterval,
                  int primary,
                  int secondary,
                  int tertiary)
Stores the cluster object on the local objectStore.

Parameters:
id - the object's unique id.
is - the input stream to the serialized object
length - the length object the serialized object
expireInterval - how long the object lives w/o objectAccess

storeData

public boolean storeData(HashKey id,
                         byte[] dataHash,
                         java.io.InputStream is,
                         int length)
Stores the cluster object on the local objectStore using an updateImpl query.

Parameters:
conn - the database connection
id - the object's unique id.
is - the input stream to the serialized object
length - the length object the serialized object

updateMetadata

public boolean updateMetadata(HashKey id,
                              HashKey storeId,
                              byte[] dataHash,
                              long expireInterval,
                              int primary,
                              int secondary,
                              int tertiary,
                              boolean isDead)
Updates the metadata from a cluster peer.

Parameters:
id - the object's unique id.
expireInterval - how long the object lives w/o objectAccess

getObjectCount

public long getObjectCount()
                    throws java.sql.SQLException
Throws:
java.sql.SQLException

destroy

public void destroy()

serverNameToTableName

public java.lang.String serverNameToTableName(java.lang.String serverName)

toString

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