aboutsummaryrefslogtreecommitdiff
path: root/src/exchange-tools
diff options
context:
space:
mode:
authorMarco Boss <bossm8@bfh.ch>2022-03-31 21:31:07 +0200
committerMarco Boss <bossm8@bfh.ch>2022-03-31 21:31:07 +0200
commit75c1e10a67d94f43d0c06433efc2b78c10bae5c5 (patch)
tree0e6d5dad60dfd8cc41b5a81d31b6e213e9bccd5e /src/exchange-tools
parent0cf9a9984ce733d8315057b810bfda90cec5c04a (diff)
add shard init for shard node
Diffstat (limited to 'src/exchange-tools')
-rw-r--r--src/exchange-tools/taler-exchange-dbinit.c39
1 files changed, 32 insertions, 7 deletions
diff --git a/src/exchange-tools/taler-exchange-dbinit.c b/src/exchange-tools/taler-exchange-dbinit.c
index 1aba05a6d..cf35466ca 100644
--- a/src/exchange-tools/taler-exchange-dbinit.c
+++ b/src/exchange-tools/taler-exchange-dbinit.c
@@ -50,9 +50,14 @@ static int gc_db;
static uint32_t num_partitions;
/**
- * -S option: setup a sharded database
+ * -F option: setup a sharded database, i.e. create foreign tables/server
*/
-static uint32_t num_shards;
+static uint32_t num_foreign_servers;
+
+/**
+ * -S option: setup a database on a shard server, creates tables with suffix shard_idx
+ */
+static uint32_t shard_idx;
/**
* Main function that will be run.
@@ -89,6 +94,20 @@ run (void *cls,
"Could not drop tables as requested. Either database was not yet initialized, or permission denied. Consult the logs. Will still try to create new tables.\n");
}
}
+ if (1 <
+ shard_idx)
+ {
+ if (GNUNET_OK != plugin->create_shard_tables (plugin->cls, shard_idx))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Could not create shard database\n");
+ global_ret = EXIT_NOTINSTALLED;
+ }
+ /* We do not want to continue if we are on a shard */
+ TALER_EXCHANGEDB_plugin_unload (plugin);
+ plugin = NULL;
+ return;
+ }
if (GNUNET_OK !=
plugin->create_tables (plugin->cls))
{
@@ -118,9 +137,10 @@ run (void *cls,
}
}
else if (1 <
- num_shards)
+ num_foreign_servers)
{
- if (GNUNET_OK != plugin->setup_shards (plugin->cls, num_shards))
+ if (GNUNET_OK != plugin->setup_foreign_servers (plugin->cls,
+ num_foreign_servers))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Could not setup shards. Aborting\n");
@@ -200,11 +220,16 @@ 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 ('F',
+ "foreign",
+ "NUMBER",
+ "Setup a sharded database whit N foreign servers (shards) / tables",
+ &num_foreign_servers),
GNUNET_GETOPT_option_uint ('S',
"shard",
- "NUMBER",
- "Setup a sharded database whit N shards",
- &num_shards),
+ "INDEX",
+ "Setup a shard server, creates tables with INDEX as suffix",
+ &shard_idx),
GNUNET_GETOPT_OPTION_END
};
enum GNUNET_GenericReturnValue ret;