namespace facebook { namespace thrift {
-using namespace boost;
-
-using namespace facebook::thrift::protocol;
-
/**
* A processor is a generic object that acts upon two streams of data, one
* an input and the other an output. The definition of this object is loose,
public:
virtual ~TProcessor() {}
- virtual bool process(shared_ptr<TProtocol> in,
- shared_ptr<TProtocol> out) = 0;
+ virtual bool process(boost::shared_ptr<protocol::TProtocol> in,
+ boost::shared_ptr<protocol::TProtocol> out) = 0;
- bool process(shared_ptr<TProtocol> io) {
+ bool process(boost::shared_ptr<facebook::thrift::protocol::TProtocol> io) {
return process(io, io);
}
}
}
- uint32_t TApplicationException::read(facebook::thrift::protocol::TProtocol* iprot);
- uint32_t TApplicationException::write(facebook::thrift::protocol::TProtocol* oprot) const;
+ uint32_t TApplicationException::read(protocol::TProtocol* iprot);
+ uint32_t TApplicationException::write(protocol::TProtocol* oprot) const;
protected:
/**
namespace facebook { namespace thrift { namespace concurrency {
-using namespace boost;
-
/**
* A thread factory to create posix threads
*
PosixThreadFactory(POLICY policy=ROUND_ROBIN, PRIORITY priority=NORMAL, int stackSize=1, bool detached=false);
// From ThreadFactory;
- shared_ptr<Thread> newThread(shared_ptr<Runnable> runnable) const;
+ boost::shared_ptr<Thread> newThread(boost::shared_ptr<Runnable> runnable) const;
/**
* Sets stack size for created threads
private:
class Impl;
- shared_ptr<Impl> impl_;
+ boost::shared_ptr<Impl> impl_;
};
}}} // facebook::thrift::concurrency
namespace facebook { namespace thrift { namespace concurrency {
-using namespace boost;
-
class Thread;
/**
/**
* Gets the thread object that is hosting this runnable object - can return
- * an empty shared pointer if no references remain on thet thread object
+ * an empty boost::shared pointer if no references remain on thet thread object
*/
- virtual shared_ptr<Thread> thread() { return thread_.lock(); }
+ virtual boost::shared_ptr<Thread> thread() { return thread_.lock(); }
/**
* Sets the thread that is executing this object. This is only meant for
* use by concrete implementations of Thread.
*/
- virtual void thread(shared_ptr<Thread> value) { thread_ = value; }
+ virtual void thread(boost::shared_ptr<Thread> value) { thread_ = value; }
private:
- weak_ptr<Thread> thread_;
+ boost::weak_ptr<Thread> thread_;
};
/**
/**
* Gets the runnable object this thread is hosting
*/
- virtual shared_ptr<Runnable> runnable() const { return _runnable; }
+ virtual boost::shared_ptr<Runnable> runnable() const { return _runnable; }
protected:
- virtual void runnable(shared_ptr<Runnable> value) { _runnable = value; }
+ virtual void runnable(boost::shared_ptr<Runnable> value) { _runnable = value; }
private:
- shared_ptr<Runnable> _runnable;
+ boost::shared_ptr<Runnable> _runnable;
};
/**
public:
virtual ~ThreadFactory() {}
- virtual shared_ptr<Thread> newThread(shared_ptr<Runnable> runnable) const = 0;
+ virtual boost::shared_ptr<Thread> newThread(boost::shared_ptr<Runnable> runnable) const = 0;
};
}}} // facebook::thrift::concurrency
namespace facebook { namespace thrift { namespace concurrency {
-using namespace boost;
-
/**
* Thread Pool Manager and related classes
*
virtual const STATE state() const = 0;
- virtual shared_ptr<ThreadFactory> threadFactory() const = 0;
+ virtual boost::shared_ptr<ThreadFactory> threadFactory() const = 0;
- virtual void threadFactory(shared_ptr<ThreadFactory> value) = 0;
+ virtual void threadFactory(boost::shared_ptr<ThreadFactory> value) = 0;
virtual void addWorker(size_t value=1) = 0;
*
* @param value The task to run
*/
- virtual void add(shared_ptr<Runnable>value) = 0;
+ virtual void add(boost::shared_ptr<Runnable>value) = 0;
/**
* Removes a pending task
*/
- virtual void remove(shared_ptr<Runnable> task) = 0;
+ virtual void remove(boost::shared_ptr<Runnable> task) = 0;
- static shared_ptr<ThreadManager> newThreadManager();
+ static boost::shared_ptr<ThreadManager> newThreadManager();
/**
* Creates a simple thread manager the uses count number of worker threads
*/
- static shared_ptr<ThreadManager> newSimpleThreadManager(size_t count=4);
+ static boost::shared_ptr<ThreadManager> newSimpleThreadManager(size_t count=4);
class Task;
namespace facebook { namespace thrift { namespace concurrency {
+using boost::shared_ptr;
+
typedef std::multimap<long long, shared_ptr<TimerManager::Task> >::iterator task_iterator;
typedef std::pair<task_iterator, task_iterator> task_range;
namespace facebook { namespace thrift { namespace concurrency {
-using namespace boost;
-
/**
* Timer Manager
*
virtual ~TimerManager();
- virtual shared_ptr<const ThreadFactory> threadFactory() const;
+ virtual boost::shared_ptr<const ThreadFactory> threadFactory() const;
- virtual void threadFactory(shared_ptr<const ThreadFactory> value);
+ virtual void threadFactory(boost::shared_ptr<const ThreadFactory> value);
/**
* Starts the timer manager service
* @param task The task to execute
* @param timeout Time in milliseconds to delay before executing task
*/
- virtual void add(shared_ptr<Runnable> task, long long timeout);
+ virtual void add(boost::shared_ptr<Runnable> task, long long timeout);
/**
* Adds a task to be executed at some time in the future by a worker thread.
* @param task The task to execute
* @param timeout Absolute time in the future to execute task.
*/
- virtual void add(shared_ptr<Runnable> task, const struct timespec& timeout);
+ virtual void add(boost::shared_ptr<Runnable> task, const struct timespec& timeout);
/**
* Removes a pending task
* @throws UncancellableTaskException Specified task is already being
* executed or has completed execution.
*/
- virtual void remove(shared_ptr<Runnable> task);
+ virtual void remove(boost::shared_ptr<Runnable> task);
enum STATE {
UNINITIALIZED,
virtual const STATE state() const;
private:
- shared_ptr<const ThreadFactory> threadFactory_;
+ boost::shared_ptr<const ThreadFactory> threadFactory_;
class Task;
friend class Task;
- std::multimap<long long, shared_ptr<Task> > taskMap_;
+ std::multimap<long long, boost::shared_ptr<Task> > taskMap_;
size_t taskCount_;
Monitor monitor_;
STATE state_;
class Dispatcher;
friend class Dispatcher;
- shared_ptr<Dispatcher> dispatcher_;
- shared_ptr<Thread> dispatcherThread_;
+ boost::shared_ptr<Dispatcher> dispatcher_;
+ boost::shared_ptr<Thread> dispatcherThread_;
};
}}} // facebook::thrift::concurrency
namespace facebook { namespace thrift { namespace concurrency { namespace test {
+using boost::shared_ptr;
using namespace facebook::thrift::concurrency;
/**
namespace facebook { namespace thrift { namespace protocol {
-using namespace boost;
-
/**
* The default binary protocol for thrift. Writes all data in a very basic
* binary format, essentially just spitting out the raw bytes.
*/
class TBinaryProtocol : public TProtocol {
public:
- TBinaryProtocol(shared_ptr<TTransport> trans) :
+ TBinaryProtocol(boost::shared_ptr<TTransport> trans) :
TProtocol(trans),
string_limit_(0),
container_limit_(0),
string_buf_(NULL),
string_buf_size_(0) {}
- TBinaryProtocol(shared_ptr<TTransport> trans,
+ TBinaryProtocol(boost::shared_ptr<TTransport> trans,
int32_t string_limit,
int32_t container_limit) :
TProtocol(trans),
namespace facebook { namespace thrift { namespace protocol {
-using namespace boost;
-
-using namespace facebook::thrift::transport;
+using facebook::thrift::transport::TTransport;
#if __BYTE_ORDER == __BIG_ENDIAN
#define ntohll(n) (n)
}
}
- inline shared_ptr<TTransport> getTransport() {
+ inline boost::shared_ptr<TTransport> getTransport() {
return ptrans_;
}
// TODO: remove these two calls, they are for backwards
// compatibility
- inline shared_ptr<TTransport> getInputTransport() {
+ inline boost::shared_ptr<TTransport> getInputTransport() {
return ptrans_;
}
- inline shared_ptr<TTransport> getOutputTransport() {
+ inline boost::shared_ptr<TTransport> getOutputTransport() {
return ptrans_;
}
protected:
- TProtocol(shared_ptr<TTransport> ptrans):
+ TProtocol(boost::shared_ptr<TTransport> ptrans):
ptrans_(ptrans) {
trans_ = ptrans.get();
}
- shared_ptr<TTransport> ptrans_;
+ boost::shared_ptr<TTransport> ptrans_;
TTransport* trans_;
private:
namespace facebook { namespace thrift { namespace server {
- void TConnection::init(int socket, short eventFlags, TNonblockingServer* s) {
+using namespace facebook::thrift::protocol;
+using namespace facebook::thrift::transport;
+
+void TConnection::init(int socket, short eventFlags, TNonblockingServer* s) {
socket_ = socket;
server_ = s;
appState_ = APP_INIT;
namespace facebook { namespace thrift { namespace server {
-using boost::shared_ptr;
+using facebook::thrift::transport::TMemoryBuffer;
+using facebook::thrift::protocol::TProtocol;
// Forward declaration of class
class TConnection;
void handleEvent(int fd, short which);
public:
- TNonblockingServer(shared_ptr<TProcessor> processor,
+ TNonblockingServer(boost::shared_ptr<TProcessor> processor,
int port) :
TServer(processor),
serverSocket_(0),
port_(port),
frameResponses_(true) {}
- TNonblockingServer(shared_ptr<TProcessor> processor,
- shared_ptr<TProtocolFactory> protocolFactory,
+ TNonblockingServer(boost::shared_ptr<TProcessor> processor,
+ boost::shared_ptr<TProtocolFactory> protocolFactory,
int port) :
TServer(processor),
serverSocket_(0),
port_(port),
frameResponses_(true) {
- setInputTransportFactory(shared_ptr<TTransportFactory>(new TTransportFactory()));
- setOutputTransportFactory(shared_ptr<TTransportFactory>(new TTransportFactory()));
+ setInputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory()));
+ setOutputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory()));
setInputProtocolFactory(protocolFactory);
setOutputProtocolFactory(protocolFactory);
}
- TNonblockingServer(shared_ptr<TProcessor> processor,
- shared_ptr<TTransportFactory> inputTransportFactory,
- shared_ptr<TTransportFactory> outputTransportFactory,
- shared_ptr<TProtocolFactory> inputProtocolFactory,
- shared_ptr<TProtocolFactory> outputProtocolFactory,
+ TNonblockingServer(boost::shared_ptr<TProcessor> processor,
+ boost::shared_ptr<TTransportFactory> inputTransportFactory,
+ boost::shared_ptr<TTransportFactory> outputTransportFactory,
+ boost::shared_ptr<TProtocolFactory> inputProtocolFactory,
+ boost::shared_ptr<TProtocolFactory> outputProtocolFactory,
int port) :
TServer(processor),
serverSocket_(0),
int32_t frameSize_;
// Transport to read from
- shared_ptr<TMemoryBuffer> inputTransport_;
+ boost::shared_ptr<TMemoryBuffer> inputTransport_;
// Transport that processor writes to
- shared_ptr<TMemoryBuffer> outputTransport_;
+ boost::shared_ptr<TMemoryBuffer> outputTransport_;
// extra transport generated by transport factory (e.g. BufferedRouterTransport)
- shared_ptr<TTransport> factoryInputTransport_;
- shared_ptr<TTransport> factoryOutputTransport_;
+ boost::shared_ptr<TTransport> factoryInputTransport_;
+ boost::shared_ptr<TTransport> factoryOutputTransport_;
// Protocol decoder
- shared_ptr<TProtocol> inputProtocol_;
+ boost::shared_ptr<TProtocol> inputProtocol_;
// Protocol encoder
- shared_ptr<TProtocol> outputProtocol_;
+ boost::shared_ptr<TProtocol> outputProtocol_;
// Go into read mode
void setRead() {
// Allocate input and output tranpsorts
// these only need to be allocated once per TConnection (they don't need to be
// reallocated on init() call)
- inputTransport_ = shared_ptr<TMemoryBuffer>(new TMemoryBuffer(readBuffer_, readBufferSize_));
- outputTransport_ = shared_ptr<TMemoryBuffer>(new TMemoryBuffer());
+ inputTransport_ = boost::shared_ptr<TMemoryBuffer>(new TMemoryBuffer(readBuffer_, readBufferSize_));
+ outputTransport_ = boost::shared_ptr<TMemoryBuffer>(new TMemoryBuffer());
init(socket, eventFlags, s);
}
namespace facebook { namespace thrift { namespace server {
-using namespace facebook::thrift;
-using namespace facebook::thrift::transport;
-using namespace boost;
+using facebook::thrift::TProcessor;
+using facebook::thrift::protocol::TBinaryProtocolFactory;
+using facebook::thrift::protocol::TProtocolFactory;
+using facebook::thrift::transport::TServerTransport;
+using facebook::thrift::transport::TTransport;
+using facebook::thrift::transport::TTransportFactory;
/**
* Thrift server.
serve();
}
- shared_ptr<TProcessor> getProcessor() {
+ boost::shared_ptr<TProcessor> getProcessor() {
return processor_;
}
- shared_ptr<TServerTransport> getServerTransport() {
+ boost::shared_ptr<TServerTransport> getServerTransport() {
return serverTransport_;
}
- shared_ptr<TTransportFactory> getInputTransportFactory() {
+ boost::shared_ptr<TTransportFactory> getInputTransportFactory() {
return inputTransportFactory_;
}
- shared_ptr<TTransportFactory> getOutputTransportFactory() {
+ boost::shared_ptr<TTransportFactory> getOutputTransportFactory() {
return outputTransportFactory_;
}
- shared_ptr<TProtocolFactory> getInputProtocolFactory() {
+ boost::shared_ptr<TProtocolFactory> getInputProtocolFactory() {
return inputProtocolFactory_;
}
- shared_ptr<TProtocolFactory> getOutputProtocolFactory() {
+ boost::shared_ptr<TProtocolFactory> getOutputProtocolFactory() {
return outputProtocolFactory_;
}
protected:
- TServer(shared_ptr<TProcessor> processor):
+ TServer(boost::shared_ptr<TProcessor> processor):
processor_(processor) {
- setInputTransportFactory(shared_ptr<TTransportFactory>(new TTransportFactory()));
- setOutputTransportFactory(shared_ptr<TTransportFactory>(new TTransportFactory()));
- setInputProtocolFactory(shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory()));
- setOutputProtocolFactory(shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory()));
+ setInputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory()));
+ setOutputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory()));
+ setInputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory()));
+ setOutputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory()));
}
- TServer(shared_ptr<TProcessor> processor,
- shared_ptr<TServerTransport> serverTransport):
+ TServer(boost::shared_ptr<TProcessor> processor,
+ boost::shared_ptr<TServerTransport> serverTransport):
processor_(processor),
serverTransport_(serverTransport) {
- setInputTransportFactory(shared_ptr<TTransportFactory>(new TTransportFactory()));
- setOutputTransportFactory(shared_ptr<TTransportFactory>(new TTransportFactory()));
- setInputProtocolFactory(shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory()));
- setOutputProtocolFactory(shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory()));
+ setInputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory()));
+ setOutputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory()));
+ setInputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory()));
+ setOutputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory()));
}
- TServer(shared_ptr<TProcessor> processor,
- shared_ptr<TServerTransport> serverTransport,
- shared_ptr<TTransportFactory> transportFactory,
- shared_ptr<TProtocolFactory> protocolFactory):
+ TServer(boost::shared_ptr<TProcessor> processor,
+ boost::shared_ptr<TServerTransport> serverTransport,
+ boost::shared_ptr<TTransportFactory> transportFactory,
+ boost::shared_ptr<TProtocolFactory> protocolFactory):
processor_(processor),
serverTransport_(serverTransport),
inputTransportFactory_(transportFactory),
inputProtocolFactory_(protocolFactory),
outputProtocolFactory_(protocolFactory) {}
- TServer(shared_ptr<TProcessor> processor,
- shared_ptr<TServerTransport> serverTransport,
- shared_ptr<TTransportFactory> inputTransportFactory,
- shared_ptr<TTransportFactory> outputTransportFactory,
- shared_ptr<TProtocolFactory> inputProtocolFactory,
- shared_ptr<TProtocolFactory> outputProtocolFactory):
+ TServer(boost::shared_ptr<TProcessor> processor,
+ boost::shared_ptr<TServerTransport> serverTransport,
+ boost::shared_ptr<TTransportFactory> inputTransportFactory,
+ boost::shared_ptr<TTransportFactory> outputTransportFactory,
+ boost::shared_ptr<TProtocolFactory> inputProtocolFactory,
+ boost::shared_ptr<TProtocolFactory> outputProtocolFactory):
processor_(processor),
serverTransport_(serverTransport),
inputTransportFactory_(inputTransportFactory),
// Class variables
- shared_ptr<TProcessor> processor_;
- shared_ptr<TServerTransport> serverTransport_;
+ boost::shared_ptr<TProcessor> processor_;
+ boost::shared_ptr<TServerTransport> serverTransport_;
- shared_ptr<TTransportFactory> inputTransportFactory_;
- shared_ptr<TTransportFactory> outputTransportFactory_;
+ boost::shared_ptr<TTransportFactory> inputTransportFactory_;
+ boost::shared_ptr<TTransportFactory> outputTransportFactory_;
- shared_ptr<TProtocolFactory> inputProtocolFactory_;
- shared_ptr<TProtocolFactory> outputProtocolFactory_;
+ boost::shared_ptr<TProtocolFactory> inputProtocolFactory_;
+ boost::shared_ptr<TProtocolFactory> outputProtocolFactory_;
- void setInputTransportFactory(shared_ptr<TTransportFactory> inputTransportFactory) {
+ void setInputTransportFactory(boost::shared_ptr<TTransportFactory> inputTransportFactory) {
inputTransportFactory_ = inputTransportFactory;
}
- void setOutputTransportFactory(shared_ptr<TTransportFactory> outputTransportFactory) {
+ void setOutputTransportFactory(boost::shared_ptr<TTransportFactory> outputTransportFactory) {
outputTransportFactory_ = outputTransportFactory;
}
- void setInputProtocolFactory(shared_ptr<TProtocolFactory> inputProtocolFactory) {
+ void setInputProtocolFactory(boost::shared_ptr<TProtocolFactory> inputProtocolFactory) {
inputProtocolFactory_ = inputProtocolFactory;
}
- void setOutputProtocolFactory(shared_ptr<TProtocolFactory> outputProtocolFactory) {
+ void setOutputProtocolFactory(boost::shared_ptr<TProtocolFactory> outputProtocolFactory) {
outputProtocolFactory_ = outputProtocolFactory;
}
#include "transport/TTransportException.h"
#include <string>
#include <iostream>
-using namespace std;
namespace facebook { namespace thrift { namespace server {
+using namespace std;
+using namespace facebook::thrift;
+using namespace facebook::thrift::protocol;
+using namespace facebook::thrift::transport;
+using boost::shared_ptr;
+
/**
* A simple single-threaded application server. Perfect for unit tests!
*
*/
class TSimpleServer : public TServer {
public:
- TSimpleServer(shared_ptr<TProcessor> processor,
- shared_ptr<TServerTransport> serverTransport,
- shared_ptr<TTransportFactory> transportFactory,
- shared_ptr<TProtocolFactory> protocolFactory) :
+ TSimpleServer(boost::shared_ptr<TProcessor> processor,
+ boost::shared_ptr<TServerTransport> serverTransport,
+ boost::shared_ptr<TTransportFactory> transportFactory,
+ boost::shared_ptr<TProtocolFactory> protocolFactory) :
TServer(processor, serverTransport, transportFactory, protocolFactory),
stop_(false) {}
- TSimpleServer(shared_ptr<TProcessor> processor,
- shared_ptr<TServerTransport> serverTransport,
- shared_ptr<TTransportFactory> inputTransportFactory,
- shared_ptr<TTransportFactory> outputTransportFactory,
- shared_ptr<TProtocolFactory> inputProtocolFactory,
- shared_ptr<TProtocolFactory> outputProtocolFactory):
+ TSimpleServer(boost::shared_ptr<TProcessor> processor,
+ boost::shared_ptr<TServerTransport> serverTransport,
+ boost::shared_ptr<TTransportFactory> inputTransportFactory,
+ boost::shared_ptr<TTransportFactory> outputTransportFactory,
+ boost::shared_ptr<TProtocolFactory> inputProtocolFactory,
+ boost::shared_ptr<TProtocolFactory> outputProtocolFactory):
TServer(processor, serverTransport,
inputTransportFactory, outputTransportFactory,
inputProtocolFactory, outputProtocolFactory),
namespace facebook { namespace thrift { namespace server {
+using boost::shared_ptr;
using namespace std;
using namespace facebook::thrift;
using namespace facebook::thrift::concurrency;
+using namespace facebook::thrift::protocol;;
using namespace facebook::thrift::transport;
class TThreadPoolServer::Task: public Runnable {
namespace facebook { namespace thrift { namespace server {
-using namespace facebook::thrift::concurrency;
-using namespace facebook::thrift::transport;
-using namespace boost;
+using facebook::thrift::concurrency::ThreadManager;
+using facebook::thrift::protocol::TProtocolFactory;
+using facebook::thrift::transport::TServerTransport;
+using facebook::thrift::transport::TTransportFactory;
class TThreadPoolServer : public TServer {
public:
class Task;
- TThreadPoolServer(shared_ptr<TProcessor> processor,
- shared_ptr<TServerTransport> serverTransport,
- shared_ptr<TTransportFactory> transportFactory,
- shared_ptr<TProtocolFactory> protocolFactory,
- shared_ptr<ThreadManager> threadManager);
-
- TThreadPoolServer(shared_ptr<TProcessor> processor,
- shared_ptr<TServerTransport> serverTransport,
- shared_ptr<TTransportFactory> inputTransportFactory,
- shared_ptr<TTransportFactory> outputTransportFactory,
- shared_ptr<TProtocolFactory> inputProtocolFactory,
- shared_ptr<TProtocolFactory> outputProtocolFactory,
- shared_ptr<ThreadManager> threadManager);
+ TThreadPoolServer(boost::shared_ptr<TProcessor> processor,
+ boost::shared_ptr<TServerTransport> serverTransport,
+ boost::shared_ptr<TTransportFactory> transportFactory,
+ boost::shared_ptr<TProtocolFactory> protocolFactory,
+ boost::shared_ptr<ThreadManager> threadManager);
+
+ TThreadPoolServer(boost::shared_ptr<TProcessor> processor,
+ boost::shared_ptr<TServerTransport> serverTransport,
+ boost::shared_ptr<TTransportFactory> inputTransportFactory,
+ boost::shared_ptr<TTransportFactory> outputTransportFactory,
+ boost::shared_ptr<TProtocolFactory> inputProtocolFactory,
+ boost::shared_ptr<TProtocolFactory> outputProtocolFactory,
+ boost::shared_ptr<ThreadManager> threadManager);
virtual ~TThreadPoolServer();
protected:
- shared_ptr<ThreadManager> threadManager_;
+ boost::shared_ptr<ThreadManager> threadManager_;
volatile bool stop_;
namespace facebook { namespace thrift { namespace server {
+using boost::shared_ptr;
using namespace std;
using namespace facebook::thrift;
+using namespace facebook::thrift::protocol;
using namespace facebook::thrift::transport;
using namespace facebook::thrift::concurrency;
namespace facebook { namespace thrift { namespace server {
-using namespace facebook::thrift::transport;
-using namespace facebook::thrift::concurrency;
-using namespace boost;
+using facebook::thrift::TProcessor;
+using facebook::thrift::transport::TServerTransport;
+using facebook::thrift::transport::TTransportFactory;
+using facebook::thrift::concurrency::ThreadFactory;
class TThreadedServer : public TServer {
public:
class Task;
- TThreadedServer(shared_ptr<TProcessor> processor,
- shared_ptr<TServerTransport> serverTransport,
- shared_ptr<TTransportFactory> transportFactory,
- shared_ptr<TProtocolFactory> protocolFactory);
+ TThreadedServer(boost::shared_ptr<TProcessor> processor,
+ boost::shared_ptr<TServerTransport> serverTransport,
+ boost::shared_ptr<TTransportFactory> transportFactory,
+ boost::shared_ptr<TProtocolFactory> protocolFactory);
virtual ~TThreadedServer();
virtual void serve();
protected:
- shared_ptr<ThreadFactory> threadFactory_;
+ boost::shared_ptr<ThreadFactory> threadFactory_;
};
#include "TTransportUtils.h"
#include <pthread.h>
- #include <sys/time.h>
+#include <sys/time.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <iostream>
#include <sys/stat.h>
+namespace facebook { namespace thrift { namespace transport {
+
+using boost::shared_ptr;
using namespace std;
+using namespace facebook::thrift::protocol;
-namespace facebook { namespace thrift { namespace transport {
TFileTransport::TFileTransport(string path)
: readState_()
namespace facebook { namespace thrift { namespace transport {
-using namespace boost;
-using std::string;
+using facebook::thrift::TProcessor;
+using facebook::thrift::protocol::TProtocolFactory;
// Data pertaining to a single event
typedef struct eventInfo {
*/
class TFileTransport : public TTransport {
public:
- TFileTransport(string path);
+ TFileTransport(std::string path);
~TFileTransport();
// TODO: what is the correct behaviour for this?
uint32_t getCurChunk();
// for changing the output file
- void resetOutputFile(int fd, string filename, long long offset);
+ void resetOutputFile(int fd, std::string filename, long long offset);
// Setter/Getter functions for user-controllable options
void setReadBuffSize(uint32_t readBuffSize) {
pthread_mutex_t mutex_;
// File information
- string filename_;
+ std::string filename_;
int fd_;
// Whether the writer thread and buffers have been initialized
};
// Exception thrown when EOF is hit
-class TEOFException : public facebook::thrift::TTransportException {
+ class TEOFException : TTransportException {
public:
TEOFException():
- facebook::thrift::TTransportException(TTransportException::END_OF_FILE) {};
+ TTransportException(TTransportException::END_OF_FILE) {};
};
* @param protocolFactory protocol factory
* @param inputTransport file transport
*/
- TFileProcessor(shared_ptr<TProcessor> processor,
- shared_ptr<TProtocolFactory> protocolFactory,
- shared_ptr<TFileTransport> inputTransport);
+ TFileProcessor(boost::shared_ptr<TProcessor> processor,
+ boost::shared_ptr<TProtocolFactory> protocolFactory,
+ boost::shared_ptr<TFileTransport> inputTransport);
- TFileProcessor(shared_ptr<TProcessor> processor,
- shared_ptr<TProtocolFactory> inputProtocolFactory,
- shared_ptr<TProtocolFactory> outputProtocolFactory,
- shared_ptr<TFileTransport> inputTransport);
+ TFileProcessor(boost::shared_ptr<TProcessor> processor,
+ boost::shared_ptr<TProtocolFactory> inputProtocolFactory,
+ boost::shared_ptr<TProtocolFactory> outputProtocolFactory,
+ boost::shared_ptr<TFileTransport> inputTransport);
/**
* Constructor
* @param inputTransport input file transport
* @param output output transport
*/
- TFileProcessor(shared_ptr<TProcessor> processor,
- shared_ptr<TProtocolFactory> protocolFactory,
- shared_ptr<TFileTransport> inputTransport,
- shared_ptr<TTransport> outputTransport);
+ TFileProcessor(boost::shared_ptr<TProcessor> processor,
+ boost::shared_ptr<TProtocolFactory> protocolFactory,
+ boost::shared_ptr<TFileTransport> inputTransport,
+ boost::shared_ptr<TTransport> outputTransport);
/**
* processes events from the file
void processChunk();
private:
- shared_ptr<TProcessor> processor_;
- shared_ptr<TProtocolFactory> inputProtocolFactory_;
- shared_ptr<TProtocolFactory> outputProtocolFactory_;
- shared_ptr<TFileTransport> inputTransport_;
- shared_ptr<TTransport> outputTransport_;
+ boost::shared_ptr<TProcessor> processor_;
+ boost::shared_ptr<TProtocolFactory> inputProtocolFactory_;
+ boost::shared_ptr<TProtocolFactory> outputProtocolFactory_;
+ boost::shared_ptr<TFileTransport> inputTransport_;
+ boost::shared_ptr<TTransport> outputTransport_;
};
}
protected:
- shared_ptr<TTransport> acceptImpl();
+ boost::shared_ptr<TTransport> acceptImpl();
private:
int port_;
namespace facebook { namespace thrift { namespace transport {
-using namespace boost;
-
/**
* Server transport framework. A server needs to have some facility for
* creating base transports to read/write from.
* @return A new TTransport object
* @throws TTransportException if there is an error
*/
- shared_ptr<TTransport> accept() {
- shared_ptr<TTransport> result = acceptImpl();
+ boost::shared_ptr<TTransport> accept() {
+ boost::shared_ptr<TTransport> result = acceptImpl();
if (result == NULL) {
throw TTransportException("accept() may not return NULL");
}
* @return A newly allocated TTransport object
* @throw TTransportException If an error occurs
*/
- virtual shared_ptr<TTransport> acceptImpl() = 0;
+ virtual boost::shared_ptr<TTransport> acceptImpl() = 0;
};
--- /dev/null
+Thrift Software License
+Copyright (c) 2006- Facebook, Inc.
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
--- /dev/null
+Thrift Software License
+Copyright (c) 2006- Facebook, Inc.
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.