Back-End Utility Function

From Unofficial BOINC Wiki

Jump to: navigation, search

Contents

[edit] General

Because there are some common needs when creating Back-End Programs, the following functions can be used in your Validator Program and Assimilator Program code:

int get_output_file_path(RESULT const&, std::string&);

Returns the path of a Result Data File (parses result.xml_doc_out and computes the file's position in the Hierarchical Upload/Download Directory structure).

Note: this function doesn't handle multiple output files (if there are multiple files, it returns the path of the first one). If your Application has multiple output files, see below.

int try_fopen(char* path, FILE*& f, char* mode);

Open a file, distinguishing between recoverable and nonrecoverable errors. Returns zero on success. Returns ERR_FOPEN if the directory is present but not the file (this is considered a nonrecoverable error). Returns ERR_OPENDIR if the directory is not there (this is generally a recoverable error, like NFS mount failure).

double median_mean_credit(vector<RESULT> const& results);

Given a vector of N correct results, computes a Canonical Credit as follows:

  • if N==1, return that Result's Claimed Credit
  • if N==2, return min of Claimed Credits
  • if N>2, toss out high and low claimed credit, and return the average of the rest.

[edit] Multiple Result Data Files

If your Application has multiple output files you'll need to generalize get_output_file_path(). To do this you'll need to know the following:

The database field 'result.xml_doc_out' describes a result's output files. It has the form

<file_info>...</file_info>
[ ... ]
<result>
    <name>foobar</name>
    <wu_name>blah</wu_name>
    <exit_status>blah</exit_status>
    <file_ref>...</file_ref>
    [ ... ]
</result>

The components are:

  • The <name> element is the Result Name.
  • The <wu_name> element is the Work Unit Name.
  • Each <file_ref> element is an association to an output file, described by a corresponding <file_info> element.

The XML document describing the sizes and checksums of the output files is a list of <file_info> elements, with the nbytes and md5_cksum fields present. The project back end must parse this field to find the locations and checksums of output files.

[edit] UCB Source

[edit] Copyright ©

  • 2005 University of California
  • 2005 Paul D. Buck

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.

Personal tools