This commit is contained in:
biosvos
2026-08-07 17:38:18 +09:00
commit 873193a243
9613 changed files with 2755992 additions and 0 deletions
+159
View File
@@ -0,0 +1,159 @@
/****************************************************************************
rc_balanced config processing module
-----------------------------------------
begin : 2019/02/25
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 <time.h>
#include "Config.h"
// 2021-01-05 NEW huibong 이동 대상 content 선택 관련 mode 기능 추가 (#33306)
typedef enum TypeContentSelectMode {
SELECT_MODE_SIZE = 0, // 큰 파일 우선 이동 처리
SELECT_MODE_RANDOM // 이동 대상 content 를 random 으로 선택
} ContentSelectMode;
#define CONTENT_SELECT_MODE_TO_DEFAULT_TIMEOUT 10800 // content mode 가 default 가 아닌 경우... 다시 default 로 전환시킬 timeout 값 (sec)
// 본 모듈은 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_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.
// 프로세스 설정 정보
unsigned int m_nMaxQueueSize; // Max Queue Size ( default: 4096 )
unsigned int m_nFhsTransferDaemonPort; // FHS File Transfer Daemon (ftsd) TCP Listen Port = 14001 (default)
// Rebalance target FHS reselect time limit (minutes), default 30 min, use transfer total size calc, max 1440
unsigned int m_nFhsReselectionTimeLimit;
unsigned int m_nHashCheckLevel; // Content 복제 및 Cache 관련 전송시 Hash Check Level 설정.
// 0:Not check (default), 1:Partitial hash, 2:Full Hash
// 2021-01-19 NEW huibong move 대상 FHS 선정시 disk busy 허용 max 값 추가 (#33395)
// - conf 처리 관련 멤버 변수 추가
double m_dTargetFhsMaxDiskBusyLimit;
// 프로세스 내부 동작 관련 변수
// 2021-01-05 NEW huibong 이동 대상 content 선택 관련 mode 기능 추가 (#33306)
ContentSelectMode m_nContentSelectMode; // move content select mode, 상세내역은 ContentSelectMode 참고
struct timespec m_timeContentSelectModeChange; // move content select mode 가 변경된 최종 시간.
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(); }
unsigned int GetMaxQueueSize() { return m_nMaxQueueSize; }
unsigned int GetFhsTransferDaemonPort() { return m_nFhsTransferDaemonPort; }
unsigned int GetFhsReselectionTimeLimit() { return m_nFhsReselectionTimeLimit; }
unsigned int GetHashCheckLevel() { return m_nHashCheckLevel; }
double GetTargetFhsMaxDiskBusyLimit() { return m_dTargetFhsMaxDiskBusyLimit; }
// 2021-01-05 NEW huibong 이동 대상 content 선택 관련 mode 기능 추가 (#33306)
// - GET/SET 함수 추가
ContentSelectMode GetContentSelectMode() { return m_nContentSelectMode; }
void SetContentSelectMode( ContentSelectMode mode );
bool SetContentSelectModeToDefault();
};
#endif /* __PROCESS_CONFIG_H__ */