THRIFT-2729: C++ - .clang-format created and applied

Client: C++
Patch: Konrad Grochowski

make style command added
diff --git a/test/cpp/src/StressTest.cpp b/test/cpp/src/StressTest.cpp
index dfe8350..fa468a4 100644
--- a/test/cpp/src/StressTest.cpp
+++ b/test/cpp/src/StressTest.cpp
@@ -40,7 +40,7 @@
 #include <sstream>
 #include <map>
 #if _WIN32
-   #include <thrift/windows/TWinsockSingleton.h>
+#include <thrift/windows/TWinsockSingleton.h>
 #endif
 
 using namespace std;
@@ -54,23 +54,18 @@
 using namespace test::stress;
 
 struct eqstr {
-  bool operator()(const char* s1, const char* s2) const {
-    return strcmp(s1, s2) == 0;
-  }
+  bool operator()(const char* s1, const char* s2) const { return strcmp(s1, s2) == 0; }
 };
 
 struct ltstr {
-  bool operator()(const char* s1, const char* s2) const {
-    return strcmp(s1, s2) < 0;
-  }
+  bool operator()(const char* s1, const char* s2) const { return strcmp(s1, s2) < 0; }
 };
 
-
 // typedef hash_map<const char*, int, hash<const char*>, eqstr> count_map;
 typedef map<const char*, int, ltstr> count_map;
 
 class Server : public ServiceIf {
- public:
+public:
   Server() {}
 
   void count(const char* method) {
@@ -89,43 +84,46 @@
     return counts_;
   }
 
-  int8_t echoByte(const int8_t arg) {return arg;}
-  int32_t echoI32(const int32_t arg) {return arg;}
-  int64_t echoI64(const int64_t arg) {return arg;}
-  void echoString(string& out, const string &arg) {
+  int8_t echoByte(const int8_t arg) { return arg; }
+  int32_t echoI32(const int32_t arg) { return arg; }
+  int64_t echoI64(const int64_t arg) { return arg; }
+  void echoString(string& out, const string& arg) {
     if (arg != "hello") {
       T_ERROR_ABORT("WRONG STRING (%s)!!!!", arg.c_str());
     }
     out = arg;
   }
-  void echoList(vector<int8_t> &out, const vector<int8_t> &arg) { out = arg; }
-  void echoSet(set<int8_t> &out, const set<int8_t> &arg) { out = arg; }
-  void echoMap(map<int8_t, int8_t> &out, const map<int8_t, int8_t> &arg) { out = arg; }
+  void echoList(vector<int8_t>& out, const vector<int8_t>& arg) { out = arg; }
+  void echoSet(set<int8_t>& out, const set<int8_t>& arg) { out = arg; }
+  void echoMap(map<int8_t, int8_t>& out, const map<int8_t, int8_t>& arg) { out = arg; }
 
 private:
   count_map counts_;
   Mutex lock_;
-
 };
 
-class ClientThread: public Runnable {
+class ClientThread : public Runnable {
 public:
-
-  ClientThread(boost::shared_ptr<TTransport>transport, boost::shared_ptr<ServiceClient> client, Monitor& monitor, size_t& workerCount, size_t loopCount, TType loopType) :
-    _transport(transport),
-    _client(client),
-    _monitor(monitor),
-    _workerCount(workerCount),
-    _loopCount(loopCount),
-    _loopType(loopType)
-  {}
+  ClientThread(boost::shared_ptr<TTransport> transport,
+               boost::shared_ptr<ServiceClient> client,
+               Monitor& monitor,
+               size_t& workerCount,
+               size_t loopCount,
+               TType loopType)
+    : _transport(transport),
+      _client(client),
+      _monitor(monitor),
+      _workerCount(workerCount),
+      _loopCount(loopCount),
+      _loopType(loopType) {}
 
   void run() {
 
     // Wait for all worker threads to start
 
-    {Synchronized s(_monitor);
-      while(_workerCount == 0) {
+    {
+      Synchronized s(_monitor);
+      while (_workerCount == 0) {
         _monitor.wait();
       }
     }
@@ -134,13 +132,25 @@
 
     _transport->open();
 
-    switch(_loopType) {
-    case T_VOID: loopEchoVoid(); break;
-    case T_BYTE: loopEchoByte(); break;
-    case T_I32: loopEchoI32(); break;
-    case T_I64: loopEchoI64(); break;
-    case T_STRING: loopEchoString(); break;
-    default: cerr << "Unexpected loop type" << _loopType << endl; break;
+    switch (_loopType) {
+    case T_VOID:
+      loopEchoVoid();
+      break;
+    case T_BYTE:
+      loopEchoByte();
+      break;
+    case T_I32:
+      loopEchoI32();
+      break;
+    case T_I64:
+      loopEchoI64();
+      break;
+    case T_STRING:
+      loopEchoString();
+      break;
+    default:
+      cerr << "Unexpected loop type" << _loopType << endl;
+      break;
     }
 
     _endTime = Util::currentTime();
@@ -149,7 +159,8 @@
 
     _done = true;
 
-    {Synchronized s(_monitor);
+    {
+      Synchronized s(_monitor);
 
       _workerCount--;
 
@@ -170,7 +181,7 @@
     for (size_t ix = 0; ix < _loopCount; ix++) {
       int8_t arg = 1;
       int8_t result;
-      result =_client->echoByte(arg);
+      result = _client->echoByte(arg);
       (void)result;
       assert(result == arg);
     }
@@ -180,7 +191,7 @@
     for (size_t ix = 0; ix < _loopCount; ix++) {
       int32_t arg = 1;
       int32_t result;
-      result =_client->echoI32(arg);
+      result = _client->echoI32(arg);
       (void)result;
       assert(result == arg);
     }
@@ -190,7 +201,7 @@
     for (size_t ix = 0; ix < _loopCount; ix++) {
       int64_t arg = 1;
       int64_t result;
-      result =_client->echoI64(arg);
+      result = _client->echoI64(arg);
       (void)result;
       assert(result == arg);
     }
@@ -217,28 +228,26 @@
   Monitor _sleep;
 };
 
-class TStartObserver : public apache::thrift::server::TServerEventHandler
-{
+class TStartObserver : public apache::thrift::server::TServerEventHandler {
 public:
-   TStartObserver() : awake_(false) {}
-   virtual void preServe()
-   {
-      apache::thrift::concurrency::Synchronized s(m_);
-      awake_ = true;
-      m_.notifyAll();
-   }
-   void waitForService()
-   {
-      apache::thrift::concurrency::Synchronized s(m_);
-      while(!awake_)
-         m_.waitForever();
-   }
- private:
-   apache::thrift::concurrency::Monitor m_;
-   bool awake_;
+  TStartObserver() : awake_(false) {}
+  virtual void preServe() {
+    apache::thrift::concurrency::Synchronized s(m_);
+    awake_ = true;
+    m_.notifyAll();
+  }
+  void waitForService() {
+    apache::thrift::concurrency::Synchronized s(m_);
+    while (!awake_)
+      m_.waitForever();
+  }
+
+private:
+  apache::thrift::concurrency::Monitor m_;
+  bool awake_;
 };
 
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
 #if _WIN32
   transport::TWinsockSingleton::create();
 #endif
@@ -249,7 +258,7 @@
   size_t workerCount = 4;
   size_t clientCount = 20;
   size_t loopCount = 50000;
-  TType loopType  = T_VOID;
+  TType loopType = T_VOID;
   string callName = "echoVoid";
   bool runServer = true;
   bool logRequests = false;
@@ -258,28 +267,34 @@
 
   ostringstream usage;
 
-  usage <<
-    argv[0] << " [--port=<port number>] [--server] [--server-type=<server-type>] [--protocol-type=<protocol-type>] [--workers=<worker-count>] [--clients=<client-count>] [--loop=<loop-count>]" << endl <<
-    "\tclients        Number of client threads to create - 0 implies no clients, i.e. server only.  Default is " << clientCount << endl <<
-    "\thelp           Prints this help text." << endl <<
-    "\tcall           Service method to call.  Default is " << callName << endl <<
-    "\tloop           The number of remote thrift calls each client makes.  Default is " << loopCount << endl <<
-    "\tport           The port the server and clients should bind to for thrift network connections.  Default is " << port << endl <<
-    "\tserver         Run the Thrift server in this process.  Default is " << runServer << endl <<
-    "\tserver-type    Type of server, \"simple\" or \"thread-pool\".  Default is " << serverType << endl <<
-    "\tprotocol-type  Type of protocol, \"binary\", \"ascii\", or \"xml\".  Default is " << protocolType << endl <<
-    "\tlog-request    Log all request to ./requestlog.tlog. Default is " << logRequests << endl <<
-    "\treplay-request Replay requests from log file (./requestlog.tlog) Default is " << replayRequests << endl <<
-    "\tworkers        Number of thread pools workers.  Only valid for thread-pool server type.  Default is " << workerCount << endl;
+  usage << argv[0] << " [--port=<port number>] [--server] [--server-type=<server-type>] "
+                      "[--protocol-type=<protocol-type>] [--workers=<worker-count>] "
+                      "[--clients=<client-count>] [--loop=<loop-count>]" << endl
+        << "\tclients        Number of client threads to create - 0 implies no clients, i.e. "
+           "server only.  Default is " << clientCount << endl
+        << "\thelp           Prints this help text." << endl
+        << "\tcall           Service method to call.  Default is " << callName << endl
+        << "\tloop           The number of remote thrift calls each client makes.  Default is "
+        << loopCount << endl << "\tport           The port the server and clients should bind to "
+                                "for thrift network connections.  Default is " << port << endl
+        << "\tserver         Run the Thrift server in this process.  Default is " << runServer
+        << endl << "\tserver-type    Type of server, \"simple\" or \"thread-pool\".  Default is "
+        << serverType << endl
+        << "\tprotocol-type  Type of protocol, \"binary\", \"ascii\", or \"xml\".  Default is "
+        << protocolType << endl
+        << "\tlog-request    Log all request to ./requestlog.tlog. Default is " << logRequests
+        << endl << "\treplay-request Replay requests from log file (./requestlog.tlog) Default is "
+        << replayRequests << endl << "\tworkers        Number of thread pools workers.  Only valid "
+                                     "for thread-pool server type.  Default is " << workerCount
+        << endl;
 
-
-  map<string, string>  args;
+  map<string, string> args;
 
   for (int ix = 1; ix < argc; ix++) {
 
     string arg(argv[ix]);
 
-    if (arg.compare(0,2, "--") == 0) {
+    if (arg.compare(0, 2, "--") == 0) {
 
       size_t end = arg.find_first_of("=", 2);
 
@@ -291,7 +306,7 @@
         args[key] = "true";
       }
     } else {
-      throw invalid_argument("Unexcepted command line token: "+arg);
+      throw invalid_argument("Unexcepted command line token: " + arg);
     }
   }
 
@@ -341,7 +356,7 @@
 
       } else {
 
-        throw invalid_argument("Unknown server type "+serverType);
+        throw invalid_argument("Unknown server type " + serverType);
       }
     }
 
@@ -349,12 +364,13 @@
       workerCount = atoi(args["workers"].c_str());
     }
 
-  } catch(std::exception& e) {
+  } catch (std::exception& e) {
     cerr << e.what() << endl;
     cerr << usage.str();
   }
 
-  boost::shared_ptr<PlatformThreadFactory> threadFactory = boost::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
+  boost::shared_ptr<PlatformThreadFactory> threadFactory
+      = boost::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
 
   // Dispatcher
   boost::shared_ptr<Server> serviceHandler(new Server());
@@ -372,15 +388,12 @@
     // Protocol Factory
     boost::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
 
-    TFileProcessor fileProcessor(serviceProcessor,
-                                 protocolFactory,
-                                 fileTransport);
+    TFileProcessor fileProcessor(serviceProcessor, protocolFactory, fileTransport);
 
     fileProcessor.process(0, true);
     exit(0);
   }
 
-
   if (runServer) {
 
     boost::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler));
@@ -400,27 +413,34 @@
       fileTransport->setChunkSize(2 * 1024 * 1024);
       fileTransport->setMaxEventSize(1024 * 16);
 
-      transportFactory =
-        boost::shared_ptr<TTransportFactory>(new TPipedTransportFactory(fileTransport));
+      transportFactory
+          = boost::shared_ptr<TTransportFactory>(new TPipedTransportFactory(fileTransport));
     }
 
     boost::shared_ptr<TServer> server;
 
     if (serverType == "simple") {
 
-      server.reset(new TSimpleServer(serviceProcessor, serverSocket, transportFactory, protocolFactory));
+      server.reset(
+          new TSimpleServer(serviceProcessor, serverSocket, transportFactory, protocolFactory));
 
     } else if (serverType == "threaded") {
 
-      server.reset(new TThreadedServer(serviceProcessor, serverSocket, transportFactory, protocolFactory));
+      server.reset(
+          new TThreadedServer(serviceProcessor, serverSocket, transportFactory, protocolFactory));
 
     } else if (serverType == "thread-pool") {
 
-      boost::shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(workerCount);
+      boost::shared_ptr<ThreadManager> threadManager
+          = ThreadManager::newSimpleThreadManager(workerCount);
 
       threadManager->threadFactory(threadFactory);
       threadManager->start();
-      server.reset(new TThreadPoolServer(serviceProcessor, serverSocket, transportFactory, protocolFactory, threadManager));
+      server.reset(new TThreadPoolServer(serviceProcessor,
+                                         serverSocket,
+                                         transportFactory,
+                                         protocolFactory,
+                                         threadManager));
     }
 
     boost::shared_ptr<TStartObserver> observer(new TStartObserver);
@@ -446,12 +466,19 @@
 
     set<boost::shared_ptr<Thread> > clientThreads;
 
-    if (callName == "echoVoid") { loopType = T_VOID;}
-    else if (callName == "echoByte") { loopType = T_BYTE;}
-    else if (callName == "echoI32") { loopType = T_I32;}
-    else if (callName == "echoI64") { loopType = T_I64;}
-    else if (callName == "echoString") { loopType = T_STRING;}
-    else {throw invalid_argument("Unknown service call "+callName);}
+    if (callName == "echoVoid") {
+      loopType = T_VOID;
+    } else if (callName == "echoByte") {
+      loopType = T_BYTE;
+    } else if (callName == "echoI32") {
+      loopType = T_I32;
+    } else if (callName == "echoI64") {
+      loopType = T_I64;
+    } else if (callName == "echoString") {
+      loopType = T_STRING;
+    } else {
+      throw invalid_argument("Unknown service call " + callName);
+    }
 
     for (size_t ix = 0; ix < clientCount; ix++) {
 
@@ -460,30 +487,34 @@
       boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(bufferedSocket));
       boost::shared_ptr<ServiceClient> serviceClient(new ServiceClient(protocol));
 
-      clientThreads.insert(threadFactory->newThread(boost::shared_ptr<ClientThread>(new ClientThread(socket, serviceClient, monitor, threadCount, loopCount, loopType))));
+      clientThreads.insert(threadFactory->newThread(boost::shared_ptr<ClientThread>(
+          new ClientThread(socket, serviceClient, monitor, threadCount, loopCount, loopType))));
     }
 
-    for (std::set<boost::shared_ptr<Thread> >::const_iterator thread = clientThreads.begin(); thread != clientThreads.end(); thread++) {
+    for (std::set<boost::shared_ptr<Thread> >::const_iterator thread = clientThreads.begin();
+         thread != clientThreads.end();
+         thread++) {
       (*thread)->start();
     }
 
     int64_t time00;
     int64_t time01;
 
-    {Synchronized s(monitor);
+    {
+      Synchronized s(monitor);
       threadCount = clientCount;
 
-      cerr << "Launch "<< clientCount << " client threads" << endl;
+      cerr << "Launch " << clientCount << " client threads" << endl;
 
-      time00 =  Util::currentTime();
+      time00 = Util::currentTime();
 
       monitor.notifyAll();
 
-      while(threadCount > 0) {
+      while (threadCount > 0) {
         monitor.wait();
       }
 
-      time01 =  Util::currentTime();
+      time01 = Util::currentTime();
     }
 
     int64_t firstTime = 9223372036854775807LL;
@@ -493,9 +524,12 @@
     int64_t minTime = 9223372036854775807LL;
     int64_t maxTime = 0;
 
-    for (set<boost::shared_ptr<Thread> >::iterator ix = clientThreads.begin(); ix != clientThreads.end(); ix++) {
+    for (set<boost::shared_ptr<Thread> >::iterator ix = clientThreads.begin();
+         ix != clientThreads.end();
+         ix++) {
 
-      boost::shared_ptr<ClientThread> client = boost::dynamic_pointer_cast<ClientThread>((*ix)->runnable());
+      boost::shared_ptr<ClientThread> client
+          = boost::dynamic_pointer_cast<ClientThread>((*ix)->runnable());
 
       int64_t delta = client->_endTime - client->_startTime;
 
@@ -517,13 +551,13 @@
         maxTime = delta;
       }
 
-      averageTime+= delta;
+      averageTime += delta;
     }
 
     averageTime /= clientCount;
 
-
-    cout <<  "workers :" << workerCount << ", client : " << clientCount << ", loops : " << loopCount << ", rate : " << (clientCount * loopCount * 1000) / ((double)(time01 - time00)) << endl;
+    cout << "workers :" << workerCount << ", client : " << clientCount << ", loops : " << loopCount
+         << ", rate : " << (clientCount * loopCount * 1000) / ((double)(time01 - time00)) << endl;
 
     count_map count = serviceHandler->getCount();
     count_map::iterator iter;