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

Modified Files:
        ChangeLog merovingian_discoveryrunner.c monetdb.1 
Log Message:
Basically undo most of yesterdays commit; revert AVAI command, now just use 
ANNC, also use a ttl again.  After a discussion with Arjen, it became clear 
that announcing the control port should be just an explicit entry, and now it 
is.

U monetdb.1
Index: monetdb.1
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/merovingian/monetdb.1,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- monetdb.1   23 Sep 2009 16:22:44 -0000      1.10
+++ monetdb.1   25 Sep 2009 08:20:39 -0000      1.11
@@ -199,8 +199,8 @@
 Like set, but unsets the database-local value, and reverts to inherit
 from the default again.
 .IP "discover [expression]"
-Returns a list of remote databases URIs for databases that were
-discovered by
+Returns a list of remote merovingians and database URIs
+that were discovered by
 .BR merovingian (1).
 All databases listed can be connected to via the local MonetDB Database
 Server as if it were local databases using their database name.  The
@@ -210,6 +210,15 @@
 URI matches the expression.  The expression syntax is described in the
 section
 .IR EXPRESSIONS .
+Next to database URIs the hostnames and ports for merovingians that
+allow to be controlled remotely can be found in the discover list masked
+with an asterisk.  These entries can easily be filtered out using an
+expression (e.g. "mapi:monetdb:*") if desired.  The control entries come
+in handy when one wants to get an overview of available merovingians in
+e.g. a local cluster.  Note that for merovingian to announce its control
+port, the
+.I mero_controlport
+setting for that merovingian must be enabled in the configuration file.
 .IP \-h
 .IP "help [command]"
 Shows general help, or short help for a given command.

U merovingian_discoveryrunner.c
Index: merovingian_discoveryrunner.c
===================================================================
RCS file: 
/cvsroot/monetdb/sql/src/backends/monet5/merovingian/merovingian_discoveryrunner.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- merovingian_discoveryrunner.c       24 Sep 2009 14:15:32 -0000      1.5
+++ merovingian_discoveryrunner.c       25 Sep 2009 08:20:39 -0000      1.6
@@ -70,7 +70,6 @@
        remotedb rdb;
        remotedb prv;
        char *tag;
-       char *p;
 
        pthread_mutex_lock(&_mero_remotedb_lock);
 
@@ -84,29 +83,10 @@
                                        strcmp(conn, rdb->conn) == 0)
                        {
                                /* refresh ttl */
-                               rdb->ttl = (ttl > 0 ? time(NULL) : 0) + ttl;
+                               rdb->ttl = time(NULL) + ttl;
                                rdb = prv;
                                break;
                        }
-                       /* look if we have a merovingian entry for this 
database, in
-                        * which case we can drop that one (as it is implied by 
the
-                        * database entry) */
-                       if (strcmp("*", rdb->fullname) == 0 &&
-                                       (p = strstr(conn, rdb->conn)) != NULL &&
-                                       p > conn && p[-1] == '/' &&
-                                       p[strlen(rdb->conn)] == '/')
-                       {
-                               if (prv == NULL) {
-                                       _mero_remotedbs = rdb->next;
-                               } else {
-                                       prv->next = rdb->next;
-                               }
-                               free(rdb->dbname);
-                               free(rdb->conn);
-                               free(rdb->tag);
-                               free(rdb->fullname);
-                               free(rdb);
-                       }
                        prv = rdb;
                        rdb = rdb->next;
                }
@@ -122,7 +102,7 @@
        rdb->dbname = strdup(dbname);
        rdb->tag = tag != NULL ? strdup(tag) : NULL;
        rdb->conn = strdup(conn);
-       rdb->ttl = (ttl > 0 ? time(NULL) : 0) + ttl;
+       rdb->ttl = time(NULL) + ttl;
        rdb->next = NULL;
 
        pthread_mutex_unlock(&_mero_remotedb_lock);
@@ -164,8 +144,7 @@
 
        /* start shouting around that we're here ;) request others to tell
         * what databases they have */
-       snprintf(buf, 512, "HELO %s:%hu", _mero_hostname,
-                       _mero_controlport == 0 ? _mero_port :  
_mero_controlport);
+       snprintf(buf, 512, "HELO %s", _mero_hostname);
        broadcast(buf);
 
        ckv = getDefaultProps();
@@ -176,6 +155,7 @@
                /* do a round of announcements, we're ahead of the ttl because
                 * when we announce, we add 60 seconds to avoid a "gap" */
                if (forceannc == 1 || deadline <= now) {
+                       forceannc = 0;
                        /* set new deadline */
                        deadline = now + _mero_discoveryttl;
 
@@ -205,15 +185,16 @@
                                freeConfFile(ckv);
                        }
 
-                       if (orig != NULL) {
+                       if (orig != NULL)
                                SABAOTHfreeStatus(&orig);
-                       } else if (forceannc == 1 && _mero_controlport != 0) {
-                               /* no databases, yet still announce we're here 
*/
-                               snprintf(buf, 512, "AVAI %s:%hu",
-                                               _mero_hostname, 
_mero_controlport);
+                       
+                       if (_mero_controlport != 0) {
+                               /* announce control port */
+                               snprintf(buf, 512, "ANNC * %s:%hu %d",
+                                               _mero_hostname, 
_mero_controlport,
+                                               _mero_discoveryttl + 60);
                                broadcast(buf);
                        }
-                       forceannc = 0;
                }
 
                /* do a round to see if we have to cleanup anything (expired
@@ -287,11 +268,6 @@
                        /* force an announcement round by dropping the deadline 
*/
                        forceannc = 1;
                        continue;
-               } else if (strncmp(buf, "AVAI ", 5) == 0) {
-                       /* AVAILABLE message, register merovingian */
-                       if (addRemoteDB("*", buf + 5, 0) == 1)
-                               Mfprintf(_mero_discout, "registered neighbour 
%s (%s)\n",
-                                               buf + 5, host);
                } else if (strncmp(buf, "LEAV ", 5) == 0) {
                        /* LEAVE message, unregister database */
                        char *sp = NULL;
@@ -324,10 +300,16 @@
                        if (dbname == NULL || conn == NULL || ttl == NULL)
                                continue;
 
-                       if (addRemoteDB(dbname, conn, atoi(ttl)) == 1)
-                               Mfprintf(_mero_discout, "new database "
-                                               "%s%s (ttl=%ss)\n",
-                                               conn, dbname, ttl);
+                       if (addRemoteDB(dbname, conn, atoi(ttl)) == 1) {
+                               if (strcmp(dbname, "*") == 0) {
+                                       Mfprintf(_mero_discout, "registered 
neighbour %s\n",
+                                                       conn);
+                               } else {
+                                       Mfprintf(_mero_discout, "new database "
+                                                       "%s%s (ttl=%ss)\n",
+                                                       conn, dbname, ttl);
+                               }
+                       }
                } else {
                        Mfprintf(_mero_discout, "ignoring unknown message from "
                                        "%s:%s: '%s'\n", host, service, buf);
@@ -364,7 +346,7 @@
                SABAOTHfreeStatus(&orig);
 
        /* deregister this merovingian, so it doesn't remain a stale entry */
-       if (c == 0 && _mero_controlport != 0) {
+       if (_mero_controlport != 0) {
                snprintf(buf, 512, "LEAV * %s:%hu",
                                _mero_hostname, _mero_controlport);
                broadcast(buf);

U ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/merovingian/ChangeLog,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- ChangeLog   23 Sep 2009 16:22:44 -0000      1.26
+++ ChangeLog   25 Sep 2009 08:20:39 -0000      1.27
@@ -1,6 +1,11 @@
 # ChangeLog file for sql/src/backends/monet5
 # This file is updated with mchangelog (Gentoo echangelog bastard script)
 
+  25 Sep 2009; Fabian Groffen <[email protected]> merovingian_discoveryrunner.c,
+  monetdb.1:
+  Remote controllable merovingians now announce their controlport. These
+  control entries show up in monetdb discover output marked with an asterisk.
+
   23 Sep 2009; Fabian Groffen <[email protected]> monetdb.1, monetdb.c,
   merovingian.1, merovingian.c, merovingian_controlrunner.c:
   Implemented Feature Request #2830754. monetdb can now control a remote


------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to