当前位置: 首页>>代码示例>>C++>>正文


C++ Oam::processInitFailure方法代码示例

本文整理汇总了C++中Oam::processInitFailure方法的典型用法代码示例。如果您正苦于以下问题:C++ Oam::processInitFailure方法的具体用法?C++ Oam::processInitFailure怎么用?C++ Oam::processInitFailure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Oam的用法示例。


在下文中一共展示了Oam::processInitFailure方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char* argv[])
{
    // get and set locale language
	string systemLang = "C";

	BRM::DBRM dbrm;
    Oam oam;
	//BUG 5362
	systemLang = funcexp::utf8::idb_setlocale();

    Config* cf = Config::makeConfig();

    setupCwd();

    WriteEngine::WriteEngineWrapper::init( WriteEngine::SUBSYSTEM_ID_DMLPROC );
#ifdef _MSC_VER
    // In windows, initializing the wrapper (A dll) does not set the static variables
    // in the main program
    idbdatafile::IDBPolicy::configIDBPolicy();
#endif
	
    try
    {
		// At first we set to BUSY_INIT
		oam.processInitComplete("DMLProc", oam::BUSY_INIT);
    }
    catch (...)
    {
    }
	
	//@Bug 1627
	try 
	{
    	rollbackAll(&dbrm); // Rollback any 
	}
	catch ( std::exception &e )
	{
		//@Bug 2299 Set DMLProc process to fail and log a message 
		try
		{
			oam.processInitFailure();
		}
		catch (...)
        {
        } 
		logging::Message::Args args;
        logging::Message message(2);
        args.add("DMLProc failed to start due to :");
		args.add(e.what());
        message.format( args );
		logging::LoggingID lid(20);
        logging::MessageLog ml(lid);

        ml.logCriticalMessage( message );
		
		cerr << "DMLProc failed to start due to : " << e.what() << endl;
		return 1;
	}

	int temp;
	int serverThreads = 10;
	int serverQueueSize = 50;
	const string DMLProc("DMLProc");
	
	temp = toInt(cf->getConfig(DMLProc, "ServerThreads"));
	if (temp > 0)
			serverThreads = temp;

	temp = toInt(cf->getConfig(DMLProc, "ServerQueueSize"));
	if (temp > 0)
			serverQueueSize = temp;


    bool rootUser = true;
#ifndef _MSC_VER
    //check if root-user
    int user;
    user = getuid();
    if (user != 0)
        rootUser = false;
#endif
    //read and cleanup port before trying to use
    try {
        string port = cf->getConfig(DMLProc, "Port");
        string cmd = "fuser -k " + port + "/tcp >/dev/null 2>&1";
        if ( !rootUser)
            cmd = "sudo fuser -k " + port + "/tcp >/dev/null 2>&1";

        (void)::system(cmd.c_str());
    }
    catch(...)
    {
    }

	DMLServer dmlserver(serverThreads, serverQueueSize,&dbrm);

	//set ACTIVE state
    try
    {
        oam.processInitComplete("DMLProc", ACTIVE);
//.........这里部分代码省略.........
开发者ID:DYFeng,项目名称:infinidb,代码行数:101,代码来源:dmlproc.cpp


注:本文中的Oam::processInitFailure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。