📄 drserver_impl.cpp
字号:
// IDRecoveryServer_impl.cpp
// IDRecoveryServer_impl.h的实现
//
#include "DRServer_impl.h"
#include <fstream>
#include <STAR/ATF_IIOP.h>
#ifdef __UNIX__
#include <sys/time.h>
#endif
#ifdef _WIN32
#include <time.h>
#endif
#ifdef HAS_DEBUG_LEVEL
#include "LogClient.h"
extern LogClient * g_pLogWriter;
#endif
char filename[128];
extern int g_nDebugLevel;
IDRecoveryServer_impl::IDRecoveryServer_impl(PortableServer::POA_ptr poa , ATF::Current_ptr current)
: m_poa(PortableServer::POA::_duplicate(poa)), m_current(ATF::Current::_duplicate(current))
{
// m_current
m_ErrMsg = CORBA::string_dup("");
m_OCIErrMsg = CORBA::string_dup("");
time_t thetime = time(0);
struct tm * curr_time = localtime(&thetime);
m_TimeThread = NULL;
m_requestCounter = NULL;
m_levelControl = NULL;
m_requestCounter = new RequestCounter_impl(m_poa);
m_levelControl = new ILevelControl_impl(m_poa,true);
// if ( (m_requestCounter == NULL )||(m_levelControl==NULL))
// {
// return ERR_SQSERVER_NOT_ENOUGH_MEMORY;
// }
}
IDRecoveryServer_impl::~IDRecoveryServer_impl()
{
}
//do nothing ,just create a IResult object that contains all parameter except sqlstatement
DataRecovery_ptr IDRecoveryServer_impl::ResGet(const char* strClientID, CORBA::Short timeOut)
throw(CORBA::SystemException)
{
//// ENTERING("ResConnect()",strClientID,0)
//
// CORBA::Short rc;
//
// //如果客户指定非零值,则以客户的值为准,否则取默认值
CORBA::Short t = timeOut ;
// //启动一个线程查询指定时间间隔内客户端有无动作,如果无则断开连接
// //这些参数是不是应该从数据字典中读取?
// cout << "11" << endl;
m_TimeThread = new CTimeOutThread(3600, 3000);
if (!m_TimeThread)
{
return DataRecovery::_nil();
}
m_TimeThread -> start();
// cout << "22" << endl;
DataRecovery_impl * impl = new DataRecovery_impl(m_poa, m_TimeThread, timeOut);
if (impl == NULL) // error message
{
return DataRecovery::_nil();
}
cout << "33" << endl;
PortableServer::ServantBase_var servant = impl;
cout << "44" << endl;
//--------------------------------------------
//get client ip and port
ATF::TransportInfo_var info = m_current -> get_transportInfo();
ATF::IIOP::TransportInfo_var iiopInfo =
ATF::IIOP::TransportInfo::_narrow(info);
char ipport[50] = "";
if(!CORBA::is_nil(iiopInfo))
{
ATF::IIOP::InetAddr_var remoteAddr = iiopInfo -> remote_addr();
CORBA::UShort remotePort = iiopInfo -> remote_port();
//cout << "Call from: "
// << (int)remoteAddr[0] << '.' << (int)remoteAddr[1] << '.'
// << (int)remoteAddr[2] << '.' << (int)remoteAddr[3]
// << ":" << remotePort << endl;
sprintf(ipport,"%d.%d.%d.%d:%d",(int)remoteAddr[0],
(int)remoteAddr[1],
(int)remoteAddr[2],
(int)remoteAddr[3],remotePort);
}
cout << "55" << endl;
//加入超时队列,如果上一个if语句失败,则传入空的ipport,最终将由超时释放
m_TimeThread -> addNode(ipport,impl);
// time_t now = time(0);
//// NEWRESULT(strClientID,ipport,now)
//// LEAVING("ResGet")
// cout << "66" << endl;
DataRecovery_ptr tempBJ = impl -> _this();
cout << "555" << endl;
return tempBJ;
}
char* IDRecoveryServer_impl::strErrorMessage(CORBA::Short nErrorId)
throw(CORBA::SystemException)
{
MultiSync;
/*switch (nErrorId)
{
case ERR_SQSERVER_COMMON:
m_ErrMsg = CORBA::string_dup("common error:can not know which type error.");
break;
case ERR_SQSERVER_GET_CONNPOOL:
m_ErrMsg = CORBA::string_dup("constructor the connectionpool error:parameter error or not enough memory.");
break;
case ERR_SQSERVER_GET_DIC:
m_ErrMsg = CORBA::string_dup("constructor the dictionary error:not enough memory.");
break;
//case ERR_SQSERVER_OPEN_DB:
// m_ErrMsg = CORBA::string_dup("constructor the dictionary error or constructor the connectionpool error");
// break;
case ERR_SQSERVER_NOTSUPPORTED_FUNCTION:
m_ErrMsg = CORBA::string_dup("the function is not supported now.");
break;
case ERR_SQSERVER_OPENFILEINDATAQUERY:
m_ErrMsg = CORBA::string_dup("cannot open file in DataQurey module.");
break;
case ERR_SQSERVER_GETRESULTLIST :
m_ErrMsg = CORBA::string_dup("can not get result list from timeoutthread: narrow() error");
break;
case ERR_SQSERVER_GET_CONN_FROM_POOL:
m_ErrMsg = CORBA::string_dup("can not get connection from connectionpool:input parameter error or connection is full");
break;
case ERR_SQSERVER_NEW_DQS:
m_ErrMsg = CORBA::string_dup("can not initialize the DataQuery object");
break;
case ERR_SQSERVER_NEW_THREAD:
m_ErrMsg = CORBA::string_dup("can not initialize thread");
break;
case ERR_SQSERVER_MTL_Exception:
m_ErrMsg = CORBA::string_dup("MTL thread exception");
break;
case ERR_SQSERVER_GET_DOMAIN:
m_ErrMsg = CORBA::string_dup("get domain from dictionary error");
break;
case ERR_SQSERVER_GET_DISNODE:
m_ErrMsg = CORBA::string_dup("get distribute node from dictionary error");
break;
case ERR_SQSERVER_GET_DIS_TYPE:
m_ErrMsg = CORBA::string_dup("get distribute type from dictionary error");
break;
case ERR_SQSERVER_LOAD_DIC_TABLE:
m_ErrMsg = CORBA::string_dup("read dictionary table from db error");
break;
case ERR_SQSERVER_DOMAIN_DISMATCH:
m_ErrMsg = CORBA::string_dup("two or more table in a statement that is not belong to the same domain");
break;
case ERR_SQSERVER_OCI:
m_ErrMsg = CORBA::string_dup("OCI common error");
break;
case NODATA:
m_ErrMsg = CORBA::string_dup("can not get more data from DB");
break;
case IS_EOF:
m_ErrMsg = CORBA::string_dup("the cursor is at the end of record list");
break;
case IS_BOF:
m_ErrMsg = CORBA::string_dup("the cursor is at the top of record list");
break;
case ERR_SQSERVER_OCIHandleAlloc:
m_ErrMsg = CORBA::string_dup("OCIHandleAlloc statement execute error");
break;
case ERR_SQSERVER_OCIStmtPrepare:
m_ErrMsg = CORBA::string_dup("OCIStmtPrepare statement execute error");
break;
case ERR_SQSERVER_OCIStmtExecute:
m_ErrMsg = CORBA::string_dup(m_OCIErrMsg);
break;
case ERR_SQSERVER_SYNTAX:
m_ErrMsg = CORBA::string_dup("query statement\'s syntax error");
break;
case ERR_SQSERVER_DDL:
m_ErrMsg = CORBA::string_dup("DDL statement\'s syntax error");
break;
case ERR_SQSERVER_CORBA:
m_ErrMsg = CORBA::string_dup("CORBA error");
break;
case ERR_SQSERVER_NOT_SUPPORT_SQL:
m_ErrMsg = CORBA::string_dup("This is a not support statement");
break;
case ERR_SQSERVER_MIN_MAX:
m_ErrMsg = CORBA::string_dup("Error in min and max function,could not comare value");
break;
case ERR_SQSERVER_GET_VALUE_BY_INDEX:
m_ErrMsg = CORBA::string_dup("can not get value by the index which is user given");
break;
case ERR_SQSERVER_CONFLICT:
m_ErrMsg = CORBA::string_dup("this SQL has some field conflict !");
break;
case ERR_SQSERVER_FIELD_NAME:
m_ErrMsg = CORBA::string_dup("no field in the table !");
break;
case ERR_SQSERVER_INVALID_RESULT:
m_ErrMsg = CORBA::string_dup("The IResult object is invalid");
break;
default:
m_ErrMsg = CORBA::string_dup("no such error code");
break;
}*/
return CORBA::string_dup(m_ErrMsg);
}
//
// Attribute declare nRunLevel
//
CORBA::Short IDRecoveryServer_impl::nRunLevel()
throw(CORBA::SystemException)
{
MultiSync;
return m_levelControl->nRunLevel();
}
void IDRecoveryServer_impl::nRunLevel(CORBA::Short rlevel)
throw(CORBA::SystemException)
{
MultiSync;
m_levelControl->nRunLevel(rlevel);
}
CORBA::Short IDRecoveryServer_impl::nTraceLevel()
throw(CORBA::SystemException)
{
MultiSync;
return m_levelControl->nTraceLevel();
}
void IDRecoveryServer_impl::nTraceLevel(CORBA::Short tlevel)
throw(CORBA::SystemException)
{
MultiSync;
m_levelControl->nTraceLevel(tlevel);
}
CORBA::ULongLong IDRecoveryServer_impl::lRequestCount()
throw(CORBA::SystemException)
{
MultiSync;
return m_requestCounter->lRequestCount();
}
void IDRecoveryServer_impl::vReset()
throw(CORBA::SystemException)
{
MultiSync;
m_requestCounter->vReset();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -