![]() |
|
|||
File indexing completed on 2025-02-22 10:38:44
0001 /* 0002 * Copyright (c) CERN 2013-2017 0003 * 0004 * Copyright (c) Members of the EMI Collaboration. 2010-2013 0005 * See http://www.eu-emi.eu/partners for details on the copyright 0006 * holders. 0007 * 0008 * Licensed under the Apache License, Version 2.0 (the "License"); 0009 * you may not use this file except in compliance with the License. 0010 * You may obtain a copy of the License at 0011 * 0012 * http://www.apache.org/licenses/LICENSE-2.0 0013 * 0014 * Unless required by applicable law or agreed to in writing, software 0015 * distributed under the License is distributed on an "AS IS" BASIS, 0016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 0017 * See the License for the specific language governing permissions and 0018 * limitations under the License. 0019 */ 0020 0021 #pragma once 0022 #ifndef GFAL_TRANSFER_H_ 0023 #define GFAL_TRANSFER_H_ 0024 0025 #if !defined(__GFAL2_H_INSIDE__) && !defined(__GFAL2_BUILD__) 0026 # warning "Direct inclusion of gfal2 headers is deprecated. Please, include only gfal_api.h or gfal_plugins_api.h" 0027 #endif 0028 0029 0030 #include <common/gfal_common.h> 0031 #include <logger/gfal_logger.h> 0032 #include <common/gfal_constants.h> 0033 0034 0035 #ifdef __cplusplus 0036 extern "C" 0037 { 0038 #endif 0039 0040 /*! 0041 \defgroup transfer_group File Transfer API 0042 */ 0043 0044 /*! 0045 \addtogroup transfer_group 0046 @{ 0047 */ 0048 0049 0050 /** 0051 * @brief container for transfer related parameters 0052 * */ 0053 typedef struct _gfalt_params_t* gfalt_params_t; 0054 0055 /** 0056 * @brief internal status of a copy file action 0057 * */ 0058 typedef struct _gfalt_transfer_status* gfalt_transfer_status_t; 0059 0060 /** 0061 * @brief copy gfalt_monitor_transfer 0062 * This function is called callback_mperiod milli-seconds in order to provide information and a control on the transfers. 0063 * @param src : URL of the source file 0064 * @param dst : URL of the dest file 0065 * @param user_data : external pointer provided before 0066 * */ 0067 typedef void (*gfalt_monitor_func)(gfalt_transfer_status_t h, const char* src, const char* dst, gpointer user_data); 0068 0069 /** 0070 * @brief Predefined stages. 0071 */ 0072 extern GQuark GFAL_EVENT_PREPARE_ENTER; /**< Triggered before entering preparation */ 0073 extern GQuark GFAL_EVENT_PREPARE_EXIT; /**< Triggered after exiting the preparation */ 0074 extern GQuark GFAL_EVENT_TRANSFER_ENTER; /**< Triggered before entering the transfer */ 0075 extern GQuark GFAL_EVENT_TRANSFER_EXIT; /**< Triggered after exiting the transfer */ 0076 extern GQuark GFAL_EVENT_CLOSE_ENTER; /**< Triggered before entering the closing (putdone) */ 0077 extern GQuark GFAL_EVENT_CLOSE_EXIT; /**< Triggered after exiting the closing (putdone) */ 0078 extern GQuark GFAL_EVENT_CHECKSUM_ENTER; /**< Triggered before entering checksum validation */ 0079 extern GQuark GFAL_EVENT_CHECKSUM_EXIT; /**< Triggered after exiting checksum validation */ 0080 extern GQuark GFAL_EVENT_CANCEL_ENTER; /**< Triggered before the cancellation logic */ 0081 extern GQuark GFAL_EVENT_CANCEL_EXIT; /**< Triggered after the cancellation logic */ 0082 extern GQuark GFAL_EVENT_OVERWRITE_DESTINATION; /**< Triggered before overwriting */ 0083 extern GQuark GFAL_EVENT_LIST_ENTER; /**< Triggered before listing the urls to be transferred */ 0084 extern GQuark GFAL_EVENT_LIST_ITEM; /**< Triggered once per url pair to be transferred */ 0085 extern GQuark GFAL_EVENT_LIST_EXIT; /**< Triggered after listing the urls to be transferred */ 0086 extern GQuark GFAL_EVENT_TRANSFER_TYPE; /**< Triggered to register the transfer type being done */ 0087 extern GQuark GFAL_EVENT_IPV4; /**< Triggered to register the transfer is done over IPv4 */ 0088 extern GQuark GFAL_EVENT_IPV6; /**< Triggered to register the transfer is done over IPv6 */ 0089 extern GQuark GFAL_EVENT_EVICT; /**< Triggered after a file eviction operation */ 0090 extern GQuark GFAL_EVENT_CLEANUP; /**< Triggered after a delete to cleanup a failed transfer */ 0091 0092 /** 0093 * Types for for GFAL_EVENT_TRANSFER_TYPE 0094 */ 0095 #define GFAL_TRANSFER_TYPE_STREAMED "streamed" 0096 #define GFAL_TRANSFER_TYPE_PUSH "3rd push" 0097 #define GFAL_TRANSFER_TYPE_PULL "3rd pull" 0098 0099 /** 0100 * Enable or disable DNS resolution within the copy function 0101 */ 0102 #define RESOLVE_DNS "RESOLVE_DNS" 0103 0104 /** Trigger of the event */ 0105 typedef enum { 0106 GFAL_EVENT_SOURCE = 0, /**< Event triggered by the source */ 0107 GFAL_EVENT_DESTINATION, /**< Event triggered by the destination */ 0108 GFAL_EVENT_NONE /**< Event triggered by the transfer */ 0109 } gfal_event_side_t; 0110 0111 /** 0112 * @brief Event message. 0113 */ 0114 struct _gfalt_event { 0115 gfal_event_side_t side; /**< Which side triggered the stage change */ 0116 gint64 timestamp; /**< Timestamp in milliseconds */ 0117 GQuark stage; /**< Stage. You can check the predefined ones. */ 0118 GQuark domain; /**< Domain/protocol of this stage. i.e. SRM*/ 0119 const char *description; /**< Additional description */ 0120 }; 0121 0122 /** 0123 * Event message 0124 */ 0125 typedef struct _gfalt_event* gfalt_event_t; 0126 0127 /** 0128 * This function is called when a transfer changes its stage. 0129 * @param e : Event message. 0130 * @param user_data : external pointer provided before 0131 */ 0132 typedef void (*gfalt_event_func)(const gfalt_event_t e, gpointer user_data); 0133 0134 /** 0135 * Checksum verification mode 0136 */ 0137 typedef enum { 0138 /// Don't verify checksum 0139 GFALT_CHECKSUM_NONE = 0x00, 0140 /// Compare user provided checksum vs source 0141 GFALT_CHECKSUM_SOURCE = 0x01, 0142 /// Compare user provided checksum vs destination 0143 GFALT_CHECKSUM_TARGET = 0x02, 0144 /// Compare user provided checksum vs both, *or* source checksum vs target checksum 0145 GFALT_CHECKSUM_BOTH = (GFALT_CHECKSUM_SOURCE | GFALT_CHECKSUM_TARGET) 0146 } gfalt_checksum_mode_t; 0147 0148 /** 0149 * Create a new parameter handle 0150 */ 0151 gfalt_params_t gfalt_params_handle_new(GError ** err); 0152 0153 /** 0154 * Delete a created parameters handle 0155 */ 0156 void gfalt_params_handle_delete(gfalt_params_t params, GError ** err); 0157 0158 0159 /** 0160 Create a copy of a parameter handle 0161 */ 0162 gfalt_params_t gfalt_params_handle_copy(gfalt_params_t params, GError ** err); 0163 0164 /** 0165 * Define the maximum time acceptable for the file transfer 0166 */ 0167 gint gfalt_set_timeout(gfalt_params_t, guint64 timeout, GError** err); 0168 0169 /** 0170 * Get the maximum connexion timeout 0171 */ 0172 guint64 gfalt_get_timeout(gfalt_params_t handle, GError** err); 0173 0174 /** 0175 * Define the maximum number of parallels connexion to use for the file transfer 0176 */ 0177 gint gfalt_set_nbstreams(gfalt_params_t, guint nbstreams, GError** err); 0178 0179 /** 0180 * Get the maximum number of parallels streams to use for the transfer 0181 */ 0182 guint gfalt_get_nbstreams(gfalt_params_t params, GError** err); 0183 0184 /** 0185 * Define the size of the tcp buffer size for network transfer 0186 */ 0187 gint gfalt_set_tcp_buffer_size(gfalt_params_t, guint64 tcp_buffer_size, GError** err); 0188 0189 /** 0190 * get the size of the tcp buffer size for network transfer 0191 */ 0192 guint64 gfalt_get_tcp_buffer_size(gfalt_params_t params, GError** err); 0193 0194 /** 0195 * Enable or disable the non-third party transfer execution ( default : true ) 0196 */ 0197 gint gfalt_set_local_transfer_perm(gfalt_params_t, gboolean local_transfer_status, GError ** err); 0198 0199 /** 0200 * Get the current authorization for the non-third party transfer execution 0201 */ 0202 gboolean gfalt_get_local_transfer_perm(gfalt_params_t, GError ** err); 0203 0204 /** 0205 * Set the source spacetoken for SRM transfers 0206 */ 0207 gint gfalt_set_src_spacetoken(gfalt_params_t params, const char* srm_spacetoken, GError** err); 0208 0209 /** 0210 * Get the source spacetoken for SRM transfers 0211 */ 0212 const gchar* gfalt_get_src_spacetoken(gfalt_params_t params, GError** err); 0213 0214 /** 0215 * Set the destination spacetoken for SRM transfers 0216 */ 0217 gint gfalt_set_dst_spacetoken(gfalt_params_t params, const char* srm_spacetoken, GError** err); 0218 0219 /** 0220 * Get the destination spacetoken for SRM transfers 0221 */ 0222 const gchar* gfalt_get_dst_spacetoken(gfalt_params_t params, GError** err); 0223 0224 /** 0225 * set the replace/overwrite option. 0226 * default : false 0227 * when True, if a destination file already exist, it is deleted before the copy. 0228 */ 0229 gint gfalt_set_replace_existing_file(gfalt_params_t, gboolean replace, GError** err); 0230 0231 /** 0232 * Get the policy in case of destination file already existing ( replace or cancel ) 0233 * default : cancel 0234 */ 0235 gboolean gfalt_get_replace_existing_file(gfalt_params_t, GError** err); 0236 0237 /** 0238 * Set the strict copy mode 0239 * default : false 0240 * In the strict copy mode, the destination/source checks are skipped. 0241 * only the minimum of the operations are done 0242 * This option can leads to undefined behavior depending of the underlying protocol 0243 */ 0244 gint gfalt_set_strict_copy_mode(gfalt_params_t, gboolean strict_mode, GError** err); 0245 0246 /** 0247 * Get the strict copy mode value 0248 */ 0249 gboolean gfalt_get_strict_copy_mode(gfalt_params_t, GError** err); 0250 0251 /** 0252 * @deprecated Equivalent to gfalt_get_checksum_check(params, GFALT_CHECKSUM_BOTH, err) 0253 * Force additional checksum verification between source and destination 0254 * an Error is return by the copy function is case of checksum failure. 0255 * @warning for safety reason, even in case of checksum failure the destination file is not removed. 0256 */ 0257 GFAL2_DEPRECATED(gfalt_set_checksum) gint gfalt_set_checksum_check(gfalt_params_t, gboolean value, GError** err); 0258 0259 /** 0260 * @deprecated 0261 * Get the checksum verification boolean 0262 */ 0263 GFAL2_DEPRECATED(gfalt_get_checksum) gboolean gfalt_get_checksum_check(gfalt_params_t, GError** err); 0264 0265 /** 0266 * @deprecated gfalt_set_checksum 0267 * Set an user-defined checksum for file content verification 0268 * Setting NULL & NULL clear the current one. 0269 * This function requires to enable global checksum verification with \ref gfalt_set_checksum_check 0270 0271 * @param param : parameter handle 0272 * @param chktype : checksum type string ( MD5, ADLER32, CRC32, etc... ) 0273 * @param checksum : value of checksum in string format 0274 * @param err : GError error report 0275 */ 0276 GFAL2_DEPRECATED(gfalt_set_checksum) gint gfalt_set_user_defined_checksum(gfalt_params_t param, 0277 const gchar* chktype, const gchar* checksum, GError** err); 0278 0279 /** 0280 * @deprecated gfalt_get_checksum 0281 * Get the current user-defined checksum for file content verification 0282 * If current user-defined checksum is NULL, both of the buffer are set to empty string 0283 * If the value is set, but not the type, ADLER32 will be assumed 0284 */ 0285 GFAL2_DEPRECATED(gfalt_get_checksum) gint gfalt_get_user_defined_checksum(gfalt_params_t params, 0286 gchar* chktype_buff, size_t chk_type_len, gchar* checksum_buff, size_t checksum_len, GError** err); 0287 0288 /** 0289 * Set the checksum configuration to use 0290 * @param mode For GFALT_CHECKSUM_SOURCE or GFALT_CHECKSUM_TARGET only, the checksum value is mandatory. 0291 * For GFALT_CHECKSUM_BOTH, the checksum value can be NULL, as the verification can be done end to end. 0292 * @param type Checksum algorithm to use. Support depends on protocol and storage, but ADLER32 and MD5 0293 * are normally safe bets. If NULL, previous type is kept. 0294 * @param checksum Expected checksum value. Can be NULL for GFALT_CHECKSUM_BOTH mode. If NULL, clears value. 0295 * @param err GError error report 0296 * @return 0 on success, < 0 on failure 0297 * @version 2.13.0 0298 */ 0299 gint gfalt_set_checksum(gfalt_params_t params, gfalt_checksum_mode_t mode, 0300 const gchar* type, const gchar *checksum, GError **err); 0301 0302 /** 0303 * Get the checksum configuration 0304 * @param type_buff Put in this buffer the configured algorithm (or "\0" if none). 0305 * @param type_buff_len algorithm_buffer capacity. 0306 * @param checksum_buff Put in this buffer the configured checksum value ("\0" if none). 0307 * @param checksum_buff_len checksum_buff capacity. 0308 * @param err GError error report 0309 * @return The configured checksum mode 0310 * @version 2.13.0 0311 */ 0312 gfalt_checksum_mode_t gfalt_get_checksum(gfalt_params_t params, 0313 gchar* type_buff, size_t type_buff_len, gchar* checksum_buff, size_t checksum_buff_len, 0314 GError **err); 0315 0316 /** 0317 * Get only the checksum mode configured 0318 * @return The configured checksum mode 0319 */ 0320 gfalt_checksum_mode_t gfalt_get_checksum_mode(gfalt_params_t params, GError **err); 0321 0322 /** 0323 * Enable or disable the destination parent directory creation 0324 */ 0325 gint gfalt_set_create_parent_dir(gfalt_params_t, gboolean create_parent, GError** err); 0326 0327 /** 0328 * Get the parent directory creation value 0329 */ 0330 gboolean gfalt_get_create_parent_dir(gfalt_params_t, GError** err); 0331 0332 /** 0333 * Enable or disable the clean-up happening when a transfer fails 0334 */ 0335 gint gfalt_set_transfer_cleanup(gfalt_params_t, gboolean transfer_cleanup, GError** err); 0336 0337 /** 0338 * Get the transfer clean-up mode 0339 */ 0340 gboolean gfalt_get_transfer_cleanup(gfalt_params_t, GError** err); 0341 0342 /** 0343 * Enable or disable usage of TPC proxy delegation 0344 */ 0345 gint gfalt_set_use_proxy_delegation(gfalt_params_t, gboolean proxy_delegation, GError** err); 0346 0347 /** 0348 * Get the usage of TPC proxy delegation value 0349 */ 0350 gboolean gfalt_get_use_proxy_delegation(gfalt_params_t, GError** err); 0351 0352 /** 0353 * Set the SciTag transfer flow label 0354 */ 0355 gint gfalt_set_scitag(gfalt_params_t, guint scitag, GError** err); 0356 0357 /** 0358 * Get the SciTag transfer flow label 0359 */ 0360 guint gfalt_get_scitag(gfalt_params_t, GError** err); 0361 0362 /** 0363 * Enable or disable usage of file eviction 0364 */ 0365 gint gfalt_set_use_evict(gfalt_params_t, gboolean evict, GError** err); 0366 0367 /** 0368 * Get the usage of file eviction 0369 */ 0370 gboolean gfalt_get_use_evict(gfalt_params_t, GError** err); 0371 0372 /** 0373 * Set the request id used in the staging operation 0374 */ 0375 gint gfalt_set_stage_request_id(gfalt_params_t, const char* request_id, GError** err); 0376 0377 /** 0378 * Get the request id used in the staging operation 0379 */ 0380 const gchar* gfalt_get_stage_request_id(gfalt_params_t, GError** err); 0381 0382 /** 0383 * Set the transfer metadata to be sent to the transfer destination 0384 */ 0385 gint gfalt_set_transfer_metadata(gfalt_params_t, const char* metadata, GError** err); 0386 0387 /** 0388 * Get the transfer metadata to be sent to the transfer destination 0389 */ 0390 const gchar* gfalt_get_transfer_metadata(gfalt_params_t, GError** err); 0391 0392 /** 0393 * Set the archive metadata to be sent to the transfer destination 0394 */ 0395 gint gfalt_set_archive_metadata(gfalt_params_t, const char* metadata, GError** err); 0396 0397 /** 0398 * Get the transfer metadata to be sent to the transfer destination 0399 */ 0400 const gchar* gfalt_get_archive_metadata(gfalt_params_t, GError** err); 0401 0402 /** 0403 * @brief Add a new callback for monitoring the current transfer 0404 * Adding the same callback with a different udata will just change the udata and the free method, but the callback will not be called twice. 0405 * In this case, udata_free will be called with the old data. 0406 * udata_free can be left to NULL 0407 */ 0408 gint gfalt_add_monitor_callback(gfalt_params_t params, gfalt_monitor_func callback, 0409 gpointer udata, GDestroyNotify udata_free, GError** err); 0410 0411 /** 0412 * @brief Remove an installed monitor callback 0413 * It will call the method registered to free the user data 0414 */ 0415 gint gfalt_remove_monitor_callback(gfalt_params_t params, gfalt_monitor_func callback, GError** err); 0416 0417 /** 0418 * @brief Add a new callback for event monitoring 0419 * Adding the same callback with a different udata will just change the udata, but the callback will not be called twice. 0420 * In this case, udata_free will be called with the old data. 0421 * udata_free can be left to NULL 0422 */ 0423 gint gfalt_add_event_callback(gfalt_params_t params, gfalt_event_func callback, 0424 gpointer udata, GDestroyNotify udata_free, GError** err); 0425 0426 /** 0427 * @brief Remove an installed callback 0428 * It will call the method registered to free the user data 0429 */ 0430 gint gfalt_remove_event_callback(gfalt_params_t params, gfalt_event_func callback, GError** err); 0431 0432 /** 0433 * @brief copy function 0434 * start a synchronous copy of the file 0435 * @param context : gfal2 context 0436 * @param params parameter handle ( \ref gfalt_parameters_new ) 0437 * @param src source URL supported by GFAL 0438 * @param dst destination URL supported by GFAL 0439 * @param err the error is put here 0440 */ 0441 int gfalt_copy_file(gfal2_context_t context, gfalt_params_t params, const char* src, 0442 const char* dst, GError** err); 0443 0444 /** 0445 * @brief bulk copy operation 0446 * If not provided by the plugin, it will fallback to a serialized implementation 0447 * Note that file_errors will point to an array of nbfiles pointers to GError, where each one 0448 * corresponds to the source and destination pair in the same position 0449 * op_error will contain an error if something happened _before_ file transferring could be attempted 0450 */ 0451 int gfalt_copy_bulk(gfal2_context_t context, gfalt_params_t params, size_t nbfiles, 0452 const char* const * srcs, const char* const * dsts, const char* const* checksums, 0453 GError** op_error, GError*** file_errors); 0454 0455 /** 0456 * Get a transfer status indicator 0457 */ 0458 gint gfalt_copy_get_status(gfalt_transfer_status_t, GError ** err); 0459 0460 /** 0461 * Get an estimation of the average baudrate in bytes/s 0462 */ 0463 size_t gfalt_copy_get_average_baudrate(gfalt_transfer_status_t, GError ** err); 0464 0465 /** 0466 * Get an estimation of the instant baudrate in bytes/s 0467 */ 0468 size_t gfalt_copy_get_instant_baudrate(gfalt_transfer_status_t, GError ** err); 0469 0470 /** 0471 * Get the current number of bytes transferred 0472 */ 0473 GFAL2_DEPRECATED(gfalt_copy_get_bytes_transferred) size_t gfalt_copy_get_bytes_transfered(gfalt_transfer_status_t, GError ** err); 0474 size_t gfalt_copy_get_bytes_transferred(gfalt_transfer_status_t, GError ** err); 0475 /** 0476 * Get the elapsed time since the call to \ref gfalt_copy_file 0477 */ 0478 time_t gfalt_copy_get_elapsed_time(gfalt_transfer_status_t, GError ** err); 0479 0480 /** 0481 @} 0482 End of the File Transfer API 0483 */ 0484 0485 #ifdef __cplusplus 0486 } 0487 #endif 0488 0489 #endif /* GFAL_TRANSFER_H_ */ 0490
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |