com.caucho.distcache.jdbc
Class JdbcMnodeStore

java.lang.Object
  extended by com.caucho.server.distcache.MnodeStore
      extended by com.caucho.distcache.jdbc.JdbcMnodeStore
All Implemented Interfaces:
AlarmListener, java.util.EventListener

public class JdbcMnodeStore
extends MnodeStore

Manages backing for the cache map.


Constructor Summary
JdbcMnodeStore(javax.sql.DataSource dataSource, java.lang.String tableName, java.lang.String serverName)
           
 
Method Summary
 void close()
           
 void destroy()
           
 long getCount()
           
 javax.sql.DataSource getDataSource()
          Returns the data source.
 java.util.ArrayList<CacheData> getGlobalUpdates(long updateTime, int offset)
          Returns the maximum update time on startup
 long getStartupLastUpdateTime()
          Returns the max update time detected on startup.
 java.lang.String getTableName()
          Returns the data source.
 java.util.ArrayList<CacheData> getUpdates(long updateTime, int offset)
          Returns the maximum update time on startup
 void handleAlarm(Alarm alarm)
          Handles a callback from an alarm.
 void init()
           
protected  void initDatabase()
          Create the database, initializing if necessary.
 boolean insert(HashKey id, MnodeValue mnodeUpdate)
          Stores the data, returning true on success
 MnodeEntry load(HashKey id)
          Reads the object from the data store.
 void removeExpiredData()
          Clears the expired data
 java.lang.String toString()
           
 boolean updateSave(byte[] keyHash, MnodeValue mnodeUpdate)
          Stores the data, returning true on success
 boolean updateUpdateTime(HashKey id, long itemVersion, long idleTimeout, long updateTime)
          Updates the update time, returning true on success
 
Methods inherited from class com.caucho.server.distcache.MnodeStore
getStartupLastUpdateTime, getUpdates
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JdbcMnodeStore

public JdbcMnodeStore(javax.sql.DataSource dataSource,
                      java.lang.String tableName,
                      java.lang.String serverName)
               throws java.lang.Exception
Throws:
java.lang.Exception
Method Detail

getDataSource

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

Overrides:
getDataSource in class MnodeStore

getTableName

public java.lang.String getTableName()
Returns the data source.

Overrides:
getTableName in class MnodeStore

getStartupLastUpdateTime

public long getStartupLastUpdateTime()
Returns the max update time detected on startup.

Overrides:
getStartupLastUpdateTime in class MnodeStore

init

public void init()
          throws java.lang.Exception
Overrides:
init in class MnodeStore
Throws:
java.lang.Exception

initDatabase

protected void initDatabase()
                     throws java.lang.Exception
Create the database, initializing if necessary.

Overrides:
initDatabase in class MnodeStore
Throws:
java.lang.Exception

close

public void close()
Overrides:
close in class MnodeStore

getUpdates

public java.util.ArrayList<CacheData> getUpdates(long updateTime,
                                                 int offset)
Returns the maximum update time on startup

Overrides:
getUpdates in class MnodeStore

getGlobalUpdates

public java.util.ArrayList<CacheData> getGlobalUpdates(long updateTime,
                                                       int offset)
Returns the maximum update time on startup


load

public MnodeEntry load(HashKey id)
Reads the object from the data store.

Overrides:
load in class MnodeStore
Parameters:
id - the hash identifier for the data
Returns:
true on successful load

insert

public boolean insert(HashKey id,
                      MnodeValue mnodeUpdate)
Stores the data, returning true on success

Overrides:
insert in class MnodeStore
Parameters:
id - the key hash
value - the value hash
idleTimeout - the item's timeout

updateSave

public boolean updateSave(byte[] keyHash,
                          MnodeValue mnodeUpdate)
Stores the data, returning true on success

Overrides:
updateSave in class MnodeStore
Parameters:
id - the key hash
value - the value hash
idleTimeout - the item's timeout

updateUpdateTime

public boolean updateUpdateTime(HashKey id,
                                long itemVersion,
                                long idleTimeout,
                                long updateTime)
Updates the update time, returning true on success

Overrides:
updateUpdateTime in class MnodeStore
Parameters:
id - the key hash
itemVersion - the value version
idleTimeout - the item's timeout
updateTime - the item's timeout

removeExpiredData

public void removeExpiredData()
Clears the expired data

Overrides:
removeExpiredData in class MnodeStore

getCount

public long getCount()
Overrides:
getCount in class MnodeStore

handleAlarm

public void handleAlarm(Alarm alarm)
Description copied from interface: AlarmListener
Handles a callback from an alarm.

Specified by:
handleAlarm in interface AlarmListener
Overrides:
handleAlarm in class MnodeStore

destroy

public void destroy()
Overrides:
destroy in class MnodeStore

toString

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