From 0cf9a9984ce733d8315057b810bfda90cec5c04a Mon Sep 17 00:00:00 2001 From: Marco Boss Date: Thu, 31 Mar 2022 17:00:44 +0200 Subject: add sharding logic --- src/exchange-tools/taler-exchange-dbinit.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/exchange-tools/taler-exchange-dbinit.c') diff --git a/src/exchange-tools/taler-exchange-dbinit.c b/src/exchange-tools/taler-exchange-dbinit.c index 9ec31afc1..1aba05a6d 100644 --- a/src/exchange-tools/taler-exchange-dbinit.c +++ b/src/exchange-tools/taler-exchange-dbinit.c @@ -49,6 +49,10 @@ static int gc_db; */ static uint32_t num_partitions; +/** + * -S option: setup a sharded database + */ +static uint32_t num_shards; /** * Main function that will be run. @@ -113,6 +117,24 @@ run (void *cls, return; } } + else if (1 < + num_shards) + { + if (GNUNET_OK != plugin->setup_shards (plugin->cls, num_shards)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Could not setup shards. Aborting\n"); + if (GNUNET_OK != plugin->drop_tables (plugin->cls)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Could not drop tables after failed shard setup, please delete the DB manually\n"); + } + TALER_EXCHANGEDB_plugin_unload (plugin); + plugin = NULL; + global_ret = EXIT_NOTINSTALLED; + return; + } + } if (gc_db || clear_shards) { if (GNUNET_OK != @@ -178,6 +200,11 @@ main (int argc, "NUMBER", "Setup a partitioned database where each table which can be partitioned holds NUMBER partitions on a single DB node (NOTE: this is different from sharding)", &num_partitions), + GNUNET_GETOPT_option_uint ('S', + "shard", + "NUMBER", + "Setup a sharded database whit N shards", + &num_shards), GNUNET_GETOPT_OPTION_END }; enum GNUNET_GenericReturnValue ret; -- cgit v1.2.3