diff options
| author | Ben Pfaff <blp@nicira.com> | 2010-03-18 11:24:55 -0700 |
|---|---|---|
| committer | Ben Pfaff <blp@nicira.com> | 2010-03-18 11:24:55 -0700 |
| commit | ada496b5cc123fca2913be8b73097934f528cec8 (patch) | |
| tree | da5c46004219db89e58333e92efd6ea38d38e876 /ovsdb/ovsdb-server.c | |
| parent | afe20d5c7092f31943e32ff2b9d99526fbfbc6cd (diff) | |
| download | openvswitch-ada496b5cc123fca2913be8b73097934f528cec8.tar.gz | |
ovsdb: Compact databases online automatically and on-demand.
If the database grows fairly large, and we've written a fair number of
transactions to it, and it's been a while since the database was compacted,
then (after the next commit) compact the database.
Also, compact the database online if the "ovsdb-server/compact" command is
issued via unixctl. I suspect that this feature will rarely if ever be
used in practice, but it's easier to test than compacting automatically.
Bug #2391.
Diffstat (limited to 'ovsdb/ovsdb-server.c')
| -rw-r--r-- | ovsdb/ovsdb-server.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c index ac3ae4a91..7c4b73306 100644 --- a/ovsdb/ovsdb-server.c +++ b/ovsdb/ovsdb-server.c @@ -50,6 +50,7 @@ #define THIS_MODULE VLM_ovsdb_server static unixctl_cb_func ovsdb_server_exit; +static unixctl_cb_func ovsdb_server_compact; static void parse_options(int argc, char *argv[], char **file_namep, struct shash *remotes, char **unixctl_pathp, @@ -68,6 +69,7 @@ main(int argc, char *argv[]) struct ovsdb_jsonrpc_server *jsonrpc; struct shash remotes; struct ovsdb_error *error; + struct ovsdb_file *file; struct ovsdb *db; struct process *run_process; char *file_name; @@ -87,7 +89,7 @@ main(int argc, char *argv[]) die_if_already_running(); daemonize_start(); - error = ovsdb_file_open(file_name, false, &db); + error = ovsdb_file_open(file_name, false, &db, &file); if (error) { ovs_fatal(0, "%s", ovsdb_error_to_string(error)); } @@ -119,6 +121,8 @@ main(int argc, char *argv[]) daemonize_complete(); unixctl_command_register("exit", ovsdb_server_exit, &exiting); + unixctl_command_register("ovsdb-server/compact", ovsdb_server_compact, + file); exiting = false; while (!exiting) { @@ -235,6 +239,25 @@ ovsdb_server_exit(struct unixctl_conn *conn, const char *args OVS_UNUSED, } static void +ovsdb_server_compact(struct unixctl_conn *conn, const char *args OVS_UNUSED, + void *file_) +{ + struct ovsdb_file *file = file_; + struct ovsdb_error *error; + + VLOG_INFO("compacting database by user request"); + error = ovsdb_file_compact(file); + if (!error) { + unixctl_command_reply(conn, 200, NULL); + } else { + char *s = ovsdb_error_to_string(error); + ovsdb_error_destroy(error); + unixctl_command_reply(conn, 503, s); + free(s); + } +} + +static void parse_options(int argc, char *argv[], char **file_namep, struct shash *remotes, char **unixctl_pathp, char **run_command) |
