Update of /cvsroot/monetdb/sql/src/backends/monet5
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv13659
Modified Files:
monetdb.1 monetdb.mx
Log Message:
Added discover to monetdb. It simply prints a list of remote databases
discovered by merovingian.
% $INSTALL_DIR/bin/monetdb discover
name location
sdss mapi:monetdb://tweek.ins.cwi.nl:50000/
U monetdb.1
Index: monetdb.1
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/monetdb.1,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- monetdb.1 30 Aug 2008 10:52:13 -0000 1.10
+++ monetdb.1 30 Aug 2008 12:15:28 -0000 1.11
@@ -1,7 +1,7 @@
.\" Process this file with
.\" groff -man -Tascii foo.1
.\"
-.TH MONETDB 1 "SEPTEMBER 2007" Application "MonetDB Applications"
+.TH MONETDB 1 "SEPTEMBER 2008" Application "MonetDB Applications"
.SH NAME
monetdb \- control a MonetDB Database Server instance
.SH SYNOPSIS
@@ -17,7 +17,7 @@
The commands for the
.B monetdb
utility are
-.B create, destroy, lock, release, status, start, stop, kill, help, version.
+.B create, destroy, lock, release, status, start, stop, kill, discover, help,
version.
The commands facilitate adding, removing, maintaining, starting and
stopping a database inside the MonetDB Database Server.
.IP "create [\-l] database [database ...]"
@@ -129,6 +129,12 @@
.BR monetdb (1)
indicates failure if one of the databases had a failure, even though
other databases were successful.
+.IP discover
+Returns a list of remote databases that were discovered by
+.B merovingian (1).
+All databases listed can be connected to via the local MonetDB Database
+Server as if it were local databases. The connection is redirected or
+proxied based on configuration settings.
.IP \-h
.IP "help [command]"
Shows general help, or short help for a given command.
U monetdb.mx
Index: monetdb.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/monetdb.mx,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- monetdb.mx 30 Aug 2008 10:52:14 -0000 1.24
+++ monetdb.mx 30 Aug 2008 12:15:28 -0000 1.25
@@ -87,7 +87,7 @@
printf(" where command is one of:\n");
printf(" create, destroy, lock, release\n");
printf(" status, start, stop, kill\n");
- printf(" help, version\n");
+ printf(" discover, help, version\n");
printf(" use the help command to get help for a particular
command\n");
} else if (strcmp(argv[1], "create") == 0) {
printf("Usage: monetdb create [-l] database [database ...]\n");
@@ -149,6 +149,11 @@
printf("Options:\n");
printf(" -a kill all known databases\n");
printf(" -w wait for a database to be killed instead of
returning immediately\n");
+ } else if (strcmp(argv[1], "discover") == 0) {
+ printf("Usage: monetdb discover\n");
+ printf(" Lists the remote databases discovered by the
MonetDB\n");
+ printf(" Database Server. Databases in this list can be
connected\n");
+ printf(" to as well.\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) {
@@ -546,6 +551,79 @@
SABAOTHfreeStatus(&orig);
}
+static void
+command_discover(int argc, char *argv[])
+{
+ char path[8096];
+ int sock = -1;
+ struct sockaddr_un server;
+ char buf[256];
+ char *p, *q;
+ int len;
+ int pos = 0;
+
+ (void)argc;
+ (void)argv;
+
+ /* if Merovingian isn't running, there's not much we can do */
+ if (mero_running == 0) {
+ fprintf(stderr, "discover: cannot perform: MonetDB Database
Server "
+ "(merovingian) is not running\n");
+ exit(1);
+ }
+
+ snprintf(path, 8095, "%s/.merovingian_control", dbfarm);
+ path[8095] = '\0';
+
+ if ((sock = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
+ fprintf(stderr, "discover: cannot open connection: %s\n",
+ strerror(errno));
+ exit(2);
+ }
+ memset(&server, 0, sizeof(struct sockaddr_un));
+ server.sun_family = AF_UNIX;
+ strncpy(server.sun_path, path, sizeof(server.sun_path) - 1);
+ if (connect(sock, (SOCKPTR) &server, sizeof(struct sockaddr_un))) {
+ fprintf(stderr, "discover: cannot connect: %s\n",
strerror(errno));
+ exit(2);
+ }
+
+ printf(" name location\n");
+ /* Send the pass phrase to unlock the information available in
+ * merovingian. Anelosimus eximius is a social species of spiders,
+ * which help each other, just like merovingians do among each
+ * other. */
+ len = snprintf(buf, sizeof(buf), "anelosimus eximius\n");
+ send(sock, buf, len, 0);
+ while ((len = recv(sock, buf + pos, sizeof(buf) - 1 - pos, 0)) > 0) {
+ buf[pos + len] = '\0';
+ if ((p = strchr(buf, '\n')) == NULL) {
+ /* no newline in this block too large, warn and discard
*/
+ printf("discover: WARNING: discarding (too long?) line:
%s\n", buf);
+ pos = 0;
+ continue;
+ }
+ *p++ = '\0';
+ if ((q = strchr(buf, '\t')) == NULL) {
+ /* doesn't look correct */
+ printf("discover: WARNING: discarding incorrect line:
%s\n", buf);
+ memmove(buf, p, len - (p - buf));
+ pos = len - (p - buf);
+ continue;
+ }
+ *q++ = '\0';
+ printf("%-14s %s\n", buf, q);
+ memmove(buf, p, len - (p - buf));
+ pos = len - (p - buf);
+ }
+ if (len < 0) {
+ fprintf(stderr, "discover: error while reading from from
merovingian\n");
+ exit(2);
+ }
+
+ close(sock);
+}
+
typedef enum {
START = 0,
STOP,
@@ -1268,6 +1346,8 @@
command_merocom(argc - 1, &argv[1], STOP);
} else if (strcmp(argv[1], "kill") == 0) {
command_merocom(argc - 1, &argv[1], KILL);
+ } else if (strcmp(argv[1], "discover") == 0) {
+ command_discover(argc - 1, &argv[1]);
} else if (strcmp(argv[1], "help") == 0 || strcmp(argv[1], "-h") == 0) {
command_help(argc - 1, &argv[1]);
} else if (strcmp(argv[1], "version") == 0 || strcmp(argv[1], "-v") ==
0) {
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins