[jboss-cvs] JBossCache/src/org/jboss/cache ...
Manik Surtani
manik at jboss.org
Fri Mar 30 10:22:27 EDT 2007
User: msurtani
Date: 07/03/30 10:22:27
Modified: src/org/jboss/cache Region.java RegionImpl.java
RegionManager.java
Log:
JBCACHE-404
Revision Changes Path
1.14 +10 -1 JBossCache/src/org/jboss/cache/Region.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Region.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/Region.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- Region.java 19 Jan 2007 12:05:41 -0000 1.13
+++ Region.java 30 Mar 2007 14:22:27 -0000 1.14
@@ -48,8 +48,17 @@
/**
* Activates this region for replication.
* By default, the entire cache is activated for replication at start-up.
+ *
+ * @throws RegionNotEmptyException if the {@link Fqn} that represents this region already exists and contains data or children.
+ */
+ void activate() throws RegionNotEmptyException;
+
+ /**
+ * Activates this region for replication, but if the {@link Fqn} that represents this region already exists and
+ * either contains data or children, no state transfers take place. The region is simply marked as active in this
+ * case.
*/
- void activate();
+ public void activateIfEmpty();
/**
* Deactivates this region from being replicated.
1.21 +6 -0 JBossCache/src/org/jboss/cache/RegionImpl.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: RegionImpl.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/RegionImpl.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- RegionImpl.java 19 Jan 2007 12:05:41 -0000 1.20
+++ RegionImpl.java 30 Mar 2007 14:22:27 -0000 1.21
@@ -74,6 +74,12 @@
active = true;
}
+ public void activateIfEmpty()
+ {
+ regionManager.activateIfEmpty(fqn);
+ active = true;
+ }
+
public void deactivate()
{
regionManager.deactivate(fqn);
1.34 +36 -16 JBossCache/src/org/jboss/cache/RegionManager.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: RegionManager.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/RegionManager.java,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -b -r1.33 -r1.34
--- RegionManager.java 12 Mar 2007 18:13:46 -0000 1.33
+++ RegionManager.java 30 Mar 2007 14:22:27 -0000 1.34
@@ -233,10 +233,35 @@
/**
* Activates unmarshalling of replication messages for the region
* rooted in the given Fqn.
+ * <p/>
+ * <strong>NOTE:</strong> This method will cause the creation of a node
+ * in the local cache at <code>subtreeFqn</code> whether or not that
+ * node exists anywhere else in the cluster. If the node does not exist
+ * elsewhere, the local node will be empty. The creation of this node will
+ * not be replicated.
+ * <p/>
*
* @param fqn representing the region to be activated.
+ * @throws RegionNotEmptyException if the node <code>fqn</code>
+ * exists and already has either data or children
*/
- public void activate(Fqn fqn)
+ public void activate(Fqn fqn) throws RegionNotEmptyException
+ {
+ activate(fqn, false);
+ }
+
+ /**
+ * Attempts to activate a given region rooted at a given Fqn, similar to {@link #activate(Fqn)} except
+ * that if the fqn is currently already in use (probably already been activated) this method is a no-op.
+ *
+ * @param fqn which represents the region to activate
+ */
+ public void activateIfEmpty(Fqn fqn)
+ {
+ activate(fqn, true);
+ }
+
+ private void activate(Fqn fqn, boolean suppressRegionNotEmptyException)
{
try
{
@@ -260,7 +285,7 @@
// FIXME - persistent state transfer counts too!
if (cache.getConfiguration().isFetchInMemoryState())
{
- activateRegion(r.getFqn());
+ activateRegion(r.getFqn(), suppressRegionNotEmptyException);
}
}
}
@@ -272,7 +297,7 @@
// FIXME - persistent state transfer counts too!
if (cache.getConfiguration().isFetchInMemoryState())
{
- activateRegion(r.getFqn());
+ activateRegion(r.getFqn(), suppressRegionNotEmptyException);
}
}
}
@@ -296,18 +321,13 @@
* node exists anywhere else in the cluster. If the node does not exist
* elsewhere, the local node will be empty. The creation of this node will
* not be replicated.
- * <p/>
- * <p/>
- * This is legacy code and should not be called directly. This is a private method for now and will be refactored out.
- * You should be using {@link #activate(Fqn)} and {@link #deactivate(Fqn)}
- * <p/>
*
* @param fqn Fqn string indicating the uppermost node in the
* portion of the cache that should be activated.
* @throws RegionNotEmptyException if the node <code>subtreeFqn</code>
* exists and has either data or children
*/
- private void activateRegion(Fqn fqn) throws CacheException
+ private void activateRegion(Fqn fqn, boolean suppressRegionNotEmptyException)
{
// Check whether the node already exists and has data
Node subtreeRoot = cache.findNode(fqn);
@@ -411,7 +431,7 @@
// Throw the exception on, wrapping if necessary
if (t instanceof RegionNotEmptyException)
{
- throw (RegionNotEmptyException) t;
+ if (!suppressRegionNotEmptyException) throw (RegionNotEmptyException) t;
}
else if (t instanceof CacheException)
{
More information about the jboss-cvs-commits
mailing list