INT32 utilGetRoleByConfigPath( const string &confPath, INT32 &role, BOOLEAN allowFileNotExist ) { INT32 rc = SDB_OK ; po::options_description desc ; po::variables_map vm ; desc.add_options() ( PMD_OPTION_ROLE, po::value<string>(), "" ) ; CHAR conf[OSS_MAX_PATHSIZE + 1] = { 0 } ; role = SDB_ROLE_STANDALONE ; rc = utilBuildFullPath ( confPath.c_str(), PMD_DFT_CONF, OSS_MAX_PATHSIZE, conf ) ; if ( rc ) { std::cerr << "Failed to build full path, rc: " << rc << std::endl ; goto error ; } if ( allowFileNotExist && SDB_OK != ossAccess( conf ) ) { goto done ; } rc = utilReadConfigureFile( conf, desc, vm ) ; if ( allowFileNotExist && SDB_IO == rc ) { rc = SDB_OK ; goto done ; } if ( rc ) { goto error ; } if ( vm.count ( PMD_OPTION_ROLE ) ) { string roleStr = vm [ PMD_OPTION_ROLE ].as<string>() ; role = utilGetRoleEnum( roleStr.c_str() ) ; } done : return rc ; error : goto done ; }
INT32 _SDB_KRCB::onConfigInit () { _role = utilGetRoleEnum( _optioncb.krcbRole() ) ; pmdSetDBRole( _role ) ; // Call trace start if we want to trace start up procedure if ( _optioncb.isTraceOn() && _optioncb.traceBuffSize() != 0 ) { sdbGetPDTraceCB()->start ( (UINT64)_optioncb.traceBuffSize(), 0xFFFFFFFF ) ; } // enable memory debug option ossEnableMemDebug( _optioncb.memDebugEnabled(), _optioncb.memDebugSize() ) ; return _optioncb.makeAllDir() ; }