1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-30 19:23:07 +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

View File

@ -33,26 +33,27 @@ namespace redistribute
void Redistribute::handleRedistributeMessage(ByteStream& bs, IOSocket& ios)
{
// consume the WES message id
ByteStream::byte wesMsgId;
bs >> wesMsgId;
// consume the WES message id
ByteStream::byte wesMsgId;
bs >> wesMsgId;
// peek at the message header
const RedistributeMsgHeader* h = (const RedistributeMsgHeader*) bs.buf();
switch (h->messageId)
{
case RED_CNTL_START:
case RED_CNTL_STATUS:
case RED_CNTL_STOP:
case RED_CNTL_CLEAR:
case RED_CNTL_RESP:
RedistributeControl::instance()->handleUIMsg(bs, ios);
break;
// peek at the message header
const RedistributeMsgHeader* h = (const RedistributeMsgHeader*) bs.buf();
default:
RedistributeControl::instance()->handleJobMsg(bs, ios);
break;
}
switch (h->messageId)
{
case RED_CNTL_START:
case RED_CNTL_STATUS:
case RED_CNTL_STOP:
case RED_CNTL_CLEAR:
case RED_CNTL_RESP:
RedistributeControl::instance()->handleUIMsg(bs, ios);
break;
default:
RedistributeControl::instance()->handleJobMsg(bs, ios);
break;
}
}

View File

@ -35,13 +35,13 @@ namespace redistribute
class Redistribute
{
public:
Redistribute();
~Redistribute() {};
public:
Redistribute();
~Redistribute() {};
static void handleRedistributeMessage(messageqcpp::ByteStream&, messageqcpp::IOSocket&);
static void handleRedistributeMessage(messageqcpp::ByteStream&, messageqcpp::IOSocket&);
private:
private:
};

File diff suppressed because it is too large Load Diff

View File

@ -57,72 +57,72 @@ namespace redistribute
class RedistributeControl
{
public:
~RedistributeControl();
public:
~RedistributeControl();
int handleUIMsg(messageqcpp::ByteStream&, messageqcpp::IOSocket&);
int handleJobMsg(messageqcpp::ByteStream&, messageqcpp::IOSocket&);
int handleUIMsg(messageqcpp::ByteStream&, messageqcpp::IOSocket&);
int handleJobMsg(messageqcpp::ByteStream&, messageqcpp::IOSocket&);
static RedistributeControl* instance();
static void destroyInstace();
static RedistributeControl* instance();
static void destroyInstace();
private:
int handleStartMsg(messageqcpp::ByteStream&, messageqcpp::IOSocket&);
int handleStatusMsg(messageqcpp::ByteStream&, messageqcpp::IOSocket&);
int handleStopMsg(messageqcpp::ByteStream&, messageqcpp::IOSocket&);
int handleClearMsg(messageqcpp::ByteStream&, messageqcpp::IOSocket&);
private:
int handleStartMsg(messageqcpp::ByteStream&, messageqcpp::IOSocket&);
int handleStatusMsg(messageqcpp::ByteStream&, messageqcpp::IOSocket&);
int handleStopMsg(messageqcpp::ByteStream&, messageqcpp::IOSocket&);
int handleClearMsg(messageqcpp::ByteStream&, messageqcpp::IOSocket&);
int handleStatusRpt(messageqcpp::ByteStream&, messageqcpp::IOSocket&);
int handleStatusRpt(messageqcpp::ByteStream&, messageqcpp::IOSocket&);
uint32_t getCurrentState();
bool getStartOptions(messageqcpp::ByteStream&);
uint32_t getCurrentState();
bool getStartOptions(messageqcpp::ByteStream&);
void setEntryCount(uint32_t);
void updateState(uint32_t);
void updateProgressInfo(uint32_t, time_t);
void setEntryCount(uint32_t);
void updateState(uint32_t);
void updateProgressInfo(uint32_t, time_t);
void logMessage(const std::string&);
void logMessage(const std::string&);
boost::mutex fSessionMutex;
boost::mutex fInfoFileMutex;
boost::mutex fSessionMutex;
boost::mutex fInfoFileMutex;
boost::scoped_ptr<boost::thread> fControlThread;
boost::scoped_ptr<boost::thread> fWorkThread;
boost::scoped_ptr<boost::thread> fControlThread;
boost::scoped_ptr<boost::thread> fWorkThread;
FILE* fInfoFilePtr;
FILE* fPlanFilePtr;
std::string fRedistributeDir;
std::string fInfoFilePath;
std::string fPlanFilePath;
std::string fUIResponse;
FILE* fInfoFilePtr;
FILE* fPlanFilePtr;
std::string fRedistributeDir;
std::string fInfoFilePath;
std::string fPlanFilePath;
std::string fUIResponse;
uint32_t fOptions;
std::vector<int> fSourceList;
std::vector<int> fDestinationList;
std::vector<RedistributePlanEntry> fRedistributePlan;
RedistributeInfo fRedistributeInfo;
uint32_t fOptions;
std::vector<int> fSourceList;
std::vector<int> fDestinationList;
std::vector<RedistributePlanEntry> fRedistributePlan;
RedistributeInfo fRedistributeInfo;
std::string fErrorMsg;
std::string fErrorMsg;
// for work threads, they don't have to create their own.
boost::shared_ptr<oam::Oam> fOam;
boost::shared_ptr<BRM::DBRM> fDbrm;
boost::shared_ptr<logging::Logger> fSysLogger;
// for work threads, they don't have to create their own.
boost::shared_ptr<oam::Oam> fOam;
boost::shared_ptr<BRM::DBRM> fDbrm;
boost::shared_ptr<logging::Logger> fSysLogger;
// singleton instance
static RedistributeControl* fInstance;
// singleton instance
static RedistributeControl* fInstance;
// private constructor
RedistributeControl();
// private constructor
RedistributeControl();
// disable copy constructor and assignment operator
// private without implementation
RedistributeControl(const RedistributeControl&);
RedistributeControl& operator=(const RedistributeControl&);
// disable copy constructor and assignment operator
// private without implementation
RedistributeControl(const RedistributeControl&);
RedistributeControl& operator=(const RedistributeControl&);
friend class RedistributeControlThread;
friend class RedistributeWorkerThread;
friend class RedistributeControlThread;
friend class RedistributeWorkerThread;
};

File diff suppressed because it is too large Load Diff

View File

@ -61,64 +61,68 @@ class RedistributeControl;
class RedistributeControlThread
{
public:
RedistributeControlThread(uint32_t act);
~RedistributeControlThread();
public:
RedistributeControlThread(uint32_t act);
~RedistributeControlThread();
int handleJobMsg(RedistributeMsgHeader&, messageqcpp::ByteStream&, messageqcpp::IOSocket&);
int handleJobMsg(RedistributeMsgHeader&, messageqcpp::ByteStream&, messageqcpp::IOSocket&);
void operator()();
void operator()();
// used by control to change status
static void setStopAction(bool);
// used by control to change status
static void setStopAction(bool);
private:
// struct for sort partitions
struct PartitionInfo
{
int32_t dbroot;
int32_t partition;
private:
// struct for sort partitions
struct PartitionInfo
{
int32_t dbroot;
int32_t partition;
PartitionInfo() : dbroot(0), partition(0) {}
PartitionInfo(int32_t d, int32_t p) : dbroot(d), partition(p) {}
PartitionInfo() : dbroot(0), partition(0) {}
PartitionInfo(int32_t d, int32_t p) : dbroot(d), partition(p) {}
bool operator < (const struct PartitionInfo& rhs) const
{ return ((dbroot < rhs.dbroot) || (dbroot == rhs.dbroot && partition < rhs.partition)); }
bool operator == (const struct PartitionInfo& rhs) const
{ return (dbroot == rhs.dbroot && partition == rhs.partition); }
bool operator < (const struct PartitionInfo& rhs) const
{
return ((dbroot < rhs.dbroot) || (dbroot == rhs.dbroot && partition < rhs.partition));
}
};
bool operator == (const struct PartitionInfo& rhs) const
{
return (dbroot == rhs.dbroot && partition == rhs.partition);
}
void doRedistribute();
void doStopAction();
};
int setup();
int makeRedistributePlan();
int executeRedistributePlan();
void doRedistribute();
void doStopAction();
int connectToWes(int);
void dumpPlanToFile(uint64_t, vector<PartitionInfo>&, int);
void displayPlan();
int setup();
int makeRedistributePlan();
int executeRedistributePlan();
uint32_t fAction;
oam::OamCache* fOamCache;
config::Config* fConfig;
boost::shared_ptr<messageqcpp::MessageQueueClient> fMsgQueueClient;
int connectToWes(int);
void dumpPlanToFile(uint64_t, vector<PartitionInfo>&, int);
void displayPlan();
std::set<int> fSourceSet;
std::set<int> fTargetSet;
std::set<int> fDbrootSet; // Union of fSourceSet and fTargetSet
int fMaxDbroot;
uint32_t fEntryCount;
std::string fErrorMsg;
int32_t fErrorCode;
uint32_t fAction;
oam::OamCache* fOamCache;
config::Config* fConfig;
boost::shared_ptr<messageqcpp::MessageQueueClient> fMsgQueueClient;
RedistributeControl* fControl;
std::set<int> fSourceSet;
std::set<int> fTargetSet;
std::set<int> fDbrootSet; // Union of fSourceSet and fTargetSet
int fMaxDbroot;
uint32_t fEntryCount;
std::string fErrorMsg;
int32_t fErrorCode;
static boost::mutex fActionMutex;
static volatile bool fStopAction;
static std::string fWesInUse;
RedistributeControl* fControl;
static boost::mutex fActionMutex;
static volatile bool fStopAction;
static std::string fWesInUse;
};

View File

@ -48,49 +48,50 @@ const uint32_t RED_TRANS_FAILED = 23;
// return code to shell or between redistribute entities
enum RED_ErrorCode {
RED_EC_OK,
enum RED_ErrorCode
{
RED_EC_OK,
// return code for util, for shell script to check exit status value is [0, 255]
RED_EC_HELP,
RED_EC_INVALID_OPTION,
RED_EC_EXTRA_OPERAND,
RED_EC_INVALID_DBROOTID,
RED_EC_GET_DBROOT1,
RED_EC_CONNECT_FAIL,
RED_EC_GET_DBROOT_EXCEPT,
RED_EC_NETWORK_FAIL,
RED_EC_PROTOCOL_ERROR,
RED_EC_NO_ARC_NAME,
RED_EC_ARC_NOT_EXIST,
RED_EC_READ_ARC_FAIL,
// return code for util, for shell script to check exit status value is [0, 255]
RED_EC_HELP,
RED_EC_INVALID_OPTION,
RED_EC_EXTRA_OPERAND,
RED_EC_INVALID_DBROOTID,
RED_EC_GET_DBROOT1,
RED_EC_CONNECT_FAIL,
RED_EC_GET_DBROOT_EXCEPT,
RED_EC_NETWORK_FAIL,
RED_EC_PROTOCOL_ERROR,
RED_EC_NO_ARC_NAME,
RED_EC_ARC_NOT_EXIST,
RED_EC_READ_ARC_FAIL,
// return code for control and workers
RED_EC_CNTL_SETUP_FAIL,
RED_EC_MAKEPLAN_FAIL,
RED_EC_EXECUTE_FAIL,
RED_EC_UPDATE_STATE,
RED_EC_USER_STOP,
// return code for control and workers
RED_EC_CNTL_SETUP_FAIL,
RED_EC_MAKEPLAN_FAIL,
RED_EC_EXECUTE_FAIL,
RED_EC_UPDATE_STATE,
RED_EC_USER_STOP,
RED_EC_WKR_SETUP_FAIL,
RED_EC_WKR_MSG_SHORT,
RED_EC_FILE_LIST_FAIL,
RED_EC_NO_TABLE_LOCK,
RED_EC_IDB_HARD_FAIL,
RED_EC_EXTENT_ERROR,
RED_EC_PART_EXIST_ON_TARGET,
RED_EC_OID_TO_FILENAME,
RED_EC_OPEN_FILE_FAIL,
RED_EC_FSEEK_FAIL,
RED_EC_FREAD_FAIL,
RED_EC_FWRITE_FAIL,
RED_EC_SIZE_NACK,
RED_EC_COPY_FILE_FAIL,
RED_EC_UPDATE_DBRM_FAIL,
RED_EC_BS_TOO_SHORT,
RED_EC_FILE_SIZE_NOT_MATCH,
RED_EC_UNKNOWN_DATA_MSG,
RED_EC_UNKNOWN_JOB_MSG,
RED_EC_WKR_SETUP_FAIL,
RED_EC_WKR_MSG_SHORT,
RED_EC_FILE_LIST_FAIL,
RED_EC_NO_TABLE_LOCK,
RED_EC_IDB_HARD_FAIL,
RED_EC_EXTENT_ERROR,
RED_EC_PART_EXIST_ON_TARGET,
RED_EC_OID_TO_FILENAME,
RED_EC_OPEN_FILE_FAIL,
RED_EC_FSEEK_FAIL,
RED_EC_FREAD_FAIL,
RED_EC_FWRITE_FAIL,
RED_EC_SIZE_NACK,
RED_EC_COPY_FILE_FAIL,
RED_EC_UPDATE_DBRM_FAIL,
RED_EC_BS_TOO_SHORT,
RED_EC_FILE_SIZE_NOT_MATCH,
RED_EC_UNKNOWN_DATA_MSG,
RED_EC_UNKNOWN_JOB_MSG,
};
@ -130,76 +131,76 @@ const size_t PRE_ALLOC_SIZE = 4 * 1024;
// redistribute message header
struct RedistributeMsgHeader
{
uint32_t destination;
uint32_t source;
uint32_t sequenceNum;
uint32_t messageId;
uint32_t destination;
uint32_t source;
uint32_t sequenceNum;
uint32_t messageId;
RedistributeMsgHeader(uint32_t d=0, uint32_t s=0, uint32_t n=0, uint32_t i=0) :
destination(d), source(s), sequenceNum(n), messageId(i) {};
RedistributeMsgHeader(uint32_t d = 0, uint32_t s = 0, uint32_t n = 0, uint32_t i = 0) :
destination(d), source(s), sequenceNum(n), messageId(i) {};
};
// redistribute data transfer control block
struct RedistributeDataControl
{
uint64_t oid;
uint16_t dbroot;
uint32_t partition;
uint16_t segment;
uint64_t size;
uint64_t oid;
uint16_t dbroot;
uint32_t partition;
uint16_t segment;
uint64_t size;
RedistributeDataControl(uint64_t o=0, uint16_t d=0, uint32_t p=0, uint16_t s=0, uint32_t z=0) :
oid(o), dbroot(d), partition(p), segment(s), size(z) {};
RedistributeDataControl(uint64_t o = 0, uint16_t d = 0, uint32_t p = 0, uint16_t s = 0, uint32_t z = 0) :
oid(o), dbroot(d), partition(p), segment(s), size(z) {};
};
// extent entry
struct RedistributeExtentEntry
{
int64_t oid;
int16_t dbroot;
int32_t partition;
int16_t segment;
int64_t lbid;
int64_t range;
int64_t oid;
int16_t dbroot;
int32_t partition;
int16_t segment;
int64_t lbid;
int64_t range;
RedistributeExtentEntry() :
oid(0), dbroot(0), partition(0), segment(0), lbid(0), range(0) {}
oid(0), dbroot(0), partition(0), segment(0), lbid(0), range(0) {}
};
// RedistributePlanEntry
struct RedistributePlanEntry
{
int64_t table;
int32_t source;
int32_t partition;
int32_t destination;
int32_t status;
time_t starttime;
time_t endtime;
int64_t table;
int32_t source;
int32_t partition;
int32_t destination;
int32_t status;
time_t starttime;
time_t endtime;
RedistributePlanEntry() :
table(0), source(0), partition(0), destination(0), status(0), starttime(0), endtime(0) {}
RedistributePlanEntry() :
table(0), source(0), partition(0), destination(0), status(0), starttime(0), endtime(0) {}
};
// RedistributeInfo
struct RedistributeInfo
{
uint64_t version;
uint64_t state;
uint64_t planned;
uint64_t success;
uint64_t skipped;
uint64_t failed;
time_t startTime;
time_t endTime;
uint64_t version;
uint64_t state;
uint64_t planned;
uint64_t success;
uint64_t skipped;
uint64_t failed;
time_t startTime;
time_t endTime;
RedistributeInfo() :
version(RED_VERSION_NUM), state(RED_STATE_UNDEF),
planned(0), success(0), skipped(0), failed(0),
startTime(0), endTime(0) {}
RedistributeInfo() :
version(RED_VERSION_NUM), state(RED_STATE_UNDEF),
planned(0), success(0), skipped(0), failed(0),
startTime(0), endTime(0) {}
};

File diff suppressed because it is too large Load Diff

View File

@ -69,85 +69,85 @@ namespace redistribute
class RedistributeWorkerThread
{
public:
RedistributeWorkerThread(messageqcpp::ByteStream& bs, messageqcpp::IOSocket& ios);
~RedistributeWorkerThread();
public:
RedistributeWorkerThread(messageqcpp::ByteStream& bs, messageqcpp::IOSocket& ios);
~RedistributeWorkerThread();
void operator()();
void operator()();
private:
private:
void handleRequest();
void handleStop();
void handleData();
void handleUnknowJobMsg();
void handleRequest();
void handleStop();
void handleData();
void handleUnknowJobMsg();
int setup();
int grabTableLock();
int buildEntryList();
int sendData();
int connectToWes(int);
int updateDbrm();
void confirmToPeer();
bool checkDataTransferAck(SBS&, size_t);
int setup();
int grabTableLock();
int buildEntryList();
int sendData();
int connectToWes(int);
int updateDbrm();
void confirmToPeer();
bool checkDataTransferAck(SBS&, size_t);
void sendResponse(uint32_t);
void sendResponse(uint32_t);
void doAbort();
void doAbort();
void handleDataInit();
void handleDataStart(messageqcpp::SBS&, size_t&);
void handleDataCont(messageqcpp::SBS&, size_t&);
void handleDataFinish(messageqcpp::SBS&, size_t&);
void handleDataCommit(messageqcpp::SBS&, size_t&);
void handleDataAbort(messageqcpp::SBS&, size_t&);
void handleUnknowDataMsg();
void handleDataInit();
void handleDataStart(messageqcpp::SBS&, size_t&);
void handleDataCont(messageqcpp::SBS&, size_t&);
void handleDataFinish(messageqcpp::SBS&, size_t&);
void handleDataCommit(messageqcpp::SBS&, size_t&);
void handleDataAbort(messageqcpp::SBS&, size_t&);
void handleUnknowDataMsg();
int buildFullHdfsPath( std::map<int,std::string>& rootToPathMap,
int64_t colOid,
int16_t dbRoot,
uint32_t partition,
int16_t segment,
std::string& fullFileName);
int buildFullHdfsPath( std::map<int, std::string>& rootToPathMap,
int64_t colOid,
int16_t dbRoot,
uint32_t partition,
int16_t segment,
std::string& fullFileName);
void closeFile(FILE*); // for tracing, may remove later.
void addToDirSet(const char*, bool);
void logMessage(const std::string&, int);
void closeFile(FILE*); // for tracing, may remove later.
void addToDirSet(const char*, bool);
void logMessage(const std::string&, int);
oam::OamCache* fOamCache;
config::Config* fConfig;
boost::shared_ptr<messageqcpp::MessageQueueClient> fMsgQueueClient;
oam::OamCache* fOamCache;
config::Config* fConfig;
boost::shared_ptr<messageqcpp::MessageQueueClient> fMsgQueueClient;
RedistributeMsgHeader fMsgHeader;
messageqcpp::ByteStream& fBs;
messageqcpp::IOSocket& fIOSocket;
RedistributePlanEntry fPlanEntry;
uint64_t fTableLockId;
int32_t fErrorCode;
std::string fErrorMsg;
std::pair<int, int> fMyId; // <dbroot, pmid>
std::pair<int, int> fPeerId; // <dbroot, pmid>
std::set<int16_t> fSegments;
std::vector<int64_t> fOids; // column oids
std::vector<BRM::BulkUpdateDBRootArg> fUpdateRtEntries; // for dbrm update
std::vector<BRM::BulkSetHWMArg> fUpdateHwmEntries; // for dbrm update
RedistributeMsgHeader fMsgHeader;
messageqcpp::ByteStream& fBs;
messageqcpp::IOSocket& fIOSocket;
RedistributePlanEntry fPlanEntry;
uint64_t fTableLockId;
int32_t fErrorCode;
std::string fErrorMsg;
std::pair<int, int> fMyId; // <dbroot, pmid>
std::pair<int, int> fPeerId; // <dbroot, pmid>
std::set<int16_t> fSegments;
std::vector<int64_t> fOids; // column oids
std::vector<BRM::BulkUpdateDBRootArg> fUpdateRtEntries; // for dbrm update
std::vector<BRM::BulkSetHWMArg> fUpdateHwmEntries; // for dbrm update
FILE* fNewFilePtr;
FILE* fOldFilePtr;
std::set<std::string> fNewDirSet;
std::set<std::string> fOldDirSet;
boost::shared_array<char> fWriteBuffer;
FILE* fNewFilePtr;
FILE* fOldFilePtr;
std::set<std::string> fNewDirSet;
std::set<std::string> fOldDirSet;
boost::shared_array<char> fWriteBuffer;
boost::shared_ptr<BRM::DBRM> fDbrm;
boost::shared_ptr<BRM::DBRM> fDbrm;
// for segment file # workaround
//uint64_t fSegPerRoot;
// for segment file # workaround
//uint64_t fSegPerRoot;
static boost::mutex fActionMutex;
static volatile bool fStopAction;
static volatile bool fCommitted;
static std::string fWesInUse;
static boost::mutex fActionMutex;
static volatile bool fStopAction;
static volatile bool fCommitted;
static std::string fWesInUse;
};
} // namespace