Files
interactive/rcts/rc_syncd/src/ServiceConfig.h
T
2026-08-07 17:38:18 +09:00

149 lines
6.4 KiB
C++

/****************************************************************************
rc_syncd's service config module
-----------------------------------------
begin : 2014/09/02
copyright : (C) 2005 Solbox Inc.
author : Storage Dev Team
email : storage.sd@solbox.com
version : 3.4
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 __SERVICE_CONFIG_H__
#define __SERVICE_CONFIG_H__
#include <string>
#include <vector>
#include "Config.h"
// 본 모듈은 conf 파일의 정보를 read 하여... 본 프로세스 관련 설정 정보를 저장한다.
// 본 모듈은 singleton 으로 동작시켜 Main 프로세스 및 Worker 프로세스에서도 접근이 가능토록 한다.
// conf 파일에 대한 파싱 및 설정 정보 추출은 lib 하위의 Config 클래스를 이용한다.
// 본 객체는 singleton 객체이므로 상속받아 사용하지 않도록 한다. ( 상속받아 사용할 수 없도록 private 처리함 )
class CServiceConfig
{
private:
// sigleton 객체 생성을 위해 생성자를 public 으로 처리하지 않음.
CServiceConfig();
// 소멸자
virtual ~CServiceConfig();
static CServiceConfig * 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 CServiceConfig * 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
int m_nLogLevel; // 로그 기록 Level
std::string m_strRcId; // RC ID
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.
std::vector<std::string> m_vecSkipWord; // 작업 대상에서 제외할 content 문자열 정보 저장.
// 설정값이 존재하지 않을 수 있음.
// Process
unsigned int m_nOperationPort; // Operation Command TCP Listen port, OP_PORT = 14002
unsigned int m_nDbPoolCount; // Database connection pool count, DB_POOL = 4
unsigned int m_nWorkPoolCount; // Work pool count, WORK_POOL = 20
unsigned int m_nSafetyFactor; // When endtime to obtain coefficient that are subtracted. (sec), SAFETY_FACTOR = 180
unsigned int m_nOnceSize; // Get the set amount of time at a time. (Day), ONCE_SIZE = 1
// Time between sync runs & target interval
unsigned int m_nChkSmall; // range : 30 ~CHK_MIDDLE( second ), CHK_SMALL = 60
// default : 60
unsigned int m_nChkMiddle; // range : CHK_SMALL ~(second), CHK_MIDDLE = 3600
// default : 3600
unsigned int m_nChkOnce; // range : 1Days, hour( 0 - 23 ), CHK_ONCE = 7
std::string m_strDiffCommand; // diff commnad, DIFF_COMMAND=/user/service/etc/diff_com.sh
// default : /user/service/etc/diff_com.sh
std::string m_strRcCMove; // rc_cmove path, RC_CMOVE=/user/service/bin/rc_cmove
// default : /user/service/bin/rc_cmove
std::vector<std::string> m_vecFHSMount; // FHS storage mount info multi set enable, FHS_STORAGE_MOUNT = /stg/node0,/stg/node1,/stg/node2
// default : /stg/node0,/stg/node1,/stg/node2
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 * GetRcId() { return m_strRcId.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(); }
std::vector<std::string> GetSkipWord() { return m_vecSkipWord; }
unsigned int GetOperationPort() { return m_nOperationPort; }
unsigned int GetDbPoolCount() { return m_nDbPoolCount; }
unsigned int GetWorkPoolCount() { return m_nWorkPoolCount; }
unsigned int GetSafetyFactor() { return m_nSafetyFactor; }
unsigned int GetOnceSize() { return m_nOnceSize; }
unsigned int GetChkSmall() { return m_nChkSmall; }
unsigned int GetChkMiddle() { return m_nChkMiddle; }
unsigned int GetChkOnce() { return m_nChkOnce; }
const char * GetDiffCommand() { return m_strDiffCommand.c_str(); }
const char * GetRCCMoveCommand() { return m_strRcCMove.c_str(); }
std::vector<std::string> GetFHSMount() { return m_vecFHSMount; }
};
#endif /* __SERVICE_CONFIG_H__ */