/**************************************************************************** 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 #include #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 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 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 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 GetFHSMount() { return m_vecFHSMount; } }; #endif /* __SERVICE_CONFIG_H__ */