com.caucho.server.distcache
Class CacheStoreManager

java.lang.Object
  extended by com.caucho.server.distcache.CacheStoreManager

@Module
public final class CacheStoreManager
extends java.lang.Object

Manages the distributed cache


Nested Class Summary
static class CacheStoreManager.DataItem
           
 
Constructor Summary
CacheStoreManager(ResinSystem resinSystem)
           
 
Method Summary
 void addCacheListener(HashKey cacheKey, CacheMnodeListener listener)
           
 byte[] calculateValueHash(java.lang.Object value, CacheConfig config)
          Used by QA
 void clearEphemeralEntries()
          Clears ephemeral data on startup.
 void clearLeases()
          Clears leases on server start/stop
 void close()
          Closes the manager.
 void closeCache(java.lang.String guid)
           
protected  HashKey compareAndPut(DistCacheEntry entry, HashKey testValue, MnodeUpdate mnodeUpdate, java.lang.Object value, CacheConfig config)
           
 HashKey compareAndPut(DistCacheEntry entry, HashKey testValue, java.lang.Object value, CacheConfig config)
           
 boolean compareAndPut(DistCacheEntry entry, long version, HashKey valueHash, long valueLength, CacheConfig config)
           
 HashKey compareAndPutLocal(DistCacheEntry entry, HashKey testValue, MnodeUpdate mnodeUpdate, java.lang.Object value, long leaseTimeout, int leaseOwner)
           
 DistCacheEntry createCacheEntry(java.lang.Object key, HashKey hashKey)
          Returns the key entry.
protected  HashKey createHashKey(java.lang.Object key, CacheConfig config)
           
protected  HashKey createHashKeyImpl(java.lang.Object key, CacheConfig config)
          Returns the key hash
 HashKey createSelfHashKey(java.lang.Object key, CacheSerializer keySerializer)
          Returns the key hash
 void destroyCache(CacheImpl cache)
          Called when a cache is removed.
 java.lang.Object get(DistCacheEntry entry, CacheConfig config, long now)
           
 java.lang.Object get(DistCacheEntry entry, CacheConfig config, long now, boolean isExact)
           
protected  HashKey getAndPut(DistCacheEntry entry, MnodeUpdate mnodeUpdate, java.lang.Object value, long leaseTimeout, int leaseOwner, CacheConfig config)
          Sets a cache entry
 java.lang.Object getAndPut(DistCacheEntry entry, java.lang.Object value, CacheConfig config)
          Sets a cache entry
protected  java.lang.Object getAndPut(DistCacheEntry entry, java.lang.Object value, CacheConfig config, long now, MnodeEntry mnodeValue)
          Sets a cache entry
 HashKey getAndPutLocal(DistCacheEntry entry, MnodeUpdate mnodeUpdate, java.lang.Object value, long leaseTimeout, int leaseOwner)
           
 CacheEngine getCacheEngine()
           
 DistCacheEntry getCacheEntry(HashKey hashKey)
          Returns the key entry.
 DistCacheEntry getCacheEntry(HashKey hashKey, CacheConfig config)
          Returns the key entry.
 DistCacheEntry getCacheEntry(java.lang.Object key, CacheConfig config)
          Returns the key entry.
 CacheDataBacking getDataBacking()
           
 DataStore getDataStore()
           
 java.lang.Object getExact(DistCacheEntry entry, CacheConfig config, long now)
           
 DistCacheEntry getLocalEntryAndUpdateIdle(HashKey key)
           
 MnodeStore getMnodeStore()
           
 MnodeEntry getMnodeValue(DistCacheEntry entry, CacheConfig config, long now)
           
 MnodeEntry getMnodeValue(DistCacheEntry entry, CacheConfig config, long now, boolean isExact)
           
 boolean getStream(DistCacheEntry entry, java.io.OutputStream os, CacheConfig config)
          Gets a cache entry as a stream
 CacheStoreManager.DataItem getValueHash(java.lang.Object value, CacheConfig config)
           
 void initCache(CacheImpl cache)
          Called when a cache initializes.
 boolean isClosed()
           
protected  boolean isLocalExpired(CacheConfig config, HashKey key, MnodeEntry mnodeValue, long now)
           
protected  void lazyValueUpdate(DistCacheEntry entry, CacheConfig config)
           
protected  boolean loadClusterData(HashKey valueKey, CacheConfig config)
          Load the cluster data from the triad.
 DistCacheEntry loadLocalEntry(HashKey key)
           
 MnodeEntry loadMnodeValue(DistCacheEntry cacheEntry)
          Gets a cache entry
 void put(DistCacheEntry entry, java.lang.Object value, CacheConfig config)
          Sets a cache entry
protected  void put(DistCacheEntry entry, java.lang.Object value, CacheConfig config, long now, MnodeEntry mnodeValue)
          Sets a cache entry
 ExtCacheEntry put(HashKey hashKey, java.io.InputStream is, CacheConfig config, long idleTimeout)
          Sets a cache entry
 void put(HashKey hashKey, java.lang.Object value, CacheConfig config)
          Sets a cache entry
 MnodeEntry putLocalValue(DistCacheEntry entry, MnodeUpdate mnodeUpdate, java.lang.Object value, long leaseTimeout, int leaseOwner)
          Sets a cache entry
 ExtCacheEntry putStream(DistCacheEntry entry, java.io.InputStream is, CacheConfig config, long accessedExpireTime, long modifiedExpireTime, int userFlags)
           
protected  java.lang.Object readData(HashKey valueKey, CacheSerializer serializer, CacheConfig config)
           
protected  boolean readData(MnodeEntry mnodeValue, java.io.OutputStream os, CacheConfig config)
           
 boolean remove(DistCacheEntry entry, CacheConfig config)
          Sets a cache entry
 boolean remove(HashKey key, CacheConfig config)
          Sets a cache entry
 void saveLocalUpdateTime(HashKey key, long version, long accessTimeout, long updateTime)
          Sets a cache entry
 void setCacheEngine(CacheEngine cacheEngine)
           
 void start()
           
 java.lang.String toString()
           
protected  void updateAccessTime(DistCacheEntry entry, MnodeEntry mnodeValue)
           
 CacheStoreManager.DataItem writeData(HashKey oldValueHash, java.io.InputStream is)
           
 CacheStoreManager.DataItem writeData(MnodeEntry mnodeValue, java.lang.Object value, CacheSerializer serializer)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CacheStoreManager

public CacheStoreManager(ResinSystem resinSystem)
Method Detail

setCacheEngine

public void setCacheEngine(CacheEngine cacheEngine)

getCacheEngine

public CacheEngine getCacheEngine()

getDataBacking

public CacheDataBacking getDataBacking()

addCacheListener

public void addCacheListener(HashKey cacheKey,
                             CacheMnodeListener listener)

getCacheEntry

public final DistCacheEntry getCacheEntry(java.lang.Object key,
                                          CacheConfig config)
Returns the key entry.


getCacheEntry

public final DistCacheEntry getCacheEntry(HashKey hashKey,
                                          CacheConfig config)
Returns the key entry.


createCacheEntry

public DistCacheEntry createCacheEntry(java.lang.Object key,
                                       HashKey hashKey)
Returns the key entry.


getCacheEntry

public final DistCacheEntry getCacheEntry(HashKey hashKey)
Returns the key entry.


get

public final java.lang.Object get(DistCacheEntry entry,
                                  CacheConfig config,
                                  long now)

getExact

public final java.lang.Object getExact(DistCacheEntry entry,
                                       CacheConfig config,
                                       long now)

get

public final java.lang.Object get(DistCacheEntry entry,
                                  CacheConfig config,
                                  long now,
                                  boolean isExact)

getStream

public final boolean getStream(DistCacheEntry entry,
                               java.io.OutputStream os,
                               CacheConfig config)
                        throws java.io.IOException
Gets a cache entry as a stream

Throws:
java.io.IOException

getMnodeValue

public final MnodeEntry getMnodeValue(DistCacheEntry entry,
                                      CacheConfig config,
                                      long now)

getMnodeValue

public final MnodeEntry getMnodeValue(DistCacheEntry entry,
                                      CacheConfig config,
                                      long now,
                                      boolean isExact)

lazyValueUpdate

protected void lazyValueUpdate(DistCacheEntry entry,
                               CacheConfig config)

isLocalExpired

protected boolean isLocalExpired(CacheConfig config,
                                 HashKey key,
                                 MnodeEntry mnodeValue,
                                 long now)

getValueHash

public CacheStoreManager.DataItem getValueHash(java.lang.Object value,
                                               CacheConfig config)

put

public final void put(DistCacheEntry entry,
                      java.lang.Object value,
                      CacheConfig config)
Sets a cache entry


put

protected final void put(DistCacheEntry entry,
                         java.lang.Object value,
                         CacheConfig config,
                         long now,
                         MnodeEntry mnodeValue)
Sets a cache entry


putStream

public final ExtCacheEntry putStream(DistCacheEntry entry,
                                     java.io.InputStream is,
                                     CacheConfig config,
                                     long accessedExpireTime,
                                     long modifiedExpireTime,
                                     int userFlags)
                              throws java.io.IOException
Throws:
java.io.IOException

getAndPut

public final java.lang.Object getAndPut(DistCacheEntry entry,
                                        java.lang.Object value,
                                        CacheConfig config)
Sets a cache entry


getAndPut

protected final java.lang.Object getAndPut(DistCacheEntry entry,
                                           java.lang.Object value,
                                           CacheConfig config,
                                           long now,
                                           MnodeEntry mnodeValue)
Sets a cache entry


getAndPut

protected HashKey getAndPut(DistCacheEntry entry,
                            MnodeUpdate mnodeUpdate,
                            java.lang.Object value,
                            long leaseTimeout,
                            int leaseOwner,
                            CacheConfig config)
Sets a cache entry


getAndPutLocal

public HashKey getAndPutLocal(DistCacheEntry entry,
                              MnodeUpdate mnodeUpdate,
                              java.lang.Object value,
                              long leaseTimeout,
                              int leaseOwner)

compareAndPut

public HashKey compareAndPut(DistCacheEntry entry,
                             HashKey testValue,
                             java.lang.Object value,
                             CacheConfig config)

compareAndPut

protected HashKey compareAndPut(DistCacheEntry entry,
                                HashKey testValue,
                                MnodeUpdate mnodeUpdate,
                                java.lang.Object value,
                                CacheConfig config)

compareAndPutLocal

public final HashKey compareAndPutLocal(DistCacheEntry entry,
                                        HashKey testValue,
                                        MnodeUpdate mnodeUpdate,
                                        java.lang.Object value,
                                        long leaseTimeout,
                                        int leaseOwner)

compareAndPut

public boolean compareAndPut(DistCacheEntry entry,
                             long version,
                             HashKey valueHash,
                             long valueLength,
                             CacheConfig config)

loadLocalEntry

public final DistCacheEntry loadLocalEntry(HashKey key)

getLocalEntryAndUpdateIdle

public final DistCacheEntry getLocalEntryAndUpdateIdle(HashKey key)

updateAccessTime

protected final void updateAccessTime(DistCacheEntry entry,
                                      MnodeEntry mnodeValue)

loadMnodeValue

public final MnodeEntry loadMnodeValue(DistCacheEntry cacheEntry)
Gets a cache entry


saveLocalUpdateTime

public final void saveLocalUpdateTime(HashKey key,
                                      long version,
                                      long accessTimeout,
                                      long updateTime)
Sets a cache entry


remove

public final boolean remove(DistCacheEntry entry,
                            CacheConfig config)
Sets a cache entry


remove

public final boolean remove(HashKey key,
                            CacheConfig config)
Sets a cache entry


putLocalValue

public final MnodeEntry putLocalValue(DistCacheEntry entry,
                                      MnodeUpdate mnodeUpdate,
                                      java.lang.Object value,
                                      long leaseTimeout,
                                      int leaseOwner)
Sets a cache entry


writeData

public final CacheStoreManager.DataItem writeData(MnodeEntry mnodeValue,
                                                  java.lang.Object value,
                                                  CacheSerializer serializer)

calculateValueHash

public final byte[] calculateValueHash(java.lang.Object value,
                                       CacheConfig config)
Used by QA


writeData

public final CacheStoreManager.DataItem writeData(HashKey oldValueHash,
                                                  java.io.InputStream is)
                                           throws java.io.IOException
Throws:
java.io.IOException

readData

protected final java.lang.Object readData(HashKey valueKey,
                                          CacheSerializer serializer,
                                          CacheConfig config)

readData

protected final boolean readData(MnodeEntry mnodeValue,
                                 java.io.OutputStream os,
                                 CacheConfig config)
                          throws java.io.IOException
Throws:
java.io.IOException

loadClusterData

protected boolean loadClusterData(HashKey valueKey,
                                  CacheConfig config)
Load the cluster data from the triad.


clearLeases

public final void clearLeases()
Clears leases on server start/stop


clearEphemeralEntries

public void clearEphemeralEntries()
Clears ephemeral data on startup.


start

public void start()

closeCache

public void closeCache(java.lang.String guid)

createHashKey

protected HashKey createHashKey(java.lang.Object key,
                                CacheConfig config)

put

public void put(HashKey hashKey,
                java.lang.Object value,
                CacheConfig config)
Sets a cache entry


put

public ExtCacheEntry put(HashKey hashKey,
                         java.io.InputStream is,
                         CacheConfig config,
                         long idleTimeout)
                  throws java.io.IOException
Sets a cache entry

Throws:
java.io.IOException

initCache

public void initCache(CacheImpl cache)
Called when a cache initializes.


destroyCache

public void destroyCache(CacheImpl cache)
Called when a cache is removed.


createHashKeyImpl

protected HashKey createHashKeyImpl(java.lang.Object key,
                                    CacheConfig config)
Returns the key hash


createSelfHashKey

public HashKey createSelfHashKey(java.lang.Object key,
                                 CacheSerializer keySerializer)
Returns the key hash


close

public void close()
Closes the manager.


isClosed

public boolean isClosed()

getMnodeStore

public MnodeStore getMnodeStore()

getDataStore

public DataStore getDataStore()

toString

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