[jboss-cvs] JBossCache/src/org/jboss/cache ...
Brian Stansberry
brian.stansberry at jboss.com
Tue Jul 18 16:34:43 EDT 2006
User: bstansberry
Date: 06/07/18 16:34:43
Modified: src/org/jboss/cache TreeCache.java
Log:
[JBCACHE-465] Clean up state-transfer API before refactoring it out of TreeCache
Revision Changes Path
1.201 +9 -115 JBossCache/src/org/jboss/cache/TreeCache.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: TreeCache.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/TreeCache.java,v
retrieving revision 1.200
retrieving revision 1.201
diff -u -b -r1.200 -r1.201
--- TreeCache.java 18 Jul 2006 18:28:39 -0000 1.200
+++ TreeCache.java 18 Jul 2006 20:34:43 -0000 1.201
@@ -80,7 +80,7 @@
* @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
* @author Brian Stansberry
* @author Daniel Huang (dhuang at jboss.org)
- * @version $Id: TreeCache.java,v 1.200 2006/07/18 18:28:39 msurtani Exp $
+ * @version $Id: TreeCache.java,v 1.201 2006/07/18 20:34:43 bstansberry Exp $
* <p/>
* @see <a href="http://labs.jboss.com/portal/jbosscache/docs">JBossCache doc</a>
*/
@@ -1833,7 +1833,9 @@
// We'll update this node with the state we receive
subtreeRoot = createSubtreeRootNode(fqn);
}
- loadState(subtreeRoot, cl);
+
+ Object[] mbrArray = getMembers().toArray();
+ _loadState(subtreeRoot.getFqn(), subtreeRoot, mbrArray, cl);
}
else
{
@@ -1926,57 +1928,6 @@
}
/**
- * Requests state from each node in the cluster until it gets it or no
- * node replies with a timeout exception. If state is returned,
- * integrates it into the given DataNode. If no state is returned but a
- * node replies with a timeout exception, the calls will be repeated with
- * a longer timeout, until 3 attempts have been made.
- *
- * @param subtreeRoot the DataNode into which state should be integrated
- * @param cl the classloader to use to unmarshal the state.
- * Can be <code>null</code>.
- * @throws Exception
- */
- private void loadState(DataNode subtreeRoot, ClassLoader cl)
- throws Exception
- {
- Object[] mbrArray = getMembers().toArray();
- _loadState(subtreeRoot.getFqn(), subtreeRoot, mbrArray, cl);
- }
-
- /**
- * Requests state from each of the given source nodes in the cluster
- * until it gets it or no node replies with a timeout exception. If state
- * is returned, integrates it into the given DataNode. If no state is
- * returned but a node replies with a timeout exception, the calls will be
- * repeated with a longer timeout, until 3 attempts have been made.
- *
- * @param subtreeRoot Fqn of the topmost node in the subtree whose
- * state should be transferred.
- * @param integrationRoot Fqn of the node into which state should be integrated
- * @param sources the cluster nodes to query for state
- * @param cl the classloader to use to unmarshal the state.
- * Can be <code>null</code>.
- * @throws Exception
- */
- public void _loadState(Fqn subtreeRoot, Fqn integrationRoot,
- Object[] sources, ClassLoader cl)
- throws Exception
- {
- DataNode target = findNode(integrationRoot);
- if (target == null)
- {
- // Create the integration root, but do not replicate
- Option option = new Option();
- option.setCacheModeLocal(true);
- this.put(integrationRoot, null, option);
- target = findNode(integrationRoot);
- }
-
- _loadState(subtreeRoot, target, sources, cl);
- }
-
- /**
* Requests state from each of the given source nodes in the cluster
* until it gets it or no node replies with a timeout exception. If state
* is returned, integrates it into the given DataNode. If no state is
@@ -2453,33 +2404,6 @@
*/
public byte[] _getState(Fqn fqn, long timeout, boolean force, boolean suppressErrors) throws Throwable
{
- return _getState(fqn, this.fetchInMemoryState, getFetchPersistentState(), timeout, force, suppressErrors);
- }
-
- /**
- * Returns the state for the portion of the tree named by <code>fqn</code>.
- * <p/>
- * State returned is a serialized byte[][], element 0 is the transient state
- * (or null), and element 1 is the persistent state (or null).
- *
- * @param fqn Fqn indicating the uppermost node in the
- * portion of the tree whose state should be returned.
- * @param timeout max number of ms this method should wait to acquire
- * a read lock on the nodes being transferred
- * @param force if a read lock cannot be acquired after
- * <code>timeout</code> ms, should the lock acquisition
- * be forced, and any existing transactions holding locks
- * on the nodes be rolled back? <strong>NOTE:</strong>
- * In release 1.2.4, this parameter has no effect.
- * @param suppressErrors should any Throwable thrown be suppressed?
- * @return a serialized byte[][], element 0 is the transient state
- * (or null), and element 1 is the persistent state (or null).
- * @throws UnsupportedOperationException if persistent state transfer is
- * enabled, the requested Fqn is not the root node, and the
- * cache loader does not implement {@link ExtendedCacheLoader}.
- */
- public byte[] _getState(Fqn fqn, boolean fetchTransientState, boolean fetchPersistentState, long timeout, boolean force, boolean suppressErrors) throws Throwable
- {
if (marshaller_ != null)
{
@@ -2508,8 +2432,10 @@
return null;
boolean getRoot = rootNode.equals(root);
+ boolean fetchTransientState = getFetchInMemoryState();
+ boolean fetchPersistentState = getFetchPersistentState();
- if (fetchPersistentState && (!getRoot) &&
+ if (getFetchPersistentState() && (!getRoot) &&
!((cacheLoaderManager.isExtendedCacheLoader())))
{
throw new UnsupportedOperationException("Cache loader does not support " +
@@ -2541,38 +2467,6 @@
}
/**
- * Returns any state stored in the cache that needs to be propagated
- * along with the normal transient state in a subtree when
- * {@link #_getState(Fqn, long, boolean, boolean)} is called for an Fqn. Typically this would be state
- * stored outside of the subtree that is somehow associated with the subtree.
- * <p/>
- * This method is designed for overriding by
- * {@link org.jboss.cache.aop.PojoCache}.
- * The implementation in this class returns <code>null</code>.
- * </p>
- * <p/>
- * This method will only be invoked if
- * {@link #getCacheLoaderFetchTransientState()} returns <code>true</code>.
- * </p>
- *
- * @param fqn the fqn that represents the root node of the subtree.
- * @param timeout max number of ms this method should wait to acquire
- * a read lock on the nodes being transferred
- * @param force if a read lock cannot be acquired after
- * <code>timeout</code> ms, should the lock acquisition
- * be forced, and any existing transactions holding locks
- * on the nodes be rolled back? <strong>NOTE:</strong>
- * In release 1.2.4, this parameter has no effect.
- * @return a byte[] representing the marshalled form of any "associated" state,
- * or <code>null</code>. This implementation returns <code>null</code>.
- */
- protected byte[] _getAssociatedState(Fqn fqn, long timeout, boolean force) throws Exception
- {
- // default implementation does nothing
- return null;
- }
-
- /**
* Set the portion of the cache rooted in <code>targetRoot</code>
* to match the given state. Updates the contents of <code>targetRoot</code>
* to reflect those in <code>new_state</code>.
@@ -5316,7 +5210,7 @@
if (new_state == null)
my_log.info("transferred state is null (may be first member in cluster)");
else
- TreeCache.this._setState(new_state, root, null);
+ TreeCache.this._setState(new_state, Fqn.ROOT, null);
isStateSet = true;
}
More information about the jboss-cvs-commits
mailing list