Skip to content

Commit

Permalink
ISPN-1123 - Fix intermittent failures in SampleConfigFilesCorrectness…
Browse files Browse the repository at this point in the history
…Test

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.
  • Loading branch information
Dan Berindei committed Jun 26, 2011
1 parent 55843e4 commit 837caaa
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions core/src/main/java/org/infinispan/util/logging/Log.java
Expand Up @@ -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();
}
Expand Up @@ -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<String, Configuration> e : named.entrySet()) cm.defineConfiguration(e.getKey(), e.getValue());
Expand Down Expand Up @@ -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);
}

Expand Down
Expand Up @@ -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);
Expand Down

0 comments on commit 837caaa

Please sign in to comment.