|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.caucho.server.cluster.StoreManager
public abstract class StoreManager
Base class for distributed stores.
| Field Summary | |
|---|---|
protected LruCache<HashKey,ClusterObject> |
_clusterObjects
|
protected long |
_idleCheckInterval
|
protected boolean |
_isAlwaysLoad
|
protected boolean |
_isAlwaysSave
|
protected long |
_loadCount
|
protected long |
_loadFailCount
|
protected long |
_maxIdleTime
|
protected long |
_saveCount
|
protected long |
_saveFailCount
|
protected int |
_selfIndex
|
protected java.util.HashMap<HashKey,Store> |
_storeMap
|
| Constructor Summary | |
|---|---|
protected |
StoreManager()
|
| Method Summary | |
|---|---|
void |
access(HashKey objectId)
Updates the object's objectAccess time. |
void |
access(Store store,
java.lang.String id)
Updates the object's objectAccess time. |
void |
accessImpl(ClusterObject obj)
Updates the object's objectAccess time in the persistent objectStore. |
abstract void |
accessImpl(HashKey objectId)
Updates the object's objectAccess time in the persistent objectStore. |
void |
classLoaderDestroy(DynamicClassLoader loader)
Handles the case where the environment loader is dropped. |
void |
classLoaderInit(DynamicClassLoader loader)
Handles the case where the environment is activated. |
void |
clearOldObjects()
Cleans old objects. |
protected ClusterObject |
create(Store store,
HashKey key,
int primary,
int secondary,
int tertiary)
Creates the cluster object. |
Store |
createStore(java.lang.String storeId,
ObjectManager objectManager)
Creates a Store. |
void |
destroy()
Called at end of life. |
void |
environmentBind(EnvironmentClassLoader loader)
Handles the case where the environment is activated. |
void |
environmentConfigure(EnvironmentClassLoader loader)
Handles the case where the environment is in the configuration |
void |
environmentStart(EnvironmentClassLoader loader)
Handles the case where the environment is activated. |
void |
environmentStop(EnvironmentClassLoader loader)
Handles the case where the environment loader is stops |
long |
getAccessWindowTime()
Returns the length of time an idle object can remain in the objectStore before being cleaned. |
PersistentStoreMXBean |
getAdmin()
Returns the admin. |
Cluster |
getCluster()
Gets the cluster. |
long |
getIdleCheckTime()
Sets the idle check interval for the alarm. |
long |
getLoadCount()
Returns the total objects loaded. |
long |
getLoadFailCount()
Returns the objects which failed to loadImpl. |
long |
getMaxIdleTime()
Returns the length of time an idle object can remain in the objectStore before being cleaned. |
long |
getObjectCount()
Returns the objects in the objectStore |
protected ClusterServer |
getOwningServer(java.lang.String objectId)
Returns the cluster server which owns the object |
int |
getPrimaryIndex(java.lang.String id,
int offset)
Returns the owning index. |
long |
getSaveCount()
Returns the total objects saved. |
long |
getSaveFailCount()
Returns the objects which failed to save. |
int |
getSecondaryIndex(java.lang.String id,
int offset)
Returns the backup index. |
protected int |
getSelfIndex()
Returns the self servers. |
protected ClusterServer[] |
getServerList()
Returns the list of cluster servers. |
Store |
getStore(HashKey storeKey)
Creates a ClusterObjectManager. |
int |
getTertiaryIndex(java.lang.String id,
int offset)
Returns the backup index. |
void |
handleAlarm(Alarm alarm)
Handles a callback from an alarm, scheduling the timeout. |
boolean |
init()
Called after any factory settings. |
void |
invalidate(HashKey objectId)
Notify the object that the data has changed. |
boolean |
isAlwaysLoad()
Set true if the objectStore should always try to loadImpl the object. |
boolean |
isAlwaysSave()
Set true if the objectStore should always try to objectStore the object. |
protected boolean |
isPrimary(java.lang.String id)
Returns true if this server is a primary for the given object id. |
protected abstract boolean |
load(ClusterObject clusterObject,
java.lang.Object obj)
Loads an object from the backing objectStore. |
void |
remove(ClusterObject obj)
When the object is no longer valid, objectRemove it from the backing objectStore. |
void |
remove(Store store,
java.lang.String objectId)
When the object is no longer valid, objectRemove it from the backing objectStore. |
Store |
removeStore(HashKey storeKey)
Removes a Store. |
void |
setAlwaysLoad(boolean alwaysLoad)
Set true if the objectStore should always try to loadImpl the object. |
void |
setAlwaysSave(boolean alwaysSave)
Set true if the objectStore should always try to objectStore the object. |
void |
setCluster(Cluster cluster)
Sets the cluster. |
void |
setExpireInterval(HashKey uniqueId,
long expires)
Sets the timef for the expires interval. |
void |
setMaxIdleTime(Period maxIdleTime)
Sets the length of time an idle object can remain in the objectStore before being cleaned. |
boolean |
start()
Called to start the objectStore. |
boolean |
startUpdate()
Called to start any invalidate processing |
protected abstract void |
store(ClusterObject clusterObject,
TempOutputStream tempStream,
byte[] dataHash,
byte[] oldDataHash)
Save the object to the objectStore. |
java.lang.String |
toString()
|
void |
updateIdleCheckInterval(long idleCheckInterval)
Sets the idle check interval for the alarm. |
void |
updateOwner(ClusterObject objectId)
Updates the owner object. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected int _selfIndex
protected long _maxIdleTime
protected long _idleCheckInterval
protected boolean _isAlwaysLoad
protected boolean _isAlwaysSave
protected java.util.HashMap<HashKey,Store> _storeMap
protected LruCache<HashKey,ClusterObject> _clusterObjects
protected volatile long _loadCount
protected volatile long _loadFailCount
protected volatile long _saveCount
protected volatile long _saveFailCount
| Constructor Detail |
|---|
protected StoreManager()
| Method Detail |
|---|
public void setCluster(Cluster cluster)
public Cluster getCluster()
public PersistentStoreMXBean getAdmin()
public void setAlwaysLoad(boolean alwaysLoad)
public boolean isAlwaysLoad()
public void setAlwaysSave(boolean alwaysSave)
public boolean isAlwaysSave()
public long getMaxIdleTime()
public void setMaxIdleTime(Period maxIdleTime)
public void updateIdleCheckInterval(long idleCheckInterval)
public long getIdleCheckTime()
public long getAccessWindowTime()
public long getObjectCount()
public long getLoadCount()
public long getLoadFailCount()
public long getSaveCount()
public long getSaveFailCount()
public Store createStore(java.lang.String storeId,
ObjectManager objectManager)
storeId - the persistent domain.public Store removeStore(HashKey storeKey)
storeId - the persistent domain.public Store getStore(HashKey storeKey)
storeId - the persistent domain.public boolean init()
public boolean start()
throws java.lang.Exception
java.lang.Exception
public boolean startUpdate()
throws java.lang.Exception
java.lang.Exception
public void clearOldObjects()
throws java.lang.Exception
java.lang.Exceptionprotected boolean isPrimary(java.lang.String id)
public int getPrimaryIndex(java.lang.String id,
int offset)
public int getSecondaryIndex(java.lang.String id,
int offset)
public int getTertiaryIndex(java.lang.String id,
int offset)
protected abstract boolean load(ClusterObject clusterObject,
java.lang.Object obj)
throws java.lang.Exception
obj - the object to updateImpl.
java.lang.Exception
public void access(HashKey objectId)
throws java.lang.Exception
storeId - the identifier of the storage groupobj - the object to updateImpl.
java.lang.Exception
public void access(Store store,
java.lang.String id)
throws java.lang.Exception
storeId - the identifier of the storage groupobj - the object to updateImpl.
java.lang.Exception
public abstract void accessImpl(HashKey objectId)
throws java.lang.Exception
uniqueId - the identifier of the object.
java.lang.Exception
public void accessImpl(ClusterObject obj)
throws java.lang.Exception
uniqueId - the identifier of the object.
java.lang.Exception
public void setExpireInterval(HashKey uniqueId,
long expires)
throws java.lang.Exception
uniqueId - the identifier of the object.long - the time in ms for the expire
java.lang.Exception
public void invalidate(HashKey objectId)
throws java.lang.Exception
objectId - the identifier of the object to notify
java.lang.Exception
public void updateOwner(ClusterObject objectId)
throws java.lang.Exception
uniqueId - the identifier of the storage group
java.lang.Exception
protected ClusterObject create(Store store,
HashKey key,
int primary,
int secondary,
int tertiary)
protected abstract void store(ClusterObject clusterObject,
TempOutputStream tempStream,
byte[] dataHash,
byte[] oldDataHash)
throws java.lang.Exception
clusterObject - the distributed handletempStream - the byte stream to the saved datadataHash - the sha-1 hash of the dataoldDataHash - the previous hash value for the data
java.lang.Exceptionpublic void handleAlarm(Alarm alarm)
handleAlarm in interface AlarmListener
public void remove(ClusterObject obj)
throws java.lang.Exception
obj - the object to objectRemove
java.lang.Exception
public void remove(Store store,
java.lang.String objectId)
throws java.lang.Exception
objectStore - the identifier of the storeage groupobjectId - the identifier of the object to objectRemove
java.lang.Exceptionprotected int getSelfIndex()
protected ClusterServer[] getServerList()
protected ClusterServer getOwningServer(java.lang.String objectId)
public void environmentConfigure(EnvironmentClassLoader loader)
environmentConfigure in interface EnvironmentListenerpublic void environmentBind(EnvironmentClassLoader loader)
environmentBind in interface EnvironmentListenerpublic void environmentStart(EnvironmentClassLoader loader)
environmentStart in interface EnvironmentListenerpublic void environmentStop(EnvironmentClassLoader loader)
environmentStop in interface EnvironmentListenerpublic void classLoaderInit(DynamicClassLoader loader)
classLoaderInit in interface ClassLoaderListenerpublic void classLoaderDestroy(DynamicClassLoader loader)
classLoaderDestroy in interface ClassLoaderListenerpublic void destroy()
public java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||