Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ISPN-9699 Global 0.0f Capacity Factor
- Loading branch information
Showing
19 changed files
with
268 additions
and
62 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
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
59 changes: 59 additions & 0 deletions
59
core/src/test/java/org/infinispan/distribution/ZeroCapacityNodeTest.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,59 @@ | ||
package org.infinispan.distribution; | ||
|
||
import static org.testng.AssertJUnit.assertEquals; | ||
|
||
import java.util.Map; | ||
|
||
import org.infinispan.configuration.cache.CacheMode; | ||
import org.infinispan.configuration.cache.ConfigurationBuilder; | ||
import org.infinispan.configuration.global.GlobalConfigurationBuilder; | ||
import org.infinispan.distribution.ch.ConsistentHash; | ||
import org.infinispan.distribution.ch.impl.DefaultConsistentHash; | ||
import org.infinispan.distribution.group.impl.PartitionerConsistentHash; | ||
import org.infinispan.manager.EmbeddedCacheManager; | ||
import org.infinispan.remoting.transport.Address; | ||
import org.infinispan.test.MultipleCacheManagersTest; | ||
import org.infinispan.test.TestingUtil; | ||
import org.testng.annotations.Test; | ||
|
||
/** | ||
* Test the capacity factor for lite instance | ||
* | ||
* @author Katia Aresti | ||
* @since 9.4 | ||
*/ | ||
@Test(groups = "functional", testName = "distribution.ch.ZeroCapacityNodeTest") | ||
public class ZeroCapacityNodeTest extends MultipleCacheManagersTest { | ||
|
||
public static final int NUM_SEGMENTS = 60; | ||
|
||
@Override | ||
protected void createCacheManagers() throws Throwable { | ||
// Do nothing here, create the cache managers in the test | ||
} | ||
|
||
public void testCapacityFactorContainingAZeroCapacityNode() { | ||
|
||
ConfigurationBuilder cb = new ConfigurationBuilder(); | ||
cb.clustering().cacheMode(CacheMode.DIST_SYNC); | ||
cb.clustering().hash().numSegments(NUM_SEGMENTS); | ||
cb.clustering().hash().capacityFactor(0.5f); | ||
|
||
EmbeddedCacheManager node1 = addClusterEnabledCacheManager(GlobalConfigurationBuilder.defaultClusteredBuilder(), cb); | ||
EmbeddedCacheManager node2 = addClusterEnabledCacheManager(GlobalConfigurationBuilder.defaultClusteredBuilder(), cb); | ||
EmbeddedCacheManager zeroCapacityNode = addClusterEnabledCacheManager(GlobalConfigurationBuilder.defaultClusteredBuilder().zeroCapacityNode(true), cb); | ||
|
||
waitForClusterToForm(); | ||
assertCapacityFactors(node1, 0.5f); | ||
assertCapacityFactors(node2, 0.5f); | ||
assertCapacityFactors(zeroCapacityNode, 0.0f); | ||
} | ||
|
||
private void assertCapacityFactors(EmbeddedCacheManager cm, float expectedCapacityFactors) { | ||
ConsistentHash ch = cache(0).getAdvancedCache().getDistributionManager().getReadConsistentHash(); | ||
DefaultConsistentHash dch = | ||
(DefaultConsistentHash) TestingUtil.extractField(PartitionerConsistentHash.class, ch, "ch"); | ||
Map<Address, Float> capacityFactors = dch.getCapacityFactors(); | ||
assertEquals(expectedCapacityFactors, capacityFactors.get(cm.getAddress()), 0.0); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.infinispan.feature.zero-capacity-node=true |
20 changes: 20 additions & 0 deletions
20
counter/src/test/java/org/infinispan/counter/StrongCounterWithZeroCapacityNodesTest.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,20 @@ | ||
package org.infinispan.counter; | ||
|
||
import org.infinispan.configuration.global.GlobalConfigurationBuilder; | ||
import org.testng.annotations.Test; | ||
|
||
/** | ||
* A simple consistency test for {@link org.infinispan.counter.api.StrongCounter} where some nodes are capacity factor | ||
* 0. | ||
* | ||
* @author Katia Aresti, karesti@redhat.com | ||
* @since 9.4 | ||
*/ | ||
@Test(groups = "functional", testName = "counter.StrongCounterWithZeroCapacityNodesTest") | ||
public class StrongCounterWithZeroCapacityNodesTest extends StrongCounterTest { | ||
|
||
@Override | ||
protected GlobalConfigurationBuilder configure(int nodeId) { | ||
return GlobalConfigurationBuilder.defaultClusteredBuilder().zeroCapacityNode(nodeId % 2 == 0); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
counter/src/test/java/org/infinispan/counter/WeakCounterWithZeroCapacityNodesTest.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,20 @@ | ||
package org.infinispan.counter; | ||
|
||
import org.infinispan.configuration.global.GlobalConfigurationBuilder; | ||
import org.infinispan.counter.api.WeakCounter; | ||
import org.testng.annotations.Test; | ||
|
||
/** | ||
* A simple consistency test for {@link WeakCounter} with zero capacity nodes. | ||
* | ||
* @author Katia Aresti, karesti@redhat.com | ||
* @since 9.4 | ||
*/ | ||
@Test(groups = "functional", testName = "counter.WeakCounterWithZeroCapacityNodesTest") | ||
public class WeakCounterWithZeroCapacityNodesTest extends WeakCounterTest { | ||
|
||
@Override | ||
protected GlobalConfigurationBuilder configure(int nodeId) { | ||
return GlobalConfigurationBuilder.defaultClusteredBuilder().zeroCapacityNode(nodeId % 2 == 0); | ||
} | ||
} |
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
Oops, something went wrong.