Commit 7f7236d9 authored by Jonathan Shahen's avatar Jonathan Shahen
Browse files

Allow running of EqualSpreadCLients and equalSpreadClientsHalf

parent c3df61f5
......@@ -92,10 +92,12 @@ public class VagabondCUI {
public static void printCommonCommands() {
System.out.println("\n\n--- Common Commands ---");
System.out.println("-settings tests/simpletest.properties !exit");
System.out.println("-settings tests/simpletestILP-Random.properties !exit");
System.out.println("-settings tests/simpletestILP-NomadSubOptimal.properties !exit");
System.out.println("-loglevel verbose -settings tests/simpletest.properties !exit");
System.out.println("-loglevel verbose -settings tests/simpletestILP-Random.properties !exit");
System.out.println("-loglevel verbose -settings tests/simpletestILP-NomadSubOptimal.properties !exit");
System.out.println("-loglevel verbose -settings tests/equalSpread_10.properties !exit");
System.out.println("");
System.out.println("-loglevel verbose -settings tests/simpletestILP-NomadSubOptimal.properties !exit");
System.out.println("-noplacementmaps -loglevel verbose "
+ "-settings tests/simpletestILP-NomadSubOptimal.properties !exit");
System.out.println("");
......
......@@ -26,6 +26,7 @@ import vagabond.reduction.ilp.RunSolverILP;
import vagabond.reduction.nomad.ReduceToNomad;
import vagabond.reduction.nomad.RunSolverNomad;
import vagabond.singleton.VagabondSettings;
import vagabond.testing.PlacementMapExamples;
import vagabond.timing.StatisticsManager;
import vagabond.timing.TimingManager;
......@@ -86,6 +87,12 @@ public class VagabondInstance {
case PLACEMENT_FILE:
placementMap = PlacementMapFile.readPlacementMap(settings.inputPlacementMapFilePath);
break;
case PLACEMENT_EQUALSPREAD:
placementMap = PlacementMapExamples.equalSpreadClients(settings.equalSpreadNum);
break;
case PLACEMENT_EQUALSPREADHALF:
placementMap = PlacementMapExamples.equalSpreadClientsHalfFull(settings.equalSpreadNum);
break;
default:
logger.severe("No placement algorithm was picked, or one that is not implemented is used. "
+ "PlacementAlgorithm:" + settings.placementAlgorithm);
......@@ -118,7 +125,7 @@ public class VagabondInstance {
*/
for (int e = 0; e < settings.numberOfEpochs; e++) {
/* Timing */timing.startTimer("VagabondInstance::main()::epochLoop::" + e);
logger.info("Starting EPOCH " + e);
logger.info("Starting EPOCH " + e + " LOOP");
switch (settings.reductionAlgorithm) {
case REDUCTION_SAT:
......@@ -152,6 +159,7 @@ public class VagabondInstance {
/**
* Reduce the current EpochHistory
*/
logger.info("Reducing for EPOCH " + e);
// ERROR CHECKING if the reduction occurred any problems
if (reduction.reduce(epochHistory) == false) {
String placementMapFilePath = settings.logFolder + File.separator + settings.placementMapFile;
......@@ -298,36 +306,6 @@ public class VagabondInstance {
String value = null;
ArrayList<String> mustContain = VagabondOptionString.getRequiredControlSettings();
value = prop.getProperty(VagabondOptionString.NUMMACHINES.toString(), null);
if (value != null) {
mustContain.remove(VagabondOptionString.NUMMACHINES.toString());
settings.numberOfMachines = Integer.valueOf(value);
}
value = prop.getProperty(VagabondOptionString.NUMSLOTS.toString(), null);
if (value != null) {
mustContain.remove(VagabondOptionString.NUMSLOTS.toString());
settings.numberOfMachineSlots = Integer.valueOf(value);
}
value = prop.getProperty(VagabondOptionString.NUMCLIENTS.toString(), null);
if (value != null) {
mustContain.remove(VagabondOptionString.NUMCLIENTS.toString());
settings.numberOfClients = Integer.valueOf(value);
}
value = prop.getProperty(VagabondOptionString.NUMVMS.toString(), null);
if (value != null) {
mustContain.remove(VagabondOptionString.NUMVMS.toString());
settings.numberOfVMsPerClient = Integer.valueOf(value);
}
value = prop.getProperty(VagabondOptionString.FILLINEMPTY.toString(), null);
if (value != null) {
mustContain.remove(VagabondOptionString.FILLINEMPTY.toString());
settings.fillInEmptySpots = ConvertBooleanWithException.convert(value);
}
value = prop.getProperty(VagabondOptionString.EPOCHS.toString(), null);
if (value != null) {
mustContain.remove(VagabondOptionString.EPOCHS.toString());
......@@ -346,12 +324,16 @@ public class VagabondInstance {
settings.migrationBudget = Integer.valueOf(value);
}
boolean inputMachinesClientsRequired = false;
value = prop.getProperty(VagabondOptionString.PLACEMENT.toString(), null);
if (value != null) {
mustContain.remove(VagabondOptionString.PLACEMENT.toString());
if (value.equals(VagabondOptionString.PLACEMENT_RANDOM.toString())) {
settings.placementAlgorithm = VagabondOptionString.PLACEMENT_RANDOM;
// Required Settings
inputMachinesClientsRequired = true;
} else if (value.equals(VagabondOptionString.PLACEMENT_FILE.toString())) {
value = prop.getProperty(VagabondOptionString.PLACEMENTFILEPATH.toString(), null);
if (value == null) { throw new IllegalArgumentException("Must provide a placement file path!"); }
......@@ -363,6 +345,18 @@ public class VagabondInstance {
settings.placementAlgorithm = VagabondOptionString.PLACEMENT_FILE;
settings.inputPlacementMapFilePath = value;
} else if (value.equals(VagabondOptionString.PLACEMENT_EQUALSPREAD.toString())) {
value = prop.getProperty(VagabondOptionString.EQUALSPREADNUM.toString(), null);
if (value == null) { throw new IllegalArgumentException("Must provide a equalSpreadNum!"); }
settings.placementAlgorithm = VagabondOptionString.PLACEMENT_EQUALSPREAD;
settings.equalSpreadNum = Integer.valueOf(value);
} else if (value.equals(VagabondOptionString.PLACEMENT_EQUALSPREADHALF.toString())) {
value = prop.getProperty(VagabondOptionString.EQUALSPREADNUM.toString(), null);
if (value == null) { throw new IllegalArgumentException("Must provide a equalSpreadNum!"); }
settings.placementAlgorithm = VagabondOptionString.PLACEMENT_EQUALSPREADHALF;
settings.equalSpreadNum = Integer.valueOf(value);
} else {
throw new IllegalArgumentException("Placement Algorithm: " + value + " does not exist!");
}
......@@ -384,6 +378,43 @@ public class VagabondInstance {
}
// OPTIONAL SETTINGS
// The optional status of these is dependent on the Placement Algorithm
if (inputMachinesClientsRequired) {
value = prop.getProperty(VagabondOptionString.NUMMACHINES.toString(), null);
if (value != null) {
mustContain.remove(VagabondOptionString.NUMMACHINES.toString());
settings.numberOfMachines = Integer.valueOf(value);
}
value = prop.getProperty(VagabondOptionString.NUMSLOTS.toString(), null);
if (value != null) {
mustContain.remove(VagabondOptionString.NUMSLOTS.toString());
settings.numberOfMachineSlots = Integer.valueOf(value);
}
value = prop.getProperty(VagabondOptionString.NUMCLIENTS.toString(), null);
if (value != null) {
mustContain.remove(VagabondOptionString.NUMCLIENTS.toString());
}
value = prop.getProperty(VagabondOptionString.NUMVMS.toString(), null);
if (value != null) {
mustContain.remove(VagabondOptionString.NUMVMS.toString());
settings.numberOfClients = Integer.valueOf(value);
settings.numberOfVMsPerClient = Integer.valueOf(value);
}
} else {
mustContain.remove(VagabondOptionString.NUMVMS.toString());
mustContain.remove(VagabondOptionString.NUMCLIENTS.toString());
mustContain.remove(VagabondOptionString.NUMSLOTS.toString());
mustContain.remove(VagabondOptionString.NUMMACHINES.toString());
}
value = prop.getProperty(VagabondOptionString.FILLINEMPTY.toString(), null);
if (value != null) {
settings.fillInEmptySpots = ConvertBooleanWithException.convert(value);
}
value = prop.getProperty(VagabondOptionString.RANDOMSEED.toString(), null);
if (value != null) {
settings.randomSeed = Integer.valueOf(value);
......
......@@ -2,6 +2,8 @@ package vagabond;
import java.util.ArrayList;
import vagabond.testing.PlacementMapExamples;
/**
* Holds Command Line Options as well as strings that can be contained in the Settings file.
* @author Jonathan Shahen
......@@ -123,7 +125,8 @@ public enum VagabondOptionString {
*/
SLIDINGWINDOW("slidingWindow"),
/**
* [Settings File Property] The maximum number of migrations allowed per EPOCH.
* [Settings File Property] The maximum number of migrations allowed per EPOCH. If -1 then do not have a migration
* budget.
* @vagabond.category Settings File Property
*/
MIGRATIONBUDGET("migrationBudget"),
......@@ -132,6 +135,12 @@ public enum VagabondOptionString {
* @vagabond.category Settings File Property
*/
RANDOMSEED("seed"),
/**
* [Settings File Property] This is an optional setting for controlling the number sent to
* {@link PlacementMapExamples#equalSpreadClients(int)}
* @vagabond.category Settings File Property
*/
EQUALSPREADNUM("equalSpreadNum"),
/**
* [Settings File Property] This is an optional setting for setting the placement map file when
* {@link #PLACEMENT_FILE} is used.
......@@ -162,6 +171,18 @@ public enum VagabondOptionString {
*/
PLACEMENT_FILE("readFile"),
/**
* [Placement Algorithms] Generates a placement map using {@link PlacementMapExamples#equalSpreadClients(int)}
* @vagabond.category Placement Algorithms
*/
PLACEMENT_EQUALSPREAD("equalSpread"),
/**
* [Placement Algorithms] Generates a placement map using {@link PlacementMapExamples#equalSpreadClientsHalf(int)}
* @vagabond.category Placement Algorithms
*/
PLACEMENT_EQUALSPREADHALF("equalSpreadHalf"),
// Reduction Algorithms
/**
* [Reduction Algorithms] Reduces a PlacementMap to CSAT and then to CNF-SAT and then runs it through Minisat
......@@ -219,17 +240,18 @@ public enum VagabondOptionString {
public static ArrayList<String> getRequiredControlSettings() {
ArrayList<String> list = new ArrayList<String>();
list.add(NUMMACHINES._str);
list.add(NUMSLOTS._str);
list.add(NUMCLIENTS._str);
list.add(NUMVMS._str);
list.add(FILLINEMPTY._str);
list.add(EPOCHS._str);
list.add(SLIDINGWINDOW._str);
list.add(MIGRATIONBUDGET._str);
list.add(PLACEMENT._str);
list.add(REDUCTION._str);
// Semi-Optional
list.add(NUMMACHINES._str);
list.add(NUMSLOTS._str);
list.add(NUMCLIENTS._str);
list.add(NUMVMS._str);
return list;
}
......
......@@ -95,6 +95,13 @@ public class PlacementMapFile {
}
}
// Update the settings file
VagabondSettings s = VagabondSettings.getInstance();
s.numberOfClients = place.getNumberOfClients();
s.numberOfMachines = place.getNumberOfMachines();
s.numberOfMachineSlots = place.getMaxNumberOfSlotsPerMachine();
s.numberOfVMsPerClient = place.getMaxNumberOfVMsPerClient();
return place;
}
......
......@@ -10,6 +10,7 @@ import vagabond.enums.PlacementMapDisplayStyle;
import vagabond.helper.ErrorPrinter;
import vagabond.logging.CSVFileFormatter;
import vagabond.logging.ConsoleFormatter;
import vagabond.testing.PlacementMapExamples;
import vagabond.timing.StatisticsManager;
import vagabond.timing.TimingManager;
......@@ -146,6 +147,12 @@ public class VagabondSettings {
*/
public String inputPlacementMapFilePath = null;
/**
* Stores the number to be passed to {@link PlacementMapExamples#equalSpreadClients(int)}
* @see VagabondOptionString#EQUALSPREADNUM
*/
public Integer equalSpreadNum = 0;
/**
* Prevents programmers from creating their own settings, there must be only one copy of this.
* @see #getInstance()
......@@ -169,16 +176,31 @@ public class VagabondSettings {
StringBuilder s = new StringBuilder();
s.append("VagabondSettings{");
s.append("placementAlgorithm=" + numberOfMachines + ", ");
s.append("numberOfMachines=" + numberOfMachines + ", ");
s.append("numberOfMachineSlots=" + numberOfMachineSlots + ", ");
s.append("numberOfClients=" + numberOfClients + ", ");
s.append("numberOfVMsPerClient=" + numberOfVMsPerClient + ", ");
s.append("clientVmsOffByOne=" + fillInEmptySpots + ", ");
s.append("placementAlgorithm=" + placementAlgorithm + ", ");
s.append("reductionAlgorithm=" + reductionAlgorithm + ", ");
s.append("numberOfEpochs=" + numberOfEpochs + ", ");
s.append("slidingWindow=" + slidingWindow + ", ");
s.append("migrationBudget=" + migrationBudget + ", ");
s.append("settingsFile=" + settingsFile);
switch (placementAlgorithm) {
case PLACEMENT_FILE:
s.append("placementMapFile=" + placementMapFile + ", ");
break;
case PLACEMENT_EQUALSPREAD:
s.append("equalSpreadNum=" + equalSpreadNum + ", ");
break;
default:
case PLACEMENT_RANDOM:
s.append("numberOfMachines=" + numberOfMachines + ", ");
s.append("numberOfMachineSlots=" + numberOfMachineSlots + ", ");
s.append("numberOfClients=" + numberOfClients + ", ");
s.append("numberOfVMsPerClient=" + numberOfVMsPerClient + ", ");
s.append("fillInEmptySpots=" + fillInEmptySpots + ", ");
s.append("seed=" + randomSeed + ", ");
break;
}
s.append("}");
return s.toString();
......
......@@ -2,6 +2,7 @@ package vagabond.testing;
import vagabond.pieces.PlacementMap;
import vagabond.pieces.VM;
import vagabond.singleton.VagabondSettings;
public class PlacementMapExamples {
......@@ -28,6 +29,12 @@ public class PlacementMapExamples {
}
}
VagabondSettings s = VagabondSettings.getInstance();
s.numberOfClients = machineAndSlotAndClientSize;
s.numberOfMachines = machineAndSlotAndClientSize;
s.numberOfMachineSlots = machineAndSlotAndClientSize;
s.numberOfVMsPerClient = machineAndSlotAndClientSize;
return place;
}
......@@ -45,6 +52,53 @@ public class PlacementMapExamples {
return equalSpreadClients(3);
}
/**
* Creates a Placement Map where the number of machines is equal to HALF the number of clients and equal to the
* number of slots per machine and equal to the number of VMs per client. This allows the the Placement Map to be
* half filled.
* @param machineAndSlotAndClientSize the number of machines, also the number of slots per machine, and also half
* half number of clients
* @return an evenly distributed Placement Map where each client has exactly 1 VM on a machine and all machines are
* half full
*/
public static PlacementMap equalSpreadClientsHalfFull(int machineAndSlotAndClientSize) {
PlacementMap place = new PlacementMap(machineAndSlotAndClientSize, machineAndSlotAndClientSize);
int machineID = 0;
int half = machineAndSlotAndClientSize / 2;
for (int serviceID = 0; serviceID < machineAndSlotAndClientSize; serviceID++) {
machineID = serviceID;
for (int clientID = 0; clientID < half; clientID++) {
place.addNewVMToMachine(
new VM(clientID, serviceID, place.getNextAvailableVMID()),
machineID);
}
}
VagabondSettings s = VagabondSettings.getInstance();
s.numberOfClients = half;
s.numberOfMachines = machineAndSlotAndClientSize;
s.numberOfMachineSlots = machineAndSlotAndClientSize;
s.numberOfVMsPerClient = machineAndSlotAndClientSize;
return place;
}
/**
* Provides the 4x4 standard example but each client has half the number of VMs.
* <ul>
* <li>PlacementMap(4 Machines; 4 Clients; 8 Total VMS)</li>
* <li>Machine 0 {1&lt;0,0&gt;, 2&lt;1,0&gt; [], []}</li>
* <li>Machine 1 {4&lt;0,1&gt;, 5&lt;1,1&gt; [], []}</li>
* <li>Machine 2 {7&lt;0,2&gt;, 8&lt;1,2&gt; [], []}</li>
* <li>Machine 3 {7&lt;0,2&gt;, 8&lt;1,2&gt; [], []}</li>
* </ul>
* @return an equally spread placement map for 3x3x3x3 (machines x slots x clients x vms per client)
*/
public static PlacementMap equalSpreadClientsHalfFull() {
return equalSpreadClientsHalfFull(4);
}
/**
* Creates a Placement Map where the number of machines is equal to the number of clients and equal to the number
* of slots per machine. This allows the the Placement Map to be completely filled by putting all VMs from a client
......@@ -67,6 +121,12 @@ public class PlacementMapExamples {
}
}
VagabondSettings s = VagabondSettings.getInstance();
s.numberOfClients = machineAndSlotAndClientSize;
s.numberOfMachines = machineAndSlotAndClientSize;
s.numberOfMachineSlots = machineAndSlotAndClientSize;
s.numberOfVMsPerClient = machineAndSlotAndClientSize;
return place;
}
......@@ -140,6 +200,12 @@ public class PlacementMapExamples {
vm = new VM(3, 2, place.getNextAvailableVMID());
place.addNewVMToMachine(vm, 2);
VagabondSettings s = VagabondSettings.getInstance();
s.numberOfClients = 4;
s.numberOfMachines = 3;
s.numberOfMachineSlots = 3;
s.numberOfVMsPerClient = 3; // The maximum
return place;
}
}
# I am a comment
numberOfEpochs=16
slidingWindow=5
placement=equalSpreadHalf
equalSpreadNum=10
reduction=ilp
migrationBudget=3
# OPTIONAL: Can Comment these lines out
# numberOfMachines=-1
# numberOfMachineSlots=-1
# numberOfClients=-1
# numberOfVMsPerClient=-1
# fillInEmpty=false
# seed=12
\ No newline at end of file
# I am a comment
numberOfEpochs=16
slidingWindow=5
placement=equalSpread
equalSpreadNum=10
reduction=ilp
migrationBudget=3
# OPTIONAL: Can Comment these lines out
# numberOfMachines=-1
# numberOfMachineSlots=-1
# numberOfClients=-1
# numberOfVMsPerClient=-1
# fillInEmpty=false
# seed=12
\ No newline at end of file
# I am a comment
numberOfMachines=3
numberOfMachineSlots=3
numberOfClients=4
numberOfVMsPerClient=2
fillInEmpty=false
numberOfEpochs=16
slidingWindow=5
placement=readFile
......@@ -11,4 +6,9 @@ placementFile=tests/nomadSubOptimalRCPlacement.csv
reduction=ilp
migrationBudget=3
# OPTIONAL: Can Comment these lines out
seed=12
\ No newline at end of file
# numberOfMachines=-1
# numberOfMachineSlots=-1
# numberOfClients=-1
# numberOfVMsPerClient=-1
# fillInEmpty=false
# seed=12
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment