Skip to content

Commit 6203c8d

Browse files
committed
ndb
- Add a CI_BITMASK type for configuration parameters to make it possible for the ndb_mgmd to validate the bitmask spec. early. - Make LockExecuteThreadToCPU use the new type. Set max to 65535(i.e same as in ndbd).
1 parent 3e22efb commit 6203c8d

File tree

3 files changed

+60
-2
lines changed

3 files changed

+60
-2
lines changed

storage/ndb/src/mgmsrv/ConfigInfo.cpp

+23-2
Original file line numberDiff line numberDiff line change
@@ -637,9 +637,11 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
637637
"CPU list indicating which CPU will run the execution thread(s)",
638638
ConfigInfo::CI_USED,
639639
0,
640-
ConfigInfo::CI_STRING,
640+
ConfigInfo::CI_BITMASK,
641641
0,
642-
0, 0 },
642+
0,
643+
"65535"
644+
},
643645

644646
{
645647
CFG_DB_MAINT_LOCK_CPU,
@@ -3013,6 +3015,20 @@ ConfigInfo::ConfigInfo()
30133015
else if(param._default)
30143016
pinfo.put("Default", param._default);
30153017
break;
3018+
3019+
case CI_BITMASK:
3020+
assert(param._min == 0); // Bitmask can't have min value
3021+
3022+
Uint64 tmp_uint64;
3023+
require(InitConfigFileParser::convertStringToUint64(param._max,
3024+
tmp_uint64));
3025+
pinfo.put64("Max", tmp_uint64);
3026+
3027+
if(param._default == MANDATORY)
3028+
pinfo.put("Mandatory", (Uint32)1);
3029+
else if(param._default)
3030+
pinfo.put("Default", param._default);
3031+
break;
30163032
}
30173033

30183034
// Check that pinfo is really new
@@ -3043,6 +3059,7 @@ ConfigInfo::ConfigInfo()
30433059
break;
30443060
case CI_ENUM:
30453061
case CI_STRING:
3062+
case CI_BITMASK:
30463063
require(p->put(param._fname, param._default));
30473064
break;
30483065
case CI_BOOL:
@@ -3429,6 +3446,7 @@ class PrettyPrinter : public ConfigPrinter {
34293446
fprintf(m_out, "\n");
34303447
break;
34313448

3449+
case ConfigInfo::CI_BITMASK:
34323450
case ConfigInfo::CI_ENUM:
34333451
case ConfigInfo::CI_STRING:
34343452
fprintf(m_out, "%s (String)\n", param_name);
@@ -3552,6 +3570,7 @@ class XMLPrinter : public ConfigPrinter {
35523570
pairs.put("max", buf.c_str());
35533571
break;
35543572

3573+
case ConfigInfo::CI_BITMASK:
35553574
case ConfigInfo::CI_ENUM:
35563575
case ConfigInfo::CI_STRING:
35573576
pairs.put("type", "string");
@@ -3959,6 +3978,7 @@ applyDefaultValues(InitConfigFileParser::Context & ctx,
39593978
DBUG_PRINT("info",("%s=%lld #default",name,val));
39603979
break;
39613980
}
3981+
case ConfigInfo::CI_BITMASK:
39623982
case ConfigInfo::CI_STRING:{
39633983
const char * val;
39643984
require(defaults->get(name, &val));
@@ -3987,6 +4007,7 @@ applyDefaultValues(InitConfigFileParser::Context & ctx,
39874007
DBUG_PRINT("info",("%s=%lld",name,val));
39884008
break;
39894009
}
4010+
case ConfigInfo::CI_BITMASK:
39904011
case ConfigInfo::CI_ENUM:
39914012
case ConfigInfo::CI_STRING:{
39924013
const char * val;

storage/ndb/src/mgmsrv/ConfigInfo.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class ConfigInfo {
4343
CI_INT64,
4444
CI_STRING,
4545
CI_ENUM, // String externaly, int internally
46+
CI_BITMASK, // String both externally and internally
4647
CI_SECTION
4748
};
4849
enum Status { CI_USED, ///< Active

storage/ndb/src/mgmsrv/InitConfigFileParser.cpp

+36
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "ConfigInfo.hpp"
2525
#include "EventLogger.hpp"
2626
#include <m_string.h>
27+
#include <util/SparseBitmask.hpp>
2728

2829
extern EventLogger *g_eventLogger;
2930

@@ -348,6 +349,40 @@ InitConfigFileParser::storeNameValuePair(Context& ctx,
348349
break;
349350
}
350351

352+
case ConfigInfo::CI_BITMASK:{
353+
if (strlen(value) <= 0)
354+
{
355+
ctx.reportError("Illegal value '%s' for parameter %s. "
356+
"Error: Zero length string",
357+
value, fname);
358+
return false;
359+
}
360+
Uint64 max = m_info->getMax(ctx.m_currentInfo, fname);
361+
SparseBitmask mask(max);
362+
int res = mask.parseMask(value);
363+
if (res < 0)
364+
{
365+
BaseString desc("Unknown error.");
366+
switch(res)
367+
{
368+
case -1:
369+
desc.assign("Invalid syntax for bitmask");
370+
break;
371+
case -2:
372+
desc.assfmt("Too large id used in bitmask, max is %llu", max);
373+
break;
374+
default:
375+
break;
376+
}
377+
378+
ctx.reportError("Illegal value '%s' for parameter %s. Error: %s",
379+
value, fname, desc.c_str());
380+
return false;
381+
}
382+
require(ctx.m_currentSection->put(fname, value));
383+
break;
384+
}
385+
351386
case ConfigInfo::CI_SECTION:
352387
abort();
353388
}
@@ -792,6 +827,7 @@ InitConfigFileParser::parse_mycnf()
792827
break;
793828
case ConfigInfo::CI_ENUM:
794829
case ConfigInfo::CI_STRING:
830+
case ConfigInfo::CI_BITMASK:
795831
opt.value = (uchar**)malloc(sizeof(char *));
796832
opt.var_type = GET_STR;
797833
break;

0 commit comments

Comments
 (0)