|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.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 String |
driverName
|
protected StripedLock |
lock
|
protected static Map<Object,Object> |
NULL_NODE_IN_ROW
|
Fields inherited from class org.jboss.cache.loader.AbstractCacheLoader |
---|
buddyFqnTransformer, cache, regionManager, transactions |
Constructor Summary | |
---|---|
AdjListJDBCCacheLoader()
|
Method Summary | |
---|---|
void |
commit(Object tx)
Commits a transaction. |
boolean |
exists(Fqn name)
Checks that there is a row for the fqn in the database. |
Map<Object,Object> |
get(Fqn name)
Returns a map representing a node. |
protected String |
getDriverName(Connection con)
|
Set<String> |
getChildrenNames(Fqn fqn)
Fetches child node names (not pathes). |
protected abstract org.apache.commons.logging.Log |
getLogger()
|
protected void |
insertNode(Fqn name,
Map dataMap,
boolean rowMayExist)
Inserts a node into the database |
protected Map<Object,Object> |
loadNode(Fqn name)
Loads a node from the database. |
protected ByteBuffer |
marshall(Object obj)
|
protected void |
populatePreparedStatementForInsert(Fqn name,
Map dataMap,
PreparedStatement ps)
Expects a PreparedStatement binded to AdjListJDBCCacheLoaderConfig.getInsertNodeSql() |
void |
prepare(Object tx,
List<Modification> modifications,
boolean one_phase)
First phase in transaction commit process. |
protected abstract AdjListJDBCCacheLoaderConfig |
processConfig(CacheLoaderConfig.IndividualCacheLoaderConfig base)
|
Object |
remove(Fqn name,
Object key)
Removes attribute's value for a key. |
void |
removeData(Fqn name)
Nullifies the node. |
protected void |
reportAndRethrowError(String message,
Exception cause)
|
void |
rollback(Object tx)
Rolls back a transaction. |
protected void |
safeClose(InputStream is)
|
protected void |
safeClose(ResultSet rs)
|
protected void |
safeClose(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(String tableName,
Connection con)
|
protected Object |
unmarshall(InputStream from)
|
protected void |
updateNode(Fqn name,
Map<Object,Object> node)
Updates a node in the database. |
Methods inherited from class org.jboss.cache.loader.AbstractCacheLoader |
---|
create, destroy, doMarshall, doUnmarshall, getMarshaller, getNodeDataList, loadEntireState, loadState, loadStateHelper, move, put, put, regionAwareMarshall, regionAwareUnmarshall, setCache, setRegionManager, storeEntireState, storeState, storeStateHelper |
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 String driverName
protected StripedLock lock
protected static final Map<Object,Object> 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
PluggableConfigurationComponent.getProperties()
method to find configuration information. Alternatively,
may be a type-specific subclass of CacheLoaderConfig.IndividualCacheLoaderConfig
,
if there is one.public Map<Object,Object> get(Fqn name) throws Exception
name
- node's fqn
Exception
public Set<String> getChildrenNames(Fqn fqn) throws Exception
fqn
- parent fqn
Exception
public void removeData(Fqn name) throws Exception
name
- node's fqn
Exception
public void prepare(Object tx, List<Modification> modifications, boolean one_phase) throws Exception
prepare
in interface CacheLoader
prepare
in class AbstractCacheLoader
tx
- something representing transactionmodifications
- a list of modificationsone_phase
- indicates whether it's one or two phase commit transaction
Exception
public void commit(Object tx) throws Exception
commit
in interface CacheLoader
commit
in class AbstractCacheLoader
tx
- the tx to commit
Exception
public void rollback(Object tx)
rollback
in interface CacheLoader
rollback
in class AbstractCacheLoader
tx
- the tx to rollbackpublic void start() throws Exception
CacheLoader
start
in interface CacheLoader
start
in class AbstractCacheLoader
Exception
public void stop()
CacheLoader
stop
in interface CacheLoader
stop
in class AbstractCacheLoader
public boolean exists(Fqn name) throws Exception
name
- node's fqn
Exception
public Object remove(Fqn name, Object key) throws Exception
name
- node's namekey
- attribute's key
Exception
protected Map<Object,Object> loadNode(Fqn name)
name
- the fqn
protected void insertNode(Fqn name, Map dataMap, boolean rowMayExist)
name
- the fqndataMap
- the noderowMayExist
- if true, then this method will not be strict in testing for 1 row being inserted, since 0 may be inserted if the row already exists.protected void populatePreparedStatementForInsert(Fqn name, Map dataMap, PreparedStatement ps) throws Exception
AdjListJDBCCacheLoaderConfig.getInsertNodeSql()
Exception
protected void updateNode(Fqn name, Map<Object,Object> node)
name
- the fqnnode
- new node valueprotected String getDriverName(Connection con)
protected boolean tableExists(String tableName, Connection con)
protected abstract org.apache.commons.logging.Log getLogger()
protected abstract AdjListJDBCCacheLoaderConfig processConfig(CacheLoaderConfig.IndividualCacheLoaderConfig base)
protected void reportAndRethrowError(String message, Exception cause) throws IllegalStateException
IllegalStateException
protected void safeClose(InputStream is)
protected void safeClose(Statement st)
protected void safeClose(ResultSet rs)
protected Object unmarshall(InputStream from) throws Exception
Exception
protected ByteBuffer marshall(Object obj) throws Exception
Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |