From 837caaabdf41cf61dfb940998fd377182cf02f73 Mon Sep 17 00:00:00 2001 From: Dan Berindei Date: Wed, 22 Jun 2011 15:22:01 +0300 Subject: [PATCH] ISPN-1123 - Fix intermittent failures in SampleConfigFilesCorrectnessTest SampleConfigFilesCorrectnessTest and EHCache2InfinispanTransformerTest were using the default JGroups configuration, so they would join the same cluster if they ran at the same time. Since they both use the default cache, when one of the caches was distributed and the other replicated, the replicated cache would throw a NPE while executing a RehashControlCommand from the distributed cache. --- .../infinispan/commands/control/RehashControlCommand.java | 4 ++++ core/src/main/java/org/infinispan/util/logging/Log.java | 4 ++++ .../org/infinispan/test/fwk/TestCacheManagerFactory.java | 3 ++- .../tx/recovery/admin/SimpleCacheRecoveryAdminTest.java | 6 +++--- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/org/infinispan/commands/control/RehashControlCommand.java b/core/src/main/java/org/infinispan/commands/control/RehashControlCommand.java index 2126093c5e40..b4d880dd7455 100644 --- a/core/src/main/java/org/infinispan/commands/control/RehashControlCommand.java +++ b/core/src/main/java/org/infinispan/commands/control/RehashControlCommand.java @@ -115,6 +115,10 @@ public RehashControlCommand(Transport transport) { public void init(DistributionManager distributionManager, Configuration configuration, DataContainer dataContainer, CommandsFactory commandsFactory) { + if (!configuration.getCacheMode().isDistributed()) { + log.rehashCommandReceivedOnNonDistributedCache(); + throw new IllegalStateException("Rehash command received on non-distributed cache"); + } this.distributionManager = distributionManager; this.configuration = configuration; this.dataContainer = dataContainer; diff --git a/core/src/main/java/org/infinispan/util/logging/Log.java b/core/src/main/java/org/infinispan/util/logging/Log.java index a40619d96a46..599e8c64cc8e 100644 --- a/core/src/main/java/org/infinispan/util/logging/Log.java +++ b/core/src/main/java/org/infinispan/util/logging/Log.java @@ -717,4 +717,8 @@ void asyncStoreShutdownTimeoutTooHigh(long configuredAsyncStopTimeout, @LogMessage(level = WARN) @Message(value = "Fetch persistent state and purge on startup are both disabled, cache may contain stale entries on startup") void staleEntriesWithoutFetchPersistentStateOrPurgeOnStartup(); + + @LogMessage(level = FATAL) + @Message(value = "Rehash command received on non-distributed cache. All the nodes in the cluster should be using the same configuration.", id = 150) + void rehashCommandReceivedOnNonDistributedCache(); } diff --git a/core/src/test/java/org/infinispan/test/fwk/TestCacheManagerFactory.java b/core/src/test/java/org/infinispan/test/fwk/TestCacheManagerFactory.java index 82afc366f79c..c3cd8183292b 100644 --- a/core/src/test/java/org/infinispan/test/fwk/TestCacheManagerFactory.java +++ b/core/src/test/java/org/infinispan/test/fwk/TestCacheManagerFactory.java @@ -100,6 +100,7 @@ private static EmbeddedCacheManager fromConfigFileParser(InfinispanConfiguration Configuration c = parser.parseDefaultConfiguration(); minimizeThreads(gc); + amendTransport(gc); EmbeddedCacheManager cm = newDefaultCacheManager(true, gc, c, false); for (Map.Entry e : named.entrySet()) cm.defineConfiguration(e.getKey(), e.getValue()); @@ -242,7 +243,7 @@ public static EmbeddedCacheManager createCacheManager(GlobalConfiguration config return newDefaultCacheManager(true, configuration, defaultCfg, false); } - private static EmbeddedCacheManager createCacheManager(GlobalConfiguration configuration, Configuration defaultCfg, boolean transactional, boolean keepJmxDomainName) { + public static EmbeddedCacheManager createCacheManager(GlobalConfiguration configuration, Configuration defaultCfg, boolean transactional, boolean keepJmxDomainName) { return createCacheManager(configuration, defaultCfg, transactional, keepJmxDomainName, false); } diff --git a/core/src/test/java/org/infinispan/tx/recovery/admin/SimpleCacheRecoveryAdminTest.java b/core/src/test/java/org/infinispan/tx/recovery/admin/SimpleCacheRecoveryAdminTest.java index 537ff74ecde2..0efc238ff839 100644 --- a/core/src/test/java/org/infinispan/tx/recovery/admin/SimpleCacheRecoveryAdminTest.java +++ b/core/src/test/java/org/infinispan/tx/recovery/admin/SimpleCacheRecoveryAdminTest.java @@ -72,9 +72,9 @@ protected void createCacheManagers() throws Throwable { .clustering().hash().numOwners(3) .clustering().l1().disable() .build(); - EmbeddedCacheManager cm1 = TestCacheManagerFactory.createCacheManager(globalConfiguration, configuration, false, true, false); - EmbeddedCacheManager cm2 = TestCacheManagerFactory.createCacheManager(globalConfiguration, configuration, false, true, false); - EmbeddedCacheManager cm3 = TestCacheManagerFactory.createCacheManager(globalConfiguration, configuration, false, true, false); + EmbeddedCacheManager cm1 = TestCacheManagerFactory.createCacheManager(globalConfiguration, configuration, false, true); + EmbeddedCacheManager cm2 = TestCacheManagerFactory.createCacheManager(globalConfiguration, configuration, false, true); + EmbeddedCacheManager cm3 = TestCacheManagerFactory.createCacheManager(globalConfiguration, configuration, false, true); registerCacheManager(cm1); registerCacheManager(cm2); registerCacheManager(cm3);