/*************************************************************************** ftsd ( File TranSfer Daemon ) Header ( FileSender.h ) ----------------------------------------- begin : 2010/03/13 copyright : (C) 2005 SolutionBox Inc. author : Service 1 Team email : svc1@solbox.com version : 1.0 CopyRight(C) 2005 SolutionBox Inc. All Rights reserved. Redistribution and use in source and binary forms, with or with out modification, are not permitted in outside of SolutionBox Inc. ***************************************************************************/ #ifndef __FILE_SENDER_H__ #define __FILE_SENDER_H__ #include "Logger.h" #include "IPCache.h" #include "ProcessStatus.h" #include "SocketControl.h" #include "TargetFhsInfo.h" #include "FileHash.h" #include #include class CFileSender { public : CFileSender(CIPCache * pIpCache, CProcessStatus * pProcess, CSocketControl * pSockCtl ); ~CFileSender(); bool Init( const std::string& szFileName, unsigned long long nFileSize, const std::string& szTargetTranId, std::vector& vecTarget, int nHashLevel, bool bUseInternalIp, char command, std::string& szErrorMessage ); bool Start( void ); /// @brief ÆÄÀÏ Àü¼Û °ü·Ã ÀÛ¾÷À» Á¤Áö½ÃŲ´Ù. void Stop(void); // ÇöÀç °´Ã¼¸¦ »ç¿ëÇÒ ¼ö ÀÖ´ÂÁö ¿©ºÎ. // File °ü·Ã ÀÛ¾÷ÁßÀÎ °æ¿ì false, Idle »óÅÂÀÎ °æ¿ì true ¸¦ ¹ÝȯÇÑ´Ù. bool IsIdle( void ) { return !m_bProcessing; } void SetThreadStart(void) { m_bProcessing = true; } void SetThreadEnd(void) { m_bProcessing = false; } private: /// @brief FileSender Class ÀÇ Thread Function, ÆÄÀÏÀÇ Àü¼ÛÀ» ´ã´çÇÔ. static void * SenderThread( void * arg ); /// @brief ½ÇÁ¦ ÆÄÀÏÀÇ Àü¼ÛÀ» ó¸®Çϱâ À§ÇÑ ÇÔ¼ö. void Execute(void); protected: /// @brief ´ë»ó FHS Á¤º¸¸¦ ¼³Á¤Çϰí Á¢¼ÓÀ» ¼³Á¤ÇÔ. bool InitFhsInfo(void); /// @brief Àü´Þ¹ÞÀº ÆÄÀÏ ¹× Å©±â°¡ ½ÇÁ¦ ÇöÀç °æ·Î¿¡ Á¸Àç, Å©±â°¡ Á¤È®ÇÑÁö °Ë»çÇϱâ À§ÇÑ ÇÔ¼ö. bool CheckFileInfo( const std::string& szFileName, unsigned long long nFileSize, std::string& szErrorMessage ); /// @brief ´ë»ó FHS ·Î Á¢¼Ó 󸮸¦ ¼öÇà. bool ConnectTargetFhs(void); /// @brief °¢ FHS ·Î ÆÄÀÏ Àü¼ÛÀ» ½ÃÀÛÇÑ´Ù. bool SendFileToFhs(void); /// @brief ÆÄÀÏ¿¡ ´ëÇÑ Hash °ªÀ» »ý¼ºÇÏ¿© °¢ FHS ·Î Àü¼ÛµÈ File ÀÇ Hash °Ë»ç¸¦ ¿äûÇÑ´Ù. bool CheckHashValue(void); /// @brief ÆÄÀÏ Transfer ó¸® °á°ú¸¦ Control Daemon À¸·Î Àü¼Ûó¸®. bool SendTransferResultToControl(void); private: bool m_bProcessing; // ÇöÀç CFileSender °´Ã¼°¡ ÀÛ¾÷ ÁßÀÎÁö ¿©ºÎ¸¦ ÀúÀåÇϱâ À§ÇÑ º¯¼ö. bool m_bThreadStop; // Thread ÀÇ µ¿ÀÛ Á¤Áö ¿©ºÎ¸¦ ÆÇ´ÜÇϱâ À§ÇÑ º¯¼ö // Àü¿ª Object ¿¡ ´ëÇÑ ¸â¹ö Æ÷ÀÎÅÍ. CIPCache * m_pIpCache; CProcessStatus * m_pProcessStatus; // Control Daemon °ú ¿¬°áµÈ Socket Control Object Pointer CSocketControl * m_pSocketControl; std::string m_szSourceFileName; // Source File Full Name unsigned long long m_nSourceFileSize; // Source File Size std::string m_szTargetTranId; // RC °£ µ¿±âÈ­½Ã »ç¿ëÇÒ Target Tran ID Á¤º¸ std::vector< string > m_vecTargetFhs; // º¹Á¦ ´ë»ó FHS Á¤º¸ int m_nHashLevel; // Hash °Ë»ç Level char m_requestType; // ¸í·É¾î Á¤º¸, Replication or Cache bool m_bUseInternalIp; // ³»ºÎ¸Á »ç¿ë ¿©ºÎ. // ¾²·¹µå ÇÚµé pthread_t m_threadHandle; // Target FHS Handle Á¤º¸¸¦ ÀúÀåÇϱâ À§ÇÑ ¸â¹ö º¯¼ö std::list< CTargetFhsInfo > m_listTarget; int m_fhsAvailableCount; std::string m_szSourceHashValue; }; #endif /* __FILE_SENDER_H__ */