-
Notifications
You must be signed in to change notification settings - Fork 628
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ISPN-1106 - Allow the users to start multiple caches at once
This is no longer strictly necessary for ISPN-1106, as we are waiting with a shorter timeout on transactions with locks and so the rehash does not block for a very long period of time. It is recommended however to start all caches on application startup, and this method provides an easy way for users to start all their caches.
- Loading branch information
1 parent
6ed94d3
commit 548fa62
Showing
4 changed files
with
181 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
core/src/test/java/org/infinispan/api/ParallelCacheStartTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2011 Red Hat Inc. and/or its affiliates and other contributors | ||
* as indicated by the @author tags. All rights reserved. | ||
* See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* This copyrighted material is made available to anyone wishing to use, | ||
* modify, copy, or redistribute it subject to the terms and conditions | ||
* of the GNU Lesser General Public License, v. 2.1. | ||
* This program is distributed in the hope that it will be useful, but WITHOUT A | ||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. | ||
* You should have received a copy of the GNU Lesser General Public License, | ||
* v.2.1 along with this distribution; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
* MA 02110-1301, USA. | ||
*/ | ||
package org.infinispan.api; | ||
|
||
import org.infinispan.Cache; | ||
import org.infinispan.config.Configuration; | ||
import org.infinispan.config.Configuration.CacheMode; | ||
import org.infinispan.manager.EmbeddedCacheManager; | ||
import org.infinispan.test.MultipleCacheManagersTest; | ||
import org.infinispan.test.TestingUtil; | ||
import org.testng.annotations.Test; | ||
|
||
import java.util.List; | ||
|
||
@Test(groups = "functional", testName = "api.ParallelCacheStartTest") | ||
public class ParallelCacheStartTest extends MultipleCacheManagersTest { | ||
Cache cache1, cache2; | ||
EmbeddedCacheManager cm1, cm2; | ||
Configuration cfg; | ||
|
||
public ParallelCacheStartTest() { | ||
cleanup = CleanupPhase.AFTER_METHOD; | ||
} | ||
|
||
protected void createCacheManagers() throws Throwable { | ||
cm1 = addClusterEnabledCacheManager(); | ||
cfg = new Configuration(); | ||
cfg.setCacheMode(CacheMode.REPL_SYNC); | ||
cfg.setFetchInMemoryState(false); | ||
cm1.defineConfiguration("cache1", cfg); | ||
cm1.defineConfiguration("cache2", cfg); | ||
} | ||
|
||
public void testParallelStartup() throws Exception { | ||
// start both caches in parallel | ||
cm1.startCaches("cache1", "cache2"); | ||
List memb1 = cm1.getMembers(); | ||
assert 1 == memb1.size() : "Expected 1 member; was " + memb1; | ||
|
||
Object coord = memb1.get(0); | ||
|
||
cm2 = addClusterEnabledCacheManager(); | ||
cm2.defineConfiguration("cache1", cfg); | ||
cm2.defineConfiguration("cache2", cfg); | ||
|
||
// again start both caches in parallel | ||
cm2.startCaches("cache1", "cache2"); | ||
|
||
TestingUtil.blockUntilViewsReceived(50000, true, cm1, cm2); | ||
memb1 = cm1.getMembers(); | ||
List memb2 = cm2.getMembers(); | ||
assert 2 == memb1.size(); | ||
assert memb1.equals(memb2); | ||
|
||
cm1.stop(); | ||
TestingUtil.blockUntilViewsReceived(50000, false, cm2); | ||
|
||
memb2 = cm2.getMembers(); | ||
assert 1 == memb2.size(); | ||
assert !coord.equals(memb2.get(0)); | ||
} | ||
} |