121 lines
3.5 KiB
C++
121 lines
3.5 KiB
C++
/***************************************************************************
|
|
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 <list>
|
|
#include <map>
|
|
|
|
|
|
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<string>& 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__ */
|
|
|