From a217123510b0e174dd87681845205627903a199d Mon Sep 17 00:00:00 2001 From: gombasg Date: Thu, 16 Nov 2006 12:41:41 +0000 Subject: [PATCH] Add support for setting the WU priority in dc-api.conf git-svn-id: svn+ssh://cvs.lpds.sztaki.hu/var/lib/svn/szdg/dcapi/trunk@970 a7169a2c-3604-0410-bc95-c702d8d87f7a --- dcapi/boinc/wu.C | 28 +++++++++++++++++++++------- dcapi/include/dc_internal.h | 2 ++ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/dcapi/boinc/wu.C b/dcapi/boinc/wu.C index fc7dcf9d90..d6d60228fd 100644 --- a/dcapi/boinc/wu.C +++ b/dcapi/boinc/wu.C @@ -43,7 +43,8 @@ typedef enum WU_SUBMITTED, WU_SERIALIZED, WU_SUSPENDED, - WU_NOSUSPEND + WU_NOSUSPEND, + WU_PRIORITY } wu_tag; #define WU_DESC_FILE "wu_desc.xml" @@ -120,6 +121,7 @@ static const struct tag_desc tags[] = { WU_SUSPENDED, "suspended" }, { WU_SERIALIZED, "serialized" }, { WU_NOSUSPEND, "nosuspend" }, + { WU_PRIORITY, "priority" } }; static const GMarkupParser wudesc_parser = @@ -372,6 +374,11 @@ static void wudesc_text(GMarkupParseContext *ctx, const char *text, pctx->wu->subresults = atoi(tmp); g_free(tmp); break; + case WU_PRIORITY: + tmp = g_strndup(text, text_len); + pctx->wu->priority = atoi(tmp); + g_free(tmp); + break; case WU_WUDESC: break; case WU_SUSPENDED: @@ -422,6 +429,7 @@ static int write_wudesc(const DC_Workunit *wu) fprintf(f, "\t%s\n", (char *)l->data); fprintf(f, "\t%d\n", wu->subresults); + fprintf(f, "\t%d\n", wu->priority); fprintf(f, "\n"); fclose(f); @@ -499,6 +507,9 @@ DC_Workunit *DC_createWU(const char *clientName, const char *arguments[], return NULL; } + /* Set the default priority */ + wu->priority = DC_getClientCfgInt(clientName, CFG_DEFAULTPRIO, 0, TRUE); + /* Add the client config as an internal input file */ ret = generate_client_config(wu); if (ret) @@ -818,12 +829,6 @@ static void fill_wu_params(const DC_Workunit *wu, struct wu_params *params) CFG_REDUNDANCY, 1, TRUE); if (params->min_quorum < 1) params->min_quorum = 1; - if (params->min_quorum == 2) - { - DC_log(LOG_NOTICE, "Quorum of 2 does not make sense for " - "application %s, increasing to 3", wu->client_name); - params->min_quorum++; - } /* Calculate with logarithmic error */ if (params->min_quorum == 1) @@ -1507,6 +1512,8 @@ int DC_setWUPriority(DC_Workunit *wu, int priority) } wu->priority = priority; + if (wu->serialized) + write_wudesc(wu); return 0; } @@ -1547,6 +1554,13 @@ int DC_resumeWU(DC_Workunit *wu) DC_log(LOG_ERR, "%s: Missing WU", __func__); return DC_ERR_BADPARAM; } + if (!wu->suspended) + { + char *name = _DC_getWUName(wu); + DC_log(LOG_ERR, "Work unit %s is not suspended, cannot resume", name); + g_free(name); + return DC_ERR_BADPARAM; + } return DC_ERR_NOTIMPL; } diff --git a/dcapi/include/dc_internal.h b/dcapi/include/dc_internal.h index 9fa5f78b8e..5d4fdcf272 100644 --- a/dcapi/include/dc_internal.h +++ b/dcapi/include/dc_internal.h @@ -35,6 +35,8 @@ extern "C" { #define CFG_LOGFILE "LogFile" /* Configuration items to send to clients */ #define CFG_SENDKEYS "SendCfgKeys" +/* Default WU priority */ +#define CFG_DEFAULTPRIO "DefaultPriority" /********************************************************************