JBoss Cache SVN: r8154 - in core/trunk/src: test/java/org/jboss/cache/optimistic and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-08-05 11:03:41 -0400 (Wed, 05 Aug 2009)
New Revision: 8154
Modified:
core/trunk/src/main/java/org/jboss/cache/buddyreplication/JGroups28AddressLocator.java
core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java
Log:
Reverted back to JGroups 2.6 in some code as well, and removed JGroups 2.8 as a compile-time dep
Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/JGroups28AddressLocator.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/JGroups28AddressLocator.java 2009-08-05 14:33:21 UTC (rev 8153)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/JGroups28AddressLocator.java 2009-08-05 15:03:41 UTC (rev 8154)
@@ -3,9 +3,9 @@
import org.jgroups.Address;
import org.jgroups.Channel;
import org.jgroups.Event;
-import org.jgroups.PhysicalAddress;
import org.jgroups.stack.IpAddress;
+import java.lang.reflect.Field;
import java.net.InetAddress;
/**
@@ -16,6 +16,18 @@
*/
public class JGroups28AddressLocator extends JGroups26AddressLocator
{
+ int getPhysicalAddressEventId;
+
+ public JGroups28AddressLocator() {
+ try {
+ Class eventClass = Event.class;
+ Field f = eventClass.getField("GET_PHYSICAL_ADDRESS");
+ getPhysicalAddressEventId = (Integer) f.get(null);
+ } catch (Exception e) {
+ throw new RuntimeException("Unable to initialize AddressLocator", e);
+ }
+ }
+
@Override
public InetAddress locate(Channel channel, Address a)
{
@@ -25,9 +37,8 @@
}
else
{
- PhysicalAddress pa; // physical address (interface)
- pa = (PhysicalAddress) channel.downcall(new Event(Event.GET_PHYSICAL_ADDRESS, a));
- return super.locate(channel, pa);
+ Address physicalAddress = (Address) channel.downcall(new Event(getPhysicalAddressEventId, a));
+ return super.locate(channel, physicalAddress);
}
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java 2009-08-05 14:33:21 UTC (rev 8153)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java 2009-08-05 15:03:41 UTC (rev 8154)
@@ -308,16 +308,11 @@
{
private static final long serialVersionUID = -2628268587640985944L;
- public int compareTo(Address arg0)
+ public int compareTo(Object o)
{
return 0;
}
-// public int compareTo(Object o)
-// {
-// return 0;
-// }
-
public void readFrom(DataInputStream
arg0)
{
@@ -347,8 +342,5 @@
{
return false;
}
-
-
}
-
}
15 years, 4 months
JBoss Cache SVN: r8153 - core/trunk.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-08-05 10:33:21 -0400 (Wed, 05 Aug 2009)
New Revision: 8153
Modified:
core/trunk/pom.xml
Log:
Reverted back to JGroups 2.6.
Modified: core/trunk/pom.xml
===================================================================
--- core/trunk/pom.xml 2009-08-05 12:23:47 UTC (rev 8152)
+++ core/trunk/pom.xml 2009-08-05 14:33:21 UTC (rev 8153)
@@ -27,7 +27,8 @@
<dependency>
<groupId>jgroups</groupId>
<artifactId>jgroups</artifactId>
- <version>2.8.0.Beta2</version>
+ <!--<version>2.8.0.Beta2</version>-->
+ <version>2.6.9.GA</version>
</dependency>
<!--
15 years, 4 months
JBoss Cache SVN: r8152 - in core/trunk/src: main/java/org/jboss/cache/interceptors and 2 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-08-05 08:23:47 -0400 (Wed, 05 Aug 2009)
New Revision: 8152
Added:
core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesFailedRemotePrepareOptimisticTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesFailedRemotePrepareTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/Buddy3NodesFailedRemotePrepareTest.java
Modified:
core/trunk/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java
Log:
JBCACHE-1526 GlobalTransaction lost upon buddy fqn transformation of RollbackCommand
Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java 2009-08-05 11:55:43 UTC (rev 8151)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java 2009-08-05 12:23:47 UTC (rev 8152)
@@ -207,7 +207,7 @@
@Override
public Object visitRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
{
- return factory.buildRollbackCommand(null);
+ return factory.buildRollbackCommand(command.getGlobalTransaction());
}
@Override
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java 2009-08-05 11:55:43 UTC (rev 8151)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java 2009-08-05 12:23:47 UTC (rev 8152)
@@ -256,7 +256,7 @@
try
{
broadcastTxs.remove(gtx);
- RollbackCommand rollbackCommand = commandsFactory.buildRollbackCommand(null);
+ RollbackCommand rollbackCommand = commandsFactory.buildRollbackCommand(gtx);
if (log.isDebugEnabled())
log.debug("running remote rollback for " + gtx + " and coord=" + rpcManager.getLocalAddress());
Added: core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesFailedRemotePrepareOptimisticTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesFailedRemotePrepareOptimisticTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesFailedRemotePrepareOptimisticTest.java 2009-08-05 12:23:47 UTC (rev 8152)
@@ -0,0 +1,12 @@
+package org.jboss.cache.buddyreplication;
+
+import org.testng.annotations.Test;
+
+@Test(groups = "functional", testName = "buddyreplication.Buddy3NodesFailedRemotePrepareOptimisticTest")
+public class Buddy3NodesFailedRemotePrepareOptimisticTest extends Buddy3NodesFailedRemotePrepareTest
+{
+ public Buddy3NodesFailedRemotePrepareOptimisticTest()
+ {
+ optimistic = true;
+ }
+}
Property changes on: core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesFailedRemotePrepareOptimisticTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesFailedRemotePrepareTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesFailedRemotePrepareTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesFailedRemotePrepareTest.java 2009-08-05 12:23:47 UTC (rev 8152)
@@ -0,0 +1,100 @@
+package org.jboss.cache.buddyreplication;
+
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.util.TestingUtil;
+import org.jboss.cache.notifications.annotation.CacheListener;
+import org.jboss.cache.notifications.annotation.NodeModified;
+import org.jboss.cache.notifications.event.NodeModifiedEvent;
+import org.jboss.cache.transaction.DummyTransactionManagerLookup;
+import org.testng.annotations.Test;
+
+import javax.transaction.RollbackException;
+import javax.transaction.TransactionManager;
+import java.util.List;
+
+/**
+ * Tests that a failed PREPARE on a buddy results in a proper rollback.
+ *
+ * @author Brian Stansberry
+ * @since 3.1.12
+ */
+@Test(groups = "functional", testName = "buddyreplication.Buddy3NodesFailedRemotePrepareTest")
+public class Buddy3NodesFailedRemotePrepareTest extends BuddyReplicationTestsBase
+{
+ boolean optimistic = false;
+
+ @CacheListener
+ public static class FailureListener
+ {
+ private boolean rejected;
+
+ @NodeModified
+ public void nodeModified(NodeModifiedEvent event)
+ {
+ if (!rejected && !event.isOriginLocal() && event.getFqn().hasElement("0"))
+ {
+ rejected = true;
+ throw new RuntimeException("rejected");
+ }
+ }
+ }
+
+ @Test (invocationCount = 100)
+ public void testFailedPrepare() throws Exception
+ {
+ List<CacheSPI<Object, Object>> caches = createCaches(2, 3, false, false, optimistic, false);
+ cachesTL.set(caches);
+
+ int cacheNumber = 0;
+ for (CacheSPI<Object, Object> c : caches)
+ {
+ c.getConfiguration().setFetchInMemoryState(false);
+ c.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+ c.start();
+ c.put("/" + cacheNumber++, "k", "v");
+ }
+
+ waitForBuddy(caches.get(0), caches.get(1), false);
+ waitForBuddy(caches.get(0), caches.get(2), false);
+ waitForBuddy(caches.get(1), caches.get(2), false);
+ waitForBuddy(caches.get(1), caches.get(0), false);
+ waitForBuddy(caches.get(2), caches.get(0), false);
+ waitForBuddy(caches.get(2), caches.get(1), false);
+ Thread.sleep(2000);//wait for state transfer
+
+ caches.get(0).put("/0", "k", "v");
+ Fqn backup = fqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), Fqn.fromString("/0"));
+ assert (caches.get(1).exists(backup));
+ assert (caches.get(2).exists(backup));
+
+ caches.get(2).addCacheListener(new FailureListener());
+
+ TransactionManager tm = caches.get(0).getTransactionManager();
+ tm.begin();
+ caches.get(0).put("/0", "k", "v1");
+
+ try
+ {
+ tm.commit();
+ assert false : "Put should have thrown an exception";
+ }
+ catch (RollbackException expected)
+ {
+ expected.printStackTrace(System.out);
+ }
+
+ Object val = caches.get(0).get("/0", "k");
+ assert "v".equals(val) : "cache 0 had " + val;
+
+ caches.get(2).getInvocationContext().getOptionOverrides().setForceDataGravitation(true);
+ val = caches.get(2).get("/0", "k");
+ TestingUtil.sleepThread(100);
+ assert "v".equals(val) : "cache 2 had " + val;
+
+ caches.get(1).getInvocationContext().getOptionOverrides().setForceDataGravitation(true);
+ val = caches.get(1).get("/0", "k");
+ TestingUtil.sleepThread(100);
+ assert "v".equals(val) : "cache 1 had " + val;
+ }
+}
Property changes on: core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesFailedRemotePrepareTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/Buddy3NodesFailedRemotePrepareTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/Buddy3NodesFailedRemotePrepareTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/Buddy3NodesFailedRemotePrepareTest.java 2009-08-05 12:23:47 UTC (rev 8152)
@@ -0,0 +1,15 @@
+package org.jboss.cache.buddyreplication.mvcc;
+
+import org.jboss.cache.config.Configuration;
+import org.testng.annotations.Test;
+
+@Test(groups = "functional", testName = "buddyreplication.mvcc.Buddy3NodesFailedRemotePrepareTest")
+public class Buddy3NodesFailedRemotePrepareTest extends org.jboss.cache.buddyreplication.Buddy3NodesFailedRemotePrepareTest
+{
+ @Override
+ protected Configuration.NodeLockingScheme getNonOptimisticLockingScheme()
+ {
+ return Configuration.NodeLockingScheme.MVCC;
+ }
+
+}
Property changes on: core/trunk/src/test/java/org/jboss/cache/buddyreplication/mvcc/Buddy3NodesFailedRemotePrepareTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
15 years, 4 months
JBoss Cache SVN: r8151 - core/trunk/src/main/java/org/jboss/cache/buddyreplication.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-08-05 07:55:43 -0400 (Wed, 05 Aug 2009)
New Revision: 8151
Modified:
core/trunk/src/main/java/org/jboss/cache/buddyreplication/AddressLocator.java
core/trunk/src/main/java/org/jboss/cache/buddyreplication/JGroups26AddressLocator.java
core/trunk/src/main/java/org/jboss/cache/buddyreplication/JGroups28AddressLocator.java
core/trunk/src/main/java/org/jboss/cache/buddyreplication/NextMemberBuddyLocator.java
Log:
JBCACHE-1517 JGroups 2.8 compatibility
Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/AddressLocator.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/AddressLocator.java 2009-08-05 11:45:34 UTC (rev 8150)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/AddressLocator.java 2009-08-05 11:55:43 UTC (rev 8151)
@@ -1,6 +1,7 @@
package org.jboss.cache.buddyreplication;
import org.jgroups.Address;
+import org.jgroups.Channel;
import java.net.InetAddress;
@@ -11,5 +12,5 @@
* @since 3.2.0
*/
public interface AddressLocator {
- InetAddress locate(Address a);
+ InetAddress locate(Channel c, Address a);
}
Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/JGroups26AddressLocator.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/JGroups26AddressLocator.java 2009-08-05 11:45:34 UTC (rev 8150)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/JGroups26AddressLocator.java 2009-08-05 11:55:43 UTC (rev 8151)
@@ -1,6 +1,7 @@
package org.jboss.cache.buddyreplication;
import org.jgroups.Address;
+import org.jgroups.Channel;
import org.jgroups.stack.IpAddress;
import java.net.InetAddress;
@@ -13,7 +14,7 @@
*/
public class JGroups26AddressLocator implements AddressLocator
{
- public InetAddress locate(Address a)
+ public InetAddress locate(Channel c, Address a)
{
if (a instanceof IpAddress)
{
Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/JGroups28AddressLocator.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/JGroups28AddressLocator.java 2009-08-05 11:45:34 UTC (rev 8150)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/JGroups28AddressLocator.java 2009-08-05 11:55:43 UTC (rev 8151)
@@ -16,25 +16,18 @@
*/
public class JGroups28AddressLocator extends JGroups26AddressLocator
{
- private Channel channel;
-
- public JGroups28AddressLocator(Channel channel)
- {
- this.channel = channel;
- }
-
@Override
- public InetAddress locate(Address a)
+ public InetAddress locate(Channel channel, Address a)
{
if (a instanceof IpAddress)
{
- return super.locate(a);
+ return super.locate(channel, a);
}
else
{
PhysicalAddress pa; // physical address (interface)
pa = (PhysicalAddress) channel.downcall(new Event(Event.GET_PHYSICAL_ADDRESS, a));
- return super.locate(pa);
+ return super.locate(channel, pa);
}
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/NextMemberBuddyLocator.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/NextMemberBuddyLocator.java 2009-08-05 11:45:34 UTC (rev 8150)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/NextMemberBuddyLocator.java 2009-08-05 11:55:43 UTC (rev 8151)
@@ -89,7 +89,7 @@
try
{
getClass().getClassLoader().loadClass("org.jgroups.PhysicalAddress"); // this is new in JG 2.8
- addressLocator = new JGroups28AddressLocator(channel);
+ addressLocator = new JGroups28AddressLocator();
}
catch (ClassNotFoundException e)
{
@@ -180,8 +180,8 @@
protected boolean isColocated(Address candidate, Address dataOwner)
{
- InetAddress inetC = addressLocator.locate(candidate);
- InetAddress inetD = addressLocator.locate(dataOwner);
+ InetAddress inetC = addressLocator.locate(channel, candidate);
+ InetAddress inetD = addressLocator.locate(channel, dataOwner);
if (inetC.equals(inetD)) return true;
15 years, 4 months
JBoss Cache SVN: r8150 - in core/trunk/src: main/java/org/jboss/cache/marshall and 2 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-08-05 07:45:34 -0400 (Wed, 05 Aug 2009)
New Revision: 8150
Modified:
core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java
core/trunk/src/main/java/org/jboss/cache/jmx/LegacyConfiguration.java
core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java
core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/LegacyConfigurationTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java
Log:
JBCACHE-1517 JGroups 2.8 compatibility
Modified: core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java 2009-08-05 11:21:18 UTC (rev 8149)
+++ core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java 2009-08-05 11:45:34 UTC (rev 8150)
@@ -35,7 +35,6 @@
import org.jboss.cache.config.ConfigurationException;
import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.config.LegacyConfigurationException;
-import org.jboss.cache.config.RuntimeConfig;
import org.jboss.cache.config.parsing.JGroupsStackParser;
import org.jboss.cache.config.parsing.XmlConfigurationParser2x;
import org.jboss.cache.config.parsing.element.BuddyElementParser;
@@ -43,9 +42,7 @@
import org.jboss.cache.config.parsing.element.LoadersElementParser;
import org.jboss.cache.util.CachePrinter;
import org.jgroups.Address;
-import org.jgroups.Channel;
import org.jgroups.ChannelFactory;
-import org.jgroups.jmx.JChannelFactoryMBean;
import org.w3c.dom.Element;
import javax.management.*;
@@ -90,7 +87,6 @@
private Element evictionConfig;
private Element cacheLoaderConfig;
private Element clusterConfig;
- private JChannelFactoryMBean multiplexerService;
private BuddyElementParser buddyElementParser = new BuddyElementParser();
private LoadersElementParser loadersElementParser = new LoadersElementParser();
@@ -299,11 +295,6 @@
return getConfiguration().getLockAcquisitionTimeout();
}
- public JChannelFactoryMBean getMultiplexerService()
- {
- return multiplexerService;
- }
-
public String getMultiplexerStack()
{
return getConfiguration().getMultiplexerStack();
@@ -511,11 +502,6 @@
getConfiguration().setLockAcquisitionTimeout(timeout);
}
- public void setMultiplexerService(JChannelFactoryMBean muxService)
- {
- this.multiplexerService = muxService;
- }
-
public void setMultiplexerStack(String stackName)
{
getConfiguration().setMultiplexerStack(stackName);
@@ -958,10 +944,6 @@
log.debug("Constructing Cache");
CacheFactory<K, V> cf = new DefaultCacheFactory<K, V>();
setCache(cf.createCache(config, false));
- if (multiplexerService != null)
- {
- injectMuxChannel();
- }
}
protected boolean registerJmxResources() throws CacheException
@@ -990,28 +972,6 @@
// -------------------------------------------------------- Private methods
- private void injectMuxChannel() throws CacheException
- {
- Configuration cfg = getConfiguration();
- RuntimeConfig rtcfg = cfg.getRuntimeConfig();
-
- // Only inject if there isn't already a channel or factory
- if (rtcfg.getMuxChannelFactory() == null && rtcfg.getChannel() == null)
- {
- Channel ch;
- try
- {
- ch = multiplexerService.createMultiplexerChannel(cfg.getMultiplexerStack(), cfg.getClusterName());
- }
- catch (Exception e)
- {
- throw new CacheException("Exception creating multiplexed channel", e);
- }
- rtcfg.setChannel(ch);
- }
- }
-
-
/**
* Adds and removes the CacheListener.
* A counter is used to determine whether we have any clients who are
Modified: core/trunk/src/main/java/org/jboss/cache/jmx/LegacyConfiguration.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/jmx/LegacyConfiguration.java 2009-08-05 11:21:18 UTC (rev 8149)
+++ core/trunk/src/main/java/org/jboss/cache/jmx/LegacyConfiguration.java 2009-08-05 11:45:34 UTC (rev 8150)
@@ -23,7 +23,6 @@
import org.jboss.cache.Region;
import org.jgroups.ChannelFactory;
-import org.jgroups.jmx.JChannelFactoryMBean;
import org.w3c.dom.Element;
import javax.transaction.TransactionManager;
@@ -357,9 +356,4 @@
ChannelFactory getMuxChannelFactory();
void setMuxChannelFactory(ChannelFactory factory);
-
- JChannelFactoryMBean getMultiplexerService();
-
- void setMultiplexerService(JChannelFactoryMBean muxService);
-
}
\ No newline at end of file
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java 2009-08-05 11:21:18 UTC (rev 8149)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java 2009-08-05 11:45:34 UTC (rev 8150)
@@ -21,6 +21,8 @@
*/
package org.jboss.cache.marshall;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.RPCManager;
import org.jboss.cache.RPCManagerImpl.FlushTracker;
@@ -77,6 +79,7 @@
private Configuration configuration;
private RPCManager rpcManager;
private ReplicationObserver replicationObserver;
+ protected Log log = LogFactory.getLog(CommandAwareRpcDispatcher.class);
public CommandAwareRpcDispatcher() {}
Modified: core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/LegacyConfigurationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/LegacyConfigurationTest.java 2009-08-05 11:21:18 UTC (rev 8149)
+++ core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/LegacyConfigurationTest.java 2009-08-05 11:45:34 UTC (rev 8150)
@@ -46,17 +46,15 @@
import org.jboss.cache.loader.SingletonStoreCacheLoader;
import org.jboss.cache.loader.jdbm.JdbmCacheLoader;
import org.jboss.cache.lock.IsolationLevel;
-import org.jboss.cache.multiplexer.MultiplexerTestHelper;
import org.jboss.cache.transaction.BatchModeTransactionManagerLookup;
import org.jgroups.ChannelFactory;
import org.jgroups.JChannelFactory;
-import org.jgroups.jmx.JChannelFactoryMBean;
-import static org.testng.AssertJUnit.*;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertSame;
import org.testng.annotations.Test;
import org.w3c.dom.Element;
import javax.management.MBeanServerInvocationHandler;
-import javax.management.ObjectName;
import javax.transaction.TransactionManager;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
@@ -242,35 +240,35 @@
assertSame("Same ChannelFactory", cf, rc.getMuxChannelFactory());
}
- @SuppressWarnings("unchecked")
- public void testLegacyMuxChannelCreation() throws Exception
- {
- CacheJmxWrapperMBean<String, String> wrapper = new CacheJmxWrapper<String, String>();
- registerWrapper(wrapper);
+// @SuppressWarnings("unchecked")
+// public void testLegacyMuxChannelCreation() throws Exception
+// {
+// CacheJmxWrapperMBean<String, String> wrapper = new CacheJmxWrapper<String, String>();
+// registerWrapper(wrapper);
+//
+// wrapper = (CacheJmxWrapperMBean<String, String>) MBeanServerInvocationHandler.newProxyInstance(mBeanServer, mBeanName, CacheJmxWrapperMBean.class, false);
+// wrapper.setMultiplexerStack(MultiplexerTestHelper.MUX_STACK + Thread.currentThread().getName());
+//
+// JChannelFactory factory = new JChannelFactory();
+// factory.setDomain("jbc.mux.test");
+// factory.setExposeChannels(false);
+// factory.setMultiplexerConfig(MultiplexerTestHelper.getClusterConfigElement(getDefaultProperties()));
+//
+// ObjectName on = new ObjectName("jgroups:service=Mux");
+// mBeanServer.registerMBean(new org.jgroups.jmx.JChannelFactory(factory), on);
+//
+// wrapper.setMultiplexerService((JChannelFactoryMBean) MBeanServerInvocationHandler.newProxyInstance(mBeanServer, on, JChannelFactoryMBean.class, false));
+//
+// wrapper.start();
+//
+// RuntimeConfig rc = wrapper.getConfiguration().getRuntimeConfig();
+// assertNotNull("Channel created", rc.getChannel());
+//
+// //wrapper.stop();
+// //wrapper.destroy();
+//
+// }
- wrapper = (CacheJmxWrapperMBean<String, String>) MBeanServerInvocationHandler.newProxyInstance(mBeanServer, mBeanName, CacheJmxWrapperMBean.class, false);
- wrapper.setMultiplexerStack(MultiplexerTestHelper.MUX_STACK + Thread.currentThread().getName());
-
- JChannelFactory factory = new JChannelFactory();
- factory.setDomain("jbc.mux.test");
- factory.setExposeChannels(false);
- factory.setMultiplexerConfig(MultiplexerTestHelper.getClusterConfigElement(getDefaultProperties()));
-
- ObjectName on = new ObjectName("jgroups:service=Mux");
- mBeanServer.registerMBean(new org.jgroups.jmx.JChannelFactory(factory), on);
-
- wrapper.setMultiplexerService((JChannelFactoryMBean) MBeanServerInvocationHandler.newProxyInstance(mBeanServer, on, JChannelFactoryMBean.class, false));
-
- wrapper.start();
-
- RuntimeConfig rc = wrapper.getConfiguration().getRuntimeConfig();
- assertNotNull("Channel created", rc.getChannel());
-
- //wrapper.stop();
- //wrapper.destroy();
-
- }
-
protected static Element getBuddyReplicationConfig(boolean legacy) throws Exception
{
if (legacy)
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java 2009-08-05 11:21:18 UTC (rev 8149)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java 2009-08-05 11:45:34 UTC (rev 8150)
@@ -3,9 +3,9 @@
*/
package org.jboss.cache.optimistic;
-import org.jboss.cache.Cache;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.commands.VersionedDataCommand;
import org.jboss.cache.commands.WriteCommand;
import org.jboss.cache.config.CacheLoaderConfig;
@@ -40,7 +40,6 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
-import org.jboss.cache.UnitTestCacheFactory;
/**
* @author manik
@@ -314,10 +313,10 @@
return 0;
}
- public int compareTo(Object o)
- {
- return 0;
- }
+// public int compareTo(Object o)
+// {
+// return 0;
+// }
public void readFrom(DataInputStream
arg0)
15 years, 4 months
JBoss Cache SVN: r8149 - in core/trunk: src/main/java/org/jboss/cache/buddyreplication and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-08-05 07:21:18 -0400 (Wed, 05 Aug 2009)
New Revision: 8149
Added:
core/trunk/src/main/java/org/jboss/cache/buddyreplication/AddressLocator.java
core/trunk/src/main/java/org/jboss/cache/buddyreplication/JGroups26AddressLocator.java
core/trunk/src/main/java/org/jboss/cache/buddyreplication/JGroups28AddressLocator.java
Modified:
core/trunk/pom.xml
core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
core/trunk/src/main/java/org/jboss/cache/buddyreplication/NextMemberBuddyLocator.java
Log:
JBCACHE-1517 JGroups 2.8 compatibility
Modified: core/trunk/pom.xml
===================================================================
--- core/trunk/pom.xml 2009-08-05 10:54:02 UTC (rev 8148)
+++ core/trunk/pom.xml 2009-08-05 11:21:18 UTC (rev 8149)
@@ -27,7 +27,7 @@
<dependency>
<groupId>jgroups</groupId>
<artifactId>jgroups</artifactId>
- <version>2.6.7.GA</version>
+ <version>2.8.0.Beta2</version>
</dependency>
<!--
@@ -49,7 +49,7 @@
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jboss-common-core</artifactId>
- <version>2.2.10.GA</version>
+ <version>2.2.14.GA</version>
</dependency>
<!-- optional dependencies -->
Added: core/trunk/src/main/java/org/jboss/cache/buddyreplication/AddressLocator.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/AddressLocator.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/AddressLocator.java 2009-08-05 11:21:18 UTC (rev 8149)
@@ -0,0 +1,15 @@
+package org.jboss.cache.buddyreplication;
+
+import org.jgroups.Address;
+
+import java.net.InetAddress;
+
+/**
+ * Locates the InetAddress of an Address
+ *
+ * @author Manik Surtani
+ * @since 3.2.0
+ */
+public interface AddressLocator {
+ InetAddress locate(Address a);
+}
Property changes on: core/trunk/src/main/java/org/jboss/cache/buddyreplication/AddressLocator.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java 2009-08-05 10:54:02 UTC (rev 8148)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java 2009-08-05 11:21:18 UTC (rev 8149)
@@ -304,6 +304,12 @@
}
buddyGroup.setGroupName(buddyFqnTransformer.getGroupNameFromAddress(localAddress));
+ // make sure the NextMemberBuddyLocator has a ref to the Channel, to be able to convert a LogicalAddress to a PhysicalAddress.
+ if (buddyLocator instanceof NextMemberBuddyLocator)
+ {
+ ((NextMemberBuddyLocator) buddyLocator).setChannel(rpcManager.getChannel());
+ }
+
if (config.getBuddyPoolName() != null)
{
buddyPool.put(buddyGroup.getDataOwner(), config.getBuddyPoolName());
Added: core/trunk/src/main/java/org/jboss/cache/buddyreplication/JGroups26AddressLocator.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/JGroups26AddressLocator.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/JGroups26AddressLocator.java 2009-08-05 11:21:18 UTC (rev 8149)
@@ -0,0 +1,27 @@
+package org.jboss.cache.buddyreplication;
+
+import org.jgroups.Address;
+import org.jgroups.stack.IpAddress;
+
+import java.net.InetAddress;
+
+/**
+ * Address locator that has no knowledge of the new JGroups PhysicalAddress interface
+ *
+ * @author Manik Surtani
+ * @since 3.2.0
+ */
+public class JGroups26AddressLocator implements AddressLocator
+{
+ public InetAddress locate(Address a)
+ {
+ if (a instanceof IpAddress)
+ {
+ return ((IpAddress) a).getIpAddress();
+ }
+ else
+ {
+ throw new RuntimeException("Expected Address to be of type IpAddress. Instead, was " + a.getClass() + "! Don't know how to handle, giving up!");
+ }
+ }
+}
Property changes on: core/trunk/src/main/java/org/jboss/cache/buddyreplication/JGroups26AddressLocator.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: core/trunk/src/main/java/org/jboss/cache/buddyreplication/JGroups28AddressLocator.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/JGroups28AddressLocator.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/JGroups28AddressLocator.java 2009-08-05 11:21:18 UTC (rev 8149)
@@ -0,0 +1,40 @@
+package org.jboss.cache.buddyreplication;
+
+import org.jgroups.Address;
+import org.jgroups.Channel;
+import org.jgroups.Event;
+import org.jgroups.PhysicalAddress;
+import org.jgroups.stack.IpAddress;
+
+import java.net.InetAddress;
+
+/**
+ * An address locator that is able to deal with the JGroups 2.8 PhysicalAddress interface
+ *
+ * @author Manik Surtani
+ * @since 3.2.0
+ */
+public class JGroups28AddressLocator extends JGroups26AddressLocator
+{
+ private Channel channel;
+
+ public JGroups28AddressLocator(Channel channel)
+ {
+ this.channel = channel;
+ }
+
+ @Override
+ public InetAddress locate(Address a)
+ {
+ if (a instanceof IpAddress)
+ {
+ return super.locate(a);
+ }
+ else
+ {
+ PhysicalAddress pa; // physical address (interface)
+ pa = (PhysicalAddress) channel.downcall(new Event(Event.GET_PHYSICAL_ADDRESS, a));
+ return super.locate(pa);
+ }
+ }
+}
Property changes on: core/trunk/src/main/java/org/jboss/cache/buddyreplication/JGroups28AddressLocator.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/NextMemberBuddyLocator.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/NextMemberBuddyLocator.java 2009-08-05 10:54:02 UTC (rev 8148)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/NextMemberBuddyLocator.java 2009-08-05 11:21:18 UTC (rev 8149)
@@ -26,7 +26,7 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.config.BuddyReplicationConfig.BuddyLocatorConfig;
import org.jgroups.Address;
-import org.jgroups.stack.IpAddress;
+import org.jgroups.Channel;
import java.net.InetAddress;
import java.net.NetworkInterface;
@@ -56,12 +56,19 @@
private final Log log = LogFactory.getLog(NextMemberBuddyLocator.class);
private NextMemberBuddyLocatorConfig config = new NextMemberBuddyLocatorConfig();
+ private AddressLocator addressLocator;
+ private Channel channel;
public BuddyLocatorConfig getConfig()
{
return config;
}
+ public void setChannel(Channel channel)
+ {
+ this.channel = channel;
+ }
+
public void init(BuddyLocatorConfig buddyLocatorConfig)
{
if (buddyLocatorConfig instanceof NextMemberBuddyLocatorConfig)
@@ -77,6 +84,18 @@
// We were passed null; just use a default config
this.config = new NextMemberBuddyLocatorConfig();
}
+
+ // test if JGroups 2.8 is in use!
+ try
+ {
+ getClass().getClassLoader().loadClass("org.jgroups.PhysicalAddress"); // this is new in JG 2.8
+ addressLocator = new JGroups28AddressLocator(channel);
+ }
+ catch (ClassNotFoundException e)
+ {
+ // fall back to JGroups 2.6
+ addressLocator = new JGroups26AddressLocator();
+ }
}
public List<Address> locateBuddies(Map<Address, String> buddyPoolMap, List<Address> currentMembership, Address dataOwner)
@@ -151,7 +170,7 @@
return buddies;
}
- private boolean isInSameBuddyPool(Map<Address, String> buddyPoolMap, Address candidate, Address dataOwner)
+ protected boolean isInSameBuddyPool(Map<Address, String> buddyPoolMap, Address candidate, Address dataOwner)
{
if (buddyPoolMap == null) return true;
Object ownerPoolName = buddyPoolMap.get(dataOwner);
@@ -159,11 +178,10 @@
return !(ownerPoolName == null || candidatePoolName == null) && ownerPoolName.equals(candidatePoolName);
}
- private boolean isColocated(Address candidate, Address dataOwner)
+ protected boolean isColocated(Address candidate, Address dataOwner)
{
- // assume they're both IpAddresses??
- InetAddress inetC = ((IpAddress) candidate).getIpAddress();
- InetAddress inetD = ((IpAddress) dataOwner).getIpAddress();
+ InetAddress inetC = addressLocator.locate(candidate);
+ InetAddress inetD = addressLocator.locate(dataOwner);
if (inetC.equals(inetD)) return true;
15 years, 4 months
JBoss Cache SVN: r8148 - in core/trunk/src: test/java/org/jboss/cache/api/mvcc and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: galder.zamarreno(a)jboss.com
Date: 2009-08-05 06:54:02 -0400 (Wed, 05 Aug 2009)
New Revision: 8148
Added:
core/trunk/src/test/java/org/jboss/cache/api/mvcc/PutRemoveTest.java
Modified:
core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java
Log:
[JBCACHE-1519] (ClassCastException in ReadCommittedNode.markForUpdate()) Fixed by making sure that when parent node is updated after a removal, the parent is wrapped in a NodeReference if read committed is in use.
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java 2009-08-05 10:36:32 UTC (rev 8147)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java 2009-08-05 10:54:02 UTC (rev 8148)
@@ -35,6 +35,7 @@
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.NonVolatile;
import org.jboss.cache.factories.annotations.Start;
+import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.lock.LockManager;
import static org.jboss.cache.lock.LockType.WRITE;
import org.jboss.cache.lock.TimeoutException;
@@ -51,6 +52,7 @@
* locking, if necessary.
*
* @author Manik Surtani (<a href="mailto:manik AT jboss DOT org">manik AT jboss DOT org</a>)
+ * @author Galder Zamarreño
* @since 3.0
*/
@NonVolatile
@@ -196,7 +198,6 @@
// create a copy of the underlying node
n.markForUpdate(dataContainer, writeSkewCheck);
}
- if (trace) log.trace("Retrieving wrapped node " + fqn);
if (n.isDeleted() && createIfAbsent) {
if (trace) log.trace("Node is deleted in current scope. Need to un-delete.");
n.markAsDeleted(false);
@@ -335,7 +336,16 @@
// update child ref on parent to point to child as this is now a copy.
if (parentLockNeeded && (needToCopyNode || needToCopyParent)) {
if (parent == null) throw new NodeNotExistsException("Parent node " + parentFqn + " does not exist!");
- parent.getDelegationTarget().addChild(node.getDelegationTarget());
+ InternalNode ref = null;
+ if (configuration.getIsolationLevel() == IsolationLevel.READ_COMMITTED)
+ {
+ ref = new NodeReference(node.getDelegationTarget());
+ }
+ else
+ {
+ ref = node.getDelegationTarget();
+ }
+ parent.getDelegationTarget().addChild(ref);
}
// now deal with children.
Added: core/trunk/src/test/java/org/jboss/cache/api/mvcc/PutRemoveTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/PutRemoveTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/PutRemoveTest.java 2009-08-05 10:54:02 UTC (rev 8148)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.cache.api.mvcc;
+
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.factories.UnitTestConfigurationFactory;
+import org.jboss.cache.lock.IsolationLevel;
+import org.jboss.cache.transaction.DummyTransactionManagerLookup;
+import org.jboss.cache.util.TestingUtil;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import javax.transaction.TransactionManager;
+
+@Test(groups = { "functional" }, testName = "api.mvcc.PutRemoveTest")
+public class PutRemoveTest
+{
+ private CacheSPI<String, String> cache;
+ private TransactionManager tm;
+
+ @BeforeMethod(alwaysRun = true)
+ public void setUp() throws Exception
+ {
+ UnitTestCacheFactory<String, String> factory = new UnitTestCacheFactory<String, String>();
+ Configuration conf = UnitTestConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
+ conf.setIsolationLevel(IsolationLevel.READ_COMMITTED);
+ conf.setLockParentForChildInsertRemove(true);
+ conf.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+ cache = (CacheSPI<String, String>) factory.createCache(conf, true, getClass());
+ tm = cache.getTransactionManager();
+ }
+
+ @AfterMethod(alwaysRun = true)
+ public void tearDown() throws Exception
+ {
+ TestingUtil.killCaches(cache);
+ }
+
+ public void testPutRemove() throws Exception
+ {
+ Fqn fqn = Fqn.fromElements("test", "a", "b");
+
+ for (int i = 0; i < 5; i++)
+ {
+ System.out.println("i == " + i + " [1]");
+ tm.begin();
+ check(fqn);
+ tm.commit();
+
+ System.out.println("i == " + i + " [2]");
+ tm.begin();
+ // the exception is in remove() on the SECOND pass!
+ if (remove(fqn))
+ {
+ check(fqn);
+ }
+ tm.commit();
+ }
+ }
+
+ private void check(Fqn fqn)
+ {
+ if (cache.get(fqn.getAncestor(1), "a") == null)
+ {
+ cache.put(fqn.getAncestor(1), "key-a", "value-a");
+ cache.put(fqn, "test-key-a", "value-a");
+ }
+ }
+
+ private boolean remove(Fqn fqn)
+ {
+ return cache.removeNode(fqn.getAncestor(1));
+ }
+}
15 years, 4 months