{
// map the clases, crash on duplicates
for ( DuccProperties p : classes ) {
String name = p.getStringProperty("name");
if ( clmap.containsKey(name) ) {
throw new IllegalConfigurationException("Duplicate class: " + name);
}
clmap.put(name, p);
}
// now establish the parent -> child relationships
for ( DuccProperties p : clmap.values() ) {
String parent = p.getProperty("parent");
String name = p.getProperty("name");
if ( (p.getProperty("abstract") != null) &&
(p.getProperty("default") != null ) ) {
throw new IllegalConfigurationException("Class " + name + ": Abstract class is not allowed to specify \"default\"");
}
if ( parent == null ) {
independentClasses.add(name);
} else {
DuccProperties par_cl = clmap.get(parent);
if ( par_cl == null ) {
throw new IllegalConfigurationException("Class " + name + " parent pool " + parent + " cannot be found.");
}
String children = par_cl.getStringProperty("children", null);
if ( children == null ) {
children = name;
} else {
children = children + " " + name;
}
par_cl.put("children", children);
}
}
// now starting at every root, propogate stuff down
for ( String s : independentClasses ) {
propogateDown(s);
}
// must fill in defaults, which we couldn't do until we finished inheritance
for ( DuccProperties p : clmap.values() ) {
String policy = p.getStringProperty("policy", null);
String name = p.getProperty("name");
if ( policy == null ) {
throw new IllegalConfigurationException("Class " + name + " is missing scheduling policy ");
}
if ( policy.equals("FAIR_SHARE") ) {
fairShareExists = true;
handleDefault(p, fairShareDefault, policy);
supplyDefaults(p, defaultFairShareClass);
} else
if ( policy.equals("FIXED_SHARE") ) {
fixedExists = true;
handleDefault(p, fixedDefault, policy);
supplyDefaults(p, defaultFixedShareClass);
} else
if ( policy.equals("RESERVE") ) {
reserveExists = true;
handleDefault(p, reserveDefault, policy);
supplyDefaults(p, defaultReserveClass);
} else {
throw new IllegalConfigurationException("Unknown scheduling policy \"" + policy + "\" in class " + name);
}
}
// remove the abstract classes as they are no longer needed and we don't want to let them leak out
// where somebody might think they're ok to use