Changeset: ceac2926d580 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ceac2926d580
Modified Files:
tools/merovingian/client/monetdb.c
Branch: wlcr
Log Message:
Add subcommands master and replica to the monetdb tool
For the moment they are not doing anything useful, except checking that their
arguments have been given correctly.
diffs (177 lines):
diff --git a/tools/merovingian/client/monetdb.c
b/tools/merovingian/client/monetdb.c
--- a/tools/merovingian/client/monetdb.c
+++ b/tools/merovingian/client/monetdb.c
@@ -150,6 +150,17 @@ command_help(int argc, char *argv[])
printf(" Database Server. Databases in this list can be
connected\n");
printf(" to as well. If expression is given, all entries
are\n");
printf(" matched against a limited glob-style expression.\n");
+ } else if (strcmp(argv[1], "master") == 0) {
+ printf("Usage: monetdb master <dbname> [path]\n");
+ printf(" Sets the database <dbname> into master mode.\n");
+ printf(" This will actually stop the database take a
snapshot\n");
+ printf(" set the server into master mode and restart it.\n");
+ } else if (strcmp(argv[1], "replica") == 0) {
+ printf("Usage: monetdb replica <dbname> <mastername>\n");
+ printf(" Creates a new replica with name <dbname> from the\n");
+ printf(" database <mastername> The database <mastername> must
\n");
+ printf(" have been declared as master with the \"monetdb
master\"\n");
+ printf(" command.\n");
} else if (strcmp(argv[1], "help") == 0) {
printf("Yeah , help on help, how desparate can you be? ;)\n");
} else if (strcmp(argv[1], "version") == 0) {
@@ -192,7 +203,7 @@ MEROgetStatus(sabdb **ret, char *databas
char *p;
char *buf;
char *e;
-
+
if (database == NULL)
database = "#all";
@@ -597,7 +608,7 @@ simple_command(int argc, char *argv[], c
command_help(2, &argv[-1]);
exit(1);
}
-
+
/* walk through the arguments and hunt for "options" */
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "--") == 0) {
@@ -702,7 +713,7 @@ command_status(int argc, char *argv[])
break;
case '-':
if (p[1] == '\0') {
- if (argc - 1 > i)
+ if (argc - 1 > i)
doall = 0;
i = argc;
break;
@@ -760,7 +771,7 @@ command_status(int argc, char *argv[])
prev = NULL;
while (stats != NULL) {
if (stats->locked == curLock &&
- (curLock == 1 ||
+ (curLock == 1 ||
(curLock == 0 && stats->state ==
curMode)))
{
sabdb *next = stats->next;
@@ -1006,7 +1017,7 @@ command_startstop(int argc, char *argv[]
break;
case '-':
if (p[1] == '\0') {
- if (argc - 1 > i)
+ if (argc - 1 > i)
doall = 0;
i = argc;
break;
@@ -1244,7 +1255,7 @@ command_get(int argc, char *argv[])
switch (*p) {
case '-':
if (p[1] == '\0') {
- if (argc - 1 > i)
+ if (argc - 1 > i)
doall = 0;
i = argc;
break;
@@ -1308,7 +1319,7 @@ command_get(int argc, char *argv[])
exit(1);
}
readPropsBuf(defprops, buf + 3);
- if( buf)
+ if( buf)
free(buf);
if (twidth > 0) {
@@ -1503,18 +1514,18 @@ command_create(int argc, char *argv[])
size_t len = strlen("create mfunnel=") + strlen(mfunnel) + 1;
char *cmd = malloc(len);
snprintf(cmd, len, "create mfunnel=%s", mfunnel);
- simple_argv_cmd(argv[0], orig, cmd,
+ simple_argv_cmd(argv[0], orig, cmd,
"created multiplex-funnel in maintenance mode",
NULL);
free(cmd);
} else if (password != NULL) {
size_t len = strlen("create password=") + strlen(password) + 1;
char *cmd = malloc(len);
snprintf(cmd, len, "create password=%s", password);
- simple_argv_cmd(argv[0], orig, cmd,
+ simple_argv_cmd(argv[0], orig, cmd,
"created database with password for monetdb
user", NULL);
free(cmd);
} else {
- simple_argv_cmd(argv[0], orig, "create",
+ simple_argv_cmd(argv[0], orig, "create",
"created database in maintenance mode", NULL);
}
msab_freeStatus(&orig);
@@ -1609,6 +1620,34 @@ command_release(int argc, char *argv[])
simple_command(argc, argv, "release", "taken database out of
maintenance mode", 1);
}
+static void
+command_master(int argc, char *argv[])
+{
+ int i;
+ if (argc != 2 && argc != 3) {
+ /* print help message for this command */
+ command_help(argc + 1, &argv[-1]);
+ exit(1);
+ }
+
+ fprintf(stderr, "Called master with args:\n");
+ for (i = 0; i < argc; i++)
+ fprintf(stderr, " %s\n", argv[i]);
+}
+
+static void
+command_replica(int argc, char *argv[])
+{
+ int i;
+ if (argc != 3) {
+ /* print help message for this command */
+ command_help(argc + 1, &argv[-1]);
+ exit(1);
+ }
+ fprintf(stderr, "Called replica with args:\n");
+ for (i = 0; i < argc; i++)
+ fprintf(stderr, " %s\n", argv[i]);
+}
int
main(int argc, char *argv[])
@@ -1626,13 +1665,13 @@ main(int argc, char *argv[])
* monetdb [monetdb_options] command [options] [database [...]]
* this means we first scout for monetdb_options which stops as soon
* as we find a non-option argument, which then must be command */
-
+
/* first handle the simple no argument case */
if (argc <= 1) {
command_help(0, NULL);
return(1);
}
-
+
/* handle monetdb_options */
for (i = 1; argc > i && argv[i][0] == '-'; i++) {
switch (argv[i][1]) {
@@ -1715,7 +1754,7 @@ main(int argc, char *argv[])
command_help(0, NULL);
return(1);
}
-
+
/* commands that do not need merovingian to be running */
if (strcmp(argv[i], "help") == 0) {
command_help(argc - i, &argv[i]);
@@ -1803,6 +1842,10 @@ main(int argc, char *argv[])
command_set(argc - i, &argv[i], INHERIT);
} else if (strcmp(argv[i], "discover") == 0) {
command_discover(argc - i, &argv[i]);
+ } else if (strcmp(argv[i], "master") == 0) {
+ command_master(argc - i, &argv[i]);
+ } else if (strcmp(argv[i], "replica") == 0) {
+ command_replica(argc - i, &argv[i]);
} else {
fprintf(stderr, "monetdb: unknown command: %s\n", argv[i]);
command_help(0, NULL);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list