summaryrefslogtreecommitdiff
path: root/src/exchange-tools/taler-exchange-dbinit.c
diff options
context:
space:
mode:
authorMarco Boss <bossm8@bfh.ch>2022-03-31 17:00:44 +0200
committerMarco Boss <bossm8@bfh.ch>2022-03-31 17:00:44 +0200
commit0cf9a9984ce733d8315057b810bfda90cec5c04a (patch)
tree767e0d72b2a3dcc8b4cbd2cea5cadd1c6139492e /src/exchange-tools/taler-exchange-dbinit.c
parenteadee56dcf9d2fed8b8e94d271db31e3c3832cfa (diff)
downloadexchange-0cf9a9984ce733d8315057b810bfda90cec5c04a.tar.gz
exchange-0cf9a9984ce733d8315057b810bfda90cec5c04a.tar.bz2
exchange-0cf9a9984ce733d8315057b810bfda90cec5c04a.zip
add sharding logic
Diffstat (limited to 'src/exchange-tools/taler-exchange-dbinit.c')
-rw-r--r--src/exchange-tools/taler-exchange-dbinit.c27
1 files changed, 27 insertions, 0 deletions
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;