thisElement = element;
List children = element.getChildren();
if (children.size() > 1) {
String message = "DistributedMasterBuilder can only have one nested builder";
LOG.error(message);
throw new CruiseControlException(message);
} else if (children.size() == 0) {
// @todo Clarify when configure() can be called...
String message = "Nested Builder required by DistributedMasterBuilder, "
+ "ignoring and assuming this call is during plugin-preconfig";
LOG.warn(message);
return;
}
childBuilderElement = (Element) children.get(0);
// Add default/preconfigured props to builder element
addMissingPluginDefaults(childBuilderElement);
// Add default/preconfigured props to distributed element
addMissingPluginDefaults(element);
Attribute tempAttribute = thisElement.getAttribute("entries");
entries = tempAttribute != null ? tempAttribute.getValue() : "";
tempAttribute = thisElement.getAttribute("module");
if (tempAttribute != null) {
module = tempAttribute.getValue();
} else {
// try to use project name as default value
final Element elmProj = getElementProject(thisElement);
if (elmProj != null) {
module = elmProj.getAttributeValue("name");
} else {
module = null;
}
}
// optional attributes
tempAttribute = thisElement.getAttribute("agentlogdir");
setAgentLogDir(tempAttribute != null ? tempAttribute.getValue() : "");
tempAttribute = thisElement.getAttribute("agentoutputdir");
setAgentOutputDir(tempAttribute != null ? tempAttribute.getValue() : "");
tempAttribute = thisElement.getAttribute("masterlogdir");
setMasterLogDir(tempAttribute != null ? tempAttribute.getValue() : "");
tempAttribute = thisElement.getAttribute("masteroutputdir");
setMasterOutputDir(tempAttribute != null ? tempAttribute.getValue() : "");
try {
cruiseProperties = (Properties) PropertiesHelper.loadRequiredProperties(CRUISE_PROPERTIES);
} catch (RuntimeException e) {
LOG.error(e.getMessage(), e);
System.err.println(e.getMessage());
throw new CruiseControlException(e.getMessage(), e);
}
rootDir = new File(cruiseProperties.getProperty(CRUISE_RUN_DIR));
LOG.debug("CRUISE_RUN_DIR: " + rootDir);
if (!rootDir.exists()
// Don't think non-existant rootDir matters if agent/master log/output dirs are set
&& (getAgentLogDir() == null && getMasterLogDir() == null)
&& (getAgentOutputDir() == null && getMasterOutputDir() == null)
) {
String message = "Could not get property " + CRUISE_RUN_DIR + " from " + CRUISE_PROPERTIES
+ ", or run dir does not exist: " + rootDir;
LOG.error(message);
System.err.println(message);
throw new CruiseControlException(message);
}
validate();
}