1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-01 06:46:55 +03:00

Reformat all code to coding standard

This commit is contained in:
Andrew Hutchings
2017-10-26 17:18:17 +01:00
parent 4985f3456e
commit 01446d1e22
1296 changed files with 403852 additions and 353747 deletions

File diff suppressed because it is too large Load Diff

View File

@ -33,18 +33,18 @@
// ClearTableLockThread constructor
//------------------------------------------------------------------------------
ClearTableLockThread::ClearTableLockThread(
BRM::DBRM* brm,
messageqcpp::MessageQueueClient* clt,
const BRM::TableLockInfo& tInfo,
const std::string& tblName,
CLRTBLLOCK_MSGTYPE msgType,
ClearTableLockStatus* pStatus) :
fTableLockInfo(tInfo),
fBrm(brm),
fClt(clt),
fTblName(tblName),
fMsgType(msgType),
fStatus(pStatus)
BRM::DBRM* brm,
messageqcpp::MessageQueueClient* clt,
const BRM::TableLockInfo& tInfo,
const std::string& tblName,
CLRTBLLOCK_MSGTYPE msgType,
ClearTableLockStatus* pStatus) :
fTableLockInfo(tInfo),
fBrm(brm),
fClt(clt),
fTblName(tblName),
fMsgType(msgType),
fStatus(pStatus)
{
}
@ -54,21 +54,22 @@ ClearTableLockThread::ClearTableLockThread(
//------------------------------------------------------------------------------
void ClearTableLockThread::operator() ()
{
try {
if (fMsgType == CLRTBLLOCK_MSGTYPE_ROLLBACK)
executeRollback( );
else if (fMsgType == CLRTBLLOCK_MSGTYPE_CLEANUP)
executeFileCleanup( );
}
catch (std::exception& ex)
{
setStatus( 101, ex.what() );
}
catch (...)
{
std::string errMsg("Unknown exception.");
setStatus( 102, errMsg );
}
try
{
if (fMsgType == CLRTBLLOCK_MSGTYPE_ROLLBACK)
executeRollback( );
else if (fMsgType == CLRTBLLOCK_MSGTYPE_CLEANUP)
executeFileCleanup( );
}
catch (std::exception& ex)
{
setStatus( 101, ex.what() );
}
catch (...)
{
std::string errMsg("Unknown exception.");
setStatus( 102, errMsg );
}
}
//------------------------------------------------------------------------------
@ -76,72 +77,75 @@ void ClearTableLockThread::operator() ()
//------------------------------------------------------------------------------
void ClearTableLockThread::executeRollback( )
{
boost::shared_ptr<messageqcpp::ByteStream> bsIn;
messageqcpp::ByteStream bsOut;
boost::shared_ptr<messageqcpp::ByteStream> bsIn;
messageqcpp::ByteStream bsOut;
const std::string APPLNAME("cleartablelock command");
const std::string APPLNAME("cleartablelock command");
//--------------------------------------------------------------------------
// Send rollback msg to the writeengine server connected to fClt.
//--------------------------------------------------------------------------
{
boost::mutex::scoped_lock lk(fStdOutLock);
std::cout << "Sending rollback request to PM" <<
fStatus->moduleID() << "..." << std::endl;
//--------------------------------------------------------------------------
// Send rollback msg to the writeengine server connected to fClt.
//--------------------------------------------------------------------------
{
boost::mutex::scoped_lock lk(fStdOutLock);
std::cout << "Sending rollback request to PM" <<
fStatus->moduleID() << "..." << std::endl;
// std::cout << "cleartablelock rollback: tableLock-" <<fTableLockInfo.id<<
// ": oid-" << fTableLockInfo.tableOID <<
// "; name-" << fTblName <<
// "; app-" << APPLNAME << std::endl;
}
}
bsOut << (messageqcpp::ByteStream::byte)
WriteEngine::WE_CLT_SRV_CLEAR_TABLE_LOCK;
bsOut << fTableLockInfo.id;
bsOut << fTableLockInfo.tableOID;
bsOut << fTblName;
bsOut << APPLNAME;
fClt->write(bsOut);
bsOut << (messageqcpp::ByteStream::byte)
WriteEngine::WE_CLT_SRV_CLEAR_TABLE_LOCK;
bsOut << fTableLockInfo.id;
bsOut << fTableLockInfo.tableOID;
bsOut << fTblName;
bsOut << APPLNAME;
fClt->write(bsOut);
// Wait for the response, and check for any errors
std::string rollbackErrMsg;
bsIn.reset(new messageqcpp::ByteStream());
bsIn = fClt->read();
if (bsIn->length() == 0)
{
std::string errMsg("Network error, PM rollback");
setStatus( 103, errMsg );
// Wait for the response, and check for any errors
std::string rollbackErrMsg;
bsIn.reset(new messageqcpp::ByteStream());
bsIn = fClt->read();
boost::mutex::scoped_lock lk(fStdOutLock);
std::cout << "No response from PM" << fStatus->moduleID() << std::endl;
return;
}
else
{
messageqcpp::ByteStream::byte rc;
*bsIn >> rc;
*bsIn >> rollbackErrMsg;
if (bsIn->length() == 0)
{
std::string errMsg("Network error, PM rollback");
setStatus( 103, errMsg );
boost::mutex::scoped_lock lk(fStdOutLock);
std::cout << "No response from PM" << fStatus->moduleID() << std::endl;
return;
}
else
{
messageqcpp::ByteStream::byte rc;
*bsIn >> rc;
*bsIn >> rollbackErrMsg;
{
boost::mutex::scoped_lock lk(fStdOutLock);
if (rc == 0)
std::cout << "Successful rollback response from PM" <<
fStatus->moduleID() << std::endl;
else
std::cout << "Unsuccessful rollback response from PM" <<
fStatus->moduleID() << "; " << rollbackErrMsg << std::endl;
{
boost::mutex::scoped_lock lk(fStdOutLock);
if (rc == 0)
std::cout << "Successful rollback response from PM" <<
fStatus->moduleID() << std::endl;
else
std::cout << "Unsuccessful rollback response from PM" <<
fStatus->moduleID() << "; " << rollbackErrMsg << std::endl;
// std::cout << "cleartablelock rollback response; rc-" << (int)rc <<
// "; retMsg: <" << rollbackErrMsg << '>' << std::endl;
}
}
if (rc != 0)
{
std::string errMsg("PM rollback error: ");
errMsg += rollbackErrMsg;
setStatus( 104, errMsg );
return;
}
if (rc != 0)
{
std::string errMsg("PM rollback error: ");
errMsg += rollbackErrMsg;
setStatus( 104, errMsg );
return;
}
}
}
}
//------------------------------------------------------------------------------
@ -149,62 +153,65 @@ void ClearTableLockThread::executeRollback( )
//------------------------------------------------------------------------------
void ClearTableLockThread::executeFileCleanup( )
{
boost::shared_ptr<messageqcpp::ByteStream> bsIn;
messageqcpp::ByteStream bsOut;
boost::shared_ptr<messageqcpp::ByteStream> bsIn;
messageqcpp::ByteStream bsOut;
//--------------------------------------------------------------------------
// Send cleanup msg (to delete rb files) to the we server connected to fClt.
//--------------------------------------------------------------------------
{
boost::mutex::scoped_lock lk(fStdOutLock);
std::cout << "Sending cleanup request to PM" <<
fStatus->moduleID() << "..." << std::endl;
//--------------------------------------------------------------------------
// Send cleanup msg (to delete rb files) to the we server connected to fClt.
//--------------------------------------------------------------------------
{
boost::mutex::scoped_lock lk(fStdOutLock);
std::cout << "Sending cleanup request to PM" <<
fStatus->moduleID() << "..." << std::endl;
// std::cout << "cleartablelock cleanup: " <<
// "oid-" << fTableLockInfo.tableOID << std::endl;
}
}
bsOut << (messageqcpp::ByteStream::byte)
WriteEngine::WE_CLT_SRV_CLEAR_TABLE_LOCK_CLEANUP;
bsOut << fTableLockInfo.tableOID;
fClt->write(bsOut);
bsOut << (messageqcpp::ByteStream::byte)
WriteEngine::WE_CLT_SRV_CLEAR_TABLE_LOCK_CLEANUP;
bsOut << fTableLockInfo.tableOID;
fClt->write(bsOut);
// Wait for the response, and check for any errors
std::string fileDeleteErrMsg;
bsIn.reset(new messageqcpp::ByteStream());
bsIn = fClt->read();
if (bsIn->length() == 0)
{
std::string errMsg("Network error; PM rollback cleanup");
setStatus( 105, errMsg );
// Wait for the response, and check for any errors
std::string fileDeleteErrMsg;
bsIn.reset(new messageqcpp::ByteStream());
bsIn = fClt->read();
boost::mutex::scoped_lock lk(fStdOutLock);
std::cout << "No response from PM" << fStatus->moduleID() << std::endl;
return;
}
else
{
messageqcpp::ByteStream::byte rc;
*bsIn >> rc;
*bsIn >> fileDeleteErrMsg;
if (bsIn->length() == 0)
{
std::string errMsg("Network error; PM rollback cleanup");
setStatus( 105, errMsg );
boost::mutex::scoped_lock lk(fStdOutLock);
std::cout << "No response from PM" << fStatus->moduleID() << std::endl;
return;
}
else
{
messageqcpp::ByteStream::byte rc;
*bsIn >> rc;
*bsIn >> fileDeleteErrMsg;
{
boost::mutex::scoped_lock lk(fStdOutLock);
if (rc == 0)
std::cout << "Successful cleanup response from PM" <<
fStatus->moduleID() << std::endl;
else
std::cout << "Unsuccessful cleanup response from PM" <<
fStatus->moduleID() << "; " << fileDeleteErrMsg << std::endl;
{
boost::mutex::scoped_lock lk(fStdOutLock);
if (rc == 0)
std::cout << "Successful cleanup response from PM" <<
fStatus->moduleID() << std::endl;
else
std::cout << "Unsuccessful cleanup response from PM" <<
fStatus->moduleID() << "; " << fileDeleteErrMsg <<std::endl;
// std::cout << "cleartablelock cleanup response; rc-" << (int)rc <<
// "; retMsg: <" << fileDeleteErrMsg << '>' << std::endl;
}
}
if (rc != 0)
{
std::string errMsg("PM rollback cleanup error: ");
errMsg += fileDeleteErrMsg;
setStatus( 106, errMsg );
return;
}
}
if (rc != 0)
{
std::string errMsg("PM rollback cleanup error: ");
errMsg += fileDeleteErrMsg;
setStatus( 106, errMsg );
return;
}
}
}

View File

@ -35,38 +35,53 @@
class ClearTableLockStatus
{
public:
/** @brief ClearTableLockStatus constructor
* @param moduleID PM module ID relevant to this status object
*/
explicit ClearTableLockStatus(int moduleID) :
fModuleID(moduleID), fReturnStatus(0) { }
/** @brief ClearTableLockStatus constructor
* @param moduleID PM module ID relevant to this status object
*/
explicit ClearTableLockStatus(int moduleID) :
fModuleID(moduleID), fReturnStatus(0) { }
/** @brief Accessor to return status
*/
int retStatus() const { return fReturnStatus; }
/** @brief Accessor to return status
*/
int retStatus() const
{
return fReturnStatus;
}
/** @brief Accessor to return message
*/
const std::string& retMsg() const { return fReturnMsg; }
/** @brief Accessor to return message
*/
const std::string& retMsg() const
{
return fReturnMsg;
}
/** @brief Accessor to PM module ID
*/
int moduleID() const { return fModuleID; }
/** @brief Accessor to PM module ID
*/
int moduleID() const
{
return fModuleID;
}
/** @brief Mutator used to set the return status
* @param stat Status to be saved
*/
void retStatus(int stat) { fReturnStatus = stat; }
/** @brief Mutator used to set the return status
* @param stat Status to be saved
*/
void retStatus(int stat)
{
fReturnStatus = stat;
}
/** @brief Mutator used to set the return message
* @param msg Status message to be saved
*/
void retMsg (const std::string& msg) { fReturnMsg = msg;}
/** @brief Mutator used to set the return message
* @param msg Status message to be saved
*/
void retMsg (const std::string& msg)
{
fReturnMsg = msg;
}
private:
int fModuleID; // PM module ID associated with this request
int fReturnStatus; // Return status from the PM
std::string fReturnMsg; // Return message from the PM
int fModuleID; // PM module ID associated with this request
int fReturnStatus; // Return status from the PM
std::string fReturnMsg; // Return message from the PM
};
//------------------------------------------------------------------------------
@ -75,47 +90,48 @@ private:
class ClearTableLockThread
{
public:
enum CLRTBLLOCK_MSGTYPE {
CLRTBLLOCK_MSGTYPE_ROLLBACK = 1,
CLRTBLLOCK_MSGTYPE_CLEANUP = 2
};
enum CLRTBLLOCK_MSGTYPE
{
CLRTBLLOCK_MSGTYPE_ROLLBACK = 1,
CLRTBLLOCK_MSGTYPE_CLEANUP = 2
};
/** @brief ClearTableLockThread constructor
* @param brm Handle to DBRM
* @param clt MessageQueueClient used to communicate with PM
* @param tInfo Initial table lock information
* @param tblName Name of table referenced by tInfo
* @param msgType Message to process
* @param pStatus Status object used to track this bulkload rollback req
*/
ClearTableLockThread(
BRM::DBRM* brm,
messageqcpp::MessageQueueClient* clt,
const BRM::TableLockInfo& tInfo,
const std::string& tblName,
CLRTBLLOCK_MSGTYPE msgType,
ClearTableLockStatus* pStatus);
/** @brief ClearTableLockThread constructor
* @param brm Handle to DBRM
* @param clt MessageQueueClient used to communicate with PM
* @param tInfo Initial table lock information
* @param tblName Name of table referenced by tInfo
* @param msgType Message to process
* @param pStatus Status object used to track this bulkload rollback req
*/
ClearTableLockThread(
BRM::DBRM* brm,
messageqcpp::MessageQueueClient* clt,
const BRM::TableLockInfo& tInfo,
const std::string& tblName,
CLRTBLLOCK_MSGTYPE msgType,
ClearTableLockStatus* pStatus);
/** @brief Entry point for thread execution
*/
void operator() ();
/** @brief Entry point for thread execution
*/
void operator() ();
private:
void executeRollback ( );
void executeFileCleanup( );
void setStatus(int status, const std::string& msg)
{
fStatus->retStatus( status );
fStatus->retMsg ( msg );
}
void executeRollback ( );
void executeFileCleanup( );
void setStatus(int status, const std::string& msg)
{
fStatus->retStatus( status );
fStatus->retMsg ( msg );
}
BRM::TableLockInfo fTableLockInfo; // Initial table lock information
BRM::DBRM* fBrm; // Handle to DBRM
messageqcpp::MessageQueueClient* fClt;// Msg queue client to send/rcv msgs
std::string fTblName; // Name of relevant table
CLRTBLLOCK_MSGTYPE fMsgType; // Msg type to process
ClearTableLockStatus* fStatus; // Status object used to track request
static boost::mutex fStdOutLock; // Synchronize logging to stdout
BRM::TableLockInfo fTableLockInfo; // Initial table lock information
BRM::DBRM* fBrm; // Handle to DBRM
messageqcpp::MessageQueueClient* fClt;// Msg queue client to send/rcv msgs
std::string fTblName; // Name of relevant table
CLRTBLLOCK_MSGTYPE fMsgType; // Msg type to process
ClearTableLockStatus* fStatus; // Status object used to track request
static boost::mutex fStdOutLock; // Synchronize logging to stdout
};
#endif