base
This commit is contained in:
@@ -0,0 +1,167 @@
|
||||
/****************************************************************************
|
||||
cls config processing module
|
||||
-----------------------------------------
|
||||
|
||||
begin : 2015/10/06
|
||||
copyright : (C) 2005 Solbox Inc.
|
||||
author : Dev Storage team
|
||||
email : huibong@solbox.com
|
||||
version : 3.5
|
||||
|
||||
CopyRight(C) 2005 Solbox Inc. All Rights reserved.
|
||||
Redistribution and use in source and binary forms, with or with out
|
||||
modification, are not permitted in outside of Solbox Inc.
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef __PROCESS_CONFIG_H__
|
||||
#define __PROCESS_CONFIG_H__
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
// 본 모듈은 conf 파일의 정보를 read 하여... 본 프로세스 관련 설정 정보를 저장한다.
|
||||
// 본 모듈은 singleton 으로 동작시켜 Main 프로세스 및 Worker 프로세스에서도 접근이 가능토록 한다.
|
||||
// conf 파일에 대한 파싱 및 설정 정보 추출은 lib 하위의 Config 클래스를 이용한다.
|
||||
// 본 객체는 singleton 객체이므로 상속받아 사용하지 않도록 한다. ( 상속받아 사용할 수 없도록 private 처리함 )
|
||||
|
||||
class CProcessConfig
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
// sigleton 객체 생성을 위해 생성자를 public 으로 처리하지 않음.
|
||||
CProcessConfig();
|
||||
|
||||
// 소멸자
|
||||
virtual ~CProcessConfig();
|
||||
|
||||
static CProcessConfig * m_pInstance;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// 객체 초기화 처리용 Function.
|
||||
// 본 함수 호출시 Instance 생성 후 입력 받은 Config 파일 load.
|
||||
// 따라서 본 함수를 호출하지 않을 경우.. GetInstance() 함수는 NULL 을 반환
|
||||
// 본 함수를 객체가 생성된 상태에서 재 호출할 경우
|
||||
// - 주어진 Conf 파일 정보가 정확하다면.. conf 정보를 다시 load 함.
|
||||
// - 주어진 conf 파일 정보가 부정확하다면... 이전 conf 를 계속 사용함.
|
||||
static bool Init( const std::string strProgramName, const std::string & strConfFileName, std::string & strErrorMessage );
|
||||
|
||||
// Singleton 객체 접근 메소드
|
||||
static CProcessConfig * GetInstance();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// 전달받은 conf 파일에서 해당 config 정보를 로드하여 멤버 변수에 저장한다.
|
||||
// 만약 반환값이 false 인 경우 해당 오류 관련 내역은 strErrorMessage 변수에 저장된다.
|
||||
bool Load( const std::string & strProgramName, const std::string & strConfFileName, std::string & strErrorMessage );
|
||||
|
||||
|
||||
// Config 객체로 부터 지정된 strKey 정보를 가져와 유효성 여부를 판단.
|
||||
// 반환값이 false 인 경우 strErrorMessage 상에 오류 내역이 저장된다.
|
||||
bool GetConfigValue( Config & conf, const std::string & strProgramName, const std::string strKey, std::string & strValue, std::string & strErrorMessage );
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// 객체 초기화시 전달받은 정보
|
||||
std::string m_strConfigFileName; // 설정 파일 정보
|
||||
std::string m_strProgramName; // 프로그램 명 (conf 상에서 해당 프로그램의 설정 정보를 가져올 때 사용)
|
||||
|
||||
|
||||
// 기본 설정 정보.
|
||||
std::string m_strLogPath; // 로그 저장 Path (/user/service/logs)
|
||||
int m_nLogLevel; // 로그 기록 Level
|
||||
|
||||
std::string m_strStorageRoot; // content save path
|
||||
// - conf 상의 FILE_STORAGE_ROOT 설정값
|
||||
|
||||
std::string m_strRcdbIp; // RCDB IP
|
||||
unsigned int m_nRcdbPort; // RCDB Port
|
||||
std::string m_strRcdbName; // RCDB DB Name
|
||||
std::string m_strRcdbAcct; // RCDB 접근 계정
|
||||
std::string m_strRcdbAcctPw; // RCDB 접근 Password
|
||||
|
||||
|
||||
// 프로세스 설정 정보
|
||||
bool m_bRunIntegrityCheck; // content integrity check 수행 여부 ( 실행 옵션값을 통해 설정 처리)
|
||||
bool m_bRunGarbageClean; // garbage content clean 수행 여부 ( 실행 옵션값을 통해 설정 처리)
|
||||
|
||||
bool m_bGarbageCleanSlow; // garbage content clean 수행시 slow unlink 처리 여부 ( 실행 옵션값을 통해 설정 처리)
|
||||
|
||||
bool m_bGarbageForceDelete; // garbage content clean 수행시 access time check 여부 (실행 옶션값을 통해 설정 처리)
|
||||
|
||||
|
||||
bool m_bUserDefineJobRoot; // 사용자가 작업 경로를 설정했는지 여부를 판단하기 위한 함수.
|
||||
// - 지정하지 않았을 경우.. 해당 FHS 에 존재하는 content 를 조회하면 되지만..
|
||||
// - 지정시 filename_hash like 구문을 사용하여 조회해야 하므로...
|
||||
// - 이를 구분하기 위해 사용 처리.
|
||||
|
||||
std::string m_strJobRoot; // 작업을 수행할 content save path
|
||||
// 실행 옵션에서 -p 로 경로 지정시.. 검증을 통해.. 최종 작업 대상 경로가 설정됨.
|
||||
// 해당 값은 폴더 경로 정보이지만.. 마지막 '/' 정보는 입력처리 안 되도록 처리한다. ( /stg/ -> /stg )
|
||||
// 본 값이 존재하지 않을 경우... m_strStorageRoot 값을 사용한다.
|
||||
|
||||
|
||||
std::string m_strHostname; // 장비의 hostname 정보를 저장 처리. (main 프로세스 초기화시 추출하여 저장 처리)
|
||||
|
||||
|
||||
|
||||
|
||||
public: // 멤버 변수에 대한 Get 함수 선언 및 정의
|
||||
|
||||
const char * GetConfigFileName() { return m_strConfigFileName.c_str(); }
|
||||
const char * GetProgramName() { return m_strProgramName.c_str(); }
|
||||
|
||||
const char * GetLogPath() { return m_strLogPath.c_str(); }
|
||||
int GetLogLevel() { return m_nLogLevel; }
|
||||
|
||||
const char * GetStorageRoot() { return m_strStorageRoot.c_str(); }
|
||||
|
||||
const char * GetRcdbIp() { return m_strRcdbIp.c_str(); }
|
||||
unsigned int GetRcdbPort() { return m_nRcdbPort; }
|
||||
const char * GetRcdbName() { return m_strRcdbName.c_str(); }
|
||||
const char * GetRcdbAcct() { return m_strRcdbAcct.c_str(); }
|
||||
const char * GetRcdbAcctPw() { return m_strRcdbAcctPw.c_str(); }
|
||||
|
||||
|
||||
// integrity check 수행 여부 설정.
|
||||
void SetIntegrityCheck( bool & bRun ) { m_bRunIntegrityCheck = bRun; return; }
|
||||
// garbage clean job 수행 여부 설정.
|
||||
void SetGarbageClean( bool & bRun ) { m_bRunGarbageClean = bRun; return; }
|
||||
|
||||
// garbage clean job slow unlink 설정 여부
|
||||
void SetGarbageCleanSlow( bool & bRun ) { m_bGarbageCleanSlow = bRun; return; }
|
||||
|
||||
// garbage clean 작업시 access time check 여부
|
||||
void SetGarbageForceDelete(bool& bRun) { m_bGarbageForceDelete = bRun; return; }
|
||||
|
||||
|
||||
// 사용자가 옵션으로 작업 경로를 지정한 경우.. 해당 정보를 저장 처리
|
||||
// - 지정된 경로는 conf 의 FILE_STORAGE_ROOT 설정값 하위 폴더이어야 하며...
|
||||
// - 오류 발생시.. 해당 내역을 strErrorMessage 에 저장하여 반환 처리.
|
||||
bool SetJobRoot( std::string & strPath, std::string & strErrorMessage );
|
||||
|
||||
// 작업을 수행할 content 저정 경로 정보를 반환한다.
|
||||
// - 사용자가 옵션으로 경로를 지정한 경우.. 해당 정보를 반환.
|
||||
// - 사용자가 옵션으로 경로를 지정하지 않은 경우... conf 에 정의된 FILE_STORAGE_ROOT 값을 반환한다.
|
||||
// - 사용자의 옵션 지정 여부는 IsUserDefineJobRoot() 함수를 이용하여 확인 가능.
|
||||
const char * GetJobRoot();
|
||||
|
||||
bool IsRunIntegrityCheck() { return m_bRunIntegrityCheck; }
|
||||
bool IsRunGarbageClean() { return m_bRunGarbageClean; }
|
||||
bool IsSlowGarbageClean() { return m_bGarbageCleanSlow; }
|
||||
bool IsForceGarbageDelete() { return m_bGarbageForceDelete; }
|
||||
bool IsUserDefineJobRoot() { return m_bUserDefineJobRoot; }
|
||||
|
||||
// hostname 처리 관련 함수
|
||||
bool SetHostname( const char * name );
|
||||
const char * GetHostname();
|
||||
|
||||
};
|
||||
|
||||
#endif /* __PROCESS_CONFIG_H__ */
|
||||
|
||||
Reference in New Issue
Block a user