mirror of https://github.com/BOINC/boinc.git
- prepare for new release (...)
- add support for sticky files on clients git-svn-id: svn+ssh://cvs.lpds.sztaki.hu/var/lib/svn/szdg/dcapi/trunk@2530 a7169a2c-3604-0410-bc95-c702d8d87f7a
This commit is contained in:
parent
821e29d001
commit
6c10ad3a94
|
@ -296,7 +296,7 @@ static DC_Workunit *alloc_wu(void)
|
|||
* @param url the URL to perform the replace on
|
||||
* @return NULL-terminated string array of replacement result(s)
|
||||
*/
|
||||
gchar **replace_regex(const char *url)
|
||||
static gchar **replace_regex(const char *url)
|
||||
{
|
||||
if (!url)
|
||||
return NULL;
|
||||
|
@ -786,8 +786,14 @@ int DC_addWUInput(DC_Workunit *wu, const char *logicalFileName, const char *URL,
|
|||
va_list ap;
|
||||
char *workpath;
|
||||
DC_PhysicalFile *file = NULL;
|
||||
DC_RemoteFile *rfile;
|
||||
DC_RemoteFile *rfile = NULL;
|
||||
int persistent_on_client = 0;
|
||||
|
||||
if (fileMode & DC_FILE_PERSISTENT_CLIENT)
|
||||
{
|
||||
persistent_on_client = 1;
|
||||
fileMode ^= DC_FILE_PERSISTENT_CLIENT;
|
||||
}
|
||||
/* Sanity checks */
|
||||
if (!wu || !logicalFileName)
|
||||
{
|
||||
|
@ -802,7 +808,7 @@ int DC_addWUInput(DC_Workunit *wu, const char *logicalFileName, const char *URL,
|
|||
* does not exceed the max. number of file slots */
|
||||
|
||||
/* Handle remote http:// files */
|
||||
if (DC_FILE_REMOTE == fileMode && !strncmp("http://", URL, 7))
|
||||
if (fileMode == DC_FILE_REMOTE && !strncmp("http://", URL, 7))
|
||||
{
|
||||
va_start(ap, fileMode);
|
||||
char *md5 = va_arg(ap, char *);
|
||||
|
@ -813,6 +819,11 @@ int DC_addWUInput(DC_Workunit *wu, const char *logicalFileName, const char *URL,
|
|||
if (!rfile)
|
||||
return DC_ERR_INTERNAL;
|
||||
|
||||
if (persistent_on_client)
|
||||
{
|
||||
rfile->persistentonclient = 1;
|
||||
}
|
||||
|
||||
wu->remote_input_files = g_list_append(wu->remote_input_files, rfile);
|
||||
wu->num_remote_inputs++;
|
||||
|
||||
|
@ -830,7 +841,7 @@ int DC_addWUInput(DC_Workunit *wu, const char *logicalFileName, const char *URL,
|
|||
return DC_ERR_INTERNAL;
|
||||
|
||||
/* Handle remote attic:// files */
|
||||
if (DC_FILE_REMOTE == fileMode && !strncmp("attic://", URL, 8))
|
||||
if (fileMode == DC_FILE_REMOTE && !strncmp("attic://", URL, 8))
|
||||
{
|
||||
va_start(ap, fileMode);
|
||||
char *md5 = va_arg(ap, char *);
|
||||
|
@ -849,6 +860,11 @@ int DC_addWUInput(DC_Workunit *wu, const char *logicalFileName, const char *URL,
|
|||
if (!rfile)
|
||||
return DC_ERR_INTERNAL;
|
||||
|
||||
if (persistent_on_client)
|
||||
{
|
||||
rfile->persistentonclient = 1;
|
||||
}
|
||||
|
||||
wu->remote_input_files = g_list_append(wu->remote_input_files, rfile);
|
||||
wu->num_remote_inputs++;
|
||||
|
||||
|
@ -884,7 +900,7 @@ int DC_addWUInput(DC_Workunit *wu, const char *logicalFileName, const char *URL,
|
|||
file->physicalfilehash = strdup(physicalFileHashString);
|
||||
g_free(physicalFileHashString);
|
||||
}
|
||||
else if (DC_FILE_REMOTE == fileMode)
|
||||
else if (fileMode == DC_FILE_REMOTE)
|
||||
{
|
||||
DC_log(LOG_ERR, "%s: Unsupported URL received: '%s'",
|
||||
__func__, URL);
|
||||
|
@ -892,6 +908,11 @@ int DC_addWUInput(DC_Workunit *wu, const char *logicalFileName, const char *URL,
|
|||
return DC_ERR_BADPARAM;
|
||||
}
|
||||
|
||||
if (persistent_on_client)
|
||||
{
|
||||
file->persistentonclient = 1;
|
||||
}
|
||||
|
||||
switch (fileMode)
|
||||
{
|
||||
case DC_FILE_PERSISTENT:
|
||||
|
@ -1142,7 +1163,7 @@ static void fill_wu_params(const DC_Workunit *wu, struct wu_params *params)
|
|||
if (params->min_quorum < 1)
|
||||
params->min_quorum = 1;
|
||||
|
||||
params->target_nresults = params->min_quorum + 1;
|
||||
params->target_nresults = params->min_quorum;
|
||||
|
||||
/* Calculate with logarithmic error */
|
||||
params->max_error_results = params->target_nresults +
|
||||
|
@ -1154,10 +1175,15 @@ static void fill_wu_params(const DC_Workunit *wu, struct wu_params *params)
|
|||
}
|
||||
}
|
||||
|
||||
static void append_wu_file_info(GString *tmpl, int idx)
|
||||
static void append_wu_file_info(GString *tmpl, int idx, DC_PhysicalFile *file)
|
||||
{
|
||||
g_string_append(tmpl, "<file_info>\n");
|
||||
g_string_append_printf(tmpl, "\t<number>%d</number>\n", idx);
|
||||
if (file != NULL && file->persistentonclient == 1)
|
||||
{
|
||||
g_string_append(tmpl, "\t<sticky/>\n");
|
||||
g_string_append(tmpl, "\t<nodelete/>\n");
|
||||
}
|
||||
g_string_append(tmpl, "</file_info>\n");
|
||||
}
|
||||
|
||||
|
@ -1165,6 +1191,11 @@ static void append_wu_remote_file_info(GString *tmpl, int idx, DC_RemoteFile *fi
|
|||
{
|
||||
g_string_append(tmpl, "<file_info>\n");
|
||||
g_string_append_printf(tmpl, "\t<number>%d</number>\n", idx);
|
||||
if (file != NULL && file->persistentonclient == 1)
|
||||
{
|
||||
g_string_append(tmpl, "\t<sticky/>\n");
|
||||
g_string_append(tmpl, "\t<nodelete/>\n");
|
||||
}
|
||||
gchar **alts = replace_regex(file->url);
|
||||
if (!alts)
|
||||
{
|
||||
|
@ -1207,8 +1238,12 @@ static char *generate_wu_template(DC_Workunit *wu)
|
|||
num_inputs++;
|
||||
|
||||
tmpl = g_string_new("");
|
||||
for (i = 0; i < num_inputs; i++)
|
||||
append_wu_file_info(tmpl, i);
|
||||
for (i = 0, l = wu->input_files; l && i < num_inputs; l = l->next, i++)
|
||||
{
|
||||
DC_PhysicalFile *file = (DC_PhysicalFile *)l->data;
|
||||
append_wu_file_info(tmpl, i, file);
|
||||
}
|
||||
|
||||
for (l = wu->remote_input_files; l && i < num_inputs + num_remote_inputs;
|
||||
l = l->next, i++)
|
||||
{
|
||||
|
@ -1217,7 +1252,7 @@ static char *generate_wu_template(DC_Workunit *wu)
|
|||
}
|
||||
/* Checkpoint file, if exists */
|
||||
if (wu->ckpt_name)
|
||||
append_wu_file_info(tmpl, i++);
|
||||
append_wu_file_info(tmpl, i++, NULL);
|
||||
|
||||
/* Generate the workunit description */
|
||||
g_string_append(tmpl, "<workunit>\n");
|
||||
|
|
|
@ -155,6 +155,7 @@ DC_PhysicalFile *_DC_createPhysicalFile(const char *label,
|
|||
file->path = strdup(path);
|
||||
file->physicalfilename = NULL;
|
||||
file->physicalfilehash = NULL;
|
||||
file->persistentonclient = 0;
|
||||
|
||||
if (!file->label || !file->path)
|
||||
{
|
||||
|
@ -179,6 +180,7 @@ DC_RemoteFile *_DC_createRemoteFile(const char *label,
|
|||
file->url = strdup(url);
|
||||
file->remotefilehash = strdup(md5);
|
||||
file->remotefilesize = size;
|
||||
file->persistentonclient = 0;
|
||||
|
||||
if (!file->label || !file->url || !file->remotefilehash)
|
||||
{
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
dcapi (0.12-3) unstable; urgency=low
|
||||
|
||||
* Documentation update for redundancy parameters.
|
||||
|
||||
-- Attila Csaba Marosi <atisu@sztaki.hu> Mon, 17 Oct 2011 14:33:02 +0200
|
||||
|
||||
dcapi (0.12-2) unstable; urgency=high
|
||||
|
||||
* Fix: 0.12-1 broke handling of remote files when invoked from previously
|
||||
|
|
|
@ -61,12 +61,12 @@ typedef enum {
|
|||
} DC_GridCapabilities;
|
||||
|
||||
/* File classification when passing a physical file name to DC-API */
|
||||
typedef enum {
|
||||
DC_FILE_REGULAR, /* Not persistent, needs copy */
|
||||
DC_FILE_PERSISTENT, /* Persistent, link is enough */
|
||||
DC_FILE_VOLATILE, /* DC-API should remove the original */
|
||||
DC_FILE_REMOTE /* HTTP files physically not present */
|
||||
} DC_FileMode;
|
||||
typedef int DC_FileMode;
|
||||
#define DC_FILE_REGULAR (0) /* Not persistent, needs copy */
|
||||
#define DC_FILE_PERSISTENT (1) /* Persistent, link is enough */
|
||||
#define DC_FILE_VOLATILE (2) /* DC-API should remove the original */
|
||||
#define DC_FILE_REMOTE (3) /* HTTP files physically not present */
|
||||
#define DC_FILE_PERSISTENT_CLIENT (1 << 7) /* FLAG: Persistent on client */
|
||||
|
||||
/* Default name of the configuration file */
|
||||
#define DC_CONFIG_FILE "dc-api.conf"
|
||||
|
@ -90,6 +90,7 @@ struct _DC_PhysicalFile
|
|||
DC_FileMode mode;
|
||||
char *physicalfilename;
|
||||
char *physicalfilehash;
|
||||
int persistentonclient;
|
||||
};
|
||||
|
||||
/* Descriptor of a remote file */
|
||||
|
@ -100,6 +101,7 @@ struct _DC_RemoteFile
|
|||
char *url;
|
||||
char *remotefilehash;
|
||||
size_t remotefilesize;
|
||||
int persistentonclient;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -514,6 +514,13 @@ int DC_addWUInput(DC_Workunit *wu, const char *logicalFileName, const char *URL,
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (fileMode & DC_FILE_PERSISTENT_CLIENT)
|
||||
{
|
||||
DC_log(LOG_WARNING, "File mode DC_FILE_PERSISTENT_CLIENT for input file %s is not supported",
|
||||
logicalFileName);
|
||||
fileMode ^= DC_FILE_PERSISTENT_CLIENT;
|
||||
}
|
||||
|
||||
/* Remote files aren't supported */
|
||||
if (DC_FILE_REMOTE == fileMode)
|
||||
{
|
||||
|
@ -559,8 +566,11 @@ int DC_addWUInput(DC_Workunit *wu, const char *logicalFileName, const char *URL,
|
|||
_DC_destroyPhysicalFile(file);
|
||||
return DC_ERR_BADPARAM; /* XXX */
|
||||
}
|
||||
case DC_FILE_REMOTE:
|
||||
break;
|
||||
default:
|
||||
DC_log(LOG_ERR, "Unsupported file mode for input file %s",
|
||||
logicalFileName);
|
||||
_DC_destroyPhysicalFile(file);
|
||||
return DC_ERR_BADPARAM;
|
||||
}
|
||||
|
||||
wu->input_files = g_list_append(wu->input_files, file);
|
||||
|
|
Loading…
Reference in New Issue