maxCapacity = Double.parseDouble(globalConst.getAttribute("maxJobs"));
if (DEBUG) {
System.out.println(" global constraint = " + Double.toString(maxCapacity));
}
} else {
throw new LoadException("Element \"globalConstraint\" missing...");
}
//--------------DROP RULES---------------//
NodeList dropRules = region.getElementsByTagName("dropRules");
//drop rules (one for each class)
boolean[] dropThisClass = new boolean[classNumber];
//init
if (dropRules.getLength() == 0) {
//no drop rules specified: use default drop values (drop open and keep closed)
for (int c = 0; c < classNumber; c++) {
int classType = jobClasses[c].getType();
if (classType == JobClass.OPEN_CLASS) {
//drop open class jobs
dropThisClass[c] = true;
} else {
//block closed class jobs
dropThisClass[c] = false;
}
}
if (DEBUG) {
System.out.println("Loading default drop rules...");
}
} else {
//drop rules specified by user
if (DEBUG) {
System.out.println("Loading specified drop rules...");
}
//the number of drop rules must be exactly equal
//to the number of classes
/*
if (dropRules.getLength() != classNumber) {
throw new LoadException("One drop rule is required for each class.");
}
*/
Element dropRule = null;
int classPosition;
String className;
for (int dr = 0; dr < dropRules.getLength(); dr++) {
dropRule = (Element) dropRules.item(dr);
className = dropRule.getAttribute("jobClass");
//entries may be in a wrong order: find the right position
classPosition = getJobClassPosition(className);
if (classPosition == -1) {
//class not exists
throw new LoadException("The job class associated to this drop rule does not exist in model");
} else {
dropThisClass[classPosition] = dropRule.getAttribute("dropThisClass").equalsIgnoreCase("true");
}
if (DEBUG) {
System.out.println(" drop class " + className + " = " + dropThisClass[classPosition]);
}
}
}
//-----------------CLASS CONSTRAINTS-----------------//
NodeList classConstraints = region.getElementsByTagName("classConstraint");
//max capacity for each class (-1 means no constraint)
double[] maxCapacityPerClass = new double[classNumber];
//init
Arrays.fill(maxCapacityPerClass, -1.0);
if (classConstraints.getLength() > 0) {
//the number of class constraints must be exactly equal
//to the number of classes
/*
if (classConstraints.getLength() != classNumber) {
throw new LoadException("One class constraint is required for each class.");
}
*/
Element clsConst = null;
int classPosition;
String className;
for (int cc = 0; cc < classConstraints.getLength(); cc++) {
clsConst = (Element) classConstraints.item(cc);
className = clsConst.getAttribute("jobClass");
//entries may be in a wrong order: find the right position
classPosition = getJobClassPosition(className);
if (classPosition == -1) {
//class not exists
throw new LoadException("The job class associated to this class constraint does not exist in model");
} else {
//set max capacity for this class
maxCapacityPerClass[classPosition] = Double.parseDouble(clsConst.getAttribute("maxJobsPerClass"));
}
if (DEBUG) {
System.out.println(" constraint for class " + className + " = " + Double.toString(maxCapacityPerClass[classPosition]));
}
}
}
//----------------CLASS WEIGHTS----------------//
NodeList classWeights = root.getElementsByTagName("classWeight");
double[] regionClassWeights = new double[classNumber];
//init
Arrays.fill(regionClassWeights, 1.0);
if (classWeights.getLength() > 0) {
//the number of class weights must be exactly equal
//to the number of classes
/*
if (classWeights.getLength() != classNumber) {
throw new LoadException("One class weight is required for each class.");
}
*/
Element clsWeight = null;
int classPosition;
String className;
for (int c = 0; c < classWeights.getLength(); c++) {
clsWeight = (Element) classWeights.item(c);
className = clsWeight.getAttribute("jobClass");
//entries may be in a wrong order: find the right position
classPosition = getJobClassPosition(className);
if (classPosition == -1) {
//class not exists
throw new LoadException("The job class associated to this weight does not exist in model");
} else {
regionClassWeights[classPosition] = Double.parseDouble(clsWeight.getAttribute("weight"));
}
if (DEBUG) {