-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from MissionCriticalCloud/fix/expand-sec-stora…
…ge-pool Expand sec storage pool based on required capacity
- Loading branch information
Showing
10 changed files
with
379 additions
and
376 deletions.
There are no files selected for viewing
271 changes: 88 additions & 183 deletions
271
cosmic-core/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
Large diffs are not rendered by default.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
.../server/src/main/java/com/cloud/storage/secondary/SecondaryStorageCapacityCalculator.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,9 @@ | ||
package com.cloud.storage.secondary; | ||
|
||
class SecondaryStorageCapacityCalculator { | ||
|
||
public int calculateRequiredCapacity(final int commandsStandBy, final int commandsPerVm) { | ||
final double ratio = (double) commandsStandBy / (double) commandsPerVm; | ||
return new Double(Math.ceil(ratio)).intValue(); | ||
} | ||
} |
256 changes: 97 additions & 159 deletions
256
...ic-core/server/src/main/java/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java
Large diffs are not rendered by default.
Oops, something went wrong.
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
46 changes: 46 additions & 0 deletions
46
cosmic-core/server/src/main/java/com/cloud/vm/AfterScanAction.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,46 @@ | ||
package com.cloud.vm; | ||
|
||
import org.apache.commons.lang.builder.ToStringBuilder; | ||
|
||
public class AfterScanAction { | ||
public enum Action { | ||
NOP, EXPAND, SHRINK | ||
} | ||
|
||
private final Action action; | ||
private final int value; | ||
|
||
private AfterScanAction(final Action action, final int value) { | ||
this.action = action; | ||
this.value = value; | ||
} | ||
|
||
public static AfterScanAction expand() { | ||
return new AfterScanAction(Action.EXPAND, 1); | ||
} | ||
|
||
public static AfterScanAction expand(final int ammoun) { | ||
return new AfterScanAction(Action.EXPAND, ammoun); | ||
} | ||
|
||
public static AfterScanAction shrink() { | ||
return new AfterScanAction(Action.SHRINK, 1); | ||
} | ||
|
||
public static AfterScanAction nop() { | ||
return new AfterScanAction(Action.NOP, 0); | ||
} | ||
|
||
public Action getAction() { | ||
return action; | ||
} | ||
|
||
public int getValue() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return ToStringBuilder.reflectionToString(this); | ||
} | ||
} |
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
46 changes: 46 additions & 0 deletions
46
...ver/src/test/java/com/cloud/storage/secondary/SecondaryStorageCapacityCalculatorTest.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,46 @@ | ||
package com.cloud.storage.secondary; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.core.Is.is; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collection; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
import org.junit.runners.Parameterized.Parameters; | ||
|
||
@RunWith(Parameterized.class) | ||
public class SecondaryStorageCapacityCalculatorTest { | ||
|
||
@Parameters(name = "{index}: calculateRequiredCapacity({0},{1})={2}") | ||
public static Collection<Integer[]> data() { | ||
return Arrays.asList(new Integer[][]{ | ||
{1, 1, 1}, {2, 2, 1}, {3, 3, 1}, {10, 10, 1}, // required capacity is exactly matched by 1 VM | ||
{2, 1, 2}, {3, 1, 3}, {4, 1, 4}, {5, 1, 5}, // required capacity is met by having as many VMs as the required stand by | ||
{4, 2, 2}, {6, 2, 3}, {8, 2, 4}, {10, 2, 5}, // required capacity is met by having as many VMs as the required stand by (x2) | ||
{6, 3, 2}, {9, 3, 3}, {12, 3, 4}, {15, 3, 5}, // required capacity is met by having as many VMs as the required stand by (x3) | ||
{1, 2, 1}, {1, 3, 1}, {2, 4, 1}, {3, 6, 1}, // required capacity is surpassed (single VM is enough) | ||
}); | ||
} | ||
|
||
private final int commandsStandBy; | ||
private final int commandsPerVm; | ||
private final int expected; | ||
|
||
public SecondaryStorageCapacityCalculatorTest(final int commandsStandBy, final int commandsPerVm, final int expected) { | ||
this.commandsStandBy = commandsStandBy; | ||
this.commandsPerVm = commandsPerVm; | ||
this.expected = expected; | ||
} | ||
|
||
@Test | ||
public void test_calculateRequiredCapacity() throws Exception { | ||
final SecondaryStorageCapacityCalculator calculator = new SecondaryStorageCapacityCalculator(); | ||
|
||
final int requiredVms = calculator.calculateRequiredCapacity(commandsStandBy, commandsPerVm); | ||
|
||
assertThat(requiredVms, is(expected)); | ||
} | ||
} |
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