Changeset: 599114e7db4d for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=599114e7db4d
Modified Files:
monetdb5/scheduler/srvpool.c
Branch: default
Log Message:
Code cleanup
There is no need for an additional unique remote connection name.
diffs (173 lines):
diff --git a/monetdb5/scheduler/srvpool.c b/monetdb5/scheduler/srvpool.c
--- a/monetdb5/scheduler/srvpool.c
+++ b/monetdb5/scheduler/srvpool.c
@@ -30,23 +30,25 @@
*
* @verbatim
* barrier parallel:= scheduler.srvpool();
- * a:= srvpool.exec(sitename,fcnname,arg...);
+ * (s1,...,sn) := srvpool.server("queryplan");
+ * a:= user.S0_1_stub(s1,arg...);
* ...
- * b:= srvpool.exec(sitename,fcnname,arg...);
+ * b:= srvpool.S0_1_stub(sn,arg...);
* z:= mat.pack(a,...,b);
* exit parallel;
* @end verbatim
*
- * A dummy site name is generated by the compilers.
- * It is replaced by an actual name upon first call.
- * If the site went down, a new site is selected automatically.
- *
* We assume that the database versions are synchronised.
*
* To make the scheduler work, it needs a list of database instances.
* This list it gets from Merovingian by resolving
* all with the property 'shared=octopus' or 'shared=centipede' (set by
monetdb).
* The default is to use the local database as a target.
+ *
+ * Ideally, we would not like to ship query plans with each query, but
+ * this requires knowledge that the remote server has not been restarted
+ * since the last call. For the time being we assume the connection remains in
tact.
+ *
*/
#include "monetdb_config.h"
#include "mal_interpreter.h"
@@ -69,7 +71,6 @@ typedef struct REGMAL{
* All open connections are grouped here.
*/
typedef struct {
- str name; /* local unique name */
str uri; /* uri associated with remote server */
str usr; /* user credentials for using the server */
str pwd;
@@ -111,35 +112,17 @@ str SRVsetServers(Client cntxt, MalBlkPt
return MAL_SUCCEED;
}
-static int
-SRVPOOLfindServer(str dbalias)
-{
- int i;
- for (i=0; i<srvtop; i++)
- if ( strcmp(dbalias, servers[i].name) == 0 )
- return i;
- return -1;
-}
-
/* Look for and add a server with uri in the registry, give it a local unique
name. Return index in registry */
-static int serverid=0;
static int
SRVPOOLnewServer(str uri)
{
- int i;
- char buf[BUFSIZ];
-
- i = srvtop;
- /* use default settings */
- snprintf(buf,BUFSIZ,"srv_%d",serverid++);
- servers[i].name = GDKstrdup(buf);
- servers[i].usr = GDKstrdup("monetdb");
- servers[i].uri = GDKstrdup(uri);
- servers[i].pwd = GDKstrdup("monetdb");
- servers[i].nxt = NULL;
+ servers[srvtop].uri = GDKstrdup(uri);
+ servers[srvtop].usr = GDKstrdup("monetdb");
+ servers[srvtop].pwd = GDKstrdup("monetdb");
+ servers[srvtop].nxt = NULL;
srvtop++;
- return i;
+ return srvtop-1;
}
static int
@@ -148,7 +131,7 @@ SRVPOOLgetServer(str uri)
int i;
for (i=0; i<srvtop; i++)
- if ( strcmp(uri, servers[i].name) == 0 || strcmp(uri, servers[i].uri)
== 0 )
+ if ( strcmp(uri, servers[i].uri) == 0 )
return i;
return SRVPOOLnewServer(uri);
@@ -194,7 +177,7 @@ str SRVPOOLreset(int *ret)
msg = SRVPOOLdisconnect();
for ( i=0; i< srvtop; i++){
SRVPOOLcleanup(i);
- GDKfree(servers[i].name);
+ GDKfree(servers[i].uri);
}
memset((char*)servers, 0, sizeof(Server) * srvtop);
srvtop = 0;
@@ -210,14 +193,11 @@ SRVPOOLconnect(str *c, str *uri)
*c = NULL;
- i = SRVPOOLfindServer(*uri);
- if ( i < 0 ){
- for ( i =0; i < srvtop; i++)
- if ( strcmp(*uri, servers[i].uri) == 0)
- break;
- if ( i == srvtop)
- return createException(MAL, "srvpool.connect", "Server
%s is not registered", *uri);
- }
+ for ( i =0; i < srvtop; i++)
+ if ( strcmp(*uri, servers[i].uri) == 0)
+ break;
+ if ( i == srvtop)
+ return createException(MAL, "srvpool.connect", "Server %s is
not registered", *uri);
if ( servers[i].conn == NULL ) {
msg = RMTconnectScen(&conn, &servers[i].uri, &servers[i].usr,
&servers[i].pwd, &scen);
@@ -327,13 +307,13 @@ SRVPOOLfind(int srv, str qry){
static str
-SRVPOOLregisterInternal(Client cntxt, str dbalias, str fname)
+SRVPOOLregisterInternal(Client cntxt, str uri, str fname)
{
int srv;
str msg = MAL_SUCCEED, con;
Registry r;
- srv = SRVPOOLgetServer(dbalias);
+ srv = SRVPOOLgetServer(uri);
if ( srv < 0)
throw(MAL,"srvpool.register","Server not registered");
#ifdef DEBUG_RUN_SRVPOOL
@@ -341,7 +321,7 @@ SRVPOOLregisterInternal(Client cntxt, st
#else
(void) cntxt;
#endif
- msg = SRVPOOLconnect(&con, &dbalias);
+ msg = SRVPOOLconnect(&con, &uri);
if ( msg)
return msg;
if ( con) GDKfree(con);
@@ -364,13 +344,13 @@ SRVPOOLregisterInternal(Client cntxt, st
/* Make sure the MAL function identified in the srvpool.exec() is remotely
known */
str SRVPOOLregister(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
{
- str fname, dbalias;
+ str fname, uri;
(void) mb;
- dbalias = *(str*)getArgReference(stk,pci,1);
+ uri = *(str*)getArgReference(stk,pci,1);
fname = *(str*)getArgReference(stk,pci,2);
- return SRVPOOLregisterInternal(cntxt, dbalias, fname);
+ return SRVPOOLregisterInternal(cntxt, uri, fname);
}
@@ -409,7 +389,7 @@ SRVPOOLserver(Client cntxt, MalBlkPtr mb
for ( j= i=0; i < pci->retc && j < nrservers; j++) {
if ( servers[j].conn ) {
if ( !SRVPOOLfind(j,plan) ){
- msg = SRVPOOLregisterInternal(cntxt,
servers[i].name, plan);
+ msg = SRVPOOLregisterInternal(cntxt,
servers[i].uri, plan);
if ( msg) {
#ifdef DEBUG_RUN_SRVPOOL
mnstr_printf(cntxt->fdout,"#failed to
register at %d\n",i);
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list