globus_ftp_client_restart_plugin.example

The following example illustrates a typical use of the restart plugin. In this case, we configure a plugin instance to restart the operation for up to an hour, using an exponential back-off between retries.

00001 #include "globus_ftp_client.h"
00002 #include "globus_ftp_client_restart_plugin.h"
00003 #include "globus_time.h"
00004 
00005 int
00006 main(int argc, char *argv[])
00007 {
00008     globus_ftp_client_plugin_t restart_plugin;
00009     globus_ftp_client_handleattr_t handleattr;
00010     globus_ftp_client_handle_t handle;
00011     globus_abstime_t deadline;
00012 
00013     globus_module_activate(GLOBUS_FTP_CLIENT_MODULE);
00014     globus_module_activate(GLOBUS_FTP_CLIENT_RESTART_PLUGIN_MODULE);
00015 
00016     /* Set a deadline to be now + 1 hour */
00017     GlobusAbstimeSet(deadline, 60 * 60, 0);
00018 
00019     /* initialize a plugin with this deadline */
00020     globus_ftp_client_restart_plugin_init(
00021         &restart_plugin,
00022         0,                        /* # retry limit (0 means don't limit) */
00023         GLOBUS_NULL,              /* interval between retries--null means
00024                                    * exponential backoff
00025                                    */
00026         &deadline);
00027 
00028     /* Set up our handle to use the new plugin */
00029     globus_ftp_client_handleattr_init(&handleattr);
00030     globus_ftp_client_handleattr_add_plugin(&handleattr, &restart_plugin);
00031     globus_ftp_client_handle_init(&handle, &handleattr);
00032 
00033     /*
00034      * Now, if a fault occurs processing this get, the plugin will restart
00035      * it with an exponential back-off, and will bail if a fault occurs
00036      * after 1 hour of retrying
00037      */
00038     globus_ftp_client_get(&handle,
00039                           "ftp://ftp.globus.org/pub/globus/README",
00040                           GLOBUS_NULL,
00041                           GLOBUS_NULL,
00042                           callback_fn,
00043                           GLOBUS_NULL);
00044 }

Generated on 12 Dec 2014 for globus_ftp_client by  doxygen 1.4.7