| 1 | [[PageOutline]] |
| 2 | |
| 3 | = Explicit file management = |
| 4 | |
| 5 | BOINC allows you to explicitly manage files on client hosts. |
| 6 | This might be used, e.g., to implement a high-latency distributed file system. |
| 7 | |
| 8 | == Retrieving file lists == |
| 9 | |
| 10 | To instruct a host to send a list of all persistent files, use the function |
| 11 | {{{ |
| 12 | request_file_list(int host_id) |
| 13 | }}} |
| 14 | or the command line program (run from the project root directory) |
| 15 | {{{ |
| 16 | request_file_list [ -host_id X ] |
| 17 | }}} |
| 18 | If -host_id is absent, get file lists for all hosts. A message is created for the specific host (or all hosts) and added to the msg_to_host table in the database. The upload message included in the next RPC reply to the host. |
| 19 | |
| 20 | The file list will be included in the next scheduler RPC request. You must modify the scheduler to parse and store it. |
| 21 | |
| 22 | |
| 23 | |
| 24 | == Retrieving files == |
| 25 | |
| 26 | A persistent file can be retrieved from a specific host. This can be done using the function |
| 27 | |
| 28 | {{{ |
| 29 | get_file(int host_id, const char* file_name) |
| 30 | }}} |
| 31 | |
| 32 | or the command line program (run in the project root dir) |
| 33 | |
| 34 | {{{ |
| 35 | get_file -host_id X -file_name Y |
| 36 | }}} |
| 37 | |
| 38 | This program must be run in the project's root directory. get_file() creates a result with a name of the form: |
| 39 | |
| 40 | {{{ |
| 41 | get_FILENAME_HOSTID_TIME |
| 42 | }}} |
| 43 | Example: get_test.mpg_34_123456789 is a result representing the upload of test.mpg from host number 34 at time 1234567891. |
| 44 | |
| 45 | An upload message is created for the specific host and added to the msg_to_host table in the database. This message instructs the client to upload the file and acknowledge a successful upload. The upload message included in the next RPC reply to the host. The message has the form: |
| 46 | |
| 47 | {{{ |
| 48 | <app> |
| 49 | <name>FILE_MOVER</name> |
| 50 | </app> |
| 51 | <app_version> |
| 52 | <app_name>FILE_MOVER</app_name> |
| 53 | <version_num>BOINC_MAJOR_VERSION</version_num> |
| 54 | </app_version> |
| 55 | <file_info> |
| 56 | <name>file_name</name> |
| 57 | <url>upload_dir</url> |
| 58 | <max_nbytes>1e10</max_nbytes> |
| 59 | <upload_when_present/> |
| 60 | </file_info> |
| 61 | RESULT_XML |
| 62 | <workunit> |
| 63 | <name>result.name</name> |
| 64 | <app_name>FILE_MOVER</app_name> |
| 65 | </workunit> |
| 66 | }}} |
| 67 | Include |
| 68 | {{{<msg_to_host/>}}} |
| 69 | in config.xml. Currently |
| 70 | {{{<ignore_upload_certificates/>}}} |
| 71 | needs to be included as there is no way to send upload certificates with these files. |
| 72 | |
| 73 | |
| 74 | == Sending files == |
| 75 | |
| 76 | To send a file to a specific host, use the function |
| 77 | |
| 78 | {{{ |
| 79 | send_file(int host_id, const char* file_name) |
| 80 | }}} |
| 81 | |
| 82 | or the command line program (run from the project root directory) |
| 83 | |
| 84 | {{{ |
| 85 | send_file -host_id X -file_name Y |
| 86 | }}} |
| 87 | |
| 88 | send_file creates a result and initializes it with a name of the form send_FILENAME_HOSTID_TIME. |
| 89 | |
| 90 | A message is created for the host and added to the msg_to_host table. This message instructs the client to download the file and acknowledge a successful download. The download message included in the next RPC reply to the host. The message has the form: |
| 91 | |
| 92 | {{{ |
| 93 | <app> |
| 94 | <name>FILE_MOVER</name> |
| 95 | </app> |
| 96 | <app_version> |
| 97 | <app_name>FILE_MOVER</app_name> |
| 98 | <version_num>n</version_num> |
| 99 | </app_version> |
| 100 | <result> |
| 101 | <wu_name>x</wu_name> |
| 102 | <name>y</name> |
| 103 | </result> |
| 104 | <file_info> |
| 105 | <name>file_name</name> |
| 106 | <url>download_dir/file_name</url> |
| 107 | <md5_cksum>md5</md5_cksum> |
| 108 | <nbytes>file->nbytes</nbytes> |
| 109 | <sticky/> |
| 110 | </file_info> |
| 111 | <workunit> |
| 112 | <name>result.name</name> |
| 113 | <app_name>FILE_MOVER</app_name> |
| 114 | <file_ref> |
| 115 | <file_name>file_name</file_name> |
| 116 | </file_ref> |
| 117 | </workunit> |
| 118 | }}} |
| 119 | |
| 120 | For this to work, you need to include {{{<msg_to_host/>}}} in [ProjectOptions#client-control config.xml]. |
| 121 | |
| 122 | |
| 123 | == Deleting files == |
| 124 | |
| 125 | To delete a file from a host, use the function |
| 126 | |
| 127 | {{{ |
| 128 | delete_file(int host_id, const char* file_name) |
| 129 | }}} |
| 130 | |
| 131 | or the command line program (run from the project root dir) |
| 132 | |
| 133 | {{{ |
| 134 | delete_file -host_id X -file_name Y |
| 135 | }}} |
| 136 | |
| 137 | `delete_file()` creates a message for the specific host and adds it to the `msg_to_host` table. This message instructs the client to delete the file. The message is included in the next scheduler reply to the host. The message XML has the form |
| 138 | |
| 139 | {{{ |
| 140 | <delete_file_info>file_name</delete_file_info> |
| 141 | }}} |
| 142 | |
| 143 | For this to work, you need to include {{{<msg_to_host/>}}} in [ProjectOptions#client-control config.xml]. |
| 144 | |