JBoss Cache SVN: r4947 - core/trunk/src/test/java/org/jboss/cache/eviction.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-01-02 14:37:27 -0500 (Wed, 02 Jan 2008)
New Revision: 4947
Modified:
core/trunk/src/test/java/org/jboss/cache/eviction/RegionManagerTest.java
Log:
Updated test
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/RegionManagerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/RegionManagerTest.java 2008-01-02 19:32:44 UTC (rev 4946)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/RegionManagerTest.java 2008-01-02 19:37:27 UTC (rev 4947)
@@ -1,13 +1,5 @@
package org.jboss.cache.eviction;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertNotSame;
-import static org.testng.AssertJUnit.assertTrue;
-import static org.testng.AssertJUnit.fail;
-
-import java.util.List;
-
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
import org.jboss.cache.RegionManager;
@@ -16,9 +8,13 @@
import org.jboss.cache.config.EvictionRegionConfig;
import org.jboss.cache.factories.XmlConfigurationParser;
import org.jboss.cache.xml.XmlHelper;
+import static org.testng.AssertJUnit.*;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.w3c.dom.Element;
+
+import java.util.List;
+
/**
* Region Manager unit tests.
*
@@ -26,7 +22,7 @@
* @author Daniel Huang (dhuang(a)jboss.org)
* @version $Revision$
*/
-@Test(groups = {"functional"})
+@Test(groups = "functional")
public class RegionManagerTest
{
private final Fqn DEFAULT_REGION = Fqn.ROOT;
@@ -97,12 +93,10 @@
regionManager.getRegion(Fqn.fromString("/a"), Region.Type.EVICTION, false);
fail("If we don't setCache the default region, we should throw a RTE!");
}
- catch (Exception e)
+ catch (Exception expected)
{
// This is ok. Should throw an runtime exception
}
-
- assert regionManager.getRegion(Fqn.fromString("/a"), false) == null : "Should not throw an exception if we dont specify a region type!";
}
public void testGetRegion()
@@ -121,9 +115,9 @@
{
// test the new style configuration
String xml = "<region name=\"/test/\" policyClass=\"org.jboss.cache.eviction.LFUPolicy\">" +
- "<attribute name=\"minNodes\">10</attribute>" +
- "<attribute name=\"maxNodes\">20</attribute>" +
- "</region>";
+ "<attribute name=\"minNodes\">10</attribute>" +
+ "<attribute name=\"maxNodes\">20</attribute>" +
+ "</region>";
Element element = XmlHelper.stringToElement(xml);
RegionManager regionManager = new RegionManager();
regionManager.setUsingEvictions(true);
@@ -140,9 +134,9 @@
// test the 1.2.x style configuration
xml = "<region name=\"abc\">" +
- "<attribute name=\"minNodes\">10</attribute>" +
- "<attribute name=\"maxNodes\">20</attribute>" +
- "</region>";
+ "<attribute name=\"minNodes\">10</attribute>" +
+ "<attribute name=\"maxNodes\">20</attribute>" +
+ "</region>";
element = XmlHelper.stringToElement(xml);
erc = XmlConfigurationParser.parseEvictionRegionConfig(element, "org.jboss.cache.eviction.LFUPolicy", EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT);
regionManager = new RegionManager();
16 years, 11 months
JBoss Cache SVN: r4946 - in core/trunk/src/main/java/org/jboss/cache: buddyreplication and 4 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-01-02 14:32:44 -0500 (Wed, 02 Jan 2008)
New Revision: 4946
Modified:
core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java
core/trunk/src/main/java/org/jboss/cache/util/reflect/ClasspathScanner.java
Log:
Updated state transfer and BR codebases
Modified: core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/InvocationContext.java 2008-01-02 19:32:14 UTC (rev 4945)
+++ core/trunk/src/main/java/org/jboss/cache/InvocationContext.java 2008-01-02 19:32:44 UTC (rev 4946)
@@ -88,6 +88,11 @@
return optionOverrides;
}
+ public boolean isOptionsUninitialised()
+ {
+ return optionOverrides == null;
+ }
+
/**
* Sets the option overrides associated with this invocation
*
@@ -122,13 +127,13 @@
public String toString()
{
return "InvocationContext{" +
- "methodCall=" + methodCall +
- "transaction=" + transaction +
- ", globalTransaction=" + globalTransaction +
- ", optionOverrides=" + optionOverrides +
- ", originLocal=" + originLocal +
- ", txHasMods=" + txHasMods +
- '}';
+ "methodCall=" + methodCall +
+ "transaction=" + transaction +
+ ", globalTransaction=" + globalTransaction +
+ ", optionOverrides=" + optionOverrides +
+ ", originLocal=" + originLocal +
+ ", txHasMods=" + txHasMods +
+ '}';
}
public boolean isTxHasMods()
@@ -255,10 +260,11 @@
* If the acq timeout if overwritten for current call, then return that one.
* If not overwritten return default value.
*/
- public long getContextLockAcquisitionTimeout(long defaultFalue) {
+ public long getContextLockAcquisitionTimeout(long defaultFalue)
+ {
long timeout = defaultFalue;
if (getOptionOverrides() != null
- && getOptionOverrides().getLockAcquisitionTimeout() >= 0)
+ && getOptionOverrides().getLockAcquisitionTimeout() >= 0)
{
timeout = getOptionOverrides().getLockAcquisitionTimeout();
}
Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java 2008-01-02 19:32:14 UTC (rev 4945)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java 2008-01-02 19:32:44 UTC (rev 4946)
@@ -11,12 +11,14 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
+import org.jboss.cache.Node;
import org.jboss.cache.RPCManager;
import org.jboss.cache.Region;
import org.jboss.cache.RegionManager;
import org.jboss.cache.config.BuddyReplicationConfig;
import org.jboss.cache.config.BuddyReplicationConfig.BuddyLocatorConfig;
import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Option;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Stop;
import org.jboss.cache.lock.TimeoutException;
@@ -251,6 +253,8 @@
broadcastBuddyPoolMembership();
+ if (!cache.exists(BUDDY_BACKUP_SUBTREE_FQN)) cache.getRoot().addChildDirect(BUDDY_BACKUP_SUBTREE_FQN);
+
// allow waiting threads to process.
initialisationLatch.countDown();
@@ -519,43 +523,60 @@
Fqn integrationBase = new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
newGroup.getGroupName());
- for (Map.Entry<Fqn, byte[]> entry : state.entrySet())
+
+ if (state.isEmpty())
{
- Fqn fqn = entry.getKey();
- if (!regionManager.isInactive(fqn))
+ if (configuredToFetchState())
+ log.info("Data owner has no state to set, even though buddy is configured to accept state. Assuming there is no data on the data owner.");
+ // create the backup region anyway
+ Option o = cache.getInvocationContext().getOptionOverrides();
+ o.setSkipCacheStatusCheck(true);
+ Node root = cache.getRoot();
+ o = cache.getInvocationContext().getOptionOverrides();
+ o.setCacheModeLocal(true);
+ o.setSkipCacheStatusCheck(true);
+ root.addChild(new Fqn<String>(BUDDY_BACKUP_SUBTREE, newGroup.getGroupName()));
+ }
+ else
+ {
+ for (Map.Entry<Fqn, byte[]> entry : state.entrySet())
{
- //ClassLoader cl = (marshaller == null) ? null : marshaller.getClassLoader(fqnS);
- Fqn integrationRoot = new Fqn(integrationBase, fqn);
+ Fqn fqn = entry.getKey();
+ if (!regionManager.isInactive(fqn))
+ {
+ //ClassLoader cl = (marshaller == null) ? null : marshaller.getClassLoader(fqnS);
+ Fqn integrationRoot = new Fqn(integrationBase, fqn);
- byte[] stateBuffer = entry.getValue();
- MarshalledValueInputStream in = null;
- try
- {
- ByteArrayInputStream bais = new ByteArrayInputStream(stateBuffer);
- in = new MarshalledValueInputStream(bais);
- //stateMgr.setState(in, integrationRoot, cl);
- stateTransferManager.setState(in, integrationRoot);
- }
- catch (Throwable t)
- {
- if (t instanceof CacheException)
+ byte[] stateBuffer = entry.getValue();
+ MarshalledValueInputStream in = null;
+ try
{
- //excepected/common and can happen due to inactive regions and so on
- log.debug(t);
+ ByteArrayInputStream bais = new ByteArrayInputStream(stateBuffer);
+ in = new MarshalledValueInputStream(bais);
+ //stateMgr.setState(in, integrationRoot, cl);
+ stateTransferManager.setState(in, integrationRoot);
}
- else
+ catch (Throwable t)
{
- //something has gone wrong
- log.error("State for fqn " + fqn
- + " could not be transferred to a buddy at "
- + cache.getLocalAddress(), t);
+ if (t instanceof CacheException)
+ {
+ //excepected/common and can happen due to inactive regions and so on
+ log.debug(t);
+ }
+ else
+ {
+ //something has gone wrong
+ log.error("State for fqn " + fqn
+ + " could not be transferred to a buddy at "
+ + cache.getLocalAddress(), t);
+ }
}
- }
- finally
- {
- if (in != null)
+ finally
{
- in.close();
+ if (in != null)
+ {
+ in.close();
+ }
}
}
}
@@ -746,25 +767,36 @@
// Create the state transfer map
Map<Fqn, byte[]> stateMap = new HashMap<Fqn, byte[]>();
- byte[] state;
- if (configuration.isUseRegionBasedMarshalling())
+ if (configuredToFetchState())
{
- Collection<Region> regions = regionManager.getAllRegions(Region.Type.MARSHALLING);
- if (regions.size() > 0)
+ byte[] state;
+ if (configuration.isUseRegionBasedMarshalling())
{
- for (Region r : regions)
+ Collection<Region> regions = regionManager.getAllRegions(Region.Type.MARSHALLING);
+ if (regions.size() > 0)
{
- Fqn f = r.getFqn();
- state = acquireState(f);
+ for (Region r : regions)
+ {
+ Fqn f = r.getFqn();
+ state = acquireState(f);
+ if (state != null)
+ {
+ stateMap.put(f, state);
+ }
+ }
+ }
+ else if (!configuration.isInactiveOnStartup())
+ {
+ // No regions defined; try the root
+ state = acquireState(Fqn.ROOT);
if (state != null)
{
- stateMap.put(f, state);
+ stateMap.put(Fqn.ROOT, state);
}
}
}
- else if (!configuration.isInactiveOnStartup())
+ else
{
- // No regions defined; try the root
state = acquireState(Fqn.ROOT);
if (state != null)
{
@@ -772,14 +804,6 @@
}
}
}
- else
- {
- state = acquireState(Fqn.ROOT);
- if (state != null)
- {
- stateMap.put(Fqn.ROOT, state);
- }
- }
// now broadcast a message to the newly assigned buddies.
MethodCall membershipCall = MethodCallFactory.create(MethodDeclarations.remoteAssignToBuddyGroupMethod, buddyGroup, stateMap);
@@ -827,6 +851,11 @@
log.trace("addToGroup notification complete");
}
+ private boolean configuredToFetchState()
+ {
+ return configuration.isFetchInMemoryState() || (cache.getCacheLoaderManager() != null && cache.getCacheLoaderManager().isFetchPersistentState());
+ }
+
private byte[] acquireState(Fqn fqn) throws CacheException
{
// Call _getState with progressively longer timeouts until we
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java 2008-01-02 19:32:14 UTC (rev 4945)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java 2008-01-02 19:32:44 UTC (rev 4946)
@@ -37,6 +37,7 @@
{
Option txScopeOption = new Option();
txScopeOption.setCacheModeLocal(ctx.getOptionOverrides() != null && ctx.getOptionOverrides().isCacheModeLocal());
+ txScopeOption.setSkipCacheStatusCheck(ctx.getOptionOverrides() != null && ctx.getOptionOverrides().isSkipCacheStatusCheck());
entry.setOption(txScopeOption);
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-01-02 19:32:14 UTC (rev 4945)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-01-02 19:32:44 UTC (rev 4946)
@@ -1170,8 +1170,6 @@
public void beforeCompletion()
{
- if (!cache.getCacheStatus().allowInvocations()) throw new IllegalStateException("Cache not in STARTED state!");
-
if (log.isTraceEnabled()) log.trace("Running beforeCompletion on gtx " + gtx);
entry = txTable.get(gtx);
if (entry == null)
@@ -1183,6 +1181,7 @@
modifications = entry.getModifications();
ctx = cache.getInvocationContext();
+ if (ctx.isOptionsUninitialised() && entry.getOption() != null) ctx.setOptionOverrides(entry.getOption());
ctx.setOriginLocal(false);
}
@@ -1190,11 +1189,21 @@
// it is supposed to be post commit not actually run the commit
public void afterCompletion(int status)
{
- if (!cache.getCacheStatus().allowInvocations()) throw new IllegalStateException("Cache not in STARTED state!");
+ // could happen if a rollback is called and beforeCompletion() doesn't get called.
+ if (ctx == null)
+ {
+ ctx = cache.getInvocationContext();
+ }
+
+ if (ctx.isOptionsUninitialised() && entry.getOption() != null)
+ {
+ // use the options from the transaction entry instead
+ ctx.setOptionOverrides(entry.getOption());
+ }
+
try
{
- // could happen if a rollback is called and beforeCompletion() doesn't get called.
- if (ctx == null) ctx = cache.getInvocationContext();
+ assertCanContinue();
setTransactionalContext(tx, gtx, ctx);
try
@@ -1249,6 +1258,12 @@
}
}
+ private void assertCanContinue()
+ {
+ if (!cache.getCacheStatus().allowInvocations() && (ctx.getOptionOverrides() == null || !ctx.getOptionOverrides().isSkipCacheStatusCheck()))
+ throw new IllegalStateException("Cache not in STARTED state!");
+ }
+
/**
* Cleans out (nullifies) member variables held by the sync object for easier gc. Could be (falsely) seen as a mem
* leak if the TM implementation hangs on to the synchronizations for an unnecessarily long time even after the tx
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-01-02 19:32:14 UTC (rev 4945)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-01-02 19:32:44 UTC (rev 4946)
@@ -481,6 +481,7 @@
if (peek(fqn, false, false) == null)
{
getInvocationContext().getOptionOverrides().setFailSilently(true);
+ getInvocationContext().getOptionOverrides().setForceAsynchronous(true);
//GlobalTransaction tx = cache.getCurrentTransaction();
MethodCall m = MethodCallFactory.create(MethodDeclarations.putForExternalReadMethodLocal, null, fqn, key, value);
invoke(m);
Modified: core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java 2008-01-02 19:32:14 UTC (rev 4945)
+++ core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java 2008-01-02 19:32:44 UTC (rev 4946)
@@ -381,6 +381,7 @@
private Node getInternalNode(Node parent, Fqn internalFqn)
{
Object name = internalFqn.get(parent.getFqn().size());
+ cache.getInvocationContext().getOptionOverrides().setSkipCacheStatusCheck(true);
Node result = parent.getChild(new Fqn(name));
if (result != null)
{
Modified: core/trunk/src/main/java/org/jboss/cache/util/reflect/ClasspathScanner.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/util/reflect/ClasspathScanner.java 2008-01-02 19:32:14 UTC (rev 4945)
+++ core/trunk/src/main/java/org/jboss/cache/util/reflect/ClasspathScanner.java 2008-01-02 19:32:44 UTC (rev 4946)
@@ -51,7 +51,7 @@
try
{
// only scan the current ClassPath location that contains this file. Could be a directory or a JAR file.
- URL url = getURLPathFromClassLoader("org/jboss/cache/Version.class");
+ URL url = getURLPathFromClassLoader("org/jboss/cache/Cache.class");
String urlPath = url.getFile();
if (urlPath.endsWith("/"))
{
16 years, 11 months
JBoss Cache SVN: r4945 - in core/trunk/src/test/java/org/jboss/cache: buddyreplication and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-01-02 14:32:14 -0500 (Wed, 02 Jan 2008)
New Revision: 4945
Added:
core/trunk/src/test/java/org/jboss/cache/buddyreplication/DisabledStateTransferTest.java
Modified:
core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java
Log:
Updated existing tests, added new test to ensure correct classpath scanning
Modified: core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java 2008-01-02 19:08:11 UTC (rev 4944)
+++ core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java 2008-01-02 19:32:14 UTC (rev 4945)
@@ -14,6 +14,7 @@
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.lock.NodeLock;
+import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.misc.TestingUtil;
import org.jboss.cache.optimistic.TransactionWorkspace;
import org.jboss.cache.transaction.GlobalTransaction;
@@ -27,7 +28,6 @@
import javax.transaction.SystemException;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
-import java.lang.reflect.Method;
import java.util.List;
@Test(groups = {"functional", "jgroups", "transaction"})
@@ -179,7 +179,7 @@
// specify what we expect called on the mock Rpc Manager. For params we don't care about, just use ANYTHING.
// setting the mock object to expect the "sync" param to be false.
expect(rpcManager.getReplicationQueue()).andReturn(null);
- expect(rpcManager.callRemoteMethods(anyAddresses(), (Method) anyObject(), (Object[]) anyObject(), eq(false), anyBoolean(), anyInt())).andReturn(null);
+ expect(rpcManager.callRemoteMethods(anyAddresses(), (MethodCall) anyObject(), eq(false), anyBoolean(), anyInt())).andReturn(null);
}
replay(rpcManager);
@@ -237,7 +237,8 @@
{
RPCManager barfingRpcManager = new RPCManagerImpl()
{
- public List callRemoteMethods(List<Address> recipients, Method method, Object[] arguments, boolean synchronous, boolean excludeSelf, long timeout)
+ @Override
+ public List callRemoteMethods(List<Address> recipients, MethodCall method, boolean synchronous, boolean excludeSelf, int timeout)
{
throw new RuntimeException("Barf");
}
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java 2008-01-02 19:08:11 UTC (rev 4944)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java 2008-01-02 19:32:14 UTC (rev 4945)
@@ -259,13 +259,21 @@
protected List<CacheSPI<Object, Object>> createCaches(int numBuddies, int numCaches, boolean useBuddyPool, boolean useDataGravitation, boolean optimisticLocks) throws Exception
{
+ return createCaches(numBuddies, numCaches, useBuddyPool, useDataGravitation, optimisticLocks, true);
+ }
+
+ protected List<CacheSPI<Object, Object>> createCaches(int numBuddies, int numCaches, boolean useBuddyPool, boolean useDataGravitation, boolean optimisticLocks, boolean start) throws Exception
+ {
List<CacheSPI<Object, Object>> caches = new ArrayList<CacheSPI<Object, Object>>(numCaches);
for (int i = 0; i < numCaches; i++)
- caches.add(createCache(optimisticLocks, numBuddies, useBuddyPool ? Character.toString((char) ('A' + i)) : null, useDataGravitation, true));
+ caches.add(createCache(optimisticLocks, numBuddies, useBuddyPool ? Character.toString((char) ('A' + i)) : null, useDataGravitation, start));
- // allow some time for the caches to start up and discover each other
- TestingUtil.blockUntilViewsReceived(caches.toArray(new Cache[0]), VIEW_BLOCK_TIMEOUT);
- TestingUtil.sleepThread(getSleepTimeout());
+ if (start)
+ {
+ // allow some time for the caches to start up and discover each other
+ TestingUtil.blockUntilViewsReceived(caches.toArray(new Cache[0]), VIEW_BLOCK_TIMEOUT);
+ TestingUtil.sleepThread(getSleepTimeout());
+ }
return caches;
}
Added: core/trunk/src/test/java/org/jboss/cache/buddyreplication/DisabledStateTransferTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/DisabledStateTransferTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/DisabledStateTransferTest.java 2008-01-02 19:32:14 UTC (rev 4945)
@@ -0,0 +1,67 @@
+package org.jboss.cache.buddyreplication;
+
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.misc.TestingUtil;
+import org.jboss.cache.util.CachePrinter;
+import org.testng.annotations.Test;
+
+/**
+ * This is to test JBCACHE-1229
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 2.1.0
+ */
+@Test(groups = "functional")
+public class DisabledStateTransferTest extends BuddyReplicationTestsBase
+{
+ public void testCachesWithoutStateTransfer() throws Exception
+ {
+ caches = createCaches(1, 3, false, false, false, false);
+
+ int cacheNumber = 0;
+ for (CacheSPI c : caches)
+ {
+ c.getConfiguration().setFetchInMemoryState(false);
+ c.start();
+ c.put("/" + cacheNumber++, "k", "v");
+ }
+
+ TestingUtil.blockUntilViewsReceived(caches.toArray(new CacheSPI[0]), 60000);
+
+ for (CacheSPI c : caches)
+ System.out.println("Cache (local address " + c.getLocalAddress() + ") contents: " + CachePrinter.printCacheLockingInfo(c));
+
+ for (int i = 0; i < 3; i++)
+ {
+ int backupIndex = i == 2 ? 0 : i + 1;
+
+ assert caches.get(i).exists("/" + i) : "Data should exist on owner (cache #" + i + ")";
+ Fqn backup = BuddyManager.getBackupFqn(caches.get(i).getLocalAddress(), Fqn.fromString("/" + i));
+
+ assert caches.get(backupIndex).exists(backup.getParent()) : "Backup region should have been created on buddy (cache #" + backupIndex + ")";
+ boolean backupStatePropagated = caches.get(backupIndex).exists(backup);
+ boolean backupOlderThanOwner = backupIndex < i;
+ assert (!backupStatePropagated && !backupOlderThanOwner) || (backupStatePropagated && backupOlderThanOwner) : "Backup state should NOT have been transferred to buddy (cache #" + backupIndex + ")";
+ }
+
+ // now NEW state should transfer just fine.
+
+ cacheNumber = 0;
+ for (CacheSPI c : caches)
+ {
+ c.put("/" + (cacheNumber++) + "_NEW", "k", "v");
+ }
+
+ for (int i = 0; i < 3; i++)
+ {
+ int backupIndex = i == 2 ? 0 : i + 1;
+
+ assert caches.get(i).exists("/" + i + "_NEW") : "Data should exist on owner (cache #" + i + ")";
+ Fqn backup = BuddyManager.getBackupFqn(caches.get(i).getLocalAddress(), Fqn.fromString("/" + i + "_NEW"));
+
+ assert caches.get(backupIndex).exists(backup.getParent()) : "Backup region should have been created on buddy (cache #" + backupIndex + ")";
+ assert caches.get(backupIndex).exists(backup) : "Backup state should NOT have been transferred to buddy (cache #" + backupIndex + ")";
+ }
+ }
+}
16 years, 11 months
JBoss Cache SVN: r4944 - support/trunk/common.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-01-02 14:08:11 -0500 (Wed, 02 Jan 2008)
New Revision: 4944
Modified:
support/trunk/common/pom.xml
Log:
Added main class
Modified: support/trunk/common/pom.xml
===================================================================
--- support/trunk/common/pom.xml 2008-01-02 17:41:26 UTC (rev 4943)
+++ support/trunk/common/pom.xml 2008-01-02 19:08:11 UTC (rev 4944)
@@ -128,6 +128,7 @@
<manifest>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
+ <mainClass>org.jboss.cache.Version</mainClass>
</manifest>
</archive>
</configuration>
16 years, 11 months
JBoss Cache SVN: r4943 - in core/trunk/src: main/java/org/jboss/cache/loader and 3 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-01-02 12:41:26 -0500 (Wed, 02 Jan 2008)
New Revision: 4943
Modified:
core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
core/trunk/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java
core/trunk/src/main/java/org/jboss/cache/lock/IdentityLock.java
core/trunk/src/main/java/org/jboss/cache/lock/NodeLock.java
core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferGenerator.java
core/trunk/src/main/java/org/jboss/cache/statetransfer/StateTransferManager.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyGroupAssignmentTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationContentTest.java
Log:
more efficient locking with state transfer + population of internal fqns set on cache construction
Modified: core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2008-01-02 16:53:35 UTC (rev 4942)
+++ core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2008-01-02 17:41:26 UTC (rev 4943)
@@ -45,7 +45,6 @@
import org.jboss.cache.transaction.TransactionTable;
import org.jboss.cache.util.CachePrinter;
import org.jboss.cache.util.ThreadGate;
-import org.jboss.cache.util.concurrent.ConcurrentHashSet;
import org.jboss.cache.util.reflect.ReflectionUtil;
import org.jgroups.*;
import org.jgroups.blocks.GroupRequest;
@@ -134,7 +133,7 @@
* Set<Fqn> of Fqns of the topmost node of internal regions that should
* not included in standard state transfers.
*/
- private Set<Fqn> internalFqns = new ConcurrentHashSet<Fqn>();
+ private Set<Fqn> internalFqns = new HashSet<Fqn>();
/**
* Marshaller if register to handle marshalling
@@ -200,6 +199,8 @@
this.configuration = configuration;
this.componentRegistry = new ComponentRegistry(configuration);
this.cacheStatus = CacheStatus.INSTANTIATED;
+
+ internalFqns.add(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN);
}
protected ComponentRegistry getComponentRegistry()
Modified: core/trunk/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java 2008-01-02 16:53:35 UTC (rev 4942)
+++ core/trunk/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java 2008-01-02 17:41:26 UTC (rev 4943)
@@ -219,8 +219,7 @@
{
child_name = (String) children_name;
tmp_fqn = new Fqn(fqn, child_name);
- //loadStateHelper(tmp_fqn, out);
- getNodeDataList(tmp_fqn, list);
+ if (!cache.getInternalFqns().contains(tmp_fqn)) getNodeDataList(tmp_fqn, list);
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/lock/IdentityLock.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/IdentityLock.java 2008-01-02 16:53:35 UTC (rev 4942)
+++ core/trunk/src/main/java/org/jboss/cache/lock/IdentityLock.java 2008-01-02 17:41:26 UTC (rev 4943)
@@ -532,9 +532,15 @@
public Set<NodeLock> acquireAll(Object caller, long timeout, LockType lock_type)
throws LockingException, TimeoutException, InterruptedException
{
+ return acquireAll(caller, timeout, lock_type, false);
+ }
+
+ public Set<NodeLock> acquireAll(Object caller, long timeout, LockType lock_type, boolean excludeInternalFqns)
+ throws LockingException, TimeoutException, InterruptedException
+ {
boolean acquired;
- if (lock_type == LockType.NONE)
+ if (lock_type == LockType.NONE || (excludeInternalFqns && node.getCache().getInternalFqns().contains(getFqn())))
{
return Collections.emptySet();
}
@@ -548,7 +554,7 @@
for (NodeSPI n : node.getChildrenDirect())
{
- retval.addAll(n.getLock().acquireAll(caller, timeout, lock_type));
+ retval.addAll(n.getLock().acquireAll(caller, timeout, lock_type, excludeInternalFqns));
}
return retval;
}
Modified: core/trunk/src/main/java/org/jboss/cache/lock/NodeLock.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/NodeLock.java 2008-01-02 16:53:35 UTC (rev 4942)
+++ core/trunk/src/main/java/org/jboss/cache/lock/NodeLock.java 2008-01-02 17:41:26 UTC (rev 4943)
@@ -98,19 +98,29 @@
InterruptedException;
/**
- * Recursively acquire locks for this node and all subnodes.
+ * Recursively acquire locks for this node and all subnodes, including internal Fqns such as buddy backup subtrees.
*
* @param caller lock owner
* @param timeout time to wait
* @param lock_type type of lock
* @return locks acquired
- * @throws LockingException
- * @throws TimeoutException
- * @throws InterruptedException
*/
Set<NodeLock> acquireAll(Object caller, long timeout, NodeLock.LockType lock_type) throws LockingException, TimeoutException,
InterruptedException;
+ /**
+ * Same as the overloaded {@link #acquire(Object, long, org.jboss.cache.lock.NodeLock.LockType)} except that you can
+ * optionally specify that internal Fqns - such as buddy backup subtrees - can be excluded when acquiring locks.
+ *
+ * @param caller lock owner
+ * @param timeout time to wait
+ * @param lock_type type of lock
+ * @param excludeInternalFqns if true, locks on internal fqns are not acquired.
+ * @return locks acquired
+ */
+ Set<NodeLock> acquireAll(Object caller, long timeout, LockType lock_type, boolean excludeInternalFqns) throws LockingException, TimeoutException,
+ InterruptedException;
+
void printLockInfo(StringBuffer sb, int indent);
}
\ No newline at end of file
Modified: core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferGenerator.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferGenerator.java 2008-01-02 16:53:35 UTC (rev 4942)
+++ core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferGenerator.java 2008-01-02 17:41:26 UTC (rev 4943)
@@ -165,11 +165,7 @@
list.add(nd);
// then visit the children
- for (NodeSPI child : node.getChildrenDirect())
- {
- //marshallTransientState(child, out);
- generateNodeDataList(child, list);
- }
+ for (NodeSPI child : node.getChildrenDirect()) generateNodeDataList(child, list);
}
/**
Modified: core/trunk/src/main/java/org/jboss/cache/statetransfer/StateTransferManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/statetransfer/StateTransferManager.java 2008-01-02 16:53:35 UTC (rev 4942)
+++ core/trunk/src/main/java/org/jboss/cache/statetransfer/StateTransferManager.java 2008-01-02 17:41:26 UTC (rev 4943)
@@ -241,7 +241,7 @@
{
if (lockChildren)
{
- root.getLock().acquireAll(lockOwner, timeout, NodeLock.LockType.READ);
+ root.getLock().acquireAll(lockOwner, timeout, NodeLock.LockType.READ, true);
}
else
{
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyGroupAssignmentTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyGroupAssignmentTest.java 2008-01-02 16:53:35 UTC (rev 4942)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyGroupAssignmentTest.java 2008-01-02 17:41:26 UTC (rev 4943)
@@ -11,6 +11,7 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.misc.TestingUtil;
+import org.jboss.cache.util.CachePrinter;
import org.testng.annotations.Test;
/**
@@ -39,6 +40,10 @@
assertIsBuddy(caches.get(1), caches.get(2), true);
System.out.println("*** Testing cache 2:");
assertIsBuddy(caches.get(2), caches.get(0), true);
+
+ System.out.println("Cache 0 = " + CachePrinter.printCacheLockingInfo(caches.get(0)));
+ System.out.println("Cache 1 = " + CachePrinter.printCacheLockingInfo(caches.get(1)));
+ System.out.println("Cache 2 = " + CachePrinter.printCacheLockingInfo(caches.get(2)));
}
public void test2Buddies() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationContentTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationContentTest.java 2008-01-02 16:53:35 UTC (rev 4942)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationContentTest.java 2008-01-02 17:41:26 UTC (rev 4943)
@@ -71,6 +71,10 @@
assertNull("Should be null", caches.get(2).get(backupFqn, key));
assertNoStaleLocks(caches);
+
+ System.out.println("Cache 0 = " + CachePrinter.printCacheLockingInfo(caches.get(0)));
+ System.out.println("Cache 1 = " + CachePrinter.printCacheLockingInfo(caches.get(1)));
+ System.out.println("Cache 2 = " + CachePrinter.printCacheLockingInfo(caches.get(2)));
}
public void testPutAndRemove() throws Exception
16 years, 11 months
JBoss Cache SVN: r4942 - in core/trunk/src: test/java/org/jboss/cache/misc and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-01-02 11:53:35 -0500 (Wed, 02 Jan 2008)
New Revision: 4942
Modified:
core/trunk/src/main/java/org/jboss/cache/util/reflect/ClasspathScanner.java
core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java
core/trunk/src/test/java/org/jboss/cache/util/reflect/ClasspathScannerTest.java
Log:
More robust classpath scanning + a proper test
Modified: core/trunk/src/main/java/org/jboss/cache/util/reflect/ClasspathScanner.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/util/reflect/ClasspathScanner.java 2008-01-02 16:01:52 UTC (rev 4941)
+++ core/trunk/src/main/java/org/jboss/cache/util/reflect/ClasspathScanner.java 2008-01-02 16:53:35 UTC (rev 4942)
@@ -26,7 +26,7 @@
public class ClasspathScanner
{
private Log log = LogFactory.getLog(ClasspathScanner.class);
- private URLClassLoader classLoader;
+ URLClassLoader classLoader;
/**
* Constructor with the type of annotation to scan for.
@@ -51,7 +51,7 @@
try
{
// only scan the current ClassPath location that contains this file. Could be a directory or a JAR file.
- URL url = getURLPathFromClassLoader();
+ URL url = getURLPathFromClassLoader("org/jboss/cache/Version.class");
String urlPath = url.getFile();
if (urlPath.endsWith("/"))
{
@@ -81,12 +81,12 @@
return classes;
}
- private URL getURLPathFromClassLoader() throws MalformedURLException
+ URL getURLPathFromClassLoader(String resourceName) throws MalformedURLException
{
- URL u2 = classLoader.findResource("org/jboss/cache/Version.class");
+ URL u2 = classLoader.findResource(resourceName);
String u2String = u2.toString();
- boolean isJar = u2String.startsWith("jar:") && u2String.contains(".jar!/");
+ boolean isJar = u2String.startsWith("jar:") && (u2String.toLowerCase().contains(".jar!/") || u2String.toLowerCase().contains(".zip!/"));
for (URL u : classLoader.getURLs())
{
Modified: core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java 2008-01-02 16:01:52 UTC (rev 4941)
+++ core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java 2008-01-02 16:53:35 UTC (rev 4942)
@@ -387,6 +387,11 @@
public static void recursiveFileRemove(String directoryName)
{
File file = new File(directoryName);
+ recursiveFileRemove(file);
+ }
+
+ public static void recursiveFileRemove(File file)
+ {
if (file.exists())
{
System.out.println("Deleting file " + file);
Modified: core/trunk/src/test/java/org/jboss/cache/util/reflect/ClasspathScannerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/util/reflect/ClasspathScannerTest.java 2008-01-02 16:01:52 UTC (rev 4941)
+++ core/trunk/src/test/java/org/jboss/cache/util/reflect/ClasspathScannerTest.java 2008-01-02 16:53:35 UTC (rev 4942)
@@ -4,9 +4,22 @@
import org.jboss.cache.factories.EmptyConstructorFactory;
import org.jboss.cache.factories.TransactionManagerFactory;
import org.jboss.cache.factories.annotations.DefaultFactoryFor;
+import org.jboss.cache.misc.TestingUtil;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.net.URL;
+import java.net.URLClassLoader;
import java.util.Set;
+import java.util.jar.JarOutputStream;
+import java.util.zip.ZipEntry;
/**
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
@@ -15,6 +28,35 @@
@Test(groups = {"functional"})
public class ClasspathScannerTest
{
+ String tmpDir;
+ File classpathDirectory;
+ File archive;
+ String resourceName = "test.resource";
+
+ @BeforeMethod
+ public void setUp() throws Exception
+ {
+ // create a test directory and add this to my class path:
+ tmpDir = System.getProperty("java.io.tmpdir", "/tmp");
+ String tmpClasspath = tmpDir + File.separator + "tempClasspath";
+ classpathDirectory = new File(tmpClasspath);
+ classpathDirectory.mkdirs();
+ File tempResourceFile = new File(tmpClasspath + File.separator + resourceName);
+
+ PrintWriter writer = new PrintWriter(new FileWriter(tempResourceFile));
+ writer.write("Blah");
+ writer.close();
+
+ assert tempResourceFile.exists();
+ }
+
+ @AfterMethod
+ public void tearDown()
+ {
+ TestingUtil.recursiveFileRemove(classpathDirectory);
+ if (archive != null) TestingUtil.recursiveFileRemove(archive);
+ }
+
public void testScanning()
{
ClasspathScanner cs = new ClasspathScanner();
@@ -24,4 +66,53 @@
assert sc.contains(TransactionManagerFactory.class);
assert sc.contains(EmptyConstructorFactory.class);
}
+
+ public void testScanningClassDirectory() throws IOException
+ {
+ ClasspathScanner cs = new ClasspathScanner();
+ cs.classLoader = new URLClassLoader(new URL[]{classpathDirectory.toURL()}, getClass().getClassLoader());
+
+ URL u = cs.getURLPathFromClassLoader(resourceName);
+
+ assert u.equals(classpathDirectory.toURL());
+ }
+
+ public void testScanningJar() throws IOException
+ {
+ // create a JAR archive
+ archive = new File(tmpDir + File.separator + "lib" + File.separator + "archive.jar");
+ testScanningArchive();
+ }
+
+ public void testScanningZip() throws IOException
+ {
+ // create a ZIP archive
+ archive = new File(tmpDir + File.separator + "lib" + File.separator + "archive.zip");
+ testScanningArchive();
+ }
+
+ private void testScanningArchive() throws IOException
+ {
+ archive.getParentFile().mkdirs();
+ FileOutputStream fos = new FileOutputStream(archive);
+ JarOutputStream jos = new JarOutputStream(fos);
+ FileInputStream fis = new FileInputStream(classpathDirectory + File.separator + resourceName);
+ ZipEntry ze = new ZipEntry(resourceName);
+ jos.putNextEntry(ze);
+
+ byte b;
+ while ((b = (byte) fis.read()) != -1) jos.write(b);
+
+ fis.close();
+ jos.closeEntry();
+ jos.close();
+ fos.close();
+
+ ClasspathScanner cs = new ClasspathScanner();
+ cs.classLoader = new URLClassLoader(new URL[]{archive.toURL()}, getClass().getClassLoader());
+
+ URL u = cs.getURLPathFromClassLoader(resourceName);
+
+ assert u.equals(archive.toURL());
+ }
}
16 years, 11 months
JBoss Cache SVN: r4941 - in core/trunk/src: main/java/org/jboss/cache/buddyreplication and 5 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-01-02 11:01:52 -0500 (Wed, 02 Jan 2008)
New Revision: 4941
Modified:
core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java
core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java
core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
core/trunk/src/main/java/org/jboss/cache/invocation/RemoteCacheInvocationDelegate.java
core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java
core/trunk/src/main/java/org/jboss/cache/marshall/MethodDeclarations.java
core/trunk/src/test/java/org/jboss/cache/jmx/InterceptorRegistrationTest.java
Log:
moved remote-only calls to the RemoteCacheInvocationDelegate rather than the CacheImpl
Modified: core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2008-01-02 11:56:56 UTC (rev 4940)
+++ core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2008-01-02 16:01:52 UTC (rev 4941)
@@ -8,9 +8,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.buddyreplication.BuddyGroup;
import org.jboss.cache.buddyreplication.BuddyManager;
-import org.jboss.cache.buddyreplication.BuddyNotInitException;
import org.jboss.cache.buddyreplication.GravitateResult;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Option;
@@ -1946,13 +1944,14 @@
}
else
{
- if (rsp.getValue() instanceof Exception)
+ Object value = rsp.getValue();
+ if (value instanceof Exception && !(value instanceof ReplicationException))
{
- if (log.isTraceEnabled())
- log.trace("Recieved exception'" + rsp.getValue() + "' from " + rsp.getSender());
- throw (Exception) rsp.getValue();
+ // if we have any application-level exceptions make sure we throw them!!
+ if (log.isTraceEnabled()) log.trace("Recieved exception'" + value + "' from " + rsp.getSender());
+ throw (Exception) value;
}
- retval.add(rsp.getValue());
+ retval.add(value);
}
}
return retval;
@@ -2873,62 +2872,6 @@
return list;
}
- // ------------- start: buddy replication specific 'lifecycle' method calls
-
- public void _remoteAssignToBuddyGroup(BuddyGroup group, Map<Fqn, byte[]> state) throws Exception
- {
- if (buddyManager != null)
- buddyManager.handleAssignToBuddyGroup(group, state);
- else if (log.isWarnEnabled())
- log.warn("Received assignToBuddyGroup call from group owner [" + group.getDataOwner() + "] but buddy replication is not enabled on this node!");
- }
-
- public void _remoteRemoveFromBuddyGroup(String groupName) throws BuddyNotInitException
- {
- if (buddyManager != null)
- buddyManager.handleRemoveFromBuddyGroup(groupName);
- else if (log.isWarnEnabled())
- log.warn("Received removeFromBuddyGroup call for group name [" + groupName + "] but buddy replication is not enabled on this node!");
-
- }
-
- public void _remoteAnnounceBuddyPoolName(Address address, String buddyPoolName)
- {
- if (buddyManager != null)
- buddyManager.handlePoolNameBroadcast(address, buddyPoolName);
- else if (log.isWarnEnabled())
- log.warn("Received annouceBuddyPoolName call from [" + address + "] but buddy replication is not enabled on this node!");
- }
-
- public void _dataGravitationCleanup(GlobalTransaction gtx, Fqn primary, Fqn backup) throws Exception
- {
-// MethodCall primaryDataCleanup, backupDataCleanup;
- if (buddyManager.isDataGravitationRemoveOnFind())
- {
- if (log.isTraceEnabled())
- log.trace("DataGravitationCleanup: Removing primary (" + primary + ") and backup (" + backup + ")");
- //primaryDataCleanup = MethodCallFactory.create(MethodDeclarations.removeNodeMethodLocal, primary, false);
- spi.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
- spi.removeNode(primary);
- //backupDataCleanup = MethodCallFactory.create(MethodDeclarations.removeNodeMethodLocal, backup, false);
- spi.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
- spi.removeNode(backup);
- }
- else
- {
- if (log.isTraceEnabled())
- log.trace("DataGravitationCleanup: Evicting primary (" + primary + ") and backup (" + backup + ")");
- //primaryDataCleanup = MethodCallFactory.create(MethodDeclarations.evictNodeMethodLocal, primary);
- spi.evict(primary, true);
- //backupDataCleanup = MethodCallFactory.create(MethodDeclarations.evictNodeMethodLocal, backup);
- spi.evict(backup, true);
- }
-
-// invokeMethod(primaryDataCleanup, true);
-// invokeMethod(backupDataCleanup, true);
- }
-
- // ------------- end: buddy replication specific 'lifecycle' method calls
/**
* Releases all locks for a FQN.
*/
@@ -3140,7 +3083,7 @@
*/
private void configureLogCategory()
{
- StringBuilder category = new StringBuilder(getClass().getSimpleName());
+ StringBuilder category = new StringBuilder(getClass().getName());
if (configuration != null)
{
String clusterName = configuration.getClusterName();
@@ -3151,12 +3094,12 @@
if (channel != null && channel.getLocalAddress() != null)
{
category.append('.');
- category.append(channel.getLocalAddress());
+ category.append(channel.getLocalAddress().toString().replace('.', '_'));
}
}
}
// replace .s with _s otherwise Log4J will strip them out
- log = LogFactory.getLog(category.toString().replace('.', '_'));
+ log = LogFactory.getLog(category.toString());
}
/**
Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java 2008-01-02 11:56:56 UTC (rev 4940)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java 2008-01-02 16:01:52 UTC (rev 4941)
@@ -685,7 +685,6 @@
buddyGroup.removeBuddies(buddies);
// now broadcast a message to the removed buddies.
MethodCall membershipCall = MethodCallFactory.create(MethodDeclarations.remoteRemoveFromBuddyGroupMethod, buddyGroup.getGroupName());
- MethodCall replicateCall = MethodCallFactory.create(MethodDeclarations.replicateMethod, membershipCall);
int attemptsLeft = UNINIT_BUDDIES_RETRIES;
int currentAttempt = 0;
@@ -694,7 +693,7 @@
{
try
{
- makeRemoteCall(buddies, replicateCall, true);
+ makeRemoteCall(buddies, membershipCall, true);
break;
}
catch (Exception e)
@@ -784,7 +783,6 @@
// now broadcast a message to the newly assigned buddies.
MethodCall membershipCall = MethodCallFactory.create(MethodDeclarations.remoteAssignToBuddyGroupMethod, buddyGroup, stateMap);
- MethodCall replicateCall = MethodCallFactory.create(MethodDeclarations.replicateMethod, membershipCall);
int attemptsLeft = UNINIT_BUDDIES_RETRIES;
int currentAttempt = 0;
@@ -793,7 +791,7 @@
{
try
{
- makeRemoteCall(buddies, replicateCall, true);
+ makeRemoteCall(buddies, membershipCall, true);
break;
}
catch (Exception e)
@@ -943,11 +941,10 @@
}
MethodCall membershipCall = MethodCallFactory.create(MethodDeclarations.remoteAnnounceBuddyPoolNameMethod, buddyGroup.getDataOwner(), config.getBuddyPoolName());
- MethodCall replicateCall = MethodCallFactory.create(MethodDeclarations.replicateMethod, membershipCall);
try
{
- makeRemoteCall(recipients, replicateCall, true);
+ makeRemoteCall(recipients, membershipCall, true);
}
catch (Exception e)
{
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java 2008-01-02 11:56:56 UTC (rev 4940)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java 2008-01-02 16:01:52 UTC (rev 4941)
@@ -76,7 +76,12 @@
protected void replicateCall(List<Address> recipients, MethodCall call, boolean sync, Option o) throws Throwable
{
+ replicateCall(recipients, call, sync, o, true);
+ }
+ protected void replicateCall(List<Address> recipients, MethodCall call, boolean sync, Option o, boolean wrapMethodCallInReplicateMethod) throws Throwable
+ {
+
if (log.isTraceEnabled()) log.trace("Broadcasting call " + call + " to recipient list " + recipients);
Transaction tx = null;
if (cache.getTransactionManager() != null && (tx = cache.getTransactionManager().getTransaction()) != null)
@@ -108,12 +113,13 @@
long syncReplTimeout = o.getSyncReplTimeout();
if (syncReplTimeout < 0) syncReplTimeout = configuration.getSyncReplTimeout();
+ MethodCall toCall = wrapMethodCallInReplicateMethod ? toCall = MethodCallFactory.create(MethodDeclarations.replicateMethod, call) : call;
+
List rsps = rpcManager.callRemoteMethods(callRecipients,
- MethodDeclarations.replicateMethod,
- new Object[]{call},
+ toCall,
sync, // is synchronised?
true, // ignore self?
- syncReplTimeout);
+ (int) syncReplTimeout);
if (log.isTraceEnabled())
{
log.trace("responses=" + rsps);
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java 2008-01-02 11:56:56 UTC (rev 4940)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java 2008-01-02 16:01:52 UTC (rev 4941)
@@ -8,7 +8,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.*;
+import org.jboss.cache.CacheException;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.NodeSPI;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.buddyreplication.GravitateResult;
import org.jboss.cache.config.Configuration;
@@ -64,7 +68,7 @@
protected boolean skipMethodCall(InvocationContext ctx)
{
return MethodDeclarations.isBlockUnblockMethod(ctx.getMethodCall().getMethodId()) ||
- ctx.getOptionOverrides().isSkipDataGravitation();
+ ctx.getOptionOverrides().isSkipDataGravitation();
}
protected Object handleGetChildrenNamesMethod(InvocationContext ctx, Fqn fqn) throws Throwable
@@ -104,7 +108,8 @@
Object returnValue = nextInterceptor(ctx);
doPrepare(ctx.getGlobalTransaction(), ctx);
return returnValue;
- } catch (Throwable throwable)
+ }
+ catch (Throwable throwable)
{
transactionMods.remove(ctx.getGlobalTransaction());
throw throwable;
@@ -123,7 +128,8 @@
{
transactionMods.remove(ctx.getGlobalTransaction());
return nextInterceptor(ctx);
- } catch (Throwable throwable)
+ }
+ catch (Throwable throwable)
{
transactionMods.remove(ctx.getGlobalTransaction());
throw throwable;
@@ -137,7 +143,8 @@
doCommit(ctx.getGlobalTransaction(), ctx);
transactionMods.remove(ctx.getGlobalTransaction());
return nextInterceptor(ctx);
- } catch (Throwable throwable)
+ }
+ catch (Throwable throwable)
{
transactionMods.remove(ctx.getGlobalTransaction());
throw throwable;
@@ -153,7 +160,8 @@
if (BuddyManager.isBackupFqn(fqn))
{
log.info("Is call for a backup Fqn, not performing any gravitation. Direct calls on internal backup nodes are *not* supported.");
- } else
+ }
+ else
{
if (cache.peek(fqn, false) == null)
{
@@ -183,12 +191,14 @@
// Clean up the other nodes
cleanBackupData(data, ctx.getGlobalTransaction(), ctx);
}
- } else
+ }
+ else
{
log.trace("No need to gravitate; have this already.");
}
}
- } else
+ }
+ else
{
if (log.isTraceEnabled())
{
@@ -314,7 +324,7 @@
// backupDataCleanup = MethodCallFactory.create(MethodDeclarations.evictNodeMethodLocal, new Object[]{backup.backupFqn});
// }
- MethodCall cleanup = MethodCallFactory.create(MethodDeclarations.dataGravitationCleanupMethod, gtx, backup.primaryFqn, backup.backupFqn);
+ MethodCall cleanup = MethodCallFactory.create(MethodDeclarations.dataGravitationCleanupMethod, backup.primaryFqn, backup.backupFqn);
if (log.isTraceEnabled()) log.trace("Performing cleanup on [" + backup.primaryFqn + "]");
@@ -327,7 +337,7 @@
if (log.isTraceEnabled()) log.trace("Performing cleanup on [" + backup.backupFqn + "]");
// remove backup Fqn
//replicateCall(cache.getMembers(), backupDataCleanup, syncCommunications);
- replicateCall(cache.getMembers(), cleanup, syncCommunications, ctx.getOptionOverrides());
+ replicateCall(cache.getMembers(), cleanup, syncCommunications, ctx.getOptionOverrides(), false);
}
else
{
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java 2008-01-02 11:56:56 UTC (rev 4940)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java 2008-01-02 16:01:52 UTC (rev 4941)
@@ -59,7 +59,9 @@
*/
protected Object invoke(MethodCall call) throws CacheException
{
- return invoke(call, false);
+ assertIsConstructed();
+ InvocationContext ctx = invocationContextContainer.get();
+ return invoke(call, ctx.getOptionOverrides().isSkipCacheStatusCheck(), ctx);
}
/**
@@ -71,12 +73,18 @@
*/
protected Object invoke(MethodCall call, boolean skipCacheStatusCheck) throws CacheException
{
- // never create a new one directly; always let the container do this if needed.
- InvocationContext ctx = invocationContextContainer.get();
+ assertIsConstructed();
+ return invoke(call, skipCacheStatusCheck, invocationContextContainer.get());
+ }
- // BR methods should NOT block on the cache being started, since the cache depends on these completing to start.
- if (//!MethodDeclarations.isBuddyGroupOrganisationMethod(call.getMethodId()) &&
- !cache.getCacheStatus().allowInvocations() && !skipCacheStatusCheck)
+ private void assertIsConstructed()
+ {
+ if (invocationContextContainer == null) throw new IllegalStateException("The cache has been destroyed!");
+ }
+
+ private Object invoke(MethodCall call, boolean skipCacheStatusCheck, InvocationContext ctx) throws CacheException
+ {
+ if (!cache.getCacheStatus().allowInvocations() && !skipCacheStatusCheck)
{
// only throw an exception if this is a locally originating call - JBCACHE-1179
if (originLocal)
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-01-02 11:56:56 UTC (rev 4940)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-01-02 16:01:52 UTC (rev 4941)
@@ -113,7 +113,8 @@
public List<Interceptor> getInterceptorChain()
{
- return Collections.unmodifiableList(InterceptorChainFactory.asList(interceptorChain));
+ List interceptors = InterceptorChainFactory.asList(interceptorChain);
+ return interceptors == null ? Collections.emptyList() : Collections.unmodifiableList(interceptors);
}
public void addInterceptor(Interceptor i, int position)
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/RemoteCacheInvocationDelegate.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/RemoteCacheInvocationDelegate.java 2008-01-02 11:56:56 UTC (rev 4940)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/RemoteCacheInvocationDelegate.java 2008-01-02 16:01:52 UTC (rev 4941)
@@ -2,15 +2,20 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Fqn;
+import org.jboss.cache.buddyreplication.BuddyGroup;
+import org.jboss.cache.buddyreplication.BuddyManager;
+import org.jboss.cache.buddyreplication.BuddyNotInitException;
+import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.marshall.MethodCallFactory;
import org.jboss.cache.marshall.MethodDeclarations;
-import org.jboss.cache.transaction.GlobalTransaction;
+import org.jgroups.Address;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
/**
* A sublcass of CacheInvocationDelegate, used by remote instances to invoke methods on current cache.
@@ -20,50 +25,101 @@
*/
public class RemoteCacheInvocationDelegate extends CacheInvocationDelegate
{
+ private BuddyManager buddyManager;
+
public RemoteCacheInvocationDelegate()
{
originLocal = false;
log = LogFactory.getLog(RemoteCacheInvocationDelegate.class);
}
- public Object _replicate(MethodCall methodCall) throws Throwable
+ @Inject
+ private void injectBuddyManager(BuddyManager buddyManager)
{
- if (methodCall.getMethodId() == MethodDeclarations.clusteredGetMethod_id)
- return invokeClusteredGet(methodCall);
- else if (methodCall.getMethodId() == MethodDeclarations.dataGravitationCleanupMethod_id)
+ this.buddyManager = buddyManager;
+ }
+
+ // ------------- start: buddy replication specific 'lifecycle' method calls
+
+ public void assignToBuddyGroup(BuddyGroup group, Map<Fqn, byte[]> state) throws Exception
+ {
+ if (buddyManager != null)
+ buddyManager.handleAssignToBuddyGroup(group, state);
+ else if (log.isWarnEnabled())
+ log.warn("Received assignToBuddyGroup call from group owner [" + group.getDataOwner() + "] but buddy replication is not enabled on this node!");
+ }
+
+ public void removeFromBuddyGroup(String groupName) throws BuddyNotInitException
+ {
+ if (buddyManager != null)
+ buddyManager.handleRemoveFromBuddyGroup(groupName);
+ else if (log.isWarnEnabled())
+ log.warn("Received removeFromBuddyGroup call for group name [" + groupName + "] but buddy replication is not enabled on this node!");
+
+ }
+
+ public void announceBuddyPoolName(Address address, String buddyPoolName)
+ {
+ if (buddyManager != null)
+ buddyManager.handlePoolNameBroadcast(address, buddyPoolName);
+ else if (log.isWarnEnabled())
+ log.warn("Received annouceBuddyPoolName call from [" + address + "] but buddy replication is not enabled on this node!");
+ }
+
+ public void dataGravitationCleanup(Fqn primary, Fqn backup) throws Exception
+ {
+// MethodCall primaryDataCleanup, backupDataCleanup;
+ if (buddyManager.isDataGravitationRemoveOnFind())
{
- Object[] args = methodCall.getArgs();
- cache._dataGravitationCleanup((GlobalTransaction) args[0], (Fqn) args[1], (Fqn) args[2]);
- return null;
+ if (log.isTraceEnabled())
+ log.trace("DataGravitationCleanup: Removing primary (" + primary + ") and backup (" + backup + ")");
+ //primaryDataCleanup = MethodCallFactory.create(MethodDeclarations.removeNodeMethodLocal, primary, false);
+ getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
+ removeNode(primary);
+ //backupDataCleanup = MethodCallFactory.create(MethodDeclarations.removeNodeMethodLocal, backup, false);
+ getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
+ removeNode(backup);
}
-
else
{
- try
+ if (log.isTraceEnabled())
+ log.trace("DataGravitationCleanup: Evicting primary (" + primary + ") and backup (" + backup + ")");
+ //primaryDataCleanup = MethodCallFactory.create(MethodDeclarations.evictNodeMethodLocal, primary);
+ evict(primary, true);
+ //backupDataCleanup = MethodCallFactory.create(MethodDeclarations.evictNodeMethodLocal, backup);
+ evict(backup, true);
+ }
+ }
+
+ // ------------- end: buddy replication specific 'lifecycle' method calls
+
+
+ public Object _replicate(MethodCall methodCall) throws Throwable
+ {
+ try
+ {
+ Object retVal = invoke(methodCall);
+ // we only need to return values for a set of remote calls; not every call.
+ if (MethodDeclarations.returnValueForRemoteCall(methodCall.getMethodId()))
{
- Object retVal = invoke(methodCall);
- // we only need to return values for a set of remote calls; not every call.
- if (MethodDeclarations.returnValueForRemoteCall(methodCall.getMethodId()))
- {
- return retVal;
- }
- else
- {
- return null;
- }
+ return retVal;
}
- catch (Throwable ex)
+ else
{
- if (methodCall.getMethodId() != MethodDeclarations.putForExternalReadMethodLocal_id
- || methodCall.getMethodId() != MethodDeclarations.putForExternalReadVersionedMethodLocal_id)
- {
- if (!MethodDeclarations.isBuddyGroupOrganisationMethod(methodCall.getMethodId()) && log.isWarnEnabled())
- log.warn("replication failure with methodCall " + methodCall + " exception", ex);
- throw ex;
- }
- else return null;
+ return null;
}
}
+ catch (Throwable ex)
+ {
+ if (methodCall.getMethodId() != MethodDeclarations.putForExternalReadMethodLocal_id
+ || methodCall.getMethodId() != MethodDeclarations.putForExternalReadVersionedMethodLocal_id)
+ {
+ if (!MethodDeclarations.isBuddyGroupOrganisationMethod(methodCall.getMethodId()) && log.isWarnEnabled())
+ log.warn("replication failure with methodCall " + methodCall + " exception", ex);
+ throw ex;
+ }
+ else return null;
+ }
}
/**
@@ -74,12 +130,6 @@
for (MethodCall methodCall : methodCalls) _replicate(methodCall);
}
- public Object invokeClusteredGet(MethodCall call)
- {
- Object[] args = call.getArgs();
- return clusteredGet((MethodCall) args[0], (Boolean) args[1]);
- }
-
public void block()
{
MethodCall m = MethodCallFactory.create(MethodDeclarations.blockChannelLocal);
Modified: core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java 2008-01-02 11:56:56 UTC (rev 4940)
+++ core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java 2008-01-02 16:01:52 UTC (rev 4941)
@@ -676,11 +676,11 @@
{
cacheStatus = CacheStatus.DESTROYING;
- cache.destroy();
-
// The cache is destroyed, so we shouldn't leave the interceptors
// in JMX, even if we didn't register them in create
unregisterInterceptors();
+
+ cache.destroy();
}
finally
{
@@ -955,7 +955,7 @@
{
try
{
- log.debug("Unreqistering interceptors");
+ log.debug("Unregistering interceptors");
JmxUtil.unregisterInterceptors(server, cache.getInterceptorChain(), getCacheObjectName());
interceptorsRegistered = false;
}
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/MethodDeclarations.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/MethodDeclarations.java 2008-01-02 11:56:56 UTC (rev 4940)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/MethodDeclarations.java 2008-01-02 16:01:52 UTC (rev 4941)
@@ -272,11 +272,11 @@
// ------------ buddy replication
- remoteAnnounceBuddyPoolNameMethod = CacheImpl.class.getDeclaredMethod("_remoteAnnounceBuddyPoolName", Address.class, String.class);
- remoteRemoveFromBuddyGroupMethod = CacheImpl.class.getDeclaredMethod("_remoteRemoveFromBuddyGroup", String.class);
- remoteAssignToBuddyGroupMethod = CacheImpl.class.getDeclaredMethod("_remoteAssignToBuddyGroup", BuddyGroup.class, Map.class);
+ remoteAnnounceBuddyPoolNameMethod = RemoteCacheInvocationDelegate.class.getDeclaredMethod("announceBuddyPoolName", Address.class, String.class);
+ remoteRemoveFromBuddyGroupMethod = RemoteCacheInvocationDelegate.class.getDeclaredMethod("removeFromBuddyGroup", String.class);
+ remoteAssignToBuddyGroupMethod = RemoteCacheInvocationDelegate.class.getDeclaredMethod("assignToBuddyGroup", BuddyGroup.class, Map.class);
- dataGravitationCleanupMethod = CacheImpl.class.getDeclaredMethod("_dataGravitationCleanup", GlobalTransaction.class, Fqn.class, Fqn.class);
+ dataGravitationCleanupMethod = RemoteCacheInvocationDelegate.class.getDeclaredMethod("dataGravitationCleanup", Fqn.class, Fqn.class);
dataGravitationMethod = CacheSPI.class.getDeclaredMethod("gravitateData", Fqn.class, boolean.class);
// ------------ move() api
Modified: core/trunk/src/test/java/org/jboss/cache/jmx/InterceptorRegistrationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/jmx/InterceptorRegistrationTest.java 2008-01-02 11:56:56 UTC (rev 4940)
+++ core/trunk/src/test/java/org/jboss/cache/jmx/InterceptorRegistrationTest.java 2008-01-02 16:01:52 UTC (rev 4941)
@@ -22,23 +22,24 @@
package org.jboss.cache.jmx;
+import org.jboss.cache.config.Configuration;
import static org.testng.AssertJUnit.assertTrue;
+import org.testng.annotations.Test;
-import org.jboss.cache.config.Configuration;
-
/**
* Tests the interceptor registration function of CacheJmxWrapper.
*
* @author <a href="brian.stansberry(a)jboss.com">Brian Stansberry</a>
* @version $Revision$
*/
+@Test(groups = "functional")
public class InterceptorRegistrationTest extends CacheJmxWrapperTestBase
{
/**
* Confirms interceptor mbeans are registered if the following events
* occur:
- *
+ * <p/>
* cache.start();
* wrapper creation and registration.
*
@@ -71,7 +72,7 @@
/**
* Confirms interceptor mbeans are registered if the following events
* occur:
- *
+ * <p/>
* cache.start();
* wrapper creation and and start
* wrapper registration.
@@ -105,7 +106,7 @@
/**
* Confirms interceptor mbeans are registered if the following events
* occur:
- *
+ * <p/>
* Cache not injected
* wrapper registered;
* wrapper created and started.
@@ -137,7 +138,7 @@
/**
* Confirms interceptor mbeans are registered if the following events
* occur:
- *
+ * <p/>
* Cache not injected
* wrapper created and started.
* wrapper registered
@@ -172,7 +173,7 @@
/**
* Confirms interceptor mbeans are registered if the following events
* occur:
- *
+ * <p/>
* cache constructed;
* wrapper constructed and registered with manageCacheLifecycle=true
* wrapper created and started
@@ -205,7 +206,7 @@
/**
* Confirms interceptor mbeans are registered if the following events
* occur:
- *
+ * <p/>
* cache constructed;
* wrapper constructed and registered
* wrapper created and started
@@ -236,7 +237,7 @@
/**
* Confirms interceptor mbeans are registered if the following events
* occur:
- *
+ * <p/>
* cache constructed;
* wrapper created and started
* wrapper registered
16 years, 11 months
JBoss Cache SVN: r4940 - in core/trunk/src/main/java/org/jboss/cache: invocation and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-01-02 06:56:56 -0500 (Wed, 02 Jan 2008)
New Revision: 4940
Modified:
core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java
core/trunk/src/main/java/org/jboss/cache/invocation/RemoteCacheInvocationDelegate.java
core/trunk/src/main/java/org/jboss/cache/marshall/MethodDeclarations.java
Log:
Fixed data gravitation issues
Modified: core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2008-01-02 11:30:24 UTC (rev 4939)
+++ core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2008-01-02 11:56:56 UTC (rev 4940)
@@ -2827,7 +2827,7 @@
// use a get() call into the cache to make sure cache loading takes place.
ctx.getOptionOverrides().setSkipDataGravitation(true);
- actualNode = get(backupNodeFqn);
+ actualNode = spi.getNode(backupNodeFqn);
ctx.getOptionOverrides().setSkipDataGravitation(false);
if (log.isTraceEnabled())
log.trace("Looking for " + backupNodeFqn + ". Search result: " + actualNode);
@@ -2908,8 +2908,10 @@
if (log.isTraceEnabled())
log.trace("DataGravitationCleanup: Removing primary (" + primary + ") and backup (" + backup + ")");
//primaryDataCleanup = MethodCallFactory.create(MethodDeclarations.removeNodeMethodLocal, primary, false);
+ spi.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
spi.removeNode(primary);
//backupDataCleanup = MethodCallFactory.create(MethodDeclarations.removeNodeMethodLocal, backup, false);
+ spi.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
spi.removeNode(backup);
}
else
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java 2008-01-02 11:30:24 UTC (rev 4939)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java 2008-01-02 11:56:56 UTC (rev 4940)
@@ -10,7 +10,6 @@
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.interceptors.Interceptor;
import org.jboss.cache.marshall.MethodCall;
-import org.jboss.cache.marshall.MethodDeclarations;
/**
* The JBoss Cache hand-wired interceptor stack. A "minimal" AOP framework which uses delegation through an
@@ -76,7 +75,7 @@
InvocationContext ctx = invocationContextContainer.get();
// BR methods should NOT block on the cache being started, since the cache depends on these completing to start.
- if (!MethodDeclarations.isBuddyGroupOrganisationMethod(call.getMethodId()) &&
+ if (//!MethodDeclarations.isBuddyGroupOrganisationMethod(call.getMethodId()) &&
!cache.getCacheStatus().allowInvocations() && !skipCacheStatusCheck)
{
// only throw an exception if this is a locally originating call - JBCACHE-1179
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/RemoteCacheInvocationDelegate.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/RemoteCacheInvocationDelegate.java 2008-01-02 11:30:24 UTC (rev 4939)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/RemoteCacheInvocationDelegate.java 2008-01-02 11:56:56 UTC (rev 4940)
@@ -30,8 +30,13 @@
{
if (methodCall.getMethodId() == MethodDeclarations.clusteredGetMethod_id)
return invokeClusteredGet(methodCall);
- else if (MethodDeclarations.isDataGravitationMethod(methodCall.getMethodId()))
- return invokeDataGravitationCall(methodCall);
+ else if (methodCall.getMethodId() == MethodDeclarations.dataGravitationCleanupMethod_id)
+ {
+ Object[] args = methodCall.getArgs();
+ cache._dataGravitationCleanup((GlobalTransaction) args[0], (Fqn) args[1], (Fqn) args[2]);
+ return null;
+ }
+
else
{
try
@@ -75,25 +80,6 @@
return clusteredGet((MethodCall) args[0], (Boolean) args[1]);
}
- public Object invokeDataGravitationCall(MethodCall call) throws Exception
- {
- Object[] args = call.getArgs();
- if (call.getMethodId() == MethodDeclarations.dataGravitationMethod_id)
- {
- return cache.gravitateData((Fqn) args[0], (Boolean) args[1]);
- }
- else if (call.getMethodId() == MethodDeclarations.dataGravitationCleanupMethod_id)
- {
- cache._dataGravitationCleanup((GlobalTransaction) args[0], (Fqn) args[1], (Fqn) args[2]);
- return null;
- }
- else
- {
- throw new UnsupportedOperationException(call + " is not a data gravitation call!");
- }
- }
-
-
public void block()
{
MethodCall m = MethodCallFactory.create(MethodDeclarations.blockChannelLocal);
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/MethodDeclarations.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/MethodDeclarations.java 2008-01-02 11:30:24 UTC (rev 4939)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/MethodDeclarations.java 2008-01-02 11:56:56 UTC (rev 4940)
@@ -10,6 +10,7 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheImpl;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.buddyreplication.BuddyGroup;
@@ -276,7 +277,7 @@
remoteAssignToBuddyGroupMethod = CacheImpl.class.getDeclaredMethod("_remoteAssignToBuddyGroup", BuddyGroup.class, Map.class);
dataGravitationCleanupMethod = CacheImpl.class.getDeclaredMethod("_dataGravitationCleanup", GlobalTransaction.class, Fqn.class, Fqn.class);
- dataGravitationMethod = CacheImpl.class.getDeclaredMethod("gravitateData", Fqn.class, boolean.class);
+ dataGravitationMethod = CacheSPI.class.getDeclaredMethod("gravitateData", Fqn.class, boolean.class);
// ------------ move() api
moveMethodLocal = CacheImpl.class.getDeclaredMethod("_move", Fqn.class, Fqn.class);
16 years, 11 months
JBoss Cache SVN: r4939 - core/trunk/src/main/java/org/jboss/cache/jmx.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-01-02 06:30:24 -0500 (Wed, 02 Jan 2008)
New Revision: 4939
Modified:
core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java
Log:
code readability cleanups
Modified: core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java 2008-01-02 11:29:53 UTC (rev 4938)
+++ core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java 2008-01-02 11:30:24 UTC (rev 4939)
@@ -547,7 +547,7 @@
public void create() throws CacheException
{
- if (cacheStatus.createAllowed() == false)
+ if (!cacheStatus.createAllowed())
{
if (cacheStatus.needToDestroyFailedCache())
destroy();
@@ -581,7 +581,7 @@
public void start() throws CacheException
{
- if (cacheStatus.startAllowed() == false)
+ if (!cacheStatus.startAllowed())
{
if (cacheStatus.needToDestroyFailedCache())
destroy(); // this will take us back to DESTROYED
@@ -614,7 +614,7 @@
public void stop()
{
- if (cacheStatus.stopAllowed() == false)
+ if (!cacheStatus.stopAllowed())
{
return;
}
@@ -654,7 +654,7 @@
public void destroy()
{
- if (cacheStatus.destroyAllowed() == false)
+ if (!cacheStatus.destroyAllowed())
{
if (cacheStatus.needStopBeforeDestroy())
{
@@ -1072,8 +1072,8 @@
this,
getNextNotificationSequenceNumber(), now, msg,
"State", "java.lang.Integer",
- Integer.valueOf(oldState), Integer.valueOf(newState)
- );
+ oldState, newState);
+
stateChangeNotification.setUserData(t);
sendNotification(stateChangeNotification);
16 years, 11 months
JBoss Cache SVN: r4938 - core/trunk/src/main/java/org/jboss/cache/marshall.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-01-02 06:29:53 -0500 (Wed, 02 Jan 2008)
New Revision: 4938
Modified:
core/trunk/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java
Log:
made method public to aid unit testing
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java 2008-01-02 11:29:31 UTC (rev 4937)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java 2008-01-02 11:29:53 UTC (rev 4938)
@@ -42,7 +42,7 @@
private int versionInt;
@Start
- protected void initReplicationVersions()
+ public void initReplicationVersions()
{
String replVersionString = configuration.getReplVersionString();
16 years, 11 months