You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-06-13 16:01:32 +03:00
Reformat all code to coding standard
This commit is contained in:
@ -52,7 +52,8 @@ class MessageQTestSuite;
|
||||
#define EXPORT
|
||||
#endif
|
||||
|
||||
namespace messageqcpp {
|
||||
namespace messageqcpp
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief a message queue server
|
||||
@ -75,75 +76,75 @@ namespace messageqcpp {
|
||||
class MessageQueueServer
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief construct a server queue for thisEnd
|
||||
*
|
||||
* construct a server queue for thisEnd. Optionally specify a Config object to use.
|
||||
*/
|
||||
EXPORT explicit MessageQueueServer(const std::string& thisEnd, config::Config* config=0,
|
||||
size_t blocksize=ByteStream::BlockSize, int backlog=5, bool syncProto=true);
|
||||
|
||||
/**
|
||||
* @brief construct a server queue for thisEnd
|
||||
*
|
||||
* construct a server queue for thisEnd, specifying the name of a config file to use.
|
||||
*/
|
||||
EXPORT MessageQueueServer(const std::string& thisEnd, const std::string& config,
|
||||
size_t blocksize=ByteStream::BlockSize, int backlog=5, bool syncProto=true);
|
||||
|
||||
/**
|
||||
* @brief destructor
|
||||
*/
|
||||
EXPORT ~MessageQueueServer();
|
||||
//
|
||||
/**
|
||||
* @brief wait for a connection and return an IOSocket
|
||||
*
|
||||
* This method can be used by a main thread to wait for an incoming connection. The IOSocket
|
||||
* that is returned can be passed to a thread to handle the socket connection. The main thread
|
||||
* is then free to wait again for another connection. The IOSocket is already open and ready for
|
||||
* read() and/or write(). The caller is responsible for calling close() when it is done.
|
||||
*/
|
||||
EXPORT const IOSocket accept(const struct timespec* timeout=0) const;
|
||||
|
||||
/**
|
||||
* @brief get a mutable pointer to the client IOSocket
|
||||
*/
|
||||
inline IOSocket& clientSock() const;
|
||||
|
||||
/**
|
||||
* @brief set the sync proto
|
||||
*/
|
||||
EXPORT void syncProto(bool use);
|
||||
/**
|
||||
* @brief construct a server queue for thisEnd
|
||||
*
|
||||
* construct a server queue for thisEnd. Optionally specify a Config object to use.
|
||||
*/
|
||||
EXPORT explicit MessageQueueServer(const std::string& thisEnd, config::Config* config = 0,
|
||||
size_t blocksize = ByteStream::BlockSize, int backlog = 5, bool syncProto = true);
|
||||
|
||||
/**
|
||||
* allow test suite access to private data for OOB test
|
||||
*/
|
||||
friend class ::MessageQTestSuite;
|
||||
* @brief construct a server queue for thisEnd
|
||||
*
|
||||
* construct a server queue for thisEnd, specifying the name of a config file to use.
|
||||
*/
|
||||
EXPORT MessageQueueServer(const std::string& thisEnd, const std::string& config,
|
||||
size_t blocksize = ByteStream::BlockSize, int backlog = 5, bool syncProto = true);
|
||||
|
||||
/**
|
||||
* @brief destructor
|
||||
*/
|
||||
EXPORT ~MessageQueueServer();
|
||||
//
|
||||
/**
|
||||
* @brief wait for a connection and return an IOSocket
|
||||
*
|
||||
* This method can be used by a main thread to wait for an incoming connection. The IOSocket
|
||||
* that is returned can be passed to a thread to handle the socket connection. The main thread
|
||||
* is then free to wait again for another connection. The IOSocket is already open and ready for
|
||||
* read() and/or write(). The caller is responsible for calling close() when it is done.
|
||||
*/
|
||||
EXPORT const IOSocket accept(const struct timespec* timeout = 0) const;
|
||||
|
||||
/**
|
||||
* @brief get a mutable pointer to the client IOSocket
|
||||
*/
|
||||
inline IOSocket& clientSock() const;
|
||||
|
||||
/**
|
||||
* @brief set the sync proto
|
||||
*/
|
||||
EXPORT void syncProto(bool use);
|
||||
|
||||
/**
|
||||
* allow test suite access to private data for OOB test
|
||||
*/
|
||||
friend class ::MessageQTestSuite;
|
||||
|
||||
private:
|
||||
/** copy ctor
|
||||
*
|
||||
*/
|
||||
MessageQueueServer(const MessageQueueServer& rhs);
|
||||
/** copy ctor
|
||||
*
|
||||
*/
|
||||
MessageQueueServer(const MessageQueueServer& rhs);
|
||||
|
||||
/** assign op
|
||||
*
|
||||
*/
|
||||
MessageQueueServer& operator=(const MessageQueueServer& rhs);
|
||||
/** assign op
|
||||
*
|
||||
*/
|
||||
MessageQueueServer& operator=(const MessageQueueServer& rhs);
|
||||
|
||||
/** ctor helper
|
||||
*
|
||||
*/
|
||||
void setup(size_t blocksize, int backlog, bool syncProto);
|
||||
/** ctor helper
|
||||
*
|
||||
*/
|
||||
void setup(size_t blocksize, int backlog, bool syncProto);
|
||||
|
||||
std::string fThisEnd; /// the process name for this process
|
||||
struct sockaddr fServ_addr; /// the addr of the server (may be this process)
|
||||
config::Config* fConfig; /// config file has the IP addrs and port numbers
|
||||
mutable ServerSocket fListenSock; /// the socket the server listens on for new connections
|
||||
mutable IOSocket fClientSock; /// the socket connected to a client
|
||||
std::string fThisEnd; /// the process name for this process
|
||||
struct sockaddr fServ_addr; /// the addr of the server (may be this process)
|
||||
config::Config* fConfig; /// config file has the IP addrs and port numbers
|
||||
mutable ServerSocket fListenSock; /// the socket the server listens on for new connections
|
||||
mutable IOSocket fClientSock; /// the socket connected to a client
|
||||
|
||||
mutable logging::Logger fLogger;
|
||||
mutable logging::Logger fLogger;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -163,132 +164,167 @@ private:
|
||||
class MessageQueueClient
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief construct a queue to otherEnd
|
||||
*
|
||||
* construct a queue from this process to otherEnd. Optionally specify a Config object to use.
|
||||
*/
|
||||
EXPORT explicit MessageQueueClient(const std::string& otherEnd, config::Config* config=0, bool syncProto=true);
|
||||
/**
|
||||
* @brief construct a queue to otherEnd
|
||||
*
|
||||
* construct a queue from this process to otherEnd. Optionally specify a Config object to use.
|
||||
*/
|
||||
EXPORT explicit MessageQueueClient(const std::string& otherEnd, config::Config* config = 0, bool syncProto = true);
|
||||
|
||||
/**
|
||||
* @brief construct a queue to otherEnd
|
||||
*
|
||||
* construct a queue from this process to otherEnd, specifying the name of a config file to use.
|
||||
*/
|
||||
EXPORT explicit MessageQueueClient(const std::string& otherEnd, const std::string& config, bool syncProto=true);
|
||||
/**
|
||||
* @brief construct a queue to otherEnd
|
||||
*
|
||||
* construct a queue from this process to otherEnd, specifying the name of a config file to use.
|
||||
*/
|
||||
EXPORT explicit MessageQueueClient(const std::string& otherEnd, const std::string& config, bool syncProto = true);
|
||||
|
||||
/**
|
||||
* @brief construct a queue to otherEnd
|
||||
*
|
||||
* construct a queue from this process to otherEnd on the given IP and Port.
|
||||
*/
|
||||
EXPORT explicit MessageQueueClient(const std::string& ip, uint16_t port, bool syncProto=true);
|
||||
/**
|
||||
* @brief construct a queue to otherEnd
|
||||
*
|
||||
* construct a queue from this process to otherEnd on the given IP and Port.
|
||||
*/
|
||||
EXPORT explicit MessageQueueClient(const std::string& ip, uint16_t port, bool syncProto = true);
|
||||
|
||||
|
||||
/**
|
||||
* @brief destructor
|
||||
*
|
||||
* calls shutdown() method.
|
||||
*/
|
||||
EXPORT ~MessageQueueClient();
|
||||
/**
|
||||
* @brief destructor
|
||||
*
|
||||
* calls shutdown() method.
|
||||
*/
|
||||
EXPORT ~MessageQueueClient();
|
||||
|
||||
/**
|
||||
* @brief read a message from the queue
|
||||
*
|
||||
* wait for and return a message from otherEnd. The deafult timeout waits forever. Note that
|
||||
* eventhough struct timespec has nanosecond resolution, this method only has milisecond resolution.
|
||||
*/
|
||||
EXPORT const SBS read(const struct timespec* timeout=0, bool* isTimeOut = NULL, Stats *stats = NULL) const;
|
||||
/**
|
||||
* @brief read a message from the queue
|
||||
*
|
||||
* wait for and return a message from otherEnd. The deafult timeout waits forever. Note that
|
||||
* eventhough struct timespec has nanosecond resolution, this method only has milisecond resolution.
|
||||
*/
|
||||
EXPORT const SBS read(const struct timespec* timeout = 0, bool* isTimeOut = NULL, Stats* stats = NULL) const;
|
||||
|
||||
/**
|
||||
* @brief write a message to the queue
|
||||
*
|
||||
* write a message to otherEnd. If the socket is not open, the timeout parm (in ms) will be used
|
||||
* to establish a sync connection w/ the server
|
||||
*/
|
||||
EXPORT void write(const ByteStream& msg, const struct timespec* timeout=0, Stats *stats = NULL) const;
|
||||
/**
|
||||
* @brief write a message to the queue
|
||||
*
|
||||
* write a message to otherEnd. If the socket is not open, the timeout parm (in ms) will be used
|
||||
* to establish a sync connection w/ the server
|
||||
*/
|
||||
EXPORT void write(const ByteStream& msg, const struct timespec* timeout = 0, Stats* stats = NULL) const;
|
||||
|
||||
/**
|
||||
* @brief shutdown the connection to the server
|
||||
*
|
||||
* indicate to the class that the user is done with the socket
|
||||
* and the other class methods won't be used.
|
||||
*/
|
||||
EXPORT void shutdown();
|
||||
/**
|
||||
* @brief shutdown the connection to the server
|
||||
*
|
||||
* indicate to the class that the user is done with the socket
|
||||
* and the other class methods won't be used.
|
||||
*/
|
||||
EXPORT void shutdown();
|
||||
|
||||
/**
|
||||
* @brief connect to the server. Returns true if connection was successful.
|
||||
*
|
||||
* read() and write() automatically connect, but this method can be used to verify a server is listening
|
||||
* before that.
|
||||
*/
|
||||
EXPORT bool connect() const;
|
||||
|
||||
/**
|
||||
* @brief accessors and mutators
|
||||
*/
|
||||
EXPORT const sockaddr serv_addr() const { return fServ_addr; }
|
||||
EXPORT const std::string otherEnd() const { return fOtherEnd; }
|
||||
EXPORT const bool isAvailable() const { return fIsAvailable; }
|
||||
EXPORT void isAvailable (const bool isAvailable) { fIsAvailable = isAvailable; }
|
||||
EXPORT const std::string moduleName() const {return fModuleName;}
|
||||
EXPORT void moduleName(const std::string& moduleName) {fModuleName = moduleName;}
|
||||
/**
|
||||
* @brief connect to the server. Returns true if connection was successful.
|
||||
*
|
||||
* read() and write() automatically connect, but this method can be used to verify a server is listening
|
||||
* before that.
|
||||
*/
|
||||
EXPORT bool connect() const;
|
||||
|
||||
/**
|
||||
* @brief set the sync proto
|
||||
*/
|
||||
inline void syncProto(bool use);
|
||||
/**
|
||||
* @brief accessors and mutators
|
||||
*/
|
||||
EXPORT const sockaddr serv_addr() const
|
||||
{
|
||||
return fServ_addr;
|
||||
}
|
||||
EXPORT const std::string otherEnd() const
|
||||
{
|
||||
return fOtherEnd;
|
||||
}
|
||||
EXPORT const bool isAvailable() const
|
||||
{
|
||||
return fIsAvailable;
|
||||
}
|
||||
EXPORT void isAvailable (const bool isAvailable)
|
||||
{
|
||||
fIsAvailable = isAvailable;
|
||||
}
|
||||
EXPORT const std::string moduleName() const
|
||||
{
|
||||
return fModuleName;
|
||||
}
|
||||
EXPORT void moduleName(const std::string& moduleName)
|
||||
{
|
||||
fModuleName = moduleName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief return the address as a string
|
||||
*/
|
||||
inline const std::string addr2String() const;
|
||||
/**
|
||||
* @brief set the sync proto
|
||||
*/
|
||||
inline void syncProto(bool use);
|
||||
|
||||
/**
|
||||
* @brief compare the addresses of 2 MessageQueueClient
|
||||
*/
|
||||
inline const bool isSameAddr(const MessageQueueClient& rhs) const;
|
||||
/**
|
||||
* @brief return the address as a string
|
||||
*/
|
||||
inline const std::string addr2String() const;
|
||||
|
||||
bool isConnected() { return fClientSock.isConnected(); }
|
||||
|
||||
bool hasData() { return fClientSock.hasData(); }
|
||||
/*
|
||||
* allow test suite access to private data for OOB test
|
||||
*/
|
||||
friend class ::MessageQTestSuite;
|
||||
/**
|
||||
* @brief compare the addresses of 2 MessageQueueClient
|
||||
*/
|
||||
inline const bool isSameAddr(const MessageQueueClient& rhs) const;
|
||||
|
||||
bool isConnected()
|
||||
{
|
||||
return fClientSock.isConnected();
|
||||
}
|
||||
|
||||
bool hasData()
|
||||
{
|
||||
return fClientSock.hasData();
|
||||
}
|
||||
/*
|
||||
* allow test suite access to private data for OOB test
|
||||
*/
|
||||
friend class ::MessageQTestSuite;
|
||||
|
||||
private:
|
||||
/** copy ctor
|
||||
*
|
||||
*/
|
||||
MessageQueueClient(const MessageQueueClient& rhs);
|
||||
/** copy ctor
|
||||
*
|
||||
*/
|
||||
MessageQueueClient(const MessageQueueClient& rhs);
|
||||
|
||||
/** assign op
|
||||
*
|
||||
*/
|
||||
MessageQueueClient& operator=(const MessageQueueClient& rhs);
|
||||
/** assign op
|
||||
*
|
||||
*/
|
||||
MessageQueueClient& operator=(const MessageQueueClient& rhs);
|
||||
|
||||
/** ctor helper
|
||||
*
|
||||
*/
|
||||
void setup(bool syncProto);
|
||||
/** ctor helper
|
||||
*
|
||||
*/
|
||||
void setup(bool syncProto);
|
||||
|
||||
std::string fOtherEnd; /// the process name for this process
|
||||
struct sockaddr fServ_addr; /// the addr of the server (may be this process)
|
||||
config::Config* fConfig; /// config file has the IP addrs and port numbers
|
||||
mutable IOSocket fClientSock; /// the socket to communicate with the server
|
||||
mutable logging::Logger fLogger;
|
||||
bool fIsAvailable;
|
||||
std::string fModuleName;
|
||||
std::string fOtherEnd; /// the process name for this process
|
||||
struct sockaddr fServ_addr; /// the addr of the server (may be this process)
|
||||
config::Config* fConfig; /// config file has the IP addrs and port numbers
|
||||
mutable IOSocket fClientSock; /// the socket to communicate with the server
|
||||
mutable logging::Logger fLogger;
|
||||
bool fIsAvailable;
|
||||
std::string fModuleName;
|
||||
};
|
||||
|
||||
inline IOSocket& MessageQueueServer::clientSock() const { return fClientSock; }
|
||||
inline const std::string MessageQueueClient::addr2String() const { return fClientSock.addr2String(); }
|
||||
inline IOSocket& MessageQueueServer::clientSock() const
|
||||
{
|
||||
return fClientSock;
|
||||
}
|
||||
inline const std::string MessageQueueClient::addr2String() const
|
||||
{
|
||||
return fClientSock.addr2String();
|
||||
}
|
||||
inline const bool MessageQueueClient::isSameAddr(const MessageQueueClient& rhs) const
|
||||
{ return fClientSock.isSameAddr(&rhs.fClientSock); }
|
||||
inline void MessageQueueClient::syncProto(bool use) { fClientSock.syncProto(use); }
|
||||
{
|
||||
return fClientSock.isSameAddr(&rhs.fClientSock);
|
||||
}
|
||||
inline void MessageQueueClient::syncProto(bool use)
|
||||
{
|
||||
fClientSock.syncProto(use);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#undef EXPORT
|
||||
|
||||
|
Reference in New Issue
Block a user