Update of /cvsroot/monetdb/sql/src/backends/monet5/merovingian
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv15652

Modified Files:
        merovingian_controlrunner.c monetdb.c monetdb_merocom.c 
Log Message:
- let Merovingian create and destroy databases if it's running (allows
  to immediately interact with discovery service (TODO)
- properly detect errors from control_send and report them




U merovingian_controlrunner.c
Index: merovingian_controlrunner.c
===================================================================
RCS file: 
/cvsroot/monetdb/sql/src/backends/monet5/merovingian/merovingian_controlrunner.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- merovingian_controlrunner.c 20 Aug 2009 16:23:19 -0000      1.3
+++ merovingian_controlrunner.c 9 Sep 2009 09:50:41 -0000       1.4
@@ -170,10 +170,11 @@
                                                Mfprintf(stderr, "failed to 
create "
                                                                "database '%s': 
%s\n", q, getErrMsg(e));
                                                len = snprintf(buf2, 
sizeof(buf2),
-                                                               "create: %s\n", 
getErrMsg(e));
+                                                               "%s\n", 
getErrMsg(e));
                                                send(msgsock, buf2, len, 0);
                                                freeErr(e);
                                        } else {
+                                               Mfprintf(stdout, "created 
database '%s'\n", q);
                                                len = snprintf(buf2, 
sizeof(buf2), "OK\n");
                                                send(msgsock, buf2, len, 0);
                                        }
@@ -183,10 +184,13 @@
                                                Mfprintf(stderr, "failed to 
destroy "
                                                                "database '%s': 
%s\n", q, getErrMsg(e));
                                                len = snprintf(buf2, 
sizeof(buf2),
-                                                               "destroy: 
%s\n", getErrMsg(e));
+                                                               "%s\n", 
getErrMsg(e));
                                                send(msgsock, buf2, len, 0);
                                                freeErr(e);
                                        } else {
+                                               /* FIXME: immediately 
deregister with neighbour
+                                                * discovery service */
+                                               Mfprintf(stdout, "destroyed 
database '%s'\n", q);
                                                len = snprintf(buf2, 
sizeof(buf2), "OK\n");
                                                send(msgsock, buf2, len, 0);
                                        }

U monetdb.c
Index: monetdb.c
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/merovingian/monetdb.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- monetdb.c   4 Sep 2009 12:40:44 -0000       1.38
+++ monetdb.c   9 Sep 2009 09:50:41 -0000       1.39
@@ -76,6 +76,7 @@
 
 static str dbfarm = NULL;
 static int mero_running = 0;
+static char mero_control[8096];
 static int TERMWIDTH = 80;  /* default to classic terminal width */
 
 static void
@@ -218,7 +219,14 @@
                if (argv[i] == NULL)
                        continue;
 
-               ret = db_create(argv[i]);
+               if (mero_running == 0) {
+                       ret = db_create(argv[i]);
+               } else {
+                       char *out;
+                       ret = control_send(&out, mero_control, -1, argv[i], 
"create");
+                       if (ret == NULL && strcmp(out, "OK\n") != 0)
+                               ret = out;
+               }
 
                if (ret == NULL) {
                        printf("successfully created database '%s' "
@@ -297,7 +305,15 @@
                if (argv[i] == NULL)
                        continue;
 
-               ret = db_destroy(argv[i]);
+               if (mero_running == 0) {
+                       ret = db_destroy(argv[i]);
+               } else {
+                       char *out;
+                       ret = control_send(&out, mero_control, -1, argv[i], 
"destroy");
+                       if (ret == NULL && strcmp(out, "OK\n") != 0)
+                               ret = out;
+               }
+
 
                if (ret == NULL) {
                        printf("successfully destroyed database '%s'\n", 
argv[i]);
@@ -395,6 +411,10 @@
                mero_running = 0;
        }
 
+       /* set path to control channel */
+       snprintf(mero_control, sizeof(mero_control),
+                       "%s/.merovingian_control", dbfarm);
+
        /* initialise Sabaoth so it knows where to look */
        SABAOTHinit(dbfarm, NULL);
 

U monetdb_merocom.c
Index: monetdb_merocom.c
===================================================================
RCS file: 
/cvsroot/monetdb/sql/src/backends/monet5/merovingian/monetdb_merocom.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- monetdb_merocom.c   8 Sep 2009 19:38:38 -0000       1.3
+++ monetdb_merocom.c   9 Sep 2009 09:50:41 -0000       1.4
@@ -23,15 +23,13 @@
        KILL,
        SHARE
 } merocom;
-/*     CREATE,
-       DESTROY */
 
 static void
 command_merocom(int argc, char *argv[], merocom mode)
 {
        int doall = 0;
-       char path[8096];
        char *res;
+       char *out;
        int i;
        err e;
        sabdb *orig;
@@ -40,9 +38,6 @@
        char *p;
        int ret = 0;
 
-       snprintf(path, 8095, "%s/.merovingian_control", dbfarm);
-       path[8095] = '\0';
-
        switch (mode) {
                case START:
                        type = "start";
@@ -141,11 +136,11 @@
                        if (stats->state == SABdbRunning) {
                                printf("%s%sing database '%s'... ", type, mode 
== STOP ? "p" : "", stats->dbname);
                                fflush(stdout);
-                               control_send(&res, path, 0, stats->dbname, 
type);
-                               if (strcmp(res, "OK\n") == 0) {
+                               out = control_send(&res, mero_control, 0, 
stats->dbname, type);
+                               if (out == NULL && strcmp(res, "OK\n") == 0) {
                                        printf("done\n");
                                } else {
-                                       printf("FAILED:\n%s", res);
+                                       printf("FAILED:\n%s", (out == NULL ? 
res : out));
                                        ret = 1;
                                }
                                free(res);
@@ -156,11 +151,11 @@
                        if (stats->state != SABdbRunning) {
                                printf("starting database '%s'... ", 
stats->dbname);
                                fflush(stdout);
-                               control_send(&res, path, 0, stats->dbname, 
type);
-                               if (strcmp(res, "OK\n") == 0) {
+                               out = control_send(&res, mero_control, 0, 
stats->dbname, type);
+                               if (out == NULL && strcmp(res, "OK\n") == 0) {
                                        printf("done\n");
                                } else {
-                                       printf("FAILED:\n%s", res);
+                                       printf("FAILED:\n%s", (out == NULL ? 
res : out));
                                        ret = 1;
                                }
                                free(res);
@@ -175,9 +170,9 @@
                        /* stay quiet, we're part of monetdb set property=value 
*/
 
                        snprintf(share, sizeof(share), "share=%s", value);
-                       control_send(&res, path, 0, stats->dbname, share);
-                       if (strcmp(res, "OK\n") != 0) {
-                               printf("FAILED:\n%s", res);
+                       out = control_send(&res, mero_control, 0, 
stats->dbname, share);
+                       if (out != NULL || strcmp(res, "OK\n") != 0) {
+                               printf("FAILED:\n%s", (out == NULL ? res : 
out));
                                ret = 1;
                        }
                        free(res);


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to