Commit 1b847446 authored by unknown's avatar unknown
Browse files

Merge tulin@bk-internal.mysql.com:/home/bk/mysql-4.1

into poseidon.(none):/home/tomas/mysql-4.1

parents e5af92b0 50729d60
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -394,6 +394,14 @@ extern "C" {
   */
  const char * ndb_mgm_get_node_type_string(enum ndb_mgm_node_type type);

  /**
   * Convert an ndb_mgm_node_type to a alias string
   *
   * @param   type          Node type.
   * @return                NULL if invalid id.
   */
  const char * ndb_mgm_get_node_type_alias_string(enum ndb_mgm_node_type type, const char **str);

  /**
   * Convert a string to a ndb_mgm_node_status
   *
+30 −1
Original line number Diff line number Diff line
@@ -161,6 +161,9 @@ const int ConfigInfo::m_NoOfRules = sizeof(m_SectionRules)/sizeof(SectionRule);
/****************************************************************************
 * Config Rules declarations
 ****************************************************************************/
static bool sanity_checks(Vector<ConfigInfo::ConfigRuleSection>&sections, 
			  struct InitConfigFileParser::Context &ctx, 
			  const char * rule_data);
static bool add_node_connections(Vector<ConfigInfo::ConfigRuleSection>&sections, 
				 struct InitConfigFileParser::Context &ctx, 
				 const char * rule_data);
@@ -173,6 +176,7 @@ static bool check_node_vs_replicas(Vector<ConfigInfo::ConfigRuleSection>&section

const ConfigInfo::ConfigRule 
ConfigInfo::m_ConfigRules[] = {
  { sanity_checks, 0 },
  { add_node_connections, 0 },
  { add_server_ports, 0 },
  { check_node_vs_replicas, 0 },
@@ -2958,6 +2962,29 @@ saveInConfigValues(InitConfigFileParser::Context & ctx, const char * data){
  return true;
}

static bool
sanity_checks(Vector<ConfigInfo::ConfigRuleSection>&sections, 
	      struct InitConfigFileParser::Context &ctx, 
	      const char * rule_data)
{
  Uint32 db_nodes = 0;
  Uint32 mgm_nodes = 0;
  Uint32 api_nodes = 0;
  if (!ctx.m_userProperties.get("DB", &db_nodes)) {
    ctx.reportError("At least one database node should be defined in config file");
    return false;
  }
  if (!ctx.m_userProperties.get("MGM", &mgm_nodes)) {
    ctx.reportError("At least one management server node should be defined in config file");
    return false;
  }
  if (!ctx.m_userProperties.get("API", &api_nodes)) {
    ctx.reportError("At least one application node (for the mysqld) should be defined in config file");
    return false;
  }
  return true;
}

static bool
add_node_connections(Vector<ConfigInfo::ConfigRuleSection>&sections, 
		   struct InitConfigFileParser::Context &ctx, 
@@ -3091,7 +3118,9 @@ check_node_vs_replicas(Vector<ConfigInfo::ConfigRuleSection>&sections,
{
  Uint32 db_nodes = 0;
  Uint32 replicas = 0;
  ctx.m_userProperties.get("DB", &db_nodes);
  if (!ctx.m_userProperties.get("DB", &db_nodes)) {
    return true;
  }
  ctx.m_userProperties.get("NoOfReplicas", &replicas);
  if((db_nodes % replicas) != 0){
    ctx.reportError("Invalid no of db nodes wrt no of replicas.\n"
+29 −14
Original line number Diff line number Diff line
@@ -53,58 +53,73 @@ NdbConfig_NdbCfgName(int with_ndb_home){
  return buf;
}

static
char *get_prefix_buf(int len, int node_id)
{
  char tmp_buf[sizeof("ndb_pid#########")+1];
  if (node_id > 0)
    snprintf(tmp_buf, sizeof(tmp_buf), "ndb_%u", node_id);
  else
    snprintf(tmp_buf, sizeof(tmp_buf), "ndb_pid%u", getpid());
  tmp_buf[sizeof(tmp_buf)-1]= 0;

  char *buf= NdbConfig_AllocHomePath(len+strlen(tmp_buf));
  strcat(buf, tmp_buf);
  return buf;
}

char* 
NdbConfig_ErrorFileName(int node_id){
  char *buf= NdbConfig_AllocHomePath(128);
  char *buf= get_prefix_buf(128, node_id);
  int len= strlen(buf);
  snprintf(buf+len, 128, "ndb_%u_error.log", node_id);
  snprintf(buf+len, 128, "_error.log");
  return buf;
}

char*
NdbConfig_ClusterLogFileName(int node_id){
  char *buf= NdbConfig_AllocHomePath(128);
  char *buf= get_prefix_buf(128, node_id);
  int len= strlen(buf);
  snprintf(buf+len, 128, "ndb_%u_cluster.log", node_id);
  snprintf(buf+len, 128, "_cluster.log");
  return buf;
}

char*
NdbConfig_SignalLogFileName(int node_id){
  char *buf= NdbConfig_AllocHomePath(128);
  char *buf= get_prefix_buf(128, node_id);
  int len= strlen(buf);
  snprintf(buf+len, 128, "ndb_%u_signal.log", node_id);
  snprintf(buf+len, 128, "_signal.log");
  return buf;
}

char*
NdbConfig_TraceFileName(int node_id, int file_no){
  char *buf= NdbConfig_AllocHomePath(128);
  char *buf= get_prefix_buf(128, node_id);
  int len= strlen(buf);
  snprintf(buf+len, 128, "ndb_%u_trace.log.%u", node_id, file_no);
  snprintf(buf+len, 128, "_trace.log.%u", file_no);
  return buf;
}

char*
NdbConfig_NextTraceFileName(int node_id){
  char *buf= NdbConfig_AllocHomePath(128);
  char *buf= get_prefix_buf(128, node_id);
  int len= strlen(buf);
  snprintf(buf+len, 128, "ndb_%u_trace.log.next", node_id);
  snprintf(buf+len, 128, "_trace.log.next");
  return buf;
}

char*
NdbConfig_PidFileName(int node_id){
  char *buf= NdbConfig_AllocHomePath(128);
  char *buf= get_prefix_buf(128, node_id);
  int len= strlen(buf);
  snprintf(buf+len, 128, "ndb_%u.pid", node_id);
  snprintf(buf+len, 128, ".pid");
  return buf;
}

char*
NdbConfig_StdoutFileName(int node_id){
  char *buf= NdbConfig_AllocHomePath(128);
  char *buf= get_prefix_buf(128, node_id);
  int len= strlen(buf);
  snprintf(buf+len, 128, "ndb_%u_out.log", node_id);
  snprintf(buf+len, 128, "_out.log");
  return buf;
}
+24 −20
Original line number Diff line number Diff line
@@ -139,7 +139,7 @@ ErrorReporter::formatMessage(ErrorCategory type,
	   objRef, 
	   programName, 
	   processId, 
	   theNameOfTheTraceFile);
	   theNameOfTheTraceFile ? theNameOfTheTraceFile : "<no tracefile>");

  // Add trailing blanks to get a fixed lenght of the message
  while (strlen(messptr) <= MESSAGE_LENGTH-3){
@@ -217,8 +217,10 @@ WriteMessage(ErrorCategory thrdType, int thrdMessageID,
  /**
   * Format trace file name
   */
  int file_no= ErrorReporter::get_trace_no();
  char *theTraceFileName= NdbConfig_TraceFileName(globalData.ownId, file_no);
  char *theTraceFileName= 0;
  if (globalData.ownId > 0)
    theTraceFileName= NdbConfig_TraceFileName(globalData.ownId,
					      ErrorReporter::get_trace_no());
  NdbAutoPtr<char> tmp_aptr1(theTraceFileName);
  
  // The first 69 bytes is info about the current offset
@@ -291,6 +293,7 @@ WriteMessage(ErrorCategory thrdType, int thrdMessageID,
  fflush(stream);
  fclose(stream);
  
  if (theTraceFileName) {
    // Open the tracefile...
    FILE *jamStream = fopen(theTraceFileName, "w");
  
@@ -310,6 +313,7 @@ WriteMessage(ErrorCategory thrdType, int thrdMessageID,
    globalScheduler.dumpSignalMemory(jamStream);
  
    fclose(jamStream);
  }

  return 0;
}
+18 −3
Original line number Diff line number Diff line
@@ -403,14 +403,15 @@ ndb_mgm_disconnect(NdbMgmHandle handle)
struct ndb_mgm_type_atoi 
{
  const char * str;
  const char * alias;
  enum ndb_mgm_node_type value;
};

static struct ndb_mgm_type_atoi type_values[] = 
{
  { "NDB", NDB_MGM_NODE_TYPE_NDB},
  { "API", NDB_MGM_NODE_TYPE_API },
  { "MGM", NDB_MGM_NODE_TYPE_MGM }
  { "NDB", "ndbd", NDB_MGM_NODE_TYPE_NDB},
  { "API", "mysqld", NDB_MGM_NODE_TYPE_API },
  { "MGM", "ndb_mgmd", NDB_MGM_NODE_TYPE_MGM }
};

const int no_of_type_values = (sizeof(type_values) / 
@@ -440,6 +441,20 @@ ndb_mgm_get_node_type_string(enum ndb_mgm_node_type type)
  return 0;
}

extern "C"
const char * 
ndb_mgm_get_node_type_alias_string(enum ndb_mgm_node_type type, const char** str)
{
  for(int i = 0; i<no_of_type_values; i++)
    if(type_values[i].value == type)
      {
	if (str)
	  *str= type_values[i].str;
	return type_values[i].alias;
      }
  return 0;
}

struct ndb_mgm_status_atoi {
  const char * str;
  enum ndb_mgm_node_status value;
Loading