Don't delete the database by default. Will be deleted and refetched via -D switch.
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Tue, 22 Apr 2008 16:57:55 +0000 (16:57 +0000)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Tue, 22 Apr 2008 16:57:55 +0000 (16:57 +0000)
Update man page.

org.glite.jp.index/doc/glite-jp-indexd.sgml
org.glite.jp.index/src/bones_server.c
org.glite.jp.index/src/conf.c
org.glite.jp.index/src/conf.h
org.glite.jp.index/src/db_ops.c

index a0713bd..4a64ff5 100644 (file)
                        </group></arg>
 
                        <arg><group choice='plain'>
+                               <arg>-k</arg>
+                               <arg>--key</arg>
+                       </group></arg>
+
+                       <arg><group choice='plain'>
+                               <arg>-c</arg>
+                               <arg>--cert</arg>
+                       </group></arg>
+
+<!--                   <arg><group choice='plain'>
+                               <arg>-C</arg>
+                               <arg>CAdir</arg>
+                       </group></arg>
+
+                       <arg><group choice='plain'>
+                               <arg>-V</arg>
+                               <arg>VOMSdir</arg>
+                       </group></arg>-->
+
+                       <arg><group choice='plain'>
                                <arg>-n</arg>
                                <arg>--no-auth</arg>
                        </group></arg>
                                <arg>--config</arg>
                        </group> <replaceable>CONFIG.XML</replaceable></arg>
 
+                       <arg><group choice='plain'>
+                               <arg>-s</arg>
+                               <arg>--slaves</arg>
+                       </group> <replaceable>N</replaceable> </arg>
+
+                       <arg><group choice='plain'>
+                               <arg>-D</arg>
+                               <arg>--delete-db</arg>
+                       </group></arg>
+
                </cmdsynopsis>
        </refsynopsisdiv>
 
@@ -111,6 +141,34 @@ Type of query: <option>hist</option>, <option>cont</option> or <option>both</opt
                        </varlistentry>
 
                        <varlistentry>
+                               <term><option>-k</option>|<option>--key</option></term>
+                               <listitem><para>
+Private key file.
+                               </para></listitem>
+                       </varlistentry>
+
+                       <varlistentry>
+                               <term><option>-c</option>|<option>--cert</option></term>
+                               <listitem><para>
+Certification file.
+                               </para></listitem>
+                       </varlistentry>
+
+<!--                   <varlistentry>
+                               <term><option>-C</option>|<option>CAdir</option></term>
+                               <listitem><para>
+Trusted certificates directory.
+                               </para></listitem>
+                       </varlistentry>
+
+                       <varlistentry>
+                               <term><option>-V</option>|<option>VOMSdir</option></term>
+                               <listitem><para>
+Trusted VOMS servers certificates directory.
+                               </para></listitem>
+                       </varlistentry>-->
+
+                       <varlistentry>
                                <term><option>-n</option>|<option>--no-auth</option></term>
                                <listitem><para>
 Don't check user identity with result owner.
@@ -148,14 +206,26 @@ File to store logs (default: <filename>/var/run/glite-jp-indexd.log</filename> o
                        <varlistentry>
                                <term><option>-x</option>|<option>--config</option></term>
                                <listitem><para>
-Configuration file containing information about feeds, primary storages, ... Structure is defined in <filename>server_conf.xsd</filename>.
+Configuration file containing information about feeds, primary storages, ... Structure is defined in <filename>server_conf.xsd</filename> (default: <filename>$GLITE_LOCATION/etc/glite-jpis-config.xml</filename>).
                                </para></listitem>
                        </varlistentry>
+
+                       <varlistentry>
+                               <term><option>-s</option>|<option>--slaves</option></term>
+                               <listitem><para>
+Number of slave processes for responses (default: number of feeds, max. 20).
+                               </para></listitem>
+                       </varlistentry>
+
+                       <varlistentry>
+                               <term><option>-D</option>|<option>--delete-db</option></term>
+                               <listitem><para>
+Delete and refetch the data in the database. You need use this parameter when feeds from primary storage are already expired.
+                               </para></listitem>
+                       </varlistentry>
+
                </variablelist>
 
-               <para>
-Other parameters will be configurable in close future. Its current hard-coded values are in <filename>org.glite.jp.index/src/conf.[ch]</filename>.
-               </para>
        </refsect1>
 
        <refsect1>
@@ -257,9 +327,9 @@ GLITE_JPIS_QT=cont
                        </varlistentry>
 
                        <varlistentry>
-                               <term><command>glite-jp-indexd -s JPPS:8901 -i $HOME/jpis.log -o $HOME/jpis.pid</command></term>
+                               <term><command>glite-jp-indexd -x /opt/glite/etc/glite-jpis-config-custom.xml -i $HOME/jpis.log -o $HOME/jpis.pid</command></term>
                                <listitem><para>
-Manual run of the JP index server. Use local MySQL database, communicates with Job Provenance on JPPS:8901, listen on default port, store logs and pid to given files.
+Manual run of the JP index server. Use local MySQL database, feeds from job provenances and attributes configured in <filename>/opt/glite/etc/glite-jpis-config-custom.xml</filename>, listen on default port, store logs and pid to given files.
                                </para></listitem>
                        </varlistentry>
                </variablelist>
index e31c2c6..0c3994b 100644 (file)
@@ -102,13 +102,15 @@ int main(int argc, char *argv[])
        */
        
 
-       if (glite_jpis_dropDatabase(isctx) != 0) {
-               fprintf(stderr, "Drop DB failed: %s (%s)\n", ctx->error->desc, ctx->error->source);
-               glite_jpis_free_db(isctx);
-               glite_jpis_free_context(isctx);
-               glite_jp_free_context(ctx);
-               glite_jp_free_conf(conf);
-               return 1;
+       if (conf->delete_db) {
+               if (glite_jpis_dropDatabase(isctx) != 0) {
+                       fprintf(stderr, "Drop DB failed: %s (%s)\n", ctx->error->desc, ctx->error->source);
+                       glite_jpis_free_db(isctx);
+                       glite_jpis_free_context(isctx);
+                       glite_jp_free_context(ctx);
+                       glite_jp_free_conf(conf);
+                       return 1;
+               }
        }
 
        if (glite_jpis_initDatabase(isctx) != 0) {
index 767a120..ac073fe 100644 (file)
@@ -24,7 +24,7 @@
 
 extern SOAP_NMAC struct Namespace jp__namespaces[];
 
-static const char *get_opt_string = "dq:c:k:C:V:nm:p:i:o:x:s:";
+static const char *get_opt_string = "dq:c:k:C:V:nm:p:i:o:x:s:D";
 
 static struct option opts[] = {
        {"debug",       0, NULL,        'd'},
@@ -40,6 +40,7 @@ static struct option opts[] = {
        {"logfile",     1, NULL,        'o'},
        {"config",      1, NULL,        'x'},
        {"slaves",      1, NULL,        's'},
+       {"delete-db",   0, NULL,        'D'},
        {NULL,          0, NULL,        0}
 };
 
@@ -64,6 +65,7 @@ static void usage(char *me)
                "\t-o, --logfile\t file to store logs\n"
                "\t-x, --config\t file with server configuration\n"
                "\t-s, --slaves\t number of slaves for responses\n"
+               "\t-D, --delete-db\t delete and restore data in the database"
                "\n"
        ,me);
 }
@@ -92,6 +94,7 @@ int glite_jp_get_conf(int argc, char **argv, glite_jp_is_conf **configuration)
                case 'o': conf->logfile = optarg; break;
                case 'x': conf_file = optarg; break;
                case 's': conf->slaves = atoi(optarg); if (conf->slaves > 0) break;
+               case 'D': conf->delete_db = 1; break;
                default : usage(argv[0]); exit(0); break;
        }
 
index 4c64a79..4925e19 100644 (file)
@@ -49,6 +49,7 @@ typedef struct _glite_jp_is_conf {
                *server_cert,
                *server_key;
        int     slaves;
+       int     delete_db;
 } glite_jp_is_conf;
 
 
index 0bb18cd..fef6240 100644 (file)
@@ -282,10 +282,10 @@ char *glite_jpis_attr_name2id(const char *name) {
  */
 
 int glite_jpis_initDatabase(glite_jpis_context_t ctx) {
-       char **attrs, *attrid;
+       char **attrs, *attrid, *num;
        const char *type_index, *type_full;
        size_t i;
-       int indexed, state, locked;
+       int indexed, state, locked, nattrs;
        size_t conds_len;
        char sql[512];
        glite_jp_is_feed **feeds;
@@ -294,6 +294,25 @@ int glite_jpis_initDatabase(glite_jpis_context_t ctx) {
        glite_lbu_Statement stmt = NULL;
 
        jpctx = ctx->jpctx;
+
+       // check, if database was already created
+       if (glite_jp_db_ExecSQL(jpctx, "SELECT COUNT(*) FROM attrs", &stmt) < 0) {
+               glite_jpis_stack_error(ctx->jpctx, EIO, "error during counting attrs");
+               goto fail;
+       }
+       if (glite_jp_db_FetchRow(jpctx, stmt, 1, NULL, &num) < 0) {
+               glite_jpis_stack_error(ctx->jpctx, EIO, "error during fetching attrs");
+               goto fail;
+       }
+       nattrs = atoi(num);
+       llprintf(LOG_SQL, "found '%s' attributes in attrs table\n", num, nattrs);
+       free(num);
+       glite_jp_db_FreeStmt(&stmt);
+       if (nattrs != 0) {
+               lprintf("database with %d attributes keeped (use -D for delete)\n");
+               return 0;
+       }
+
        if (glite_jp_db_PrepareStmt(jpctx, "INSERT INTO attrs (attrid, name, indexed, type) VALUES (?, ?, ?, ?)", &stmt) != 0) goto fail;
 
        // attrs table and attrid_* tables
@@ -359,6 +378,7 @@ fail_conds:
        free(conds);
 fail:
        glite_jp_db_FreeStmt(&stmt);
+       if (!jpctx->error) glite_jpis_stack_error(ctx->jpctx, EIO, "error during initial filling of the database");
        return jpctx->error->code;
 }