* @param leader The leader hostname
* @param catalog The catalog to be updated.
* @param printLog Whether or not to print cluster configuration.
*/
private static void setClusterInfo(Catalog catalog, DeploymentType deployment) {
ClusterType cluster = deployment.getCluster();
int hostCount = cluster.getHostcount();
int sitesPerHost = cluster.getSitesperhost();
int kFactor = cluster.getKfactor();
ClusterConfig config = new ClusterConfig(hostCount, sitesPerHost, kFactor);
if (!config.validate()) {
hostLog.error(config.getErrorMsg());
} else {
Cluster catCluster = catalog.getClusters().get("cluster");
// copy the deployment info that is currently not recorded anywhere else
Deployment catDeploy = catCluster.getDeployment().get("deployment");
catDeploy.setHostcount(hostCount);
catDeploy.setSitesperhost(sitesPerHost);
catDeploy.setKfactor(kFactor);
// copy partition detection configuration from xml to catalog
String defaultPPDPrefix = "partition_detection";
if (deployment.getPartitionDetection() != null) {
if (deployment.getPartitionDetection().isEnabled()) {
catCluster.setNetworkpartition(true);
CatalogMap<SnapshotSchedule> faultsnapshots = catCluster.getFaultsnapshots();
SnapshotSchedule sched = faultsnapshots.add("CLUSTER_PARTITION");
if (deployment.getPartitionDetection().getSnapshot() != null) {
sched.setPrefix(deployment.getPartitionDetection().getSnapshot().getPrefix());
}
else {
sched.setPrefix(defaultPPDPrefix);
}
}
else {
catCluster.setNetworkpartition(false);
}
}
else {
// Default partition detection on
catCluster.setNetworkpartition(true);
CatalogMap<SnapshotSchedule> faultsnapshots = catCluster.getFaultsnapshots();
SnapshotSchedule sched = faultsnapshots.add("CLUSTER_PARTITION");
sched.setPrefix(defaultPPDPrefix);
}
// copy admin mode configuration from xml to catalog
if (deployment.getAdminMode() != null)
{
catCluster.setAdminport(deployment.getAdminMode().getPort());
catCluster.setAdminstartup(deployment.getAdminMode().isAdminstartup());
}
else
{
// encode the default values
catCluster.setAdminport(VoltDB.DEFAULT_ADMIN_PORT);
catCluster.setAdminstartup(false);
}
setSystemSettings(deployment, catDeploy);
if (deployment.getHeartbeat() != null)
{
catCluster.setHeartbeattimeout(deployment.getHeartbeat().getTimeout());
}
else
{
// default to 10 seconds
catCluster.setHeartbeattimeout(10);
}
// copy schema modification behavior from xml to catalog
if (cluster.getSchema() != null) {
catCluster.setUseddlschema(cluster.getSchema() == SchemaType.DDL);
}
else {
// Don't think we can get here, deployment schema guarantees a default value
hostLog.warn("Schema modification setting not found. " +
"Forcing default behavior of UpdateCatalog to modify database schema.");