1 /* OpenLDAP WiredTiger backend */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2002-2015 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
17 * This work was developed by HAMANO Tsukasa <hamano@osstech.co.jp>
18 * based on back-bdb for inclusion in OpenLDAP Software.
19 * WiredTiger is a product of MongoDB Inc.
25 #include <ac/string.h>
32 static ConfigDriver wt_cf_gen;
40 static ConfigTable wtcfg[] = {
41 { "directory", "dir", 2, 2, 0, ARG_STRING|ARG_MAGIC|WT_DIRECTORY,
42 wt_cf_gen, "( OLcfgDbAt:0.1 NAME 'olcDbDirectory' "
43 "DESC 'Directory for database content' "
44 "EQUALITY caseIgnoreMatch "
45 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
46 { "wtconfig", "config", 2, 2, 0, ARG_STRING|ARG_MAGIC|WT_CONFIG,
47 wt_cf_gen, "( OLcfgDbAt:13.1 NAME 'olcWtConfig' "
48 "DESC 'Configuration for WiredTiger' "
49 "EQUALITY caseIgnoreMatch "
50 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
51 { "index", "attr> <[pres,eq,approx,sub]", 2, 3, 0, ARG_MAGIC|WT_INDEX,
52 wt_cf_gen, "( OLcfgDbAt:0.2 NAME 'olcDbIndex' "
53 "DESC 'Attribute index parameters' "
54 "EQUALITY caseIgnoreMatch "
55 "SYNTAX OMsDirectoryString )", NULL, NULL },
56 { NULL, NULL, 0, 0, 0, ARG_IGNORED,
57 NULL, NULL, NULL, NULL }
60 static ConfigOCs wtocs[] = {
63 "DESC 'Wt backend ocnfiguration' "
64 "SUP olcDatabaseConfig "
65 "MUST olcDbDirectory "
66 "MAY ( olcWtConfig $ olcDbIndex ) )",
67 Cft_Database, wtcfg },
71 /* reindex entries on the fly */
73 wt_online_index( void *ctx, void *arg )
78 /* Cleanup loose ends after Modify completes */
80 wt_cf_cleanup( ConfigArgs *c )
87 wt_cf_gen( ConfigArgs *c )
89 struct wt_info *wi = (struct wt_info *) c->be->be_private;
92 if(c->op == SLAP_CONFIG_EMIT) {
100 ch_free( wi->wi_dbenv_home );
101 wi->wi_dbenv_home = c->value_string;
104 ch_free( wi->wi_dbenv_config );
105 wi->wi_dbenv_config = c->value_string;
109 rc = wt_attr_index_config( wi, c->fname, c->lineno,
110 c->argc - 1, &c->argv[1], &c->reply);
112 if( rc != LDAP_SUCCESS ) return 1;
113 wi->wi_flags |= WT_OPEN_INDEX;
115 if ( wi->wi_flags & WT_IS_OPEN ) {
116 c->cleanup = wt_cf_cleanup;
118 if ( !wi->wi_index_task ) {
119 /* Start the task as soon as we finish here. Set a long
120 * interval (10 hours) so that it only gets scheduled once.
122 if ( c->be->be_suffix == NULL || BER_BVISNULL( &c->be->be_suffix[0] ) ) {
123 fprintf( stderr, "%s: "
124 "\"index\" must occur after \"suffix\".\n",
128 ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
129 wi->wi_index_task = ldap_pvt_runqueue_insert(&slapd_rq, 36000,
130 wt_online_index, c->be,
131 LDAP_XSTRING(wt_online_index),
132 c->be->be_suffix[0].bv_val );
133 ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
142 int wt_back_init_cf( BackendInfo *bi )
145 bi->bi_cf_ocs = wtocs;
147 rc = config_register_schema( wtcfg, wtocs );
154 * indent-tabs-mode: t