diff --git a/dcapi/boinc/wu.C b/dcapi/boinc/wu.C index 36620055b7..bf30203477 100644 --- a/dcapi/boinc/wu.C +++ b/dcapi/boinc/wu.C @@ -703,17 +703,13 @@ static int check_logical_name(DC_Workunit *wu, const char *logicalFileName) } int DC_addWUInput(DC_Workunit *wu, const char *logicalFileName, const char *URL, - DC_FileMode fileMode) + DC_FileMode fileMode, ...) { - return DC_addWUInputAdvanced(wu, logicalFileName, URL, fileMode, NULL, NULL); -} - -int DC_addWUInputAdvanced(DC_Workunit *wu, const char *logicalFileName, const char *URL, - DC_FileMode fileMode, const char *physicalFileName, const char *physicalFileHashString) -{ - DC_PhysicalFile *file; - char *workpath; int ret; + va_list ap; + char *workpath; + DC_PhysicalFile *file; + DC_RemoteFile *rfile; /* Sanity checks */ if (!wu || !logicalFileName) @@ -725,14 +721,38 @@ int DC_addWUInputAdvanced(DC_Workunit *wu, const char *logicalFileName, const ch if (ret) return ret; - /* XXX Check if the wu->num_inputs + wu->num_outputs + wu->subresults - * does not exceed the max. number of file slots */ + /* Handle remote files */ + if (DC_FILE_REMOTE == fileMode) + { + va_start(ap, fileMode); + char *md5 = va_arg(ap, char *); + int size = va_arg(ap, int); + va_end(ap); + rfile = _DC_createRemoteFile(logicalFileName, URL, md5, size); + if (!rfile) + return DC_ERR_INTERNAL; + + wu->remote_input_files = g_list_append(wu->remote_input_files, rfile); + wu->num_remote_inputs++; + + if (wu->serialized) + write_wudesc(wu); + + return 0; + } + + /* Now handle local files */ workpath = _DC_workDirPath(wu, logicalFileName, FILE_IN); file = _DC_createPhysicalFile(logicalFileName, workpath); g_free(workpath); if (!file) return DC_ERR_INTERNAL; + + va_start(ap, fileMode); + char *physicalFileName = va_arg(ap, char *); + char *physicalFileHashString = va_arg(ap, char *); + va_end(ap); if (physicalFileName) { file->physicalfilename = strdup(physicalFileName); @@ -799,36 +819,6 @@ int DC_addWUInputAdvanced(DC_Workunit *wu, const char *logicalFileName, const ch return 0; } -int DC_addWURemoteInput(DC_Workunit *wu, const char *logicalFileName, const char *URL, - const char *md5, const int size) -{ - int ret; - DC_RemoteFile *file; - - /* Sanity checks */ - if (!wu || !logicalFileName || !URL || !md5 || !size) - { - DC_log(LOG_ERR, "%s: Missing arguments", __func__); - return DC_ERR_BADPARAM; - } - ret = check_logical_name(wu, logicalFileName); - if (ret) - return ret; - - file = _DC_createRemoteFile(logicalFileName, URL, md5, size); - if (!file) - return DC_ERR_INTERNAL; - - wu->remote_input_files = g_list_append(wu->remote_input_files, file); - wu->num_remote_inputs++; - - if (wu->serialized) - write_wudesc(wu); - - return 0; - -} - int DC_addWUOutput(DC_Workunit *wu, const char *logicalFileName) { int ret; @@ -900,11 +890,11 @@ static int install_input_files(DC_Workunit *wu) if (!f) { if (errno == EEXIST && file->physicalfilename) - { - DC_log(LOG_NOTICE, "File %s already exists under Boinc. Skipping...",hashFile->str); - } - else - { + { + DC_log(LOG_NOTICE, "File %s already exists under Boinc. Skipping...",hashFile->str); + } + else + { DC_log(LOG_ERR, "Failed to create hash file %s: %s", hashFile->str,strerror(errno)); g_string_free(hashFile, TRUE); g_free(dest); @@ -914,7 +904,7 @@ static int install_input_files(DC_Workunit *wu) else { fprintf(f, "%s", file->physicalfilehash); - fclose(f); + fclose(f); DC_log(LOG_DEBUG, "Hash file \"%s\" has been created with content \"%s\".", hashFile->str, file->physicalfilehash); } @@ -1315,7 +1305,6 @@ int DC_submitWU(DC_Workunit *wu) l = l->next, i++) { DC_RemoteFile *file = (DC_RemoteFile *)l->data; - //infiles[i] = get_input_download_name(wu, file->label, NULL); infiles[i] = g_strdup_printf("%s_%s", file->label, md5_string(file->url)); } if (wu->ckpt_name) diff --git a/dcapi/condor/condor_master.c b/dcapi/condor/condor_master.c index 365afa2abf..d6de7c14fe 100644 --- a/dcapi/condor/condor_master.c +++ b/dcapi/condor/condor_master.c @@ -431,26 +431,12 @@ DC_destroyWU(DC_Workunit *wu) } -int DC_addWUInputAdvanced(DC_Workunit *wu, const char *logicalFileName, const char *URL, - DC_FileMode fileMode, const char *physicalFileName, const char *physicalFileHashString) -{ - DC_log(LOG_ERR,"Function \"%s\" is not implemented in this backend.",__func__); - return DC_ERR_INTERNAL; -} - -int DC_addWURemoteInput(DC_Workunit *wu, const char *logicalFileName, const char *URL, - const char *md5, const int size) -{ - DC_log(LOG_ERR,"Function \"%s\" is not implemented in this backend.",__func__); - return DC_ERR_INTERNAL; -} - /* Sets an input file for the work unit. */ int DC_addWUInput(DC_Workunit *wu, const char *logicalFileName, const char *URL, - DC_FileMode fileMode) + DC_FileMode fileMode, ...) { DC_PhysicalFile *file; char *workpath; @@ -458,6 +444,15 @@ DC_addWUInput(DC_Workunit *wu, if (!_DC_wu_check(wu)) return(DC_ERR_UNKNOWN_WU); + + /* Remote file aren't supported */ + if (DC_FILE_REMOTE == fileMode) + { + DC_log(LOG_ERR, "Unsupported file mode for input file %s", + logicalFileName); + return(DC_ERR_BADPARAM); + } + DC_log(LOG_DEBUG, "DC_addWUInput(%p-\"%s\", %s, %s, %d)", wu, wu->data.name, logicalFileName, URL, fileMode); diff --git a/dcapi/doc/tmpl/dc.sgml b/dcapi/doc/tmpl/dc.sgml index 6d8a8b17c5..a953539abe 100644 --- a/dcapi/doc/tmpl/dc.sgml +++ b/dcapi/doc/tmpl/dc.sgml @@ -269,23 +269,8 @@ units in state %DC_WU_READY (i.e., before the work unit is submitted). @fileMode: usage mode of the file. Passing %DC_FILE_PERSISTENT or %DC_FILE_VOLATILE allows DC-API to optimize the disk space requirements of the application. -@Returns: 0 if successful or a #DC_ErrorCode. - - - - -Adds a remote input file to a work unit. This function may be called only for -work units in state %DC_WU_READY (i.e., before the work unit is submitted). - - -@wu: the work unit to add the input file to. -@logicalFileName: the logical file name the client will use to refer to this - input file. The client should call the DC_resolveFileName() function - with the %DC_FILE_IN file type and this name to get the real name of - the file on the local system. -@URL: remote URL of the input file. -@md5: the MD5 hash of the remote input file. -@size: the size of the remote input file in bytes. +@Varargs: in case using %DC_FILE_REMOTE file mode, the MD5 hash string (char *) + and file size information (int) have to be passed. @Returns: 0 if successful or a #DC_ErrorCode. diff --git a/dcapi/doc/tmpl/dc_common.sgml b/dcapi/doc/tmpl/dc_common.sgml index dce61b82e1..be12b48085 100644 --- a/dcapi/doc/tmpl/dc_common.sgml +++ b/dcapi/doc/tmpl/dc_common.sgml @@ -59,6 +59,7 @@ Tells how should DC-API treat physical files passed to it. lets DC-API use symbolic or hard links instead of copying to save space. @DC_FILE_VOLATILE: the application does not want to use the file in any way in the future. DC-API will remove the file when it is no longer needed. +@DC_FILE_REMOTE: the application uses a remote file not physically present. @@ -99,16 +100,6 @@ Describes a physical file. @physicalfilename: @physicalfilehash: - - -Describes a remote file. - - -@label: logical name of the file as used by the application. -@url: URL of the remote file. -@remotefilehash: MD5 hash of the remote file. -@remotefilesize: size of the remote file in bytes. - Returns the value belonging to the specified key @name in the configuration file. diff --git a/dcapi/include/dc.h b/dcapi/include/dc.h index bf84367499..a065fba1a0 100644 --- a/dcapi/include/dc.h +++ b/dcapi/include/dc.h @@ -147,15 +147,7 @@ DC_Workunit *DC_createWU(const char *clientName, const char *arguments[], /* Sets an input file for the work unit. */ int DC_addWUInput(DC_Workunit *wu, const char *logicalFileName, const char *URL, - DC_FileMode fileMode); - -/* Sets a remote input file for the work unit. */ -int DC_addWURemoteInput(DC_Workunit *wu, const char *logicalFileName, const char *URL, - const char *md5, const int size); - -/* Sets an input file for the work unit. */ -int DC_addWUInputAdvanced(DC_Workunit *wu, const char *logicalFileName, const char *URL, - DC_FileMode fileMode, const char *physicalFileName, const char *physicalFileHashString); + DC_FileMode fileMode, ...); /* Defines an output file for the work unit. */ int DC_addWUOutput(DC_Workunit *wu, const char *logicalFileName); diff --git a/dcapi/include/dc_common.h b/dcapi/include/dc_common.h index a91d5b6bfc..3cdaef51c3 100644 --- a/dcapi/include/dc_common.h +++ b/dcapi/include/dc_common.h @@ -63,7 +63,8 @@ typedef enum { 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_VOLATILE, /* DC-API should remove the original */ + DC_FILE_REMOTE /* HTTP files physically not present */ } DC_FileMode; /* Default name of the configuration file */ diff --git a/dcapi/local/local_master.c b/dcapi/local/local_master.c index 5b6b3a6bf1..4e3c1f25d4 100644 --- a/dcapi/local/local_master.c +++ b/dcapi/local/local_master.c @@ -502,22 +502,8 @@ static int copy_file(const char *src, const char *dst) return 0; } -int DC_addWUInputAdvanced(DC_Workunit *wu, const char *logicalFileName, const char *URL, - DC_FileMode fileMode, const char *physicalFileName, const char *physicalFileHashString) -{ - DC_log(LOG_ERR,"Function \"%s\" is not implemented in this backend.",__func__); - return DC_ERR_INTERNAL; -} - -int DC_addWURemoteInput(DC_Workunit *wu, const char *logicalFileName, const char *URL, - const char *md5, const int size) -{ - DC_log(LOG_ERR,"Function \"%s\" is not implemented in this backend.",__func__); - return DC_ERR_INTERNAL; -} - int DC_addWUInput(DC_Workunit *wu, const char *logicalFileName, const char *URL, - DC_FileMode fileMode) + DC_FileMode fileMode, ...) { DC_PhysicalFile *file; char *workpath; @@ -528,6 +514,14 @@ int DC_addWUInput(DC_Workunit *wu, const char *logicalFileName, const char *URL, if (ret) return ret; + /* Remote files aren't supported */ + if (DC_FILE_REMOTE == fileMode) + { + DC_log(LOG_ERR, "Unsupported file mode for input file %s", + logicalFileName); + return DC_ERR_BADPARAM; + } + workpath = get_workdir_path(wu, logicalFileName, FILE_IN); file = _DC_createPhysicalFile(logicalFileName, workpath); g_free(workpath);