|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jboss.cache.loader.AbstractCacheLoader org.jboss.cache.loader.AdjListJDBCCacheLoader
@ThreadSafe public abstract class AdjListJDBCCacheLoader
Adjacency List Model is the model of persisting trees in which each children holds a reference to its parent. An alternative model is the Nested Set Model (a.k.a. Modified Preorder Model) - this approach adds some additional indexing information to each persisted node. This indexing info is further used for optimizing operations like subtree loading, deleting etc. The indexes are update for each insertion.
Adjacency List Model proved more performance-effective for the following reason: the entire path is persisted rather than only a reference to parent. Looking up nodes heavily relies on that, and the performance is similar as in the case of Modified Preorder Model. Even more there is no costly update indexes operation.
Field Summary | |
---|---|
protected ConnectionFactory |
cf
|
protected java.lang.String |
driverName
|
protected StripedLock |
lock
|
protected static java.util.Map |
NULL_NODE_IN_ROW
|
Fields inherited from class org.jboss.cache.loader.AbstractCacheLoader |
---|
cache, regionManager |
Constructor Summary | |
---|---|
AdjListJDBCCacheLoader()
|
Method Summary | |
---|---|
void |
commit(java.lang.Object tx)
Commits a transaction. |
void |
create()
Lifecycle method, called when the cache loader is created. |
void |
destroy()
Lifecycle method, called when the cache loader is destroyed. |
boolean |
exists(Fqn name)
Checks that there is a row for the fqn in the database. |
java.util.Map |
get(Fqn name)
Returns a map representing a node. |
java.util.Set<java.lang.String> |
getChildrenNames(Fqn fqn)
Fetches child node names (not pathes). |
protected java.lang.String |
getDriverName(java.sql.Connection con)
|
protected abstract org.apache.commons.logging.Log |
getLogger()
|
protected void |
insertNode(Fqn name,
java.util.Map node)
Inserts a node into the database |
protected java.util.Map |
loadNode(Fqn name)
Loads a node from the database. |
protected byte[] |
marshall(java.lang.Object obj)
|
void |
prepare(java.lang.Object tx,
java.util.List<Modification> modifications,
boolean one_phase)
First phase in transaction commit process. |
protected abstract AdjListJDBCCacheLoaderConfig |
processConfig(CacheLoaderConfig.IndividualCacheLoaderConfig base)
|
java.lang.Object |
remove(Fqn name,
java.lang.Object key)
Removes attribute's value for a key. |
void |
removeData(Fqn name)
Nullifies the node. |
protected void |
reportAndRethrowError(java.lang.String message,
java.lang.Exception cause)
|
void |
rollback(java.lang.Object tx)
Rolls back a transaction. |
protected void |
safeClose(java.io.InputStream is)
|
protected void |
safeClose(java.sql.ResultSet rs)
|
protected void |
safeClose(java.sql.Statement st)
|
void |
setConfig(CacheLoaderConfig.IndividualCacheLoaderConfig base)
Sets the configuration. |
void |
start()
Lifecycle method, called when the cache loader is started. |
void |
stop()
Lifecycle method, called when the cache loader is stopped. |
protected boolean |
tableExists(java.lang.String tableName,
java.sql.Connection con)
|
protected java.lang.Object |
unmarshall(java.io.InputStream from)
|
protected void |
updateNode(Fqn name,
java.util.Map node)
Updates a node in the database. |
Methods inherited from class org.jboss.cache.loader.AbstractCacheLoader |
---|
getMarshaller, getNodeDataList, loadEntireState, loadState, loadStateHelper, put, put, setCache, setRegionManager, storeEntireState, storeState |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.jboss.cache.loader.CacheLoader |
---|
getConfig, put, put, remove |
Field Detail |
---|
protected ConnectionFactory cf
protected java.lang.String driverName
protected StripedLock lock
protected static final java.util.Map NULL_NODE_IN_ROW
Constructor Detail |
---|
public AdjListJDBCCacheLoader()
Method Detail |
---|
public void setConfig(CacheLoaderConfig.IndividualCacheLoaderConfig base)
CacheLoader
CacheLoader.create()
and CacheLoader.start()
.
base
- May be an instance of the CacheLoaderConfig.IndividualCacheLoaderConfig
base
class, in which case the cache loader should use the
CacheLoaderConfig.IndividualCacheLoaderConfig.getProperties()
method to find configuration information. Alternatively,
may be a type-specific subclass of CacheLoaderConfig.IndividualCacheLoaderConfig
,
if there is one.public java.util.Map get(Fqn name) throws java.lang.Exception
name
- node's fqn
java.lang.Exception
public java.util.Set<java.lang.String> getChildrenNames(Fqn fqn) throws java.lang.Exception
fqn
- parent fqn
java.lang.Exception
public void removeData(Fqn name) throws java.lang.Exception
name
- node's fqn
java.lang.Exception
public void prepare(java.lang.Object tx, java.util.List<Modification> modifications, boolean one_phase) throws java.lang.Exception
tx
- something representing transactionmodifications
- a list of modificationsone_phase
- indicates whether it's one or two phase commit transaction
java.lang.Exception
public void commit(java.lang.Object tx) throws java.lang.Exception
tx
- the tx to commit
java.lang.Exception
public void rollback(java.lang.Object tx)
tx
- the tx to rollbackpublic void create() throws java.lang.Exception
CacheLoader
java.lang.Exception
public void start() throws java.lang.Exception
CacheLoader
java.lang.Exception
public void stop()
CacheLoader
public void destroy()
CacheLoader
public boolean exists(Fqn name) throws java.lang.Exception
name
- node's fqn
java.lang.Exception
public java.lang.Object remove(Fqn name, java.lang.Object key) throws java.lang.Exception
name
- node's namekey
- attribute's key
java.lang.Exception
protected java.util.Map loadNode(Fqn name)
name
- the fqn
protected void insertNode(Fqn name, java.util.Map node)
name
- the fqnnode
- the nodeprotected void updateNode(Fqn name, java.util.Map node)
name
- the fqnnode
- new node valueprotected java.lang.String getDriverName(java.sql.Connection con)
protected boolean tableExists(java.lang.String tableName, java.sql.Connection con)
protected abstract org.apache.commons.logging.Log getLogger()
protected abstract AdjListJDBCCacheLoaderConfig processConfig(CacheLoaderConfig.IndividualCacheLoaderConfig base)
protected void reportAndRethrowError(java.lang.String message, java.lang.Exception cause) throws java.lang.IllegalStateException
java.lang.IllegalStateException
protected void safeClose(java.io.InputStream is)
protected void safeClose(java.sql.Statement st)
protected void safeClose(java.sql.ResultSet rs)
protected java.lang.Object unmarshall(java.io.InputStream from) throws java.lang.Exception
java.lang.Exception
protected byte[] marshall(java.lang.Object obj) throws java.lang.Exception
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |