[jboss-cvs] JBossCache/src/org/jboss/cache/loader ...
Manik Surtani
msurtani at jboss.com
Thu Jan 4 00:35:37 EST 2007
User: msurtani
Date: 07/01/04 00:35:37
Modified: src/org/jboss/cache/loader CacheLoaderManager.java
RpcDelegatingCacheLoaderConfig.java
SingletonStoreCacheLoader.java
RpcDelegatingCacheLoader.java
RmiDelegatingCacheLoader.java
LocalDelegatingCacheLoader.java
Log:
Major changes around nodes, and the way they interact with the interceptor stack.
Also removed redundant methods in NodeSPI and removed the need for casting to NodeSPI in most cases.
Revision Changes Path
1.29 +3 -3 JBossCache/src/org/jboss/cache/loader/CacheLoaderManager.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CacheLoaderManager.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/loader/CacheLoaderManager.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- CacheLoaderManager.java 3 Jan 2007 15:33:09 -0000 1.28
+++ CacheLoaderManager.java 4 Jan 2007 05:35:37 -0000 1.29
@@ -131,7 +131,7 @@
}
else
{
- CacheLoaderConfig.IndividualCacheLoaderConfig cfg = (CacheLoaderConfig.IndividualCacheLoaderConfig) config.getIndividualCacheLoaderConfigs().get(0);
+ CacheLoaderConfig.IndividualCacheLoaderConfig cfg = config.getIndividualCacheLoaderConfigs().get(0);
tmpLoader = createCacheLoader(cfg, cache);
finalConfigs.add(tmpLoader.getConfig());
fetchPersistentState = cfg.isFetchPersistentState();
@@ -180,8 +180,8 @@
tmpLoader.setCache(cache);
// we should not be creating/starting the cache loader here - this should be done in the separate
// startCacheLoader() method.
-// tmpLoader.create();
-// tmpLoader.start();
+ // tmpLoader.create();
+ // tmpLoader.start();
if (cache != null && cache.getConfiguration().isUseRegionBasedMarshalling())
{
tmpLoader.setRegionManager(cache.getRegionManager());
1.3 +3 -1 JBossCache/src/org/jboss/cache/loader/RpcDelegatingCacheLoaderConfig.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: RpcDelegatingCacheLoaderConfig.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/loader/RpcDelegatingCacheLoaderConfig.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- RpcDelegatingCacheLoaderConfig.java 3 Jan 2007 15:33:09 -0000 1.2
+++ RpcDelegatingCacheLoaderConfig.java 4 Jan 2007 05:35:37 -0000 1.3
@@ -49,8 +49,10 @@
super.setProperties(props);
String t = props.getProperty("timeout");
if (t != null && t.length() > 0)
+ {
this.timeout = Integer.parseInt(t);
}
+ }
public boolean equals(Object obj)
{
@@ -64,7 +66,7 @@
public int hashCode()
{
- return 31 * hashCodeExcludingProperties() + (int) timeout;
+ return 31 * hashCodeExcludingProperties() + timeout;
}
}
\ No newline at end of file
1.2 +14 -12 JBossCache/src/org/jboss/cache/loader/SingletonStoreCacheLoader.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: SingletonStoreCacheLoader.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/loader/SingletonStoreCacheLoader.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- SingletonStoreCacheLoader.java 29 Sep 2006 18:27:21 -0000 1.1
+++ SingletonStoreCacheLoader.java 4 Jan 2007 05:35:37 -0000 1.2
@@ -7,7 +7,7 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
-import org.jboss.cache.Node;
+import org.jboss.cache.NodeSPI;
import org.jgroups.Address;
import org.jgroups.View;
@@ -23,12 +23,12 @@
* the underlying store. The coordinator of the cluster will be responsible for the underlying CacheLoader.
* SingletonStoreCacheLoader is a simply facade to a real CacheLoader implementation. It always delegates reads to the
* real CacheLoader.
- *
+ * <p/>
* Writes are forwarded only if this SingletonStoreCacheLoader is currently the cordinator. This avoid having all
* CacheLoaders in a cluster writing the same data to the same underlying store. Although not incorrect (e.g. a DB
* will just discard additional INSERTs for the same key, and throw an exception), this will avoid a lot of
* redundant work.<br/>
- *
+ * <p/>
* Whenever the current coordinator dies (or leaves), the second in line will take over. That SingletonStoreCacheLoader
* will then pass writes through to its underlying CacheLoader. Optionally, when a new coordinator takes over the
* Singleton, it can push the in-memory state to the cache cacheLoader.
@@ -40,7 +40,7 @@
{
private static final Log log = LogFactory.getLog(SingletonStoreCacheLoader.class);
private Address localAddress;
- private boolean active; // only active if coordinator
+ private boolean active;// only active if coordinator
private boolean pushStateWhenCoordinator;
private Thread pushStateThread;
private CacheListener cacheListener;
@@ -75,7 +75,8 @@
{
log.debug("joining currently running state push thread");
pushStateThread.join();
- } catch (InterruptedException e)
+ }
+ catch (InterruptedException e)
{
log.error("joining existing push state thread was interrupted", e);
}
@@ -94,7 +95,8 @@
{
pushState(cache.getRoot());
log.debug("in-memory state passed to cache cacheLoader successfully");
- } catch (Exception e)
+ }
+ catch (Exception e)
{
log.error("unable to finish pushing the state", e);
}
@@ -123,10 +125,10 @@
return active;
}
- private void pushState(Node node) throws Exception
+ private void pushState(NodeSPI node) throws Exception
{
/* Put the node's data first */
- Set keys = node.getKeys();
+ Set keys = node.getKeysDirect();
Fqn fqn = node.getFqn();
for (Object aKey : keys)
@@ -136,8 +138,8 @@
}
/* Navigates to the children */
- Collection<Node> children = node.getChildren();
- for (Node aChildren : children)
+ Collection<NodeSPI> children = node.getChildrenDirect();
+ for (NodeSPI aChildren : children)
{
//Map.Entry entry = (Map.Entry) aChildren;
pushState(aChildren);
@@ -255,7 +257,7 @@
{
public void cacheStarted(CacheSPI cache)
{
- localAddress = (Address) cache.getLocalAddress();
+ localAddress = cache.getLocalAddress();
active = cache.getRPCManager().isCoordinator();
log.debug("cache started: " + this);
}
1.16 +6 -6 JBossCache/src/org/jboss/cache/loader/RpcDelegatingCacheLoader.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: RpcDelegatingCacheLoader.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/loader/RpcDelegatingCacheLoader.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- RpcDelegatingCacheLoader.java 30 Dec 2006 19:48:44 -0000 1.15
+++ RpcDelegatingCacheLoader.java 4 Jan 2007 05:35:37 -0000 1.16
@@ -34,7 +34,7 @@
* specified, it defaults to <tt>5000</tt>.
*
* @author Daniel Gredler
- * @version $Id: RpcDelegatingCacheLoader.java,v 1.15 2006/12/30 19:48:44 msurtani Exp $
+ * @version $Id: RpcDelegatingCacheLoader.java,v 1.16 2007/01/04 05:35:37 msurtani Exp $
*/
public class RpcDelegatingCacheLoader extends DelegatingCacheLoader
{
@@ -131,9 +131,9 @@
/**
* @see org.jboss.cache.loader.DelegatingCacheLoader#delegateGet(org.jboss.cache.Fqn,java.lang.Object)
*/
-// protected Object delegateGet(Fqn name, Object key) throws Exception {
-// return this.doMethodCall( METHOD_GET_WITH_2_PARAMS, new Object[] { name, key } );
-// }
+ // protected Object delegateGet(Fqn name, Object key) throws Exception {
+ // return this.doMethodCall( METHOD_GET_WITH_2_PARAMS, new Object[] { name, key } );
+ // }
/**
* @see org.jboss.cache.loader.DelegatingCacheLoader#delegateGet(org.jboss.cache.Fqn)
@@ -145,7 +145,7 @@
{
return null;
}
- return n.getData();
+ return n.getDataDirect();
}
/**
@@ -244,7 +244,7 @@
}
if (this.localAddress == null)
{
- this.localAddress = (Address) this.cache.getLocalAddress();
+ this.localAddress = this.cache.getLocalAddress();
}
if (this.localAddress == null)
{
1.16 +4 -4 JBossCache/src/org/jboss/cache/loader/RmiDelegatingCacheLoader.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: RmiDelegatingCacheLoader.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/loader/RmiDelegatingCacheLoader.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- RmiDelegatingCacheLoader.java 30 Dec 2006 17:50:01 -0000 1.15
+++ RmiDelegatingCacheLoader.java 4 Jan 2007 05:35:37 -0000 1.16
@@ -9,7 +9,7 @@
import org.jboss.cache.CacheImpl;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
-import org.jboss.cache.Node;
+import org.jboss.cache.NodeSPI;
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.loader.rmi.RemoteTreeCache;
@@ -33,7 +33,7 @@
* cacheloader's cache's cluster name.
*
* @author Daniel Gredler
- * @version $Id: RmiDelegatingCacheLoader.java,v 1.15 2006/12/30 17:50:01 msurtani Exp $
+ * @version $Id: RmiDelegatingCacheLoader.java,v 1.16 2007/01/04 05:35:37 msurtani Exp $
*/
public class RmiDelegatingCacheLoader extends DelegatingCacheLoader
{
@@ -123,12 +123,12 @@
*/
protected Map delegateGet(Fqn name) throws Exception
{
- Node n = this.remoteCache != null ? this.remoteCache.get(name) : null;
+ NodeSPI n = (NodeSPI) (this.remoteCache != null ? this.remoteCache.get(name) : null);
if (n == null)
{
return null;
}
- return n.getData();
+ return n.getDataDirect();
}
/**
1.14 +15 -15 JBossCache/src/org/jboss/cache/loader/LocalDelegatingCacheLoader.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: LocalDelegatingCacheLoader.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/loader/LocalDelegatingCacheLoader.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- LocalDelegatingCacheLoader.java 30 Dec 2006 17:50:01 -0000 1.13
+++ LocalDelegatingCacheLoader.java 4 Jan 2007 05:35:37 -0000 1.14
@@ -8,7 +8,7 @@
import org.jboss.cache.CacheImpl;
import org.jboss.cache.Fqn;
-import org.jboss.cache.Node;
+import org.jboss.cache.NodeSPI;
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import java.io.ObjectInputStream;
@@ -31,7 +31,7 @@
*
* @author Bela Ban
* @author Daniel Gredler
- * @version $Id: LocalDelegatingCacheLoader.java,v 1.13 2006/12/30 17:50:01 msurtani Exp $
+ * @version $Id: LocalDelegatingCacheLoader.java,v 1.14 2007/01/04 05:35:37 msurtani Exp $
*/
public class LocalDelegatingCacheLoader extends DelegatingCacheLoader
{
@@ -63,17 +63,17 @@
return delegate.getChildrenNames(fqn);
}
-// See http://jira.jboss.com/jira/browse/JBCACHE-118 for why this is commented out.
-// protected Object delegateGet(Fqn name, Object key) throws Exception {
-// return delegate.get(name, key);
-// }
+ // See http://jira.jboss.com/jira/browse/JBCACHE-118 for why this is commented out.
+ // protected Object delegateGet(Fqn name, Object key) throws Exception {
+ // return delegate.get(name, key);
+ // }
protected Map delegateGet(Fqn name) throws Exception
{
- Node n = delegate.get(name);
+ NodeSPI n = (NodeSPI) delegate.get(name);
if (n == null) return null;
// after this stage we know that the node exists. So never return a null - at worst, an empty map.
- Map m = n.getData();
+ Map m = n.getDataDirect();
if (m == null) m = new HashMap(0);
return m;
}
@@ -117,13 +117,13 @@
{
try
{
-// // We use the lock acquisition timeout rather than the
-// // state transfer timeout, otherwise we'd never try
-// // to break locks before the requesting node gives up
-// return cache._getState(Fqn.fromString(SEPARATOR),
-// cache.getLockAcquisitionTimeout(),
-// true,
-// false);
+ // // We use the lock acquisition timeout rather than the
+ // // state transfer timeout, otherwise we'd never try
+ // // to break locks before the requesting node gives up
+ // return cache._getState(Fqn.fromString(SEPARATOR),
+ // cache.getLockAcquisitionTimeout(),
+ // true,
+ // false);
// Until flush is in place, use the old mechanism
// where we wait the full state retrieval timeout
delegate.getStateTransferManager().getState(os, Fqn.ROOT, delegate.getConfiguration().getInitialStateRetrievalTimeout(), true, false);
More information about the jboss-cvs-commits
mailing list