3 | | Projects must create one assimilator program per application. This is done by linking the program '''sched/assimilator.cpp''' with an application-specific function of the form |
| 3 | Completed jobs are handled by programs called '''assimilators'''. |
| 4 | These are generally application-specific: |
| 5 | they might copy output files from the BOINC upload directory to a permanent location, |
| 6 | or they might parse the output files and insert results into a database. |
| 7 | |
| 8 | == Creating an assimilator == |
| 9 | |
| 10 | To create an assimilator, link the program '''sched/assimilator.cpp''' with a function of the form |
10 | | This is called when either |
11 | | * The workunit has a nonzero [JobIn#Redundancyandschedulingattributes error mask] (indicating, for example, too many error results). In this case the handler might write a message to a log or send an email to the application developer. |
12 | | * The workunit has a canonical result. In this case wu.canonical_resultid will be nonzero, canonical_result will contain the canonical result. Your handler might, for example, parse the canonical result's output file and write its contents to a separate database. |
| 17 | This function is called when either |
| 18 | * The workunit has a nonzero [JobIn#Redundancyandschedulingattributes error mask] (indicating, for example, too many error results). In this case the handler might write a message to a log or send an email to the project administrator. |
| 19 | * The workunit has a canonical result. In this case wu.canonical_resultid will be nonzero, and canonical_result will contain the canonical result. |
19 | | * 0: the workunit will be marked as assimilated. |
20 | | * DEFER_ASSIMILATION: the workunit will not be marked as assimilated, and will be processed again when the next instance finishes. This is useful for appliations where you want to see all the completed results. |
21 | | * Other nonzero values: the assimilator will log an error message and exit. Typically the function should return nonzero for any error condition. This way the system administrator can fix the problem before any completed or erroneous workunits are mis-handled by BOINC. |
| 27 | * 0: success: the workunit will be marked as assimilated. |
| 28 | * DEFER_ASSIMILATION: the workunit will be processed again when another instance finishes. This is useful for appliations where you want to see all the completed results. |
| 29 | * Other nonzero values: the assimilator will log an error message and exit. Typically '''assimilate_handler()''' should return nonzero for any error condition. This way the system administrator can fix the problem before any completed or erroneous workunits are mis-handled by BOINC. |
| 32 | |
| 33 | == Running assimilators == |
| 34 | |
| 35 | Run assimilators as BOINC daemons: that is, add an entry |
| 36 | {{{ |
| 37 | <daemon> |
| 38 | <cmd> my_assimilator -app APPNAME </cmd> |
| 39 | </daemon> |
| 40 | }}} |
| 41 | to your project's [ProjectDaemons configuration file]. |
| 42 | |
| 43 | Assimilators have the followiong command-line options: |
| 44 | |
| 45 | -app name :: the application name |
| 46 | |
| 47 | [ -mod N R ] :: process only jobs with mod(ID, N) == R |
| 48 | |
| 49 | [ -d N ] :: set verbosity level (1 = least, 3 = most) |
| 50 | |
| 51 | [ -dont_update_db ] :: don't mark jobs as assimilated (for testing) |
| 52 | |
| 53 | == The sample assimilator == |
| 54 | |
| 55 | BOINC includes a sample assimilator, '''sample_assimilator'''. |
| 56 | It does the following: |
| 57 | |
| 58 | * For successful workunits, it writes the canonical instance's output files to the directory '''PROJECT/sample_results/'''. If there is only one output file it is named WU_NAME. If there are more than one they are named WU_NAME_0, WU_NAME_1, etc. If there are no output files, an empty file WU_NAME_no_output_files is created. |
| 59 | * If the workunit failed (to many errors, etc.) it appends a line to '''sample_results/errors''' containing the workunit name and the error code. |
| 60 | |
| 61 | The sample assimilator can be used as a placeholder while you |
| 62 | are developing your application. |
| 63 | In some cases you may be able to use it in production. |