Back to index

nordugrid-arc-nox  1.1.0~rc6
DataPointGridFTP.h
Go to the documentation of this file.
00001 // -*- indent-tabs-mode: nil -*-
00002 
00003 #ifndef __ARC_DATAPOINTGRIDFTP_H__
00004 #define __ARC_DATAPOINTGRIDFTP_H__
00005 
00006 #include <list>
00007 #include <string>
00008 
00009 #include <globus_common.h>
00010 #include <globus_ftp_client.h>
00011 
00012 #include <arc/Thread.h>
00013 #include <arc/data/DataPointDirect.h>
00014 
00015 namespace Arc {
00016 
00017   class GSSCredential;
00018   class URL;
00019 
00020   class DataPointGridFTP
00021     : public DataPointDirect {
00022   private:
00023     static Logger logger;
00024     bool ftp_active;
00025     globus_ftp_client_handle_t ftp_handle;
00026     globus_ftp_client_operationattr_t ftp_opattr;
00027     globus_thread_t ftp_control_thread;
00028     int ftp_threads;
00029     bool autodir;
00030 
00031     SimpleCondition cond;
00032     DataStatus condstatus;
00033     GSSCredential *credential;
00034 
00035     bool reading;
00036     bool writing;
00037 
00038     bool ftp_eof_flag;
00039 
00040     static void ftp_complete_callback(void *arg,
00041                                       globus_ftp_client_handle_t *handle,
00042                                       globus_object_t *error);
00043     static void ftp_get_complete_callback(void *arg,
00044                                           globus_ftp_client_handle_t *handle,
00045                                           globus_object_t *error);
00046     static void ftp_put_complete_callback(void *arg,
00047                                           globus_ftp_client_handle_t *handle,
00048                                           globus_object_t *error);
00049     static void ftp_read_callback(void *arg,
00050                                   globus_ftp_client_handle_t *handle,
00051                                   globus_object_t *error,
00052                                   globus_byte_t *buffer, globus_size_t length,
00053                                   globus_off_t offset, globus_bool_t eof);
00054     static void ftp_check_callback(void *arg,
00055                                    globus_ftp_client_handle_t *handle,
00056                                    globus_object_t *error,
00057                                    globus_byte_t *buffer, globus_size_t length,
00058                                    globus_off_t offset, globus_bool_t eof);
00059     static void ftp_write_callback(void *arg,
00060                                    globus_ftp_client_handle_t *handle,
00061                                    globus_object_t *error,
00062                                    globus_byte_t *buffer, globus_size_t length,
00063                                    globus_off_t offset, globus_bool_t eof);
00064     static void* ftp_read_thread(void *arg);
00065     static void* ftp_write_thread(void *arg);
00066 
00067     std::string ftp_dir_path;
00068     bool mkdir_ftp();
00069     char ftp_buf[16];
00070     bool check_credentials();
00071     void set_attributes();
00072   public:
00073     DataPointGridFTP(const URL& url, const UserConfig& usercfg);
00074     virtual ~DataPointGridFTP();
00075     static Plugin* Instance(PluginArgument *arg);
00076     virtual DataStatus StartReading(DataBuffer& buf);
00077     virtual DataStatus StartWriting(DataBuffer& buf,
00078                                     DataCallback *space_cb = NULL);
00079     virtual DataStatus StopReading();
00080     virtual DataStatus StopWriting();
00081     virtual DataStatus Check();
00082     virtual DataStatus Remove();
00083     virtual DataStatus ListFiles(std::list<FileInfo>& files, bool long_list = false, bool resolve = false, bool metadata = false);
00084     virtual bool WriteOutOfOrder();
00085     virtual bool ProvidesMeta();
00086   };
00087 
00088 } // namespace Arc
00089 
00090 #endif // __ARC_DATAPOINTGRIDFTP_H__