summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Cahill <michael.cahill@wiredtiger.com>2012-11-07 11:06:50 +1100
committerMichael Cahill <michael.cahill@wiredtiger.com>2012-11-07 11:06:50 +1100
commita828010c3aa72c20b3122a8d39d1ac51f8169807 (patch)
tree912ce58dacfc3cdecfe5eb47b4f5a4fe8890dfc0
parent34b38436d0e9f5fefe9fd038c7efa91ff36b4626 (diff)
downloadmongo-a828010c3aa72c20b3122a8d39d1ac51f8169807.tar.gz
Add support for getting config values with "X.Y" keys, update auto-generated defaults to match.
-rw-r--r--dist/config.py41
-rw-r--r--src/btree/bt_cache.c2
-rw-r--r--src/config/config.c18
-rw-r--r--src/config/config_def.c16
-rw-r--r--src/conn/conn_cache_pool.c8
-rw-r--r--src/include/extern.h1
6 files changed, 42 insertions, 44 deletions
diff --git a/dist/config.py b/dist/config.py
index 251b9b3aaeb..f235cdfbb50 100644
--- a/dist/config.py
+++ b/dist/config.py
@@ -23,15 +23,6 @@ def gettype(c):
ctype = 'int'
return ctype or 'string'
-def getsubconfigstr(c):
- '''Return a string indicating if an item has sub configuration'''
- ctype = gettype(c)
- if ctype == 'category':
- return '__wt_confchk_' + c.name + '_subconfigs'
- else:
- return 'NULL'
-
-
def typedesc(c):
'''Descripe what type of value is expected for the given config item'''
checks = c.flags
@@ -179,26 +170,19 @@ def get_default(c):
t = gettype(c)
if c.default == 'false':
return '0'
+ elif t == 'category':
+ return '(%s)' % (','.join('%s=%s' % (subc.name, get_default(subc))
+ for subc in sorted(c.subconfig)))
elif (c.default or t == 'int') and c.default != 'true':
return str(c.default)
else:
return ''
created_subconfigs=set()
-
-def add_subconfig(c, tfile):
+def add_subconfig(c):
+ if c.name in created_subconfigs:
+ return
created_subconfigs.add(c.name)
- subname = c.name.replace('.', '_')
- tfile.write('''
-const char *
-__wt_confdfl_%(name)s_subconfigs =
-%(config)s;
-''' % {
- 'name' : subname,
- 'config' : '\n'.join('\t"%s"' % line
- for line in w.wrap(','.join('%s=%s' % (subc.name, get_default(subc))
- for subc in sorted(c.subconfig))) or [""]),
-})
tfile.write('''
WT_CONFIG_CHECK
__wt_confchk_%(name)s_subconfigs[] = {
@@ -211,6 +195,15 @@ __wt_confchk_%(name)s_subconfigs[] = {
(subc.name, gettype(subc), checkstr(subc)))) for subc in sorted(c.subconfig)),
})
+def getsubconfigstr(c):
+ '''Return a string indicating if an item has sub configuration'''
+ ctype = gettype(c)
+ if ctype == 'category':
+ add_subconfig(c)
+ return '__wt_confchk_' + c.name + '_subconfigs'
+ else:
+ return 'NULL'
+
for name in sorted(api_data.methods.keys()):
ctype = api_data.methods[name].config
name = name.replace('.', '_')
@@ -224,10 +217,6 @@ __wt_confdfl_%(name)s =
for line in w.wrap(','.join('%s=%s' % (c.name, get_default(c))
for c in sorted(ctype))) or [""]),
})
- # Deal with subsets of configuration settings.
- for c in sorted(ctype):
- if gettype(c) == 'category' and c.name not in created_subconfigs:
- add_subconfig(c, tfile)
# Construct an array of allowable configuration options. Always append an empty
# string as a terminator for iteration
diff --git a/src/btree/bt_cache.c b/src/btree/bt_cache.c
index 6134c3f64a5..fa50b9e52cc 100644
--- a/src/btree/bt_cache.c
+++ b/src/btree/bt_cache.c
@@ -24,7 +24,7 @@ __wt_cache_config(WT_CONNECTION_IMPL *conn, const char *cfg[])
/* Ignore the cache size if a shared cache is configured. */
if (!F_ISSET(conn, WT_CONN_CACHE_POOL) &&
- (ret = __wt_config_gets(session, cfg, "cache_size", &cval)) == 0)
+ (ret = __wt_config_gets(session, cfg, "cache.size", &cval)) == 0)
conn->cache_size = (uint64_t)cval.val;
WT_RET_NOTFOUND_OK(ret);
diff --git a/src/config/config.c b/src/config/config.c
index bde794eee17..e351a7bf946 100644
--- a/src/config/config.c
+++ b/src/config/config.c
@@ -568,17 +568,29 @@ int
__wt_config_getraw(
WT_CONFIG *cparser, WT_CONFIG_ITEM *key, WT_CONFIG_ITEM *value)
{
- WT_CONFIG_ITEM k, v;
+ WT_CONFIG sparser;
+ WT_CONFIG_ITEM k, v, subk;
WT_DECL_RET;
int found;
found = 0;
while ((ret = __config_next(cparser, &k, &v)) == 0) {
- if ((k.type == ITEM_STRING || k.type == ITEM_ID) &&
- key->len == k.len &&
+ if (k.type != ITEM_STRING && k.type != ITEM_ID)
+ continue;
+ if (k.len == key->len &&
strncasecmp(key->str, k.str, k.len) == 0) {
*value = v;
found = 1;
+ } else if (k.len < key->len && key->str[k.len] == '.' &&
+ strncasecmp(key->str, k.str, k.len) == 0) {
+ subk.str = key->str + k.len + 1;
+ subk.len = key->len - k.len - 1;
+ WT_RET(__wt_config_initn(
+ cparser->session, &sparser, v.str, v.len));
+ if ((ret =
+ __wt_config_getraw(&sparser, &subk, value)) == 0)
+ found = 1;
+ WT_RET_NOTFOUND_OK(ret);
}
}
diff --git a/src/config/config_def.c b/src/config/config_def.c
index cbed4f729c0..6ab7530b7fd 100644
--- a/src/config/config_def.c
+++ b/src/config/config_def.c
@@ -83,11 +83,8 @@ __wt_confchk_connection_open_session[] = {
const char *
__wt_confdfl_connection_reconfigure =
- "cache=,error_prefix=,eviction_target=80,eviction_trigger=95,verbose=";
-
-const char *
-__wt_confdfl_cache_subconfigs =
- "pool=,pool_chunk=,pool_min=,size=100MB";
+ "cache=(pool=,pool_chunk=,pool_min=,size=100MB),error_prefix=,"
+ "eviction_target=80,eviction_trigger=95,verbose=";
WT_CONFIG_CHECK
__wt_confchk_cache_subconfigs[] = {
@@ -414,10 +411,11 @@ __wt_confchk_table_meta[] = {
const char *
__wt_confdfl_wiredtiger_open =
- "buffer_alignment=-1,cache=,create=0,direct_io=,error_prefix=,"
- "eviction_target=80,eviction_trigger=95,extensions=,hazard_max=1000,"
- "logging=0,lsm_merge=,multiprocess=0,session_max=50,sync=,"
- "transactional=,use_environment_priv=0,verbose=";
+ "buffer_alignment=-1,cache=(pool=,pool_chunk=,pool_min=,size=100MB),"
+ "create=0,direct_io=,error_prefix=,eviction_target=80,"
+ "eviction_trigger=95,extensions=,hazard_max=1000,logging=0,lsm_merge="
+ ",multiprocess=0,session_max=50,sync=,transactional=,"
+ "use_environment_priv=0,verbose=";
WT_CONFIG_CHECK
__wt_confchk_wiredtiger_open[] = {
diff --git a/src/conn/conn_cache_pool.c b/src/conn/conn_cache_pool.c
index deab10f5425..4ad9b8d178c 100644
--- a/src/conn/conn_cache_pool.c
+++ b/src/conn/conn_cache_pool.c
@@ -40,7 +40,7 @@ __wt_conn_cache_pool_config(WT_SESSION_IMPL *session, const char **cfg)
pool_name = NULL;
cp = NULL;
- WT_RET(__wt_config_gets(session, cfg, "cache_pool", &cval));
+ WT_RET(__wt_config_gets(session, cfg, "cache.pool", &cval));
if (cval.len <= 0)
return (0);
@@ -50,7 +50,7 @@ __wt_conn_cache_pool_config(WT_SESSION_IMPL *session, const char **cfg)
if (__wt_process.cache_pool == NULL) {
/* Create a cache pool. */
WT_ERR(__wt_config_gets(
- session, cfg, "cache_pool_size", &cval));
+ session, cfg, "cache.pool_size", &cval));
if (cval.len <= 0) {
WT_ERR_MSG(session, WT_ERROR,
"Attempting to join a cache pool that does not "
@@ -68,14 +68,14 @@ __wt_conn_cache_pool_config(WT_SESSION_IMPL *session, const char **cfg)
"cache pool server", 0, &cp->cache_pool_cond));
WT_ERR(__wt_config_gets(
- session, cfg, "cache_pool_chunk", &cval));
+ session, cfg, "cache.pool_chunk", &cval));
if (cval.len > 0)
cp->chunk = cval.val;
else
cp->chunk = WT_MAX(
50 * WT_MEGABYTE, cp->size / 20);
WT_ERR(__wt_config_gets(
- session, cfg, "cache_pool_quota", &cval));
+ session, cfg, "cache.pool_quota", &cval));
if (cval.len > 0)
cp->quota = cval.val;
else
diff --git a/src/include/extern.h b/src/include/extern.h
index 0e3908277e2..022aa8908be 100644
--- a/src/include/extern.h
+++ b/src/include/extern.h
@@ -560,7 +560,6 @@ extern WT_CONFIG_CHECK __wt_confchk_connection_load_extension[];
extern const char *__wt_confdfl_connection_open_session;
extern WT_CONFIG_CHECK __wt_confchk_connection_open_session[];
extern const char *__wt_confdfl_connection_reconfigure;
-extern const char *__wt_confdfl_cache_subconfigs;
extern WT_CONFIG_CHECK __wt_confchk_cache_subconfigs[];
extern WT_CONFIG_CHECK __wt_confchk_connection_reconfigure[];
extern const char *__wt_confdfl_cursor_close;