6ba1f17789
Summary: as subject. A new log is written to scribe via thrift client when a new db is opened and when there is a compaction. a new option var scribe_log_db_stats is added. Test Plan: manually checked using command "ptail -time 0 leveldb_deploy_stats" Reviewers: dhruba Differential Revision: https://reviews.facebook.net/D4659
594 lines
17 KiB
C++
594 lines
17 KiB
C++
/**
|
|
* Autogenerated by Thrift
|
|
*
|
|
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
|
|
* @generated
|
|
*/
|
|
#ifndef _Tleveldb_scribe_H
|
|
#define _Tleveldb_scribe_H
|
|
|
|
#include <TDispatchProcessor.h>
|
|
#include "scribe_types.h"
|
|
|
|
namespace Tleveldb {
|
|
|
|
class scribeIf {
|
|
public:
|
|
virtual ~scribeIf() {}
|
|
virtual ResultCode Log(const std::vector<LogEntry> & messages) = 0;
|
|
virtual void LogMulti(std::vector<ResultCode> & _return, const std::vector<LogEntry> & messages) = 0;
|
|
virtual ResultCode LogCompressedMsg(const std::string& compressedMessages) = 0;
|
|
};
|
|
|
|
class scribeIfFactory {
|
|
public:
|
|
typedef scribeIf Handler;
|
|
|
|
virtual ~scribeIfFactory() {}
|
|
|
|
virtual scribeIf* getHandler(::apache::thrift::server::TConnectionContext* ctx) = 0;
|
|
virtual void releaseHandler(scribeIf* handler) = 0;
|
|
};
|
|
|
|
class scribeIfSingletonFactory : virtual public scribeIfFactory {
|
|
public:
|
|
scribeIfSingletonFactory(const boost::shared_ptr<scribeIf>& iface) : iface_(iface) {}
|
|
virtual ~scribeIfSingletonFactory() {}
|
|
|
|
virtual scribeIf* getHandler(::apache::thrift::server::TConnectionContext*) {
|
|
return iface_.get();
|
|
}
|
|
virtual void releaseHandler(scribeIf* handler) {}
|
|
|
|
protected:
|
|
boost::shared_ptr<scribeIf> iface_;
|
|
};
|
|
|
|
class scribeNull : virtual public scribeIf {
|
|
public:
|
|
virtual ~scribeNull() {}
|
|
ResultCode Log(const std::vector<LogEntry> & /* messages */) {
|
|
ResultCode _return = (ResultCode)0;
|
|
return _return;
|
|
}
|
|
void LogMulti(std::vector<ResultCode> & /* _return */, const std::vector<LogEntry> & /* messages */) {
|
|
return;
|
|
}
|
|
ResultCode LogCompressedMsg(const std::string& /* compressedMessages */) {
|
|
ResultCode _return = (ResultCode)0;
|
|
return _return;
|
|
}
|
|
};
|
|
|
|
class scribe_Log_args {
|
|
public:
|
|
|
|
static const uint64_t _reflection_id = 5902265217339133004U;
|
|
static void _reflection_register(::apache::thrift::reflection::Schema&);
|
|
scribe_Log_args() {
|
|
}
|
|
|
|
scribe_Log_args(const scribe_Log_args&) = default;
|
|
scribe_Log_args& operator=(const scribe_Log_args&) = default;
|
|
scribe_Log_args(scribe_Log_args&&) = default;
|
|
scribe_Log_args& operator=(scribe_Log_args&&) = default;
|
|
|
|
void __clear() {
|
|
messages.clear();
|
|
__isset.__clear();
|
|
}
|
|
|
|
virtual ~scribe_Log_args() throw() {}
|
|
|
|
std::vector<LogEntry> messages;
|
|
|
|
struct __isset {
|
|
__isset() { __clear(); }
|
|
void __clear() {
|
|
messages = false;
|
|
}
|
|
bool messages;
|
|
} __isset;
|
|
|
|
bool operator == (const scribe_Log_args & rhs) const
|
|
{
|
|
if (!(this->messages == rhs.messages))
|
|
return false;
|
|
return true;
|
|
}
|
|
bool operator != (const scribe_Log_args &rhs) const {
|
|
return !(*this == rhs);
|
|
}
|
|
|
|
bool operator < (const scribe_Log_args & ) const;
|
|
|
|
uint32_t read(apache::thrift::protocol::TProtocol* iprot);
|
|
uint32_t write(apache::thrift::protocol::TProtocol* oprot) const;
|
|
|
|
};
|
|
|
|
class scribe_Log_pargs {
|
|
public:
|
|
|
|
static const uint64_t _reflection_id = 5555604010648986412U;
|
|
static void _reflection_register(::apache::thrift::reflection::Schema&);
|
|
|
|
virtual ~scribe_Log_pargs() throw() {}
|
|
|
|
const std::vector<LogEntry> * messages;
|
|
|
|
uint32_t write(apache::thrift::protocol::TProtocol* oprot) const;
|
|
|
|
};
|
|
|
|
class scribe_Log_result {
|
|
public:
|
|
|
|
static const uint64_t _reflection_id = 18205781396971565932U;
|
|
static void _reflection_register(::apache::thrift::reflection::Schema&);
|
|
scribe_Log_result() : success(static_cast<ResultCode>(0)) {
|
|
}
|
|
|
|
scribe_Log_result(const scribe_Log_result&) = default;
|
|
scribe_Log_result& operator=(const scribe_Log_result&) = default;
|
|
scribe_Log_result(scribe_Log_result&&) = default;
|
|
scribe_Log_result& operator=(scribe_Log_result&&) = default;
|
|
|
|
void __clear() {
|
|
success = static_cast<ResultCode>(0);
|
|
__isset.__clear();
|
|
}
|
|
|
|
virtual ~scribe_Log_result() throw() {}
|
|
|
|
ResultCode success;
|
|
|
|
struct __isset {
|
|
__isset() { __clear(); }
|
|
void __clear() {
|
|
success = false;
|
|
}
|
|
bool success;
|
|
} __isset;
|
|
|
|
bool operator == (const scribe_Log_result & rhs) const
|
|
{
|
|
if (!(this->success == rhs.success))
|
|
return false;
|
|
return true;
|
|
}
|
|
bool operator != (const scribe_Log_result &rhs) const {
|
|
return !(*this == rhs);
|
|
}
|
|
|
|
bool operator < (const scribe_Log_result & ) const;
|
|
|
|
uint32_t read(apache::thrift::protocol::TProtocol* iprot);
|
|
uint32_t write(apache::thrift::protocol::TProtocol* oprot) const;
|
|
|
|
};
|
|
|
|
class scribe_Log_presult {
|
|
public:
|
|
|
|
static const uint64_t _reflection_id = 12945584136895385836U;
|
|
static void _reflection_register(::apache::thrift::reflection::Schema&);
|
|
|
|
virtual ~scribe_Log_presult() throw() {}
|
|
|
|
ResultCode* success;
|
|
|
|
struct __isset {
|
|
__isset() { __clear(); }
|
|
void __clear() {
|
|
success = false;
|
|
}
|
|
bool success;
|
|
} __isset;
|
|
|
|
uint32_t read(apache::thrift::protocol::TProtocol* iprot);
|
|
|
|
};
|
|
|
|
class scribe_LogMulti_args {
|
|
public:
|
|
|
|
static const uint64_t _reflection_id = 7590876486278061516U;
|
|
static void _reflection_register(::apache::thrift::reflection::Schema&);
|
|
scribe_LogMulti_args() {
|
|
}
|
|
|
|
scribe_LogMulti_args(const scribe_LogMulti_args&) = default;
|
|
scribe_LogMulti_args& operator=(const scribe_LogMulti_args&) = default;
|
|
scribe_LogMulti_args(scribe_LogMulti_args&&) = default;
|
|
scribe_LogMulti_args& operator=(scribe_LogMulti_args&&) = default;
|
|
|
|
void __clear() {
|
|
messages.clear();
|
|
__isset.__clear();
|
|
}
|
|
|
|
virtual ~scribe_LogMulti_args() throw() {}
|
|
|
|
std::vector<LogEntry> messages;
|
|
|
|
struct __isset {
|
|
__isset() { __clear(); }
|
|
void __clear() {
|
|
messages = false;
|
|
}
|
|
bool messages;
|
|
} __isset;
|
|
|
|
bool operator == (const scribe_LogMulti_args & rhs) const
|
|
{
|
|
if (!(this->messages == rhs.messages))
|
|
return false;
|
|
return true;
|
|
}
|
|
bool operator != (const scribe_LogMulti_args &rhs) const {
|
|
return !(*this == rhs);
|
|
}
|
|
|
|
bool operator < (const scribe_LogMulti_args & ) const;
|
|
|
|
uint32_t read(apache::thrift::protocol::TProtocol* iprot);
|
|
uint32_t write(apache::thrift::protocol::TProtocol* oprot) const;
|
|
|
|
};
|
|
|
|
class scribe_LogMulti_pargs {
|
|
public:
|
|
|
|
static const uint64_t _reflection_id = 9124384543551655628U;
|
|
static void _reflection_register(::apache::thrift::reflection::Schema&);
|
|
|
|
virtual ~scribe_LogMulti_pargs() throw() {}
|
|
|
|
const std::vector<LogEntry> * messages;
|
|
|
|
uint32_t write(apache::thrift::protocol::TProtocol* oprot) const;
|
|
|
|
};
|
|
|
|
class scribe_LogMulti_result {
|
|
public:
|
|
|
|
static const uint64_t _reflection_id = 4828367046341273164U;
|
|
static void _reflection_register(::apache::thrift::reflection::Schema&);
|
|
scribe_LogMulti_result() {
|
|
}
|
|
|
|
scribe_LogMulti_result(const scribe_LogMulti_result&) = default;
|
|
scribe_LogMulti_result& operator=(const scribe_LogMulti_result&) = default;
|
|
scribe_LogMulti_result(scribe_LogMulti_result&&) = default;
|
|
scribe_LogMulti_result& operator=(scribe_LogMulti_result&&) = default;
|
|
|
|
void __clear() {
|
|
success.clear();
|
|
__isset.__clear();
|
|
}
|
|
|
|
virtual ~scribe_LogMulti_result() throw() {}
|
|
|
|
std::vector<ResultCode> success;
|
|
|
|
struct __isset {
|
|
__isset() { __clear(); }
|
|
void __clear() {
|
|
success = false;
|
|
}
|
|
bool success;
|
|
} __isset;
|
|
|
|
bool operator == (const scribe_LogMulti_result & rhs) const
|
|
{
|
|
if (!(this->success == rhs.success))
|
|
return false;
|
|
return true;
|
|
}
|
|
bool operator != (const scribe_LogMulti_result &rhs) const {
|
|
return !(*this == rhs);
|
|
}
|
|
|
|
bool operator < (const scribe_LogMulti_result & ) const;
|
|
|
|
uint32_t read(apache::thrift::protocol::TProtocol* iprot);
|
|
uint32_t write(apache::thrift::protocol::TProtocol* oprot) const;
|
|
|
|
};
|
|
|
|
class scribe_LogMulti_presult {
|
|
public:
|
|
|
|
static const uint64_t _reflection_id = 5642041737363050316U;
|
|
static void _reflection_register(::apache::thrift::reflection::Schema&);
|
|
|
|
virtual ~scribe_LogMulti_presult() throw() {}
|
|
|
|
std::vector<ResultCode> * success;
|
|
|
|
struct __isset {
|
|
__isset() { __clear(); }
|
|
void __clear() {
|
|
success = false;
|
|
}
|
|
bool success;
|
|
} __isset;
|
|
|
|
uint32_t read(apache::thrift::protocol::TProtocol* iprot);
|
|
|
|
};
|
|
|
|
class scribe_LogCompressedMsg_args {
|
|
public:
|
|
|
|
static const uint64_t _reflection_id = 12705053036625273964U;
|
|
static void _reflection_register(::apache::thrift::reflection::Schema&);
|
|
scribe_LogCompressedMsg_args() : compressedMessages("") {
|
|
}
|
|
|
|
scribe_LogCompressedMsg_args(const scribe_LogCompressedMsg_args&) = default;
|
|
scribe_LogCompressedMsg_args& operator=(const scribe_LogCompressedMsg_args&) = default;
|
|
scribe_LogCompressedMsg_args(scribe_LogCompressedMsg_args&&) = default;
|
|
scribe_LogCompressedMsg_args& operator=(scribe_LogCompressedMsg_args&&) = default;
|
|
|
|
void __clear() {
|
|
compressedMessages = "";
|
|
__isset.__clear();
|
|
}
|
|
|
|
virtual ~scribe_LogCompressedMsg_args() throw() {}
|
|
|
|
std::string compressedMessages;
|
|
|
|
struct __isset {
|
|
__isset() { __clear(); }
|
|
void __clear() {
|
|
compressedMessages = false;
|
|
}
|
|
bool compressedMessages;
|
|
} __isset;
|
|
|
|
bool operator == (const scribe_LogCompressedMsg_args & rhs) const
|
|
{
|
|
if (!(this->compressedMessages == rhs.compressedMessages))
|
|
return false;
|
|
return true;
|
|
}
|
|
bool operator != (const scribe_LogCompressedMsg_args &rhs) const {
|
|
return !(*this == rhs);
|
|
}
|
|
|
|
bool operator < (const scribe_LogCompressedMsg_args & ) const;
|
|
|
|
uint32_t read(apache::thrift::protocol::TProtocol* iprot);
|
|
uint32_t write(apache::thrift::protocol::TProtocol* oprot) const;
|
|
|
|
};
|
|
|
|
class scribe_LogCompressedMsg_pargs {
|
|
public:
|
|
|
|
static const uint64_t _reflection_id = 13645577436870531500U;
|
|
static void _reflection_register(::apache::thrift::reflection::Schema&);
|
|
|
|
virtual ~scribe_LogCompressedMsg_pargs() throw() {}
|
|
|
|
const std::string* compressedMessages;
|
|
|
|
uint32_t write(apache::thrift::protocol::TProtocol* oprot) const;
|
|
|
|
};
|
|
|
|
class scribe_LogCompressedMsg_result {
|
|
public:
|
|
|
|
static const uint64_t _reflection_id = 15026639991904524972U;
|
|
static void _reflection_register(::apache::thrift::reflection::Schema&);
|
|
scribe_LogCompressedMsg_result() : success(static_cast<ResultCode>(0)) {
|
|
}
|
|
|
|
scribe_LogCompressedMsg_result(const scribe_LogCompressedMsg_result&) = default;
|
|
scribe_LogCompressedMsg_result& operator=(const scribe_LogCompressedMsg_result&) = default;
|
|
scribe_LogCompressedMsg_result(scribe_LogCompressedMsg_result&&) = default;
|
|
scribe_LogCompressedMsg_result& operator=(scribe_LogCompressedMsg_result&&) = default;
|
|
|
|
void __clear() {
|
|
success = static_cast<ResultCode>(0);
|
|
__isset.__clear();
|
|
}
|
|
|
|
virtual ~scribe_LogCompressedMsg_result() throw() {}
|
|
|
|
ResultCode success;
|
|
|
|
struct __isset {
|
|
__isset() { __clear(); }
|
|
void __clear() {
|
|
success = false;
|
|
}
|
|
bool success;
|
|
} __isset;
|
|
|
|
bool operator == (const scribe_LogCompressedMsg_result & rhs) const
|
|
{
|
|
if (!(this->success == rhs.success))
|
|
return false;
|
|
return true;
|
|
}
|
|
bool operator != (const scribe_LogCompressedMsg_result &rhs) const {
|
|
return !(*this == rhs);
|
|
}
|
|
|
|
bool operator < (const scribe_LogCompressedMsg_result & ) const;
|
|
|
|
uint32_t read(apache::thrift::protocol::TProtocol* iprot);
|
|
uint32_t write(apache::thrift::protocol::TProtocol* oprot) const;
|
|
|
|
};
|
|
|
|
class scribe_LogCompressedMsg_presult {
|
|
public:
|
|
|
|
static const uint64_t _reflection_id = 5311776576442573772U;
|
|
static void _reflection_register(::apache::thrift::reflection::Schema&);
|
|
|
|
virtual ~scribe_LogCompressedMsg_presult() throw() {}
|
|
|
|
ResultCode* success;
|
|
|
|
struct __isset {
|
|
__isset() { __clear(); }
|
|
void __clear() {
|
|
success = false;
|
|
}
|
|
bool success;
|
|
} __isset;
|
|
|
|
uint32_t read(apache::thrift::protocol::TProtocol* iprot);
|
|
|
|
};
|
|
|
|
class scribeClient : virtual public scribeIf, virtual public apache::thrift::TClientBase {
|
|
public:
|
|
scribeClient(boost::shared_ptr<apache::thrift::protocol::TProtocol> prot) :
|
|
checkSeqid_(true),
|
|
nextSendSequenceId_(1),
|
|
nextRecvSequenceId_(1),
|
|
piprot_(prot),
|
|
poprot_(prot) {
|
|
iprot_ = prot.get();
|
|
oprot_ = prot.get();
|
|
}
|
|
scribeClient(boost::shared_ptr<apache::thrift::protocol::TProtocol> iprot, boost::shared_ptr<apache::thrift::protocol::TProtocol> oprot) :
|
|
checkSeqid_(true),
|
|
nextSendSequenceId_(1),
|
|
nextRecvSequenceId_(1),
|
|
piprot_(iprot),
|
|
poprot_(oprot) {
|
|
iprot_ = iprot.get();
|
|
oprot_ = oprot.get();
|
|
}
|
|
boost::shared_ptr<apache::thrift::protocol::TProtocol> getInputProtocol() {
|
|
return piprot_;
|
|
}
|
|
boost::shared_ptr<apache::thrift::protocol::TProtocol> getOutputProtocol() {
|
|
return poprot_;
|
|
}
|
|
ResultCode Log(const std::vector<LogEntry> & messages);
|
|
void send_Log(const std::vector<LogEntry> & messages);
|
|
ResultCode recv_Log();
|
|
void LogMulti(std::vector<ResultCode> & _return, const std::vector<LogEntry> & messages);
|
|
void send_LogMulti(const std::vector<LogEntry> & messages);
|
|
void recv_LogMulti(std::vector<ResultCode> & _return);
|
|
ResultCode LogCompressedMsg(const std::string& compressedMessages);
|
|
void send_LogCompressedMsg(const std::string& compressedMessages);
|
|
ResultCode recv_LogCompressedMsg();
|
|
|
|
/**
|
|
* Disable checking the seqid field in server responses.
|
|
*
|
|
* This should only be used with broken servers that return incorrect seqid values.
|
|
*/
|
|
void _disableSequenceIdChecks() {
|
|
checkSeqid_ = false;
|
|
}
|
|
|
|
protected:
|
|
bool checkSeqid_;
|
|
int32_t nextSendSequenceId_;
|
|
int32_t nextRecvSequenceId_;
|
|
int32_t getNextSendSequenceId();
|
|
int32_t getNextRecvSequenceId();
|
|
boost::shared_ptr<apache::thrift::protocol::TProtocol> piprot_;
|
|
boost::shared_ptr<apache::thrift::protocol::TProtocol> poprot_;
|
|
apache::thrift::protocol::TProtocol* iprot_;
|
|
apache::thrift::protocol::TProtocol* oprot_;
|
|
};
|
|
|
|
class scribeProcessor : public ::apache::thrift::TDispatchProcessor {
|
|
protected:
|
|
boost::shared_ptr<scribeIf> iface_;
|
|
virtual bool dispatchCall(apache::thrift::protocol::TProtocol* iprot, apache::thrift::protocol::TProtocol* oprot, const std::string& fname, int32_t seqid, apache::thrift::server::TConnectionContext* connectionContext);
|
|
private:
|
|
typedef void (scribeProcessor::*ProcessFunction)(int32_t, apache::thrift::protocol::TProtocol*, apache::thrift::protocol::TProtocol*, apache::thrift::server::TConnectionContext*);
|
|
typedef std::map<std::string, ProcessFunction> ProcessMap;
|
|
ProcessMap processMap_;
|
|
void process_Log(int32_t seqid, apache::thrift::protocol::TProtocol* iprot, apache::thrift::protocol::TProtocol* oprot, apache::thrift::server::TConnectionContext* connectionContext);
|
|
void process_LogMulti(int32_t seqid, apache::thrift::protocol::TProtocol* iprot, apache::thrift::protocol::TProtocol* oprot, apache::thrift::server::TConnectionContext* connectionContext);
|
|
void process_LogCompressedMsg(int32_t seqid, apache::thrift::protocol::TProtocol* iprot, apache::thrift::protocol::TProtocol* oprot, apache::thrift::server::TConnectionContext* connectionContext);
|
|
public:
|
|
scribeProcessor(boost::shared_ptr<scribeIf> iface) :
|
|
iface_(iface) {
|
|
processMap_["Log"] = &scribeProcessor::process_Log;
|
|
processMap_["LogMulti"] = &scribeProcessor::process_LogMulti;
|
|
processMap_["LogCompressedMsg"] = &scribeProcessor::process_LogCompressedMsg;
|
|
}
|
|
|
|
virtual ~scribeProcessor() {}
|
|
|
|
boost::shared_ptr<std::set<std::string> > getProcessFunctions() {
|
|
boost::shared_ptr<std::set<std::string> > rSet(new std::set<std::string>());
|
|
rSet->insert("scribe.Log");
|
|
rSet->insert("scribe.LogMulti");
|
|
rSet->insert("scribe.LogCompressedMsg");
|
|
return rSet;
|
|
}
|
|
};
|
|
|
|
class scribeProcessorFactory : public ::apache::thrift::TProcessorFactory {
|
|
public:
|
|
scribeProcessorFactory(const ::boost::shared_ptr< scribeIfFactory >& handlerFactory) :
|
|
handlerFactory_(handlerFactory) {}
|
|
|
|
::boost::shared_ptr< ::apache::thrift::TProcessor > getProcessor(::apache::thrift::server::TConnectionContext* ctx);
|
|
|
|
protected:
|
|
::boost::shared_ptr< scribeIfFactory > handlerFactory_;
|
|
};
|
|
|
|
class scribeMultiface : virtual public scribeIf {
|
|
public:
|
|
scribeMultiface(std::vector<boost::shared_ptr<scribeIf> >& ifaces) : ifaces_(ifaces) {
|
|
}
|
|
virtual ~scribeMultiface() {}
|
|
protected:
|
|
std::vector<boost::shared_ptr<scribeIf> > ifaces_;
|
|
scribeMultiface() {}
|
|
void add(boost::shared_ptr<scribeIf> iface) {
|
|
ifaces_.push_back(iface);
|
|
}
|
|
public:
|
|
ResultCode Log(const std::vector<LogEntry> & messages) {
|
|
uint32_t i;
|
|
uint32_t sz = ifaces_.size();
|
|
for (i = 0; i < sz - 1; ++i) {
|
|
ifaces_[i]->Log(messages);
|
|
}
|
|
return ifaces_[i]->Log(messages);
|
|
}
|
|
|
|
void LogMulti(std::vector<ResultCode> & _return, const std::vector<LogEntry> & messages) {
|
|
uint32_t i;
|
|
uint32_t sz = ifaces_.size();
|
|
for (i = 0; i < sz; ++i) {
|
|
ifaces_[i]->LogMulti(_return, messages);
|
|
}
|
|
}
|
|
|
|
ResultCode LogCompressedMsg(const std::string& compressedMessages) {
|
|
uint32_t i;
|
|
uint32_t sz = ifaces_.size();
|
|
for (i = 0; i < sz - 1; ++i) {
|
|
ifaces_[i]->LogCompressedMsg(compressedMessages);
|
|
}
|
|
return ifaces_[i]->LogCompressedMsg(compressedMessages);
|
|
}
|
|
|
|
};
|
|
|
|
} // namespace
|
|
|
|
#endif
|