on proxy - do not store events which will arrive thru server too
authorMiloš Mulač <mulac@civ.zcu.cz>
Tue, 11 Sep 2007 15:30:14 +0000 (15:30 +0000)
committerMiloš Mulač <mulac@civ.zcu.cz>
Tue, 11 Sep 2007 15:30:14 +0000 (15:30 +0000)
org.glite.lb.server/src/bkserverd.c
org.glite.lb.server/src/db_store.c
org.glite.lb.server/src/store.c.T

index 2074fb6..d141bb2 100644 (file)
@@ -390,6 +390,10 @@ int main(int argc, char *argv[])
        name = strrchr(argv[0],'/');
        if (name) name++; else name = argv[0];
 
+       memset(host, 0, sizeof host);
+       edg_wll_gss_gethostname(host,sizeof host);
+       host[sizeof host - 1] = 0;
+
        asprintf(&port, "%d", GLITE_JOBID_DEFAULT_PORT);
 #ifdef GLITE_LB_SERVER_WITH_WS
        asprintf(&ws_port, "%d", GLITE_JOBID_DEFAULT_PORT+3);
@@ -553,13 +557,8 @@ int main(int argc, char *argv[])
                        }
                        else fake_port = atoi(port);
                }
-               else
-               {
-                       char    buf[300];
-
-                       edg_wll_gss_gethostname(buf,sizeof buf);
-                       buf[sizeof buf - 1] = 0;
-                       fake_host = strdup(buf);
+               else {
+                       fake_host = strdup(host);
                        fake_port = atoi(port); 
                }
 
@@ -1201,8 +1200,15 @@ int bk_handle_connection_proxy(int conn, struct timeval *timeout, void *data)
        ctx->semset = semset;
        ctx->semaphores = semaphores;
 
-       ctx->srvName = strdup(host);
-       ctx->srvPort = atoi(port);
+       if (fake_host)
+       {
+               ctx->srvName = strdup(fake_host);
+               ctx->srvPort = fake_port;
+       }
+       else {
+               ctx->srvName = strdup(host);
+               ctx->srvPort = atoi(port);
+       }
        
        ctx->connProxy = (edg_wll_ConnProxy *) calloc(1, sizeof(edg_wll_ConnProxy));
        if ( !ctx->connProxy ) {
index 4c7349b..23b1a8d 100644 (file)
@@ -56,6 +56,21 @@ db_store(edg_wll_Context ctx,char *ucs, char *event)
   }
 #endif
 
+  /* events logged to proxy and server (DIRECT flag) may be ignored on proxy
+   * if jobid prefix hostname matches server hostname -> they will
+   * sooner or later arrive to server too and are stored in common DB 
+   */
+  if (ctx->isProxy && ctx->serverRunning && (ev->any.priority & EDG_WLL_LOGFLAG_DIRECT) ) {
+       char            *srvName;
+       unsigned int    srvPort;
+
+       
+       edg_wlc_JobIdGetServerParts(ev->any.jobId, &srvName, &srvPort);
+       if (!strcmp(ctx->srvName, srvName)) {
+               return 0;
+       }
+
+  }
 
   /* XXX: if event type is user tag, convert the tag name to lowercase!
    *     (not sure whether to convert a value too is reasonable
index 45e55ae..12241a7 100644 (file)
@@ -292,7 +292,7 @@ static int store_job(edg_wll_Context ctx,const edg_wlc_JobId job,const char *use
                server = 1;
        }
        
-       trio_asprintf(&stmt,"insert into jobs(jobid,dg_jobid,userid,proxy,bkserver) "
+       trio_asprintf(&stmt,"insert into jobs(jobid,dg_jobid,userid,proxy,server) "
                "values ('%|Ss','%|Ss','%|Ss', '%|Sd', '%|Sd')",jobid,jobstr,userid,proxy,server);
 
        if (edg_wll_ExecStmt(ctx,stmt,NULL) < 0) {