Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
poolmanager: add possibility to create nested pool groups.
Motivation: Many sites have the setup like following: poolA-1,poolA-2,...poolZ-1,poolZ-2 pgroup-odd: poolA-1,...poolZ-1 pgroup-even: poolA-2,..poolZ-2 group-all: poolA-1,poolA-2,...poolZ-1,poolZ-2 The manual adding to all those pool groups might (and does) endup with invalid configuration. Moreover, this is not possible with dynamic groups. The configuration issue can be addressed by nested pool groups, which are identified by special prefix '@': i``` psu create pgroup -dynamic -tags=hw-class=IO io-pools psu create pgroup -dynamic -tags=hw-class=replica replica-pools psu create pgroup all-pools psu addto pgroup all-pools @io-pools @replica-pools ``` Modification: Update PGroup class to support poolgroups. Update addToPoolGroup/removeFromPoolGroup commands to support nested groups, identified by '@' prefix. Add unit tests to validate the behaviour. Result: More flexible pool manager config. Acked-by: Paul Millar Target: master Require-book: no Require-notes: yes
- Loading branch information
Showing
7 changed files
with
250 additions
and
23 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
101 changes: 101 additions & 0 deletions
101
modules/dcache/src/test/java/diskCacheV111/poolManager/PoolSelectionUnitV2Test.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,101 @@ | ||
package diskCacheV111.poolManager; | ||
|
||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
public class PoolSelectionUnitV2Test { | ||
|
||
private PoolSelectionUnitV2 psu; | ||
|
||
@Before | ||
public void setUp() { | ||
psu = new PoolSelectionUnitV2(); | ||
} | ||
|
||
@Test | ||
public void testAddGroup() { | ||
psu.createPoolGroup("group", false); | ||
psu.getPoolGroups().containsKey("group"); | ||
} | ||
|
||
@Test | ||
public void testAddPoolToGroup() { | ||
psu.createPoolGroup("group", false); | ||
psu.createPool("poolA", true, false, false); | ||
psu.addToPoolGroup("group", "poolA"); | ||
|
||
assertTrue(psu.getPoolGroups().get("group").getPools().contains(psu.getPool("poolA"))); | ||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void testNestedCyclicGroup() { | ||
psu.createPoolGroup("group", false); | ||
psu.addToPoolGroup("group", "@group"); | ||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void testNestedCyclicGroupChain() { | ||
psu.createPoolGroup("groupA", false); | ||
psu.createPoolGroup("groupB", false); | ||
psu.createPoolGroup("groupC", false); | ||
|
||
psu.addToPoolGroup("groupA", "@groupB"); | ||
psu.addToPoolGroup("groupB", "@groupC"); | ||
psu.addToPoolGroup("groupC", "@groupA"); | ||
} | ||
|
||
@Test | ||
public void testNestedGroup() { | ||
psu.createPoolGroup("group", false); | ||
|
||
psu.createPoolGroup("foo", false); | ||
psu.createPool("pool-foo", true, false, false); | ||
psu.addToPoolGroup("foo", "pool-foo"); | ||
|
||
psu.createPoolGroup("bar", false); | ||
psu.createPool("pool-bar", true, false, false); | ||
psu.addToPoolGroup("bar", "pool-bar"); | ||
|
||
psu.addToPoolGroup("group", "@foo"); | ||
psu.addToPoolGroup("group", "@bar"); | ||
|
||
assertTrue(psu.getPoolGroups().get("group").getPools().contains(psu.getPool("pool-foo"))); | ||
assertTrue(psu.getPoolGroups().get("group").getPools().contains(psu.getPool("pool-bar"))); | ||
} | ||
|
||
@Test | ||
public void testRemoveNestedGroup() { | ||
psu.createPoolGroup("group", false); | ||
psu.createPoolGroup("foo", false); | ||
psu.createPoolGroup("bar", false); | ||
|
||
|
||
psu.createPool("pool-foo", true, false, false); | ||
psu.addToPoolGroup("foo", "pool-foo"); | ||
|
||
psu.createPool("pool-bar", true, false, false); | ||
psu.addToPoolGroup("bar", "pool-bar"); | ||
|
||
psu.addToPoolGroup("group", "@foo"); | ||
psu.addToPoolGroup("group", "@bar"); | ||
|
||
psu.removeFromPoolGroup("group", "@foo"); | ||
|
||
assertFalse(psu.getPoolGroups().get("group").getPools().contains(psu.getPool("pool-foo"))); | ||
assertTrue(psu.getPoolGroups().get("group").getPools().contains(psu.getPool("pool-bar"))); | ||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void testRemoveMissingNestedGroup() { | ||
psu.createPoolGroup("group", false); | ||
psu.createPoolGroup("foo", false); | ||
psu.createPoolGroup("bar", false); | ||
|
||
psu.addToPoolGroup("group", "@foo"); | ||
|
||
psu.removeFromPoolGroup("group", "@bar"); | ||
} | ||
} |