From 2a6a87986dbc51a1f27a32ee9f548cbf882add45 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Milo=C5=A1=20Mula=C4=8D?= Date: Thu, 15 Sep 2005 11:39:09 +0000 Subject: [PATCH] filter and query type per each feed --- org.glite.jp.index/src/conf.c | 26 +++++++++++++++++--------- org.glite.jp.index/src/conf.h | 13 +++++++++---- org.glite.jp.index/src/soap_ps_calls.c | 26 ++++++++++++++++++++------ 3 files changed, 46 insertions(+), 19 deletions(-) diff --git a/org.glite.jp.index/src/conf.c b/org.glite.jp.index/src/conf.c index 5e45113..764ce32 100644 --- a/org.glite.jp.index/src/conf.c +++ b/org.glite.jp.index/src/conf.c @@ -24,9 +24,6 @@ int glite_jp_get_conf(int argc, char **argv, char *config_file, glite_jp_is_conf conf->attrs[2] = strdup("location"); conf->attrs[3] = strdup("jobid"); - conf->PS_list = calloc(2, sizeof(*conf->PS_list)); - conf->PS_list[0] = strdup("http://localhost:8901"); - conf->indexed_attrs = calloc(3, sizeof(*conf->indexed_attrs)); conf->indexed_attrs[0] = strdup("owner"); conf->indexed_attrs[1] = strdup("location"); @@ -34,14 +31,25 @@ int glite_jp_get_conf(int argc, char **argv, char *config_file, glite_jp_is_conf // XXX: some plugin names should come here in future conf->plugins = NULL; + + /* ask for one feed */ + conf->feeds = calloc(2, sizeof(*(conf->feeds))); + + conf->feeds[0] = calloc(1, sizeof(**(conf->feeds))); + conf->feeds[0]->PS_URL = strdup("http://localhost:8901"); + // all job since Epoche - conf->query = calloc(2,sizeof(*conf->query)); - conf->query[0] = calloc(2,sizeof(**conf->query)); - conf->query[0][0].attr = strdup("date"); - conf->query[0][0].op = GLITE_JP_QUERYOP_GREATER; - conf->query[0][0].value = strdup("0"); + conf->feeds[0]->query = calloc(2,sizeof(*conf->feeds[0]->query)); + conf->feeds[0]->query[0] = calloc(2,sizeof(**conf->feeds[0]->query)); + conf->feeds[0]->query[0][0].attr = strdup("date"); + conf->feeds[0]->query[0][0].op = GLITE_JP_QUERYOP_GREATER; + conf->feeds[0]->query[0][0].value = strdup("0"); + + conf->feeds[0]->history = 0; + conf->feeds[0]->continuous = 1; + + conf->feeds[1] = NULL; - conf->continuous = 1; *configuration = conf; diff --git a/org.glite.jp.index/src/conf.h b/org.glite.jp.index/src/conf.h index b7ab90e..9138ee7 100644 --- a/org.glite.jp.index/src/conf.h +++ b/org.glite.jp.index/src/conf.h @@ -7,18 +7,23 @@ #include "glite/jp/types.h" +typedef struct _glite_jp_is_feed { + char *PS_URL; //URLs of Primary Storage servers + glite_jp_query_rec_t **query; // query to Primary Server (aka filter) + int history, // type of query + continuous; +} glite_jp_is_feed; + + typedef struct _glite_jp_is_conf { // all I need to get from comman line options and configuration file // arrays are zero-terminated char **attrs; // atributes to obtain - char **PS_list; // URLs of Primary Storage servers char **indexed_attrs; // list of indexed atributes char **plugins; // list of plugin.so's - glite_jp_query_rec_t **query; // query to Primary Server - - int history, continuous; // type of query + glite_jp_is_feed **feeds; // null terminated list of feeds } glite_jp_is_conf; diff --git a/org.glite.jp.index/src/soap_ps_calls.c b/org.glite.jp.index/src/soap_ps_calls.c index 19a68f3..12e27ef 100644 --- a/org.glite.jp.index/src/soap_ps_calls.c +++ b/org.glite.jp.index/src/soap_ps_calls.c @@ -65,6 +65,16 @@ static void err2fault(const glite_jp_context_t ctx,struct soap *soap) /* PS WSDL client calls */ /*----------------------*/ +static int find_dest_index(glite_jp_is_conf *conf, char *dest) +{ + int i; + + for (i=0; conf->feeds[i]; i++) + if (!strcmp(dest, conf->feeds[i]->PS_URL)) return(i); + + return -1; +} + // call PS FeedIndex for a given destination void MyFeedIndex(glite_jp_is_conf *conf, char *dest) @@ -74,7 +84,7 @@ void MyFeedIndex(glite_jp_is_conf *conf, char *dest) struct jptype__primaryQuery query; struct jptype__stringOrBlob value; // struct xsd__base64Binary blob; - int i; + int i, dest_index; struct soap *soap = soap_new(); @@ -89,18 +99,22 @@ printf("MyFeedIndex for %s called\n", dest); in.__sizeattributes = i; in.attributes = conf->attrs; - for (in.__sizeconditions=0; conf->query[in.__sizeconditions]; in.__sizeconditions++); + if ((dest_index = find_dest_index(conf, dest)) < 0) goto err; + + for (i=0; conf->feeds[dest_index]->query[i]; i++); + in.__sizeconditions = i; in.conditions = malloc(in.__sizeconditions * sizeof(*in.conditions)); - for (i=0; conf->query[i]; i++) { - if (glite_jpis_QueryCondToSoap(soap, conf->query[i], &(in.conditions[i])) != SOAP_OK) { + for (i=0; conf->feeds[dest_index]->query[i]; i++) { + if (glite_jpis_QueryCondToSoap(soap, conf->feeds[dest_index]->query[i], + &(in.conditions[i])) != SOAP_OK) { printf("MyFeedIndex() - error during conds conversion\n"); goto err; } } - in.history = conf->history; - in.continuous = conf->continuous; + in.history = conf->feeds[dest_index]->history; + in.continuous = conf->feeds[dest_index]->continuous; //if (!check_fault(soap,soap_call_jpsrv___FeedIndex(soap,dest,"", if (soap_call___jpsrv__FeedIndex(soap,dest,"", &in, &out)) { -- 1.8.2.3