mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-29 18:33:58 +00:00
Cleanup thrift header files.
Move thrift api from thrift/leveldb.thrift to thrift/if/leveldb.thrift Summary: Test Plan: Reviewers: CC: Task ID: # Blame Rev:
This commit is contained in:
parent
d11b637f34
commit
bfaa1bd26c
|
@ -1,5 +1,7 @@
|
|||
This directory has the thrift server code that exposes leveldb apis.
|
||||
|
||||
The thrift api is specified in thrift/if/leveldb.thrift.
|
||||
|
||||
The thrift header files are in ./thrift/lib. These are part of
|
||||
Apache Thrift code base and are needed for compilation of the leveldb
|
||||
thrift server. The thrift libraries are copied into ./thrift/libs.
|
||||
|
@ -16,3 +18,8 @@ enviroment variables appropriately:
|
|||
You can run the leveldb server unit tests by
|
||||
./leveldb_server_test
|
||||
|
||||
You can regenerate the thrift cpp files by doing the following
|
||||
|
||||
cd ./thrift
|
||||
thrift --gen cpp if/leveldb.thrift
|
||||
|
||||
|
|
|
@ -28,6 +28,19 @@ extern const std::map<int, const char*> _CompressionType_VALUES_TO_NAMES;
|
|||
|
||||
extern const std::map<const char*, int, apache::thrift::ltstr> _CompressionType_NAMES_TO_VALUES;
|
||||
|
||||
} // namespace
|
||||
namespace apache { namespace thrift {
|
||||
template<>
|
||||
inline constexpr ::Tleveldb::CompressionType TEnumTraits< ::Tleveldb::CompressionType>::min() {
|
||||
return ::Tleveldb::CompressionType::kNoCompression;
|
||||
}
|
||||
template<>
|
||||
inline constexpr ::Tleveldb::CompressionType TEnumTraits< ::Tleveldb::CompressionType>::max() {
|
||||
return ::Tleveldb::CompressionType::kSnappyCompression;
|
||||
}
|
||||
}} // apache:thrift
|
||||
|
||||
namespace Tleveldb {
|
||||
enum Code {
|
||||
kOk = 0,
|
||||
kNotFound = 1,
|
||||
|
@ -42,6 +55,19 @@ extern const std::map<int, const char*> _Code_VALUES_TO_NAMES;
|
|||
|
||||
extern const std::map<const char*, int, apache::thrift::ltstr> _Code_NAMES_TO_VALUES;
|
||||
|
||||
} // namespace
|
||||
namespace apache { namespace thrift {
|
||||
template<>
|
||||
inline constexpr ::Tleveldb::Code TEnumTraits< ::Tleveldb::Code>::min() {
|
||||
return ::Tleveldb::Code::kOk;
|
||||
}
|
||||
template<>
|
||||
inline constexpr ::Tleveldb::Code TEnumTraits< ::Tleveldb::Code>::max() {
|
||||
return ::Tleveldb::Code::kEnd;
|
||||
}
|
||||
}} // apache:thrift
|
||||
|
||||
namespace Tleveldb {
|
||||
enum IteratorType {
|
||||
seekToFirst = 0,
|
||||
seekToLast = 1,
|
||||
|
@ -52,6 +78,19 @@ extern const std::map<int, const char*> _IteratorType_VALUES_TO_NAMES;
|
|||
|
||||
extern const std::map<const char*, int, apache::thrift::ltstr> _IteratorType_NAMES_TO_VALUES;
|
||||
|
||||
} // namespace
|
||||
namespace apache { namespace thrift {
|
||||
template<>
|
||||
inline constexpr ::Tleveldb::IteratorType TEnumTraits< ::Tleveldb::IteratorType>::min() {
|
||||
return ::Tleveldb::IteratorType::seekToFirst;
|
||||
}
|
||||
template<>
|
||||
inline constexpr ::Tleveldb::IteratorType TEnumTraits< ::Tleveldb::IteratorType>::max() {
|
||||
return ::Tleveldb::IteratorType::seekToKey;
|
||||
}
|
||||
}} // apache:thrift
|
||||
|
||||
namespace Tleveldb {
|
||||
typedef std::string Text;
|
||||
|
||||
typedef std::string Bytes;
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
# TARGETS file for thrift/lib/cpp
|
||||
|
||||
cpp_library (
|
||||
name = "thrift_exception",
|
||||
srcs = [
|
||||
"TApplicationException.cpp",
|
||||
],
|
||||
external_deps = [
|
||||
('boost', None),
|
||||
],
|
||||
)
|
||||
|
||||
cpp_library (
|
||||
name = "thrift",
|
||||
srcs = [
|
||||
"VirtualProfiling.cpp",
|
||||
],
|
||||
deps = [
|
||||
"@/thrift/lib/cpp:thrift_base",
|
||||
"@/thrift/lib/cpp/concurrency",
|
||||
"@/thrift/lib/cpp/processor",
|
||||
"@/thrift/lib/cpp/protocol",
|
||||
"@/thrift/lib/cpp/server",
|
||||
"@/thrift/lib/cpp/transport",
|
||||
"@/thrift/lib/cpp:thrift_exception",
|
||||
]
|
||||
)
|
||||
|
||||
cpp_library (
|
||||
name = "thrift_base",
|
||||
srcs = [
|
||||
"Thrift.cpp",
|
||||
"EventHandlerBase.cpp",
|
||||
],
|
||||
external_deps = [
|
||||
('boost', None),
|
||||
],
|
||||
)
|
||||
|
||||
cpp_library(
|
||||
name = "reflection",
|
||||
srcs = [],
|
||||
deps = [
|
||||
"@/thrift/lib/thrift:reflection-cpp",
|
||||
],
|
||||
)
|
|
@ -77,6 +77,16 @@ struct TEnumTraits {
|
|||
* Note the use of helper function 'findValue(...)', below.
|
||||
*/
|
||||
static bool findValue(const char* name, T* outValue);
|
||||
|
||||
/**
|
||||
* Return the minimum value.
|
||||
*/
|
||||
static constexpr T min();
|
||||
|
||||
/**
|
||||
* Return the maximum value.
|
||||
*/
|
||||
static constexpr T max();
|
||||
private:
|
||||
/**
|
||||
* Helper method used by codegen implementation of findName, Supports
|
||||
|
@ -216,6 +226,12 @@ extern TOutput GlobalOutput;
|
|||
* Should never be instantiated, only caught.
|
||||
*/
|
||||
class TException : public std::exception {
|
||||
public:
|
||||
TException() {}
|
||||
TException(TException&&) {}
|
||||
TException(const TException&) {}
|
||||
TException& operator=(const TException&) { return *this; }
|
||||
TException& operator=(TException&&) { return *this; }
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,103 +0,0 @@
|
|||
# The base async library
|
||||
cpp_library(
|
||||
name = 'async_base',
|
||||
srcs = [
|
||||
'TAsyncServerSocket.cpp',
|
||||
'TAsyncSignalHandler.cpp',
|
||||
'TAsyncSocket.cpp',
|
||||
'TAsyncTimeout.cpp',
|
||||
'TBinaryAsyncChannel.cpp',
|
||||
'THeaderAsyncChannel.cpp',
|
||||
'TEventBase.cpp',
|
||||
'TEventBaseManager.cpp',
|
||||
'TEventHandler.cpp',
|
||||
'TFramedAsyncChannel.cpp',
|
||||
'TNotificationPipe.cpp',
|
||||
'TUnframedAsyncChannel.cpp',
|
||||
'THttpAsyncChannel.cpp',
|
||||
],
|
||||
deps = [
|
||||
'@/folly/experimental/io',
|
||||
'@/thrift/lib/cpp:thrift_base',
|
||||
'@/thrift/lib/cpp/transport',
|
||||
'@/thrift/lib/cpp/transport:header',
|
||||
'@/thrift/lib/cpp/protocol',
|
||||
'@/thrift/lib/cpp/server',
|
||||
'@/thrift/lib/cpp/util:httpparser',
|
||||
],
|
||||
external_deps = [ ('libevent', None) ],
|
||||
)
|
||||
|
||||
# TEventServer library (async name is used all over), now depends on ssl
|
||||
cpp_library(
|
||||
name = 'async',
|
||||
srcs = [
|
||||
'TEventConnection.cpp',
|
||||
'TEventServer.cpp',
|
||||
'TEventTask.cpp',
|
||||
'TEventWorker.cpp',
|
||||
],
|
||||
deps = [
|
||||
':async_ssl',
|
||||
],
|
||||
)
|
||||
|
||||
cpp_library (
|
||||
name = "async_ssl",
|
||||
srcs = [
|
||||
'TAsyncSSLServerSocket.cpp',
|
||||
'TAsyncSSLSocket.cpp',
|
||||
],
|
||||
deps = [
|
||||
":async_base",
|
||||
"@/thrift/lib/cpp/transport:transport_ssl",
|
||||
],
|
||||
external_deps = [ ("openssl", None, "ssl"),
|
||||
("openssl", None, "crypto") ],
|
||||
)
|
||||
|
||||
# This library is the same as async_ssl, except that it has the debug
|
||||
# logging level set to 4, whereas async_ssl has debug logging disabled.
|
||||
cpp_library (
|
||||
name = "async_ssl_log",
|
||||
srcs = [
|
||||
'TAsyncSSLServerSocket.cpp',
|
||||
'TAsyncSSLSocket.cpp',
|
||||
],
|
||||
deps = [
|
||||
":async_base",
|
||||
"@/thrift/lib/cpp/transport:transport_ssl",
|
||||
],
|
||||
external_deps = [ ("openssl", None, "ssl"),
|
||||
("openssl", None, "crypto") ],
|
||||
preprocessor_flags = [
|
||||
"-DT_GLOBAL_DEBUGGING_LEVEL=4"
|
||||
],
|
||||
output_subdir = "async_ssl_log",
|
||||
)
|
||||
|
||||
cpp_library(
|
||||
name = 'zlib',
|
||||
srcs = [
|
||||
'TZlibAsyncChannel.cpp',
|
||||
],
|
||||
deps = [
|
||||
':async',
|
||||
'@/thrift/lib/cpp/transport:zlib',
|
||||
],
|
||||
)
|
||||
|
||||
# Parts of the async library that depend on C++11 features.
|
||||
# This is separate from the main async library for now so that users who cannot
|
||||
# depend on C++11 features yet will still be able to use the bulk of the async
|
||||
# library.
|
||||
cpp_library(
|
||||
name = 'async_cxx11',
|
||||
srcs = [
|
||||
'TAsyncTimeoutSet.cpp',
|
||||
],
|
||||
deps = [
|
||||
':async_base',
|
||||
'@/folly',
|
||||
],
|
||||
)
|
|
@ -103,6 +103,12 @@ class TAsyncChannel {
|
|||
return sendAndRecvMessage(cob, cob, sendBuf, recvBuf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel pending callbacks. Use this when the channel is closing because the
|
||||
* server had been shut down.
|
||||
*/
|
||||
virtual void cancelCallbacks() = 0;
|
||||
|
||||
// TODO(dreiss): Make this nonvirtual when TFramedSocketAsyncChannel gets
|
||||
// renamed to TFramedAsyncChannel.
|
||||
virtual boost::shared_ptr<TAsyncTransport> getTransport() = 0;
|
||||
|
|
|
@ -120,6 +120,14 @@ class TAsyncSSLSocket : public TAsyncSocket {
|
|||
TAsyncSSLSocket* sslSocket_;
|
||||
};
|
||||
|
||||
/**
|
||||
* These are passed to the application via errno, so values have to be
|
||||
* outside the valid errno range
|
||||
*/
|
||||
enum SSLError {
|
||||
SSL_CLIENT_RENEGOTIATION_ATTEMPT = 0x8001
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a client TAsyncSSLSocket
|
||||
*/
|
||||
|
@ -128,6 +136,8 @@ class TAsyncSSLSocket : public TAsyncSocket {
|
|||
TAsyncSocket(evb),
|
||||
corked_(false),
|
||||
server_(false),
|
||||
handshakeComplete_(false),
|
||||
renegotiateAttempted_(false),
|
||||
sslState_(STATE_UNINIT),
|
||||
ctx_(ctx),
|
||||
handshakeCallback_(NULL),
|
||||
|
@ -176,7 +186,7 @@ class TAsyncSSLSocket : public TAsyncSocket {
|
|||
}
|
||||
|
||||
/**
|
||||
* TODO: implement support for SSL renegosiation.
|
||||
* TODO: implement support for SSL renegotiation.
|
||||
*
|
||||
* This involves proper handling of the SSL_ERROR_WANT_READ/WRITE
|
||||
* code as a result of SSL_write/read(), instead of returning an
|
||||
|
@ -293,6 +303,41 @@ class TAsyncSSLSocket : public TAsyncSocket {
|
|||
*/
|
||||
bool getSSLSessionReused() const;
|
||||
|
||||
/**
|
||||
* Get the negociated cipher name for this SSL connection.
|
||||
* Returns the cipher used or the constant value "NONE" when no SSL session
|
||||
* has been established.
|
||||
*/
|
||||
const char *getNegotiatedCipherName() const;
|
||||
|
||||
/**
|
||||
* Get the SSL version for this connection.
|
||||
* Possible return values are SSL2_VERSION, SSL3_VERSION, TLS1_VERSION,
|
||||
* with hexa representations 0x200, 0x300, 0x301,
|
||||
* or 0 if no SSL session has been established.
|
||||
*/
|
||||
int getSSLVersion() const;
|
||||
|
||||
/* Get the number of bytes read from the wire (including protocol
|
||||
* overhead). Returns 0 once the connection has been closed.
|
||||
*/
|
||||
unsigned long getBytesRead() const {
|
||||
if (ssl_ != NULL) {
|
||||
return BIO_number_read(SSL_get_rbio(ssl_));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Get the number of bytes written to the wire (including protocol
|
||||
* overhead). Returns 0 once the connection has been closed.
|
||||
*/
|
||||
unsigned long getBytesWritten() const {
|
||||
if (ssl_ != NULL) {
|
||||
return BIO_number_written(SSL_get_wbio(ssl_));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual void attachEventBase(TEventBase* eventBase) {
|
||||
TAsyncSocket::attachEventBase(eventBase);
|
||||
handshakeTimeout_.attachEventBase(eventBase);
|
||||
|
@ -339,10 +384,18 @@ class TAsyncSSLSocket : public TAsyncSocket {
|
|||
|
||||
void invokeHandshakeCallback();
|
||||
|
||||
static void sslInfoCallback(const SSL *ssl, int type, int val);
|
||||
|
||||
// Whether we've applied the TCP_CORK option to the socket
|
||||
bool corked_;
|
||||
// SSL related members.
|
||||
bool server_;
|
||||
// Used to prevent client-initiated renegotiation. Note that TAsyncSSLSocket
|
||||
// doesn't fully support renegotiation, so we could just fail all attempts
|
||||
// to enforce this. Once it is supported, we should make it an option
|
||||
// to disable client-initiated renegotiation.
|
||||
bool handshakeComplete_;
|
||||
bool renegotiateAttempted_;
|
||||
SSLStateEnum sslState_;
|
||||
boost::shared_ptr<transport::SSLContext> ctx_;
|
||||
// Callback for SSL_accept() or SSL_connect()
|
||||
|
|
|
@ -285,6 +285,32 @@ class TAsyncSocket : public TAsyncTransport,
|
|||
return sendTimeout_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the maximum number of reads to execute from the underlying
|
||||
* socket each time the TEventBase detects that new ingress data is
|
||||
* available. The default is unlimited, but callers can use this method
|
||||
* to limit the amount of data read from the socket per event loop
|
||||
* iteration.
|
||||
*
|
||||
* @param maxReads Maximum number of reads per data-available event;
|
||||
* a value of zero means unlimited.
|
||||
*/
|
||||
void setMaxReadsPerEvent(uint16_t maxReads) {
|
||||
maxReadsPerEvent_ = maxReads;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the maximum number of reads this object will execute from
|
||||
* the underlying socket each time the TEventBase detects that new
|
||||
* ingress data is available.
|
||||
*
|
||||
* @returns Maximum number of reads per data-available event; a value
|
||||
* of zero means unlimited.
|
||||
*/
|
||||
uint16_t getMaxReadsPerEvent() const {
|
||||
return maxReadsPerEvent_;
|
||||
}
|
||||
|
||||
// Methods inherited from TAsyncTransport
|
||||
// See the documentation in TAsyncTransport.h
|
||||
virtual void setReadCallback(ReadCallback* callback);
|
||||
|
@ -298,6 +324,7 @@ class TAsyncSocket : public TAsyncTransport,
|
|||
|
||||
virtual void close();
|
||||
virtual void closeNow();
|
||||
virtual void closeWithReset();
|
||||
virtual void shutdownWrite();
|
||||
virtual void shutdownWriteNow();
|
||||
|
||||
|
@ -333,6 +360,24 @@ class TAsyncSocket : public TAsyncTransport,
|
|||
*/
|
||||
int setNoDelay(bool noDelay);
|
||||
|
||||
/*
|
||||
* Forces ACKs to be sent immediately
|
||||
*
|
||||
* @return Returns 0 if the TCP_QUICKACK flag was successfully updated,
|
||||
* or a non-zero errno value on error.
|
||||
*/
|
||||
int setQuickAck(bool quickack);
|
||||
|
||||
/**
|
||||
* Set the send bufsize
|
||||
*/
|
||||
int setSendBufSize(size_t bufsize);
|
||||
|
||||
/**
|
||||
* Set the recv bufsize
|
||||
*/
|
||||
int setRecvBufSize(size_t bufsize);
|
||||
|
||||
/**
|
||||
* Generic API for reading a socket option.
|
||||
*
|
||||
|
@ -459,6 +504,19 @@ class TAsyncSocket : public TAsyncTransport,
|
|||
*/
|
||||
virtual ssize_t performRead(void* buf, size_t buflen);
|
||||
|
||||
/**
|
||||
* Populate an iovec array from an IOBuf and attempt to write it.
|
||||
*
|
||||
* @param callback Write completion/error callback.
|
||||
* @param vec Target iovec array; caller retains ownership.
|
||||
* @param count Number of IOBufs to write, beginning at start of buf.
|
||||
* @param buf Chain of iovecs.
|
||||
* @param cork Whether to delay the output until a subsequent
|
||||
* non-corked write.
|
||||
*/
|
||||
void writeChainImpl(WriteCallback* callback, iovec* vec,
|
||||
size_t count, std::unique_ptr<folly::IOBuf>&& buf, bool cork);
|
||||
|
||||
/**
|
||||
* Write as much data as possible to the socket without blocking,
|
||||
* and queue up any leftover data to send when the socket can
|
||||
|
@ -536,6 +594,7 @@ class TAsyncSocket : public TAsyncTransport,
|
|||
uint16_t eventFlags_; ///< TEventBase::HandlerFlags settings
|
||||
int fd_; ///< The socket file descriptor
|
||||
uint32_t sendTimeout_; ///< The send timeout, in milliseconds
|
||||
uint16_t maxReadsPerEvent_; ///< Max reads per event loop iteration
|
||||
TEventBase* eventBase_; ///< The TEventBase
|
||||
WriteTimeout writeTimeout_; ///< A timeout for connect and write
|
||||
IoHandler ioHandler_; ///< A TEventHandler to monitor the fd
|
||||
|
|
|
@ -286,6 +286,20 @@ class TAsyncTransport {
|
|||
*/
|
||||
virtual void closeNow() = 0;
|
||||
|
||||
/**
|
||||
* Reset the transport immediately.
|
||||
*
|
||||
* This closes the transport immediately, sending a reset to the remote peer
|
||||
* if possible to indicate abnormal shutdown.
|
||||
*
|
||||
* Note that not all subclasses implement this reset functionality: some
|
||||
* subclasses may treat reset() the same as closeNow(). Subclasses that use
|
||||
* TCP transports should terminate the connection with a TCP reset.
|
||||
*/
|
||||
virtual void closeWithReset() {
|
||||
closeNow();
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a half-shutdown of the write side of the transport.
|
||||
*
|
||||
|
|
|
@ -246,6 +246,11 @@ class TEventServer : public apache::thrift::server::TServer {
|
|||
*/
|
||||
uint32_t maxNumMsgsInPipe_;
|
||||
|
||||
/**
|
||||
* The max number of active connections for each worker
|
||||
*/
|
||||
int32_t maxNumActiveConnectionsPerWorker_;
|
||||
|
||||
/**
|
||||
* The transport type to use
|
||||
*/
|
||||
|
@ -320,6 +325,7 @@ class TEventServer : public apache::thrift::server::TServer {
|
|||
queuingMode_(false),
|
||||
acceptRateAdjustSpeed_(0),
|
||||
maxNumMsgsInPipe_(T_MAX_NUM_MESSAGES_IN_PIPE),
|
||||
maxNumActiveConnectionsPerWorker_(0),
|
||||
transportType_(T_ASYNC_DEFAULT_TRANSPORT_TYPE) {
|
||||
processor->setAsyncServer(this);
|
||||
}
|
||||
|
@ -360,6 +366,7 @@ class TEventServer : public apache::thrift::server::TServer {
|
|||
queuingMode_(false),
|
||||
acceptRateAdjustSpeed_(0),
|
||||
maxNumMsgsInPipe_(T_MAX_NUM_MESSAGES_IN_PIPE),
|
||||
maxNumActiveConnectionsPerWorker_(0),
|
||||
transportType_(T_ASYNC_DEFAULT_TRANSPORT_TYPE) {
|
||||
processor->setAsyncServer(this);
|
||||
|
||||
|
@ -407,6 +414,7 @@ class TEventServer : public apache::thrift::server::TServer {
|
|||
queuingMode_(false),
|
||||
acceptRateAdjustSpeed_(0),
|
||||
maxNumMsgsInPipe_(T_MAX_NUM_MESSAGES_IN_PIPE),
|
||||
maxNumActiveConnectionsPerWorker_(0),
|
||||
transportType_(T_ASYNC_DEFAULT_TRANSPORT_TYPE) {
|
||||
processor->setAsyncServer(this);
|
||||
|
||||
|
@ -452,6 +460,7 @@ class TEventServer : public apache::thrift::server::TServer {
|
|||
queuingMode_(false),
|
||||
acceptRateAdjustSpeed_(0),
|
||||
maxNumMsgsInPipe_(T_MAX_NUM_MESSAGES_IN_PIPE),
|
||||
maxNumActiveConnectionsPerWorker_(0),
|
||||
transportType_(T_ASYNC_DEFAULT_TRANSPORT_TYPE) {
|
||||
processor->setAsyncServer(this);
|
||||
|
||||
|
@ -498,6 +507,7 @@ class TEventServer : public apache::thrift::server::TServer {
|
|||
queuingMode_(true),
|
||||
acceptRateAdjustSpeed_(0),
|
||||
maxNumMsgsInPipe_(T_MAX_NUM_MESSAGES_IN_PIPE),
|
||||
maxNumActiveConnectionsPerWorker_(0),
|
||||
transportType_(T_ASYNC_DEFAULT_TRANSPORT_TYPE) {
|
||||
setProtocolFactory(protocolFactory);
|
||||
setThreadManager(threadManager);
|
||||
|
@ -542,6 +552,7 @@ class TEventServer : public apache::thrift::server::TServer {
|
|||
queuingMode_(true),
|
||||
acceptRateAdjustSpeed_(0),
|
||||
maxNumMsgsInPipe_(T_MAX_NUM_MESSAGES_IN_PIPE),
|
||||
maxNumActiveConnectionsPerWorker_(0),
|
||||
transportType_(T_ASYNC_DEFAULT_TRANSPORT_TYPE) {
|
||||
setDuplexProtocolFactory(duplexProtocolFactory);
|
||||
setThreadManager(threadManager);
|
||||
|
@ -671,6 +682,21 @@ class TEventServer : public apache::thrift::server::TServer {
|
|||
maxNumMsgsInPipe_ = num;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the maxmum number of active connections each TAsyncWorker can have
|
||||
*/
|
||||
int32_t getMaxNumActiveConnectionsPerWorker() const {
|
||||
return maxNumActiveConnectionsPerWorker_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the maxmum number of active connections each TAsyncWorker can have.
|
||||
* Zero means unlimited
|
||||
*/
|
||||
void setMaxNumActiveConnectionsPerWorker(int32_t num) {
|
||||
maxNumActiveConnectionsPerWorker_ = num;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the speed of adjusting connection accept rate.
|
||||
*/
|
||||
|
|
|
@ -129,6 +129,9 @@ class TEventWorker :
|
|||
*/
|
||||
ConnectionMap activeConnectionMap_;
|
||||
|
||||
// Max number of active connections
|
||||
int32_t maxNumActiveConnections_;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
|
@ -156,7 +159,8 @@ class TEventWorker :
|
|||
server_(server),
|
||||
eventBase_(),
|
||||
workerID_(workerID),
|
||||
transportType_(TEventServer::FRAMED) {
|
||||
transportType_(TEventServer::FRAMED),
|
||||
maxNumActiveConnections_(0) {
|
||||
|
||||
setDuplexProtocolFactory(protocolFactory);
|
||||
transportType_ = server->getTransportType();
|
||||
|
@ -174,7 +178,7 @@ class TEventWorker :
|
|||
* of freeing up memory, so nothing to be done here but release the
|
||||
* connection stack.
|
||||
*/
|
||||
virtual ~TEventWorker();
|
||||
virtual ~TEventWorker();
|
||||
|
||||
/**
|
||||
* Get my TAsyncProcessorFactory object.
|
||||
|
@ -212,6 +216,14 @@ class TEventWorker :
|
|||
return workerID_;
|
||||
}
|
||||
|
||||
void setMaxNumActiveConnections(int32_t numActiveConnections) {
|
||||
maxNumActiveConnections_ = numActiveConnections;
|
||||
}
|
||||
|
||||
int32_t getMaxNumActiveConnections() const {
|
||||
return maxNumActiveConnections_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispose of a TEventConnection object.
|
||||
* Will add to a pool of these objects or destroy as necessary.
|
||||
|
|
|
@ -175,7 +175,7 @@ class TNotificationQueue {
|
|||
FdType fdType = FdType::EVENTFD)
|
||||
: spinlock_(),
|
||||
eventfd_(-1),
|
||||
pipeFds_({-1, -1}),
|
||||
pipeFds_{-1, -1},
|
||||
advisoryMaxQueueSize_(maxSize),
|
||||
queue_() {
|
||||
if (fdType == FdType::EVENTFD) {
|
||||
|
|
|
@ -194,7 +194,8 @@ class TStreamAsyncChannel : public TAsyncEventChannel,
|
|||
protected TAsyncTransport::WriteCallback,
|
||||
protected TAsyncTimeout {
|
||||
public:
|
||||
TStreamAsyncChannel(const boost::shared_ptr<TAsyncTransport>& transport);
|
||||
explicit TStreamAsyncChannel(
|
||||
const boost::shared_ptr<TAsyncTransport>& transport);
|
||||
|
||||
/**
|
||||
* Helper function to create a shared_ptr<TStreamAsyncChannel>.
|
||||
|
@ -328,6 +329,15 @@ class TStreamAsyncChannel : public TAsyncEventChannel,
|
|||
return recvTimeout_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel pending callbacks. Use this when the channel is closing because the
|
||||
* server had been shut down.
|
||||
*/
|
||||
virtual void cancelCallbacks() {
|
||||
readCallback_ = NULL;
|
||||
readErrorCallback_ = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the TAsyncTransport used by this channel.
|
||||
*/
|
||||
|
@ -407,6 +417,11 @@ class TStreamAsyncChannel : public TAsyncEventChannel,
|
|||
return req;
|
||||
}
|
||||
|
||||
void clearCallbacks() {
|
||||
readCallback_ = NULL;
|
||||
readErrorCallback_ = NULL;
|
||||
}
|
||||
|
||||
void failAllReads();
|
||||
|
||||
boost::shared_ptr<TAsyncTransport> transport_;
|
||||
|
|
|
@ -26,7 +26,8 @@ namespace apache { namespace thrift { namespace async {
|
|||
|
||||
class TZlibAsyncChannel : public TAsyncEventChannel {
|
||||
public:
|
||||
TZlibAsyncChannel(const boost::shared_ptr<TAsyncEventChannel>& channel);
|
||||
explicit TZlibAsyncChannel(
|
||||
const boost::shared_ptr<TAsyncEventChannel>& channel);
|
||||
|
||||
/**
|
||||
* Helper function to create a shared_ptr<TZlibAsyncChannel>.
|
||||
|
@ -85,6 +86,11 @@ class TZlibAsyncChannel : public TAsyncEventChannel {
|
|||
channel_->setRecvTimeout(milliseconds);
|
||||
}
|
||||
|
||||
virtual void cancelCallbacks() {
|
||||
sendRequest_.cancelCallbacks();
|
||||
recvRequest_.cancelCallbacks();
|
||||
}
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Protected destructor.
|
||||
|
@ -109,6 +115,11 @@ class TZlibAsyncChannel : public TAsyncEventChannel {
|
|||
|
||||
void send(TAsyncEventChannel* channel);
|
||||
|
||||
void cancelCallbacks() {
|
||||
callback_ = NULL;
|
||||
errorCallback_ = NULL;
|
||||
}
|
||||
|
||||
private:
|
||||
void invokeCallback(VoidCallback callback);
|
||||
void sendSuccess();
|
||||
|
@ -137,6 +148,11 @@ class TZlibAsyncChannel : public TAsyncEventChannel {
|
|||
|
||||
void recv(TAsyncEventChannel* channel);
|
||||
|
||||
void cancelCallbacks() {
|
||||
callback_ = NULL;
|
||||
errorCallback_ = NULL;
|
||||
}
|
||||
|
||||
private:
|
||||
void invokeCallback(VoidCallback callback);
|
||||
void recvSuccess();
|
||||
|
|
|
@ -68,27 +68,37 @@ class PosixThreadFactory : public ThreadFactory {
|
|||
DECREMENT = 8
|
||||
};
|
||||
|
||||
static const POLICY kDefaultPolicy = ROUND_ROBIN;
|
||||
static const PRIORITY kDefaultPriority = NORMAL;
|
||||
static const int kDefaultStackSizeMB = 1;
|
||||
|
||||
/**
|
||||
* Posix thread (pthread) factory. All threads created by a factory are reference-counted
|
||||
* via boost::shared_ptr and boost::weak_ptr. The factory guarantees that threads and
|
||||
* the Runnable tasks they host will be properly cleaned up once the last strong reference
|
||||
* to both is given up.
|
||||
* Posix thread (pthread) factory. All threads created by a factory are
|
||||
* reference-counted via boost::shared_ptr and boost::weak_ptr. The factory
|
||||
* guarantees that threads and the Runnable tasks they host will be properly
|
||||
* cleaned up once the last strong reference to both is given up.
|
||||
*
|
||||
* Threads are created with the specified policy, priority, stack-size and detachable-mode
|
||||
* detached means the thread is free-running and will release all system resources the
|
||||
* when it completes. A detachable thread is not joinable. The join method
|
||||
* of a detachable thread will return immediately with no error.
|
||||
* Threads are created with the specified policy, priority, stack-size and
|
||||
* detachable-mode detached means the thread is free-running and will release
|
||||
* all system resources the when it completes. A detachable thread is not
|
||||
* joinable. The join method of a detachable thread will return immediately
|
||||
* with no error.
|
||||
*
|
||||
* By default threads are not joinable.
|
||||
*/
|
||||
|
||||
explicit PosixThreadFactory(POLICY policy=ROUND_ROBIN,
|
||||
PRIORITY priority=NORMAL,
|
||||
int stackSize=1,
|
||||
explicit PosixThreadFactory(POLICY policy=kDefaultPolicy,
|
||||
PRIORITY priority=kDefaultPriority,
|
||||
int stackSize=kDefaultStackSizeMB,
|
||||
bool detached=true);
|
||||
|
||||
explicit PosixThreadFactory(DetachState detached);
|
||||
|
||||
// From ThreadFactory;
|
||||
boost::shared_ptr<Thread> newThread(boost::shared_ptr<Runnable> runnable) const;
|
||||
boost::shared_ptr<Thread> newThread(
|
||||
const boost::shared_ptr<Runnable>& runnable) const;
|
||||
boost::shared_ptr<Thread> newThread(
|
||||
const boost::shared_ptr<Runnable>& runnable,
|
||||
DetachState detachState) const;
|
||||
|
||||
// From ThreadFactory;
|
||||
Thread::id_t getCurrentThreadId() const;
|
||||
|
@ -121,6 +131,7 @@ class PosixThreadFactory : public ThreadFactory {
|
|||
* Sets detached mode of threads
|
||||
*/
|
||||
virtual void setDetached(bool detached);
|
||||
virtual void setDetached(DetachState detached);
|
||||
|
||||
/**
|
||||
* Gets current detached mode
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
# TARGETS file for thrift/lib/cpp/concurrency
|
||||
|
||||
cpp_library (
|
||||
name = "concurrency",
|
||||
srcs = [
|
||||
"Util.cpp",
|
||||
"Monitor.cpp",
|
||||
"Mutex.cpp",
|
||||
"PosixThreadFactory.cpp",
|
||||
"ThreadManager.cpp",
|
||||
"TimerManager.cpp"
|
||||
],
|
||||
deps = [ '@/common/base:profiler',
|
||||
'@/thrift/lib/cpp:thrift_base' ],
|
||||
)
|
||||
|
||||
|
|
@ -110,8 +110,18 @@ class Thread {
|
|||
class ThreadFactory {
|
||||
|
||||
public:
|
||||
enum DetachState {
|
||||
ATTACHED,
|
||||
DETACHED
|
||||
};
|
||||
|
||||
virtual ~ThreadFactory() {}
|
||||
virtual boost::shared_ptr<Thread> newThread(boost::shared_ptr<Runnable> runnable) const = 0;
|
||||
virtual boost::shared_ptr<Thread> newThread(
|
||||
const boost::shared_ptr<Runnable>& runnable) const = 0;
|
||||
|
||||
virtual boost::shared_ptr<Thread> newThread(
|
||||
const boost::shared_ptr<Runnable>& runnable,
|
||||
DetachState detachState) const = 0;
|
||||
|
||||
/** Gets the current thread id or unknown_thread_id if the current thread is not a thrift thread */
|
||||
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
# TARGETS file for thrift/lib/cpp/concurrency/test
|
||||
|
||||
cpp_binary (
|
||||
name = "test",
|
||||
srcs = [
|
||||
"Tests.cpp"
|
||||
],
|
||||
deps = [
|
||||
"@/thrift/lib/cpp/concurrency"
|
||||
]
|
||||
)
|
||||
|
||||
cpp_unittest (
|
||||
name = "test_mutex",
|
||||
srcs = [
|
||||
"RWMutexTest.cpp"
|
||||
],
|
||||
deps = [
|
||||
"@/thrift/lib/cpp/concurrency",
|
||||
"@/thrift/lib/cpp:thrift",
|
||||
],
|
||||
external_deps = [
|
||||
('boost', '>= 1.37', 'boost_unit_test_framework'),
|
||||
],
|
||||
type = 'boost',
|
||||
owner = 'putivsky',
|
||||
emails = ['adback-dev@lists.facebook.com',
|
||||
'thrift-team@lists.facebook.com'],
|
||||
|
||||
)
|
||||
|
||||
cpp_unittest(
|
||||
name = 'ThreadManagerTests',
|
||||
srcs = [
|
||||
'ThreadManagerTests.cpp',
|
||||
],
|
||||
deps = [
|
||||
'@/thrift/lib/cpp/concurrency',
|
||||
],
|
||||
external_deps = [
|
||||
('boost', '>= 1.37', 'boost_unit_test_framework'),
|
||||
],
|
||||
type = 'boost',
|
||||
emails = ['thrift-team@lists.facebook.com'],
|
||||
)
|
|
@ -1,9 +0,0 @@
|
|||
# TARGETS file for thrift/lib/cpp/processor
|
||||
|
||||
cpp_library (
|
||||
name = "processor",
|
||||
srcs = [
|
||||
"PeekProcessor.cpp"
|
||||
],
|
||||
deps = [ "@/thrift/lib/cpp/transport" ]
|
||||
)
|
|
@ -1,24 +0,0 @@
|
|||
cpp_unittest(
|
||||
name = 'ProcessorTest',
|
||||
srcs = [
|
||||
'EventLog.cpp',
|
||||
'ProcessorTest.cpp',
|
||||
'ServerThread.cpp',
|
||||
],
|
||||
deps = [
|
||||
':thrift',
|
||||
'@/thrift/lib/cpp/server:nonblocking',
|
||||
],
|
||||
external_deps = [
|
||||
# Versions of boost lower than 1.37 don't support BOOST_AUTO_TEST_CASE.
|
||||
('boost', '>= 1.37', 'boost_unit_test_framework'),
|
||||
],
|
||||
type = 'boost',
|
||||
emails = ['thrift-team@lists.facebook.com'],
|
||||
)
|
||||
|
||||
cpp_library(
|
||||
name = 'thrift',
|
||||
thrift_srcs = { 'proc.thrift' : ['ParentService', 'ChildService']},
|
||||
thrift_cpp_options = 'templates',
|
||||
)
|
|
@ -1,18 +0,0 @@
|
|||
# TARGETS file for thrift/lib/cpp/protocol
|
||||
|
||||
cpp_library (
|
||||
name = "protocol",
|
||||
srcs = [
|
||||
"TBase64Utils.cpp",
|
||||
"TDebugProtocol.cpp",
|
||||
"TJSONProtocol.cpp",
|
||||
"TSimpleJSONProtocol.cpp",
|
||||
"THeaderProtocol.cpp",
|
||||
"TPhpSerializeProtocol.cpp",
|
||||
],
|
||||
deps = [
|
||||
"@/thrift/lib/cpp/transport",
|
||||
"@/thrift/lib/cpp/transport:header",
|
||||
"@/thrift/lib/cpp:thrift_exception",
|
||||
],
|
||||
)
|
|
@ -37,6 +37,8 @@ class TCompactProtocolT
|
|||
static const int8_t VERSION_N = 2;
|
||||
static const int8_t VERSION_LOW = 1;
|
||||
static const int8_t VERSION_DOUBLE_BE = 2;
|
||||
static const int8_t PROTOCOL_ID = static_cast<int8_t>(0x82);
|
||||
static const int8_t VERSION_MASK = 0x1f; // 0001 1111
|
||||
|
||||
protected:
|
||||
// Normally we can define static const data members of integral
|
||||
|
@ -44,10 +46,8 @@ class TCompactProtocolT
|
|||
// high bit is set (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49896)
|
||||
// unless we cast to a value that fits in an int8_t (0x82 and 0xE0 are
|
||||
// uint8_t)
|
||||
static const int8_t PROTOCOL_ID = static_cast<int8_t>(0x82);
|
||||
static const int8_t TYPE_MASK = static_cast<int8_t>(0xE0);
|
||||
|
||||
static const int8_t VERSION_MASK = 0x1f; // 0001 1111
|
||||
static const int8_t TYPE_MASK = static_cast<int8_t>(0xE0);
|
||||
static const int32_t TYPE_SHIFT_AMOUNT = 5;
|
||||
|
||||
Transport_* trans_;
|
||||
|
|
|
@ -279,7 +279,7 @@ class THeaderProtocol
|
|||
const boost::shared_ptr<TTransport>& outTrans,
|
||||
std::bitset<CLIENT_TYPES_LEN>* clientTypes) {
|
||||
assert(dynamic_cast<THeaderTransport*>(inTrans.get()) == NULL
|
||||
&& dynamic_cast<THeaderTransport*>(outTrans.get()) == NULL);
|
||||
&& dynamic_cast<THeaderTransport*>(outTrans.get()) == NULL);
|
||||
|
||||
return boost::shared_ptr<THeaderTransport>(
|
||||
new THeaderTransport(inTrans, outTrans, clientTypes)
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
# Copyright 2011 Facebook
|
||||
# @author Tudor Bosman (tudorb@fb.com)
|
||||
|
||||
cpp_library(
|
||||
name = "neutronium",
|
||||
srcs = [
|
||||
"Schema.cpp",
|
||||
"Encoder.cpp",
|
||||
"Decoder.cpp",
|
||||
"InternTable.cpp",
|
||||
],
|
||||
thrift_srcs = {
|
||||
"intern_table.thrift": [],
|
||||
},
|
||||
deps = [
|
||||
"@/folly",
|
||||
"@/folly/experimental/io",
|
||||
"@/thrift/lib/cpp/protocol",
|
||||
],
|
||||
external_deps = [
|
||||
("boost", None, "boost"),
|
||||
],
|
||||
)
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
# Copyright 2011 Facebook
|
||||
# @author Tudor Bosman (tudorb@fb.com)
|
||||
|
||||
thrift_library(
|
||||
name = "if",
|
||||
thrift_srcs = {
|
||||
"neutronium_test.thrift" : [],
|
||||
},
|
||||
languages = ["cpp"],
|
||||
thrift_cpp_options = "templates=only,neutronium",
|
||||
cpp_deps = [],
|
||||
)
|
||||
|
||||
cpp_unittest(
|
||||
name = "intern_table_test",
|
||||
srcs = ["InternTableTest.cpp"],
|
||||
deps = [
|
||||
"@/thrift/lib/cpp/protocol/neutronium",
|
||||
"@/external/gflags",
|
||||
],
|
||||
external_deps = [
|
||||
("gtest", None, "gtest_main"),
|
||||
],
|
||||
type = 'gtest',
|
||||
)
|
||||
|
||||
cpp_unittest(
|
||||
name = "neutronium_test",
|
||||
srcs = ["NeutroniumTest.cpp"],
|
||||
deps = [
|
||||
"@/thrift/lib/cpp/protocol/neutronium",
|
||||
"@/thrift/lib/cpp/util",
|
||||
":if-cpp",
|
||||
"@/common/fbunit:old_folly_benchmark",
|
||||
],
|
||||
external_deps = [
|
||||
("gtest", None),
|
||||
],
|
||||
type = 'gtest',
|
||||
)
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
# TARGETS file for thrift/lib/cpp/server
|
||||
|
||||
cpp_library (
|
||||
name = "server",
|
||||
srcs = [
|
||||
"TRpcTransportContext.cpp",
|
||||
"TServer.cpp",
|
||||
"TSimpleServer.cpp",
|
||||
"TThreadedServer.cpp",
|
||||
"TThreadPoolServer.cpp",
|
||||
],
|
||||
deps = [
|
||||
"@/thrift/lib/cpp/concurrency",
|
||||
"@/thrift/lib/cpp/transport",
|
||||
]
|
||||
)
|
||||
|
||||
cpp_library (
|
||||
name = "nonblocking",
|
||||
srcs = [ "TNonblockingServer.cpp" ],
|
||||
deps = [
|
||||
":server",
|
||||
"@/thrift/lib/cpp/concurrency",
|
||||
"@/thrift/lib/cpp/transport",
|
||||
"@/thrift/lib/cpp/transport:header",
|
||||
"@/thrift/lib/cpp/protocol:protocol",
|
||||
],
|
||||
preprocessor_flags = [ "-DTCP_LOW_MIN_RTO=15" ],
|
||||
external_deps = [ ('libevent', None) ],
|
||||
)
|
|
@ -1,60 +0,0 @@
|
|||
cpp_binary (
|
||||
name = "aggregatorserver_test",
|
||||
srcs = [
|
||||
"AggregatorServerTest.cpp",
|
||||
],
|
||||
deps = [
|
||||
"@/thrift/lib/cpp/async",
|
||||
"@/thrift/lib/cpp/concurrency",
|
||||
"@/thrift/lib/cpp/protocol",
|
||||
"@/thrift/lib/cpp/server:nonblocking",
|
||||
"@/common/fb303/cpp:fb303",
|
||||
"@/common/base:profiler",
|
||||
":aggregator_test_thrift",
|
||||
],
|
||||
allocator='tcmalloc',
|
||||
)
|
||||
|
||||
cpp_binary (
|
||||
name = "aggregatorclient_test",
|
||||
srcs = [
|
||||
"AggregatorClientTest.cpp",
|
||||
],
|
||||
deps = [
|
||||
"@/thrift/lib/cpp/async",
|
||||
"@/thrift/lib/cpp/concurrency",
|
||||
"@/thrift/lib/cpp/protocol",
|
||||
"@/common/fb303/cpp:fb303",
|
||||
"@/common/base:profiler",
|
||||
"@/common/client_mgmt:asyncclient",
|
||||
"@/common/logging:logging",
|
||||
":aggregator_test_thrift",
|
||||
],
|
||||
allocator='tcmalloc',
|
||||
)
|
||||
|
||||
cpp_library (
|
||||
name = "aggregator_test_thrift",
|
||||
thrift_srcs = { "AggregatorTest.thrift" : [ "AggregatorTest" ] },
|
||||
thrift_cpp_options = "cob_style",
|
||||
deps = [
|
||||
"@/common/fb303/if:fb303-cpp",
|
||||
],
|
||||
)
|
||||
|
||||
cpp_unittest(
|
||||
name = "conn_ctx_test",
|
||||
srcs = [
|
||||
"ConnCtxTest.cpp",
|
||||
],
|
||||
thrift_srcs = { "connctx.thrift" : [ "ConnCtxService" ] },
|
||||
deps = [
|
||||
"@/thrift/lib/cpp/test:util",
|
||||
"@/thrift/lib/cpp/util:nonblocking",
|
||||
],
|
||||
external_deps = [
|
||||
('boost', '>= 1.37', 'boost_unit_test_framework'),
|
||||
],
|
||||
type = 'boost',
|
||||
emails = ['thrift-team@lists.facebook.com'],
|
||||
)
|
|
@ -1,167 +0,0 @@
|
|||
cpp_unittest(
|
||||
name = 'TEventBaseTest',
|
||||
srcs = [
|
||||
'TEventBaseTest.cpp',
|
||||
],
|
||||
deps = [
|
||||
':util',
|
||||
'@/thrift/lib/cpp/async',
|
||||
],
|
||||
external_deps = [
|
||||
('boost', '>= 1.37', 'boost_unit_test_framework'),
|
||||
],
|
||||
type = 'boost',
|
||||
emails = ['thrift-team@lists.facebook.com'],
|
||||
)
|
||||
|
||||
cpp_unittest(
|
||||
name = 'TAsyncChannelTest',
|
||||
srcs = [
|
||||
'TAsyncChannelTest.cpp',
|
||||
],
|
||||
deps = [
|
||||
':util',
|
||||
'@/thrift/lib/cpp/async',
|
||||
],
|
||||
external_deps = [
|
||||
('boost', '>= 1.37', 'boost_unit_test_framework'),
|
||||
],
|
||||
type = 'boost',
|
||||
emails = ['thrift-team@lists.facebook.com'],
|
||||
)
|
||||
|
||||
cpp_unittest(
|
||||
name = 'TAsyncChannelClientTest',
|
||||
srcs = [
|
||||
'TAsyncChannelClientTest.cpp',
|
||||
],
|
||||
deps = [
|
||||
':util',
|
||||
'@/thrift/lib/cpp/async:zlib',
|
||||
'@/thrift/lib/cpp/util:nonblocking',
|
||||
'@/thrift/lib/cpp/util:httpparser',
|
||||
'@/thrift/perf/cpp:load-handler',
|
||||
],
|
||||
external_deps = [
|
||||
('boost', '>= 1.37', 'boost_unit_test_framework'),
|
||||
],
|
||||
type = 'boost',
|
||||
emails = ['thrift-team@lists.facebook.com'],
|
||||
)
|
||||
|
||||
cpp_unittest(
|
||||
name = 'TAsyncSocketTest',
|
||||
srcs = [
|
||||
'TAsyncSocketTest.cpp',
|
||||
],
|
||||
deps = [
|
||||
':util',
|
||||
'@/thrift/lib/cpp/async',
|
||||
],
|
||||
external_deps = [
|
||||
('boost', '>= 1.37', 'boost_unit_test_framework'),
|
||||
],
|
||||
type = 'boost',
|
||||
emails = ['thrift-team@lists.facebook.com'],
|
||||
)
|
||||
|
||||
cpp_unittest(
|
||||
name = 'TAsyncSSLSocketTest',
|
||||
srcs = [
|
||||
'TAsyncSSLSocketTest.cpp',
|
||||
],
|
||||
deps = [
|
||||
':util',
|
||||
'@/thrift/lib/cpp/async:async_ssl',
|
||||
],
|
||||
external_deps = [
|
||||
('boost', '>= 1.37', 'boost_unit_test_framework'),
|
||||
],
|
||||
type = 'boost',
|
||||
emails = ['ti-bugs@lists.facebook.com',
|
||||
'thrift-team@lists.facebook.com'],
|
||||
)
|
||||
|
||||
cpp_unittest(
|
||||
name = 'TAsyncTimeoutSetTest',
|
||||
srcs = [
|
||||
'TAsyncTimeoutSetTest.cpp',
|
||||
],
|
||||
deps = [
|
||||
':util',
|
||||
'@/thrift/lib/cpp/async:async_cxx11',
|
||||
],
|
||||
type = 'boost',
|
||||
emails = ['thrift-team@lists.facebook.com'],
|
||||
)
|
||||
|
||||
cpp_unittest(
|
||||
name = 'TNotificationQueueTest',
|
||||
srcs = [
|
||||
'TNotificationQueueTest.cpp',
|
||||
],
|
||||
deps = [
|
||||
':async_util',
|
||||
'@/thrift/lib/cpp/async:async_cxx11',
|
||||
],
|
||||
type = 'boost',
|
||||
emails = ['thrift-team@lists.facebook.com'],
|
||||
)
|
||||
|
||||
cpp_unittest(
|
||||
name = 'TNotificationPipeTest',
|
||||
srcs = [
|
||||
'TNotificationPipeTest.cpp',
|
||||
],
|
||||
deps = [
|
||||
':async_util',
|
||||
':util',
|
||||
'@/thrift/lib/cpp/async',
|
||||
],
|
||||
external_deps = [
|
||||
('boost', '>= 1.37', 'boost_unit_test_framework'),
|
||||
],
|
||||
type = 'boost',
|
||||
emails = ['thrift-team@lists.facebook.com'],
|
||||
)
|
||||
|
||||
cpp_library(
|
||||
name = 'util',
|
||||
srcs = [
|
||||
'NetworkUtil.cpp',
|
||||
'SocketPair.cpp',
|
||||
'TimeUtil.cpp',
|
||||
],
|
||||
deps = [
|
||||
'@/thrift/lib/cpp/transport',
|
||||
],
|
||||
)
|
||||
|
||||
cpp_library(
|
||||
name = 'async_util',
|
||||
srcs = [
|
||||
'ScopedEventBaseThread.cpp',
|
||||
],
|
||||
deps = [
|
||||
'@/thrift/lib/cpp/async',
|
||||
'@/thrift/lib/cpp/concurrency',
|
||||
],
|
||||
)
|
||||
|
||||
cpp_library (
|
||||
name = "DebugProtocolLib",
|
||||
thrift_srcs = {
|
||||
"DebugProtocolTest.thrift" : "DebugProtocolService"
|
||||
},
|
||||
thrift_cpp_options = "templates"
|
||||
)
|
||||
|
||||
cpp_binary (
|
||||
name = "DebugProtocol",
|
||||
srcs = [
|
||||
"DebugProtocolTest.cpp",
|
||||
],
|
||||
deps = [
|
||||
":DebugProtocolLib",
|
||||
],
|
||||
)
|
|
@ -1,32 +0,0 @@
|
|||
cpp_library(
|
||||
name = 'loadgen',
|
||||
srcs = [
|
||||
'Controller.cpp',
|
||||
'LatencyMonitor.cpp',
|
||||
'LatencyScoreBoard.cpp',
|
||||
'LoadConfig.cpp',
|
||||
'loadgen.cpp',
|
||||
'QpsMonitor.cpp',
|
||||
'QpsScoreBoard.cpp',
|
||||
'RNG.cpp',
|
||||
'TerminalMonitor.cpp',
|
||||
'WeightedLoadConfig.cpp',
|
||||
],
|
||||
deps = [
|
||||
'@/common/time:time',
|
||||
],
|
||||
external_deps = [
|
||||
('boost', None, 'boost'),
|
||||
],
|
||||
)
|
||||
|
||||
cpp_binary(
|
||||
name = 'perftest',
|
||||
srcs = [
|
||||
'PerfTest.cpp',
|
||||
],
|
||||
deps = [
|
||||
':loadgen',
|
||||
'@/common/config',
|
||||
],
|
||||
)
|
|
@ -1,88 +0,0 @@
|
|||
# TARGETS file for thrift/lib/cpp/transport
|
||||
|
||||
cpp_library(
|
||||
name = "transport",
|
||||
srcs = [
|
||||
"TFileTransport.cpp",
|
||||
"TFDTransport.cpp",
|
||||
"THttpClient.cpp",
|
||||
"THttpServer.cpp",
|
||||
"THttpTransport.cpp",
|
||||
"TServerSocket.cpp",
|
||||
"TSimpleFileTransport.cpp",
|
||||
"TSocket.cpp",
|
||||
"TSocketAddress.cpp",
|
||||
"TSocketPool.cpp",
|
||||
"TTransportException.cpp",
|
||||
"TTransportUtils.cpp",
|
||||
"TBufferTransports.cpp",
|
||||
"TMemPagedFactory.cpp",
|
||||
"TMemPagedTransport.cpp",
|
||||
],
|
||||
deps = [
|
||||
"@/thrift/lib/cpp:thrift_base",
|
||||
"@/thrift/lib/cpp/concurrency",
|
||||
"@/external/google_base",
|
||||
],
|
||||
preprocessor_flags = [ "-DTCP_LOW_MIN_RTO=15" ],
|
||||
)
|
||||
|
||||
cpp_library(
|
||||
name = "transport_ssl",
|
||||
srcs = [
|
||||
"TSSLSocket.cpp",
|
||||
"TSSLServerSocket.cpp",
|
||||
],
|
||||
deps = [
|
||||
":transport",
|
||||
"@/thrift/lib/cpp/concurrency",
|
||||
],
|
||||
external_deps = [ ('openssl', None, 'ssl') ],
|
||||
)
|
||||
|
||||
cpp_library(
|
||||
name = "header",
|
||||
srcs = [ "THeaderTransport.cpp",
|
||||
"THeader.cpp" ],
|
||||
deps = [
|
||||
":transport",
|
||||
"@/folly/experimental/io:io",
|
||||
"@/thrift/lib/cpp/util:internal_util",
|
||||
],
|
||||
external_deps = [ ('zlib', None, 'z'),
|
||||
('snappy', None)
|
||||
],
|
||||
)
|
||||
|
||||
cpp_library(
|
||||
name = "zlib",
|
||||
srcs = [ "TZlibTransport.cpp" ],
|
||||
deps = [
|
||||
":transport",
|
||||
],
|
||||
external_deps = [ ('zlib', None, 'z') ],
|
||||
)
|
||||
|
||||
cpp_library(
|
||||
name = "hdfs_transport",
|
||||
srcs = [ "HDFS.cpp",
|
||||
"THDFSFileTransport.cpp",
|
||||
],
|
||||
|
||||
system_deps = [ "-Lexternal/hadoop/latest/",
|
||||
"-L$(JAVA_HOME)/jre/lib/amd64/server/",
|
||||
"-Lexternal/jvm/",
|
||||
"-ljvm",
|
||||
"-lhdfs"
|
||||
],
|
||||
preprocessor_flags = [ "-I@@@JAVA_HOME@@@/include",
|
||||
"-I@@@JAVA_HOME@@@/include/linux",
|
||||
"-Iexternal/hadoop/latest",
|
||||
],
|
||||
shared_system_deps = [ "hdfs",
|
||||
"jvm",
|
||||
],
|
||||
deps = [
|
||||
"@/thrift/lib/cpp:thrift_base",
|
||||
],
|
||||
)
|
|
@ -23,6 +23,7 @@
|
|||
#include <tr1/functional>
|
||||
|
||||
#include "thrift/lib/cpp/protocol/TBinaryProtocol.h"
|
||||
#include "thrift/lib/cpp/protocol/TCompactProtocol.h"
|
||||
#include "thrift/lib/cpp/protocol/TProtocolTypes.h"
|
||||
|
||||
#include "folly/experimental/io/IOBuf.h"
|
||||
|
@ -34,14 +35,15 @@
|
|||
#include <unistd.h>
|
||||
|
||||
// Don't include the unknown client.
|
||||
#define CLIENT_TYPES_LEN 4
|
||||
#define CLIENT_TYPES_LEN 5
|
||||
|
||||
enum CLIENT_TYPE {
|
||||
THRIFT_HEADER_CLIENT_TYPE = 0,
|
||||
THRIFT_FRAMED_DEPRECATED = 1,
|
||||
THRIFT_UNFRAMED_DEPRECATED = 2,
|
||||
THRIFT_HTTP_CLIENT_TYPE = 3,
|
||||
THRIFT_UNKNOWN_CLIENT_TYPE = 4,
|
||||
THRIFT_FRAMED_COMPACT = 4,
|
||||
THRIFT_UNKNOWN_CLIENT_TYPE = 5,
|
||||
};
|
||||
|
||||
namespace apache { namespace thrift { namespace transport {
|
||||
|
@ -270,6 +272,12 @@ class THeader {
|
|||
*/
|
||||
size_t getMaxWriteHeadersSize() const;
|
||||
|
||||
/**
|
||||
* Returns whether the 1st byte of the protocol payload should be hadled
|
||||
* as compact framed.
|
||||
*/
|
||||
bool compactFramed(uint32_t magic);
|
||||
|
||||
struct infoIdType {
|
||||
enum idType {
|
||||
// start at 1 to avoid confusing header padding for an infoId
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
cpp_unittest(
|
||||
name = 'THeaderTest',
|
||||
srcs = [
|
||||
'THeaderTest.cpp',
|
||||
],
|
||||
deps = [
|
||||
'@/thrift/lib/cpp/transport:header',
|
||||
],
|
||||
external_deps = [
|
||||
('boost', '>= 1.37', 'boost_unit_test_framework'),
|
||||
],
|
||||
type = 'boost',
|
||||
emails = ['thrift-team@lists.facebook.com'],
|
||||
)
|
||||
|
||||
cpp_unittest(
|
||||
name = 'TSocketAddressTest',
|
||||
srcs = [
|
||||
'TSocketAddressTest.cpp',
|
||||
],
|
||||
deps = [
|
||||
'@/thrift/lib/cpp/transport',
|
||||
],
|
||||
external_deps = [
|
||||
('boost', '>= 1.37', 'boost_unit_test_framework'),
|
||||
],
|
||||
type = 'boost',
|
||||
emails = ['thrift-team@lists.facebook.com'],
|
||||
)
|
||||
|
||||
cpp_unittest(
|
||||
name = 'TSSLSocketTest',
|
||||
srcs = [
|
||||
'TSSLSocketTest.cpp',
|
||||
],
|
||||
deps = [
|
||||
'@/thrift/lib/cpp/transport:transport_ssl',
|
||||
'@/thrift/lib/cpp/util',
|
||||
],
|
||||
external_deps = [
|
||||
('boost', '>= 1.37', 'boost_unit_test_framework'),
|
||||
],
|
||||
type = 'boost',
|
||||
emails = [
|
||||
'ti-bugs@lists.facebook.com',
|
||||
'thrift-team@lists.facebook.com',
|
||||
],
|
||||
)
|
||||
|
||||
cpp_unittest (
|
||||
name = "TSocketPoolTest",
|
||||
srcs = [
|
||||
"TSocketPoolTest.cpp",
|
||||
],
|
||||
deps = [
|
||||
'@/common/fbunit',
|
||||
'@/thrift/lib/cpp/transport',
|
||||
],
|
||||
)
|
||||
|
||||
cpp_binary (
|
||||
name = "ttransport_test",
|
||||
srcs = [
|
||||
"TransportTest.cpp",
|
||||
],
|
||||
deps = [
|
||||
"@/thrift/lib/cpp/transport",
|
||||
]
|
||||
)
|
|
@ -1,74 +0,0 @@
|
|||
cpp_library(
|
||||
name = 'util',
|
||||
srcs = [
|
||||
'ScopedServerThread.cpp',
|
||||
'ServerCreatorBase.cpp',
|
||||
'SyncServerCreator.cpp',
|
||||
'TSimpleServerCreator.cpp',
|
||||
'TThreadedServerCreator.cpp',
|
||||
'TThreadPoolServerCreator.cpp',
|
||||
],
|
||||
deps = [
|
||||
'@/thrift/lib/cpp/server',
|
||||
'@/thrift/lib/cpp/protocol',
|
||||
'@/folly',
|
||||
],
|
||||
)
|
||||
|
||||
cpp_library(
|
||||
name = 'internal_util',
|
||||
srcs = [
|
||||
'VarintUtils.cpp',
|
||||
],
|
||||
deps = [
|
||||
'@/folly',
|
||||
],
|
||||
external_deps = [
|
||||
('gflags', None, 'gflags'),
|
||||
('glog', None, 'glog'),
|
||||
],
|
||||
)
|
||||
|
||||
cpp_library(
|
||||
name = 'nonblocking',
|
||||
srcs = [
|
||||
'TNonblockingServerCreator.cpp',
|
||||
],
|
||||
deps = [
|
||||
':util',
|
||||
'@/thrift/lib/cpp/server:nonblocking',
|
||||
],
|
||||
)
|
||||
|
||||
cpp_library(
|
||||
name = 'async',
|
||||
srcs = [
|
||||
'TEventServerCreator.cpp',
|
||||
],
|
||||
deps = [
|
||||
':util',
|
||||
'@/thrift/lib/cpp/async',
|
||||
],
|
||||
)
|
||||
|
||||
cpp_library(
|
||||
name = 'httpparser',
|
||||
srcs = [
|
||||
'THttpParser.cpp',
|
||||
],
|
||||
deps = [
|
||||
'@/thrift/lib/cpp/transport',
|
||||
],
|
||||
)
|
||||
|
||||
cpp_unittest(
|
||||
name = 'ThriftSerializerTest',
|
||||
srcs = [ 'ThriftSerializerTest.cpp' ],
|
||||
thrift_srcs = { 'ThriftSerializerTest.thrift' : [ ] },
|
||||
thrift_cpp_options = 'templates',
|
||||
deps = [ '@/common/strings:strings',
|
||||
'@/common/fbunit',
|
||||
],
|
||||
)
|
||||
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
cpp_unittest(
|
||||
name = 'ServerCreatorTest',
|
||||
srcs = [
|
||||
'ServerCreatorTest.cpp',
|
||||
],
|
||||
deps = [
|
||||
'@/thrift/lib/cpp/util:async',
|
||||
'@/thrift/lib/cpp/util:nonblocking',
|
||||
'@/thrift/perf/cpp:load-handler',
|
||||
'@/thrift/perf/cpp:async-load-handler',
|
||||
],
|
||||
external_deps = [
|
||||
('boost', '>= 1.37', 'boost_unit_test_framework'),
|
||||
],
|
||||
type = 'boost',
|
||||
emails = ['thrift-team@lists.facebook.com'],
|
||||
)
|
Loading…
Reference in a new issue