Commit d68c334c authored by unknown's avatar unknown
Browse files

Bug#4970

parent c9c78341
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -154,11 +154,15 @@ bool add_node_connections(Vector<ConfigInfo::ConfigRuleSection>&sections,
bool add_server_ports(Vector<ConfigInfo::ConfigRuleSection>&sections, 
		      struct InitConfigFileParser::Context &ctx, 
		      const char * rule_data);
bool check_node_vs_replicas(Vector<ConfigInfo::ConfigRuleSection>&sections, 
			    struct InitConfigFileParser::Context &ctx, 
			    const char * rule_data);

const ConfigInfo::ConfigRule 
ConfigInfo::m_ConfigRules[] = {
  { add_node_connections, 0 },
  { add_server_ports, 0 },
  { check_node_vs_replicas, 0 },
  { 0, 0 }
};
	  
@@ -2197,6 +2201,13 @@ transformNode(InitConfigFileParser::Context & ctx, const char * data){
  ctx.m_userProperties.get("NoOfNodes", &nodes);
  ctx.m_userProperties.put("NoOfNodes", ++nodes, true);

  /**
   * Update count (per type)
   */
  nodes = 0;
  ctx.m_userProperties.get(ctx.fname, &nodes);
  ctx.m_userProperties.put(ctx.fname, ++nodes, true);

  return true;
}

@@ -2991,6 +3002,7 @@ add_node_connections(Vector<ConfigInfo::ConfigRuleSection>&sections,
  return true;
}


bool add_server_ports(Vector<ConfigInfo::ConfigRuleSection>&sections, 
		      struct InitConfigFileParser::Context &ctx, 
		      const char * rule_data)
@@ -3030,4 +3042,22 @@ bool add_server_ports(Vector<ConfigInfo::ConfigRuleSection>&sections,
  return true;
}

bool
check_node_vs_replicas(Vector<ConfigInfo::ConfigRuleSection>&sections, 
		       struct InitConfigFileParser::Context &ctx, 
		       const char * rule_data)
{
  Uint32 db_nodes = 0;
  Uint32 replicas = 0;
  ctx.m_userProperties.get("DB", &db_nodes);
  ctx.m_userProperties.get("NoOfReplicas", &replicas);
  if((db_nodes % replicas) != 0){
    ctx.reportError("Invalid no of db nodes wrt no of replicas.\n"
		    "No of nodes must be dividable with no or replicas");
    return false;
  }
  
  return true;
}

template class Vector<ConfigInfo::ConfigRuleSection>;