auser-poolparty 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (353) hide show
  1. data/VERSION.yml +1 -1
  2. data/examples/monitored_cloud.rb +1 -1
  3. data/examples/thrift/thrift_example.rb +1 -1
  4. data/lib/proto/command_interface_handler.rb +1 -1
  5. data/vendor/gems/thrift/CHANGES +35 -0
  6. data/vendor/gems/thrift/CONTRIBUTORS +77 -0
  7. data/vendor/gems/thrift/DISCLAIMER +6 -0
  8. data/vendor/gems/thrift/LICENSE +202 -0
  9. data/vendor/gems/thrift/Makefile.am +28 -0
  10. data/vendor/gems/thrift/NEWS +79 -0
  11. data/vendor/gems/thrift/NOTICE +26 -0
  12. data/vendor/gems/thrift/README +137 -0
  13. data/vendor/gems/thrift/aclocal/ax_boost_base.m4 +198 -0
  14. data/vendor/gems/thrift/aclocal/ax_javac_and_java.m4 +107 -0
  15. data/vendor/gems/thrift/aclocal/ax_lib_event.m4 +194 -0
  16. data/vendor/gems/thrift/aclocal/ax_lib_zlib.m4 +173 -0
  17. data/vendor/gems/thrift/aclocal/ax_signed_right_shift.m4 +127 -0
  18. data/vendor/gems/thrift/aclocal/ax_thrift_internal.m4 +39 -0
  19. data/vendor/gems/thrift/bootstrap.sh +35 -0
  20. data/vendor/gems/thrift/cleanup.sh +58 -0
  21. data/vendor/gems/thrift/compiler/cpp/Makefile.am +136 -0
  22. data/vendor/gems/thrift/compiler/cpp/README +39 -0
  23. data/vendor/gems/thrift/compiler/cpp/src/generate/t_cocoa_generator.cc +2331 -0
  24. data/vendor/gems/thrift/compiler/cpp/src/generate/t_cpp_generator.cc +3003 -0
  25. data/vendor/gems/thrift/compiler/cpp/src/generate/t_csharp_generator.cc +1700 -0
  26. data/vendor/gems/thrift/compiler/cpp/src/generate/t_erl_generator.cc +932 -0
  27. data/vendor/gems/thrift/compiler/cpp/src/generate/t_generator.cc +173 -0
  28. data/vendor/gems/thrift/compiler/cpp/src/generate/t_generator.h +321 -0
  29. data/vendor/gems/thrift/compiler/cpp/src/generate/t_hs_generator.cc +1445 -0
  30. data/vendor/gems/thrift/compiler/cpp/src/generate/t_html_generator.cc +637 -0
  31. data/vendor/gems/thrift/compiler/cpp/src/generate/t_java_generator.cc +3069 -0
  32. data/vendor/gems/thrift/compiler/cpp/src/generate/t_ocaml_generator.cc +1673 -0
  33. data/vendor/gems/thrift/compiler/cpp/src/generate/t_oop_generator.h +77 -0
  34. data/vendor/gems/thrift/compiler/cpp/src/generate/t_perl_generator.cc +1812 -0
  35. data/vendor/gems/thrift/compiler/cpp/src/generate/t_php_generator.cc +2281 -0
  36. data/vendor/gems/thrift/compiler/cpp/src/generate/t_py_generator.cc +2310 -0
  37. data/vendor/gems/thrift/compiler/cpp/src/generate/t_rb_generator.cc +1114 -0
  38. data/vendor/gems/thrift/compiler/cpp/src/generate/t_st_generator.cc +1071 -0
  39. data/vendor/gems/thrift/compiler/cpp/src/generate/t_xsd_generator.cc +354 -0
  40. data/vendor/gems/thrift/compiler/cpp/src/globals.h +117 -0
  41. data/vendor/gems/thrift/compiler/cpp/src/main.cc +1207 -0
  42. data/vendor/gems/thrift/compiler/cpp/src/main.h +103 -0
  43. data/vendor/gems/thrift/compiler/cpp/src/md5.c +381 -0
  44. data/vendor/gems/thrift/compiler/cpp/src/md5.h +91 -0
  45. data/vendor/gems/thrift/compiler/cpp/src/parse/t_base_type.h +137 -0
  46. data/vendor/gems/thrift/compiler/cpp/src/parse/t_const.h +59 -0
  47. data/vendor/gems/thrift/compiler/cpp/src/parse/t_const_value.h +121 -0
  48. data/vendor/gems/thrift/compiler/cpp/src/parse/t_container.h +56 -0
  49. data/vendor/gems/thrift/compiler/cpp/src/parse/t_doc.h +51 -0
  50. data/vendor/gems/thrift/compiler/cpp/src/parse/t_enum.h +59 -0
  51. data/vendor/gems/thrift/compiler/cpp/src/parse/t_enum_value.h +64 -0
  52. data/vendor/gems/thrift/compiler/cpp/src/parse/t_field.h +150 -0
  53. data/vendor/gems/thrift/compiler/cpp/src/parse/t_function.h +93 -0
  54. data/vendor/gems/thrift/compiler/cpp/src/parse/t_list.h +56 -0
  55. data/vendor/gems/thrift/compiler/cpp/src/parse/t_map.h +64 -0
  56. data/vendor/gems/thrift/compiler/cpp/src/parse/t_program.h +223 -0
  57. data/vendor/gems/thrift/compiler/cpp/src/parse/t_scope.h +86 -0
  58. data/vendor/gems/thrift/compiler/cpp/src/parse/t_service.h +68 -0
  59. data/vendor/gems/thrift/compiler/cpp/src/parse/t_set.h +55 -0
  60. data/vendor/gems/thrift/compiler/cpp/src/parse/t_struct.h +127 -0
  61. data/vendor/gems/thrift/compiler/cpp/src/parse/t_type.h +176 -0
  62. data/vendor/gems/thrift/compiler/cpp/src/parse/t_typedef.h +70 -0
  63. data/vendor/gems/thrift/compiler/cpp/src/platform.h +36 -0
  64. data/vendor/gems/thrift/compiler/cpp/src/thriftl.ll +303 -0
  65. data/vendor/gems/thrift/compiler/cpp/src/thrifty.yy +1140 -0
  66. data/vendor/gems/thrift/configure.ac +255 -0
  67. data/vendor/gems/thrift/contrib/fb303/LICENSE +16 -0
  68. data/vendor/gems/thrift/contrib/fb303/Makefile.am +31 -0
  69. data/vendor/gems/thrift/contrib/fb303/README +37 -0
  70. data/vendor/gems/thrift/contrib/fb303/acinclude.m4 +258 -0
  71. data/vendor/gems/thrift/contrib/fb303/aclocal/ax_boost_base.m4 +198 -0
  72. data/vendor/gems/thrift/contrib/fb303/bootstrap.sh +26 -0
  73. data/vendor/gems/thrift/contrib/fb303/configure.ac +115 -0
  74. data/vendor/gems/thrift/contrib/fb303/cpp/FacebookBase.cpp +124 -0
  75. data/vendor/gems/thrift/contrib/fb303/cpp/FacebookBase.h +103 -0
  76. data/vendor/gems/thrift/contrib/fb303/cpp/Makefile.am +84 -0
  77. data/vendor/gems/thrift/contrib/fb303/cpp/ServiceTracker.cpp +481 -0
  78. data/vendor/gems/thrift/contrib/fb303/cpp/ServiceTracker.h +215 -0
  79. data/vendor/gems/thrift/contrib/fb303/global_footer.mk +21 -0
  80. data/vendor/gems/thrift/contrib/fb303/global_header.mk +38 -0
  81. data/vendor/gems/thrift/contrib/fb303/if/fb303.thrift +112 -0
  82. data/vendor/gems/thrift/contrib/fb303/java/FacebookBase.java +103 -0
  83. data/vendor/gems/thrift/contrib/fb303/java/build.xml +84 -0
  84. data/vendor/gems/thrift/contrib/fb303/php/FacebookBase.php +89 -0
  85. data/vendor/gems/thrift/contrib/fb303/py/Makefile.am +44 -0
  86. data/vendor/gems/thrift/contrib/fb303/py/fb303/FacebookBase.py +82 -0
  87. data/vendor/gems/thrift/contrib/fb303/py/fb303_scripts/__init__.py +20 -0
  88. data/vendor/gems/thrift/contrib/fb303/py/fb303_scripts/fb303_simple_mgmt.py +195 -0
  89. data/vendor/gems/thrift/contrib/fb303/py/setup.py +27 -0
  90. data/vendor/gems/thrift/contrib/thrift.el +126 -0
  91. data/vendor/gems/thrift/contrib/thrift.spec +206 -0
  92. data/vendor/gems/thrift/contrib/thrift.vim +91 -0
  93. data/vendor/gems/thrift/contrib/thrift_dump.cpp +91 -0
  94. data/vendor/gems/thrift/doc/lgpl-2.1.txt +504 -0
  95. data/vendor/gems/thrift/doc/otp-base-license.txt +20 -0
  96. data/vendor/gems/thrift/doc/thrift.bnf +96 -0
  97. data/vendor/gems/thrift/doc/thrift.tex +1057 -0
  98. data/vendor/gems/thrift/lib/Makefile.am +55 -0
  99. data/vendor/gems/thrift/lib/cocoa/README +21 -0
  100. data/vendor/gems/thrift/lib/cocoa/src/TApplicationException.h +44 -0
  101. data/vendor/gems/thrift/lib/cocoa/src/TApplicationException.m +130 -0
  102. data/vendor/gems/thrift/lib/cocoa/src/TException.h +34 -0
  103. data/vendor/gems/thrift/lib/cocoa/src/TException.m +64 -0
  104. data/vendor/gems/thrift/lib/cocoa/src/TProcessor.h +29 -0
  105. data/vendor/gems/thrift/lib/cocoa/src/TProcessorFactory.h +27 -0
  106. data/vendor/gems/thrift/lib/cocoa/src/TSharedProcessorFactory.h +27 -0
  107. data/vendor/gems/thrift/lib/cocoa/src/TSharedProcessorFactory.m +51 -0
  108. data/vendor/gems/thrift/lib/cocoa/src/protocol/TBinaryProtocol.h +51 -0
  109. data/vendor/gems/thrift/lib/cocoa/src/protocol/TBinaryProtocol.m +477 -0
  110. data/vendor/gems/thrift/lib/cocoa/src/protocol/TProtocol.h +148 -0
  111. data/vendor/gems/thrift/lib/cocoa/src/protocol/TProtocolException.h +25 -0
  112. data/vendor/gems/thrift/lib/cocoa/src/protocol/TProtocolException.m +23 -0
  113. data/vendor/gems/thrift/lib/cocoa/src/protocol/TProtocolFactory.h +29 -0
  114. data/vendor/gems/thrift/lib/cocoa/src/protocol/TProtocolUtil.h +29 -0
  115. data/vendor/gems/thrift/lib/cocoa/src/protocol/TProtocolUtil.m +104 -0
  116. data/vendor/gems/thrift/lib/cocoa/src/server/TSocketServer.h +50 -0
  117. data/vendor/gems/thrift/lib/cocoa/src/server/TSocketServer.m +153 -0
  118. data/vendor/gems/thrift/lib/cocoa/src/transport/THTTPClient.h +42 -0
  119. data/vendor/gems/thrift/lib/cocoa/src/transport/THTTPClient.m +159 -0
  120. data/vendor/gems/thrift/lib/cocoa/src/transport/TNSFileHandleTransport.h +35 -0
  121. data/vendor/gems/thrift/lib/cocoa/src/transport/TNSFileHandleTransport.m +91 -0
  122. data/vendor/gems/thrift/lib/cocoa/src/transport/TNSStreamTransport.h +38 -0
  123. data/vendor/gems/thrift/lib/cocoa/src/transport/TNSStreamTransport.m +89 -0
  124. data/vendor/gems/thrift/lib/cocoa/src/transport/TSocketClient.h +32 -0
  125. data/vendor/gems/thrift/lib/cocoa/src/transport/TSocketClient.m +58 -0
  126. data/vendor/gems/thrift/lib/cocoa/src/transport/TTransport.h +36 -0
  127. data/vendor/gems/thrift/lib/cocoa/src/transport/TTransportException.h +30 -0
  128. data/vendor/gems/thrift/lib/cocoa/src/transport/TTransportException.m +43 -0
  129. data/vendor/gems/thrift/lib/cpp/Makefile.am +158 -0
  130. data/vendor/gems/thrift/lib/cpp/README +67 -0
  131. data/vendor/gems/thrift/lib/cpp/src/TLogging.h +163 -0
  132. data/vendor/gems/thrift/lib/cpp/src/TProcessor.h +53 -0
  133. data/vendor/gems/thrift/lib/cpp/src/TReflectionLocal.h +96 -0
  134. data/vendor/gems/thrift/lib/cpp/src/Thrift.cpp +148 -0
  135. data/vendor/gems/thrift/lib/cpp/src/Thrift.h +191 -0
  136. data/vendor/gems/thrift/lib/cpp/src/concurrency/Exception.h +60 -0
  137. data/vendor/gems/thrift/lib/cpp/src/concurrency/FunctionRunner.h +77 -0
  138. data/vendor/gems/thrift/lib/cpp/src/concurrency/Monitor.cpp +137 -0
  139. data/vendor/gems/thrift/lib/cpp/src/concurrency/Monitor.h +84 -0
  140. data/vendor/gems/thrift/lib/cpp/src/concurrency/Mutex.cpp +160 -0
  141. data/vendor/gems/thrift/lib/cpp/src/concurrency/Mutex.h +114 -0
  142. data/vendor/gems/thrift/lib/cpp/src/concurrency/PosixThreadFactory.cpp +314 -0
  143. data/vendor/gems/thrift/lib/cpp/src/concurrency/PosixThreadFactory.h +130 -0
  144. data/vendor/gems/thrift/lib/cpp/src/concurrency/Thread.h +125 -0
  145. data/vendor/gems/thrift/lib/cpp/src/concurrency/ThreadManager.cpp +493 -0
  146. data/vendor/gems/thrift/lib/cpp/src/concurrency/ThreadManager.h +169 -0
  147. data/vendor/gems/thrift/lib/cpp/src/concurrency/TimerManager.cpp +284 -0
  148. data/vendor/gems/thrift/lib/cpp/src/concurrency/TimerManager.h +122 -0
  149. data/vendor/gems/thrift/lib/cpp/src/concurrency/Util.cpp +55 -0
  150. data/vendor/gems/thrift/lib/cpp/src/concurrency/Util.h +100 -0
  151. data/vendor/gems/thrift/lib/cpp/src/concurrency/test/Tests.cpp +155 -0
  152. data/vendor/gems/thrift/lib/cpp/src/concurrency/test/ThreadFactoryTests.h +354 -0
  153. data/vendor/gems/thrift/lib/cpp/src/concurrency/test/ThreadManagerTests.h +379 -0
  154. data/vendor/gems/thrift/lib/cpp/src/concurrency/test/TimerManagerTests.h +155 -0
  155. data/vendor/gems/thrift/lib/cpp/src/processor/PeekProcessor.cpp +122 -0
  156. data/vendor/gems/thrift/lib/cpp/src/processor/PeekProcessor.h +77 -0
  157. data/vendor/gems/thrift/lib/cpp/src/processor/StatsProcessor.h +264 -0
  158. data/vendor/gems/thrift/lib/cpp/src/protocol/TBase64Utils.cpp +79 -0
  159. data/vendor/gems/thrift/lib/cpp/src/protocol/TBase64Utils.h +42 -0
  160. data/vendor/gems/thrift/lib/cpp/src/protocol/TBinaryProtocol.cpp +394 -0
  161. data/vendor/gems/thrift/lib/cpp/src/protocol/TBinaryProtocol.h +254 -0
  162. data/vendor/gems/thrift/lib/cpp/src/protocol/TCompactProtocol.cpp +736 -0
  163. data/vendor/gems/thrift/lib/cpp/src/protocol/TCompactProtocol.h +279 -0
  164. data/vendor/gems/thrift/lib/cpp/src/protocol/TDebugProtocol.cpp +346 -0
  165. data/vendor/gems/thrift/lib/cpp/src/protocol/TDebugProtocol.h +225 -0
  166. data/vendor/gems/thrift/lib/cpp/src/protocol/TDenseProtocol.cpp +762 -0
  167. data/vendor/gems/thrift/lib/cpp/src/protocol/TDenseProtocol.h +253 -0
  168. data/vendor/gems/thrift/lib/cpp/src/protocol/TJSONProtocol.cpp +998 -0
  169. data/vendor/gems/thrift/lib/cpp/src/protocol/TJSONProtocol.h +340 -0
  170. data/vendor/gems/thrift/lib/cpp/src/protocol/TOneWayProtocol.h +304 -0
  171. data/vendor/gems/thrift/lib/cpp/src/protocol/TProtocol.h +438 -0
  172. data/vendor/gems/thrift/lib/cpp/src/protocol/TProtocolException.h +104 -0
  173. data/vendor/gems/thrift/lib/cpp/src/protocol/TProtocolTap.h +187 -0
  174. data/vendor/gems/thrift/lib/cpp/src/server/TNonblockingServer.cpp +750 -0
  175. data/vendor/gems/thrift/lib/cpp/src/server/TNonblockingServer.h +435 -0
  176. data/vendor/gems/thrift/lib/cpp/src/server/TServer.cpp +38 -0
  177. data/vendor/gems/thrift/lib/cpp/src/server/TServer.h +213 -0
  178. data/vendor/gems/thrift/lib/cpp/src/server/TSimpleServer.cpp +118 -0
  179. data/vendor/gems/thrift/lib/cpp/src/server/TSimpleServer.h +70 -0
  180. data/vendor/gems/thrift/lib/cpp/src/server/TThreadPoolServer.cpp +217 -0
  181. data/vendor/gems/thrift/lib/cpp/src/server/TThreadPoolServer.h +79 -0
  182. data/vendor/gems/thrift/lib/cpp/src/server/TThreadedServer.cpp +243 -0
  183. data/vendor/gems/thrift/lib/cpp/src/server/TThreadedServer.h +74 -0
  184. data/vendor/gems/thrift/lib/cpp/src/transport/TBufferTransports.cpp +370 -0
  185. data/vendor/gems/thrift/lib/cpp/src/transport/TBufferTransports.h +667 -0
  186. data/vendor/gems/thrift/lib/cpp/src/transport/TFDTransport.cpp +77 -0
  187. data/vendor/gems/thrift/lib/cpp/src/transport/TFDTransport.h +73 -0
  188. data/vendor/gems/thrift/lib/cpp/src/transport/TFileTransport.cpp +953 -0
  189. data/vendor/gems/thrift/lib/cpp/src/transport/TFileTransport.h +442 -0
  190. data/vendor/gems/thrift/lib/cpp/src/transport/THttpClient.cpp +348 -0
  191. data/vendor/gems/thrift/lib/cpp/src/transport/THttpClient.h +111 -0
  192. data/vendor/gems/thrift/lib/cpp/src/transport/TServerSocket.cpp +368 -0
  193. data/vendor/gems/thrift/lib/cpp/src/transport/TServerSocket.h +76 -0
  194. data/vendor/gems/thrift/lib/cpp/src/transport/TServerTransport.h +92 -0
  195. data/vendor/gems/thrift/lib/cpp/src/transport/TShortReadTransport.h +96 -0
  196. data/vendor/gems/thrift/lib/cpp/src/transport/TSimpleFileTransport.cpp +54 -0
  197. data/vendor/gems/thrift/lib/cpp/src/transport/TSimpleFileTransport.h +41 -0
  198. data/vendor/gems/thrift/lib/cpp/src/transport/TSocket.cpp +591 -0
  199. data/vendor/gems/thrift/lib/cpp/src/transport/TSocket.h +242 -0
  200. data/vendor/gems/thrift/lib/cpp/src/transport/TSocketPool.cpp +235 -0
  201. data/vendor/gems/thrift/lib/cpp/src/transport/TSocketPool.h +191 -0
  202. data/vendor/gems/thrift/lib/cpp/src/transport/TTransport.h +224 -0
  203. data/vendor/gems/thrift/lib/cpp/src/transport/TTransportException.cpp +31 -0
  204. data/vendor/gems/thrift/lib/cpp/src/transport/TTransportException.h +117 -0
  205. data/vendor/gems/thrift/lib/cpp/src/transport/TTransportUtils.cpp +178 -0
  206. data/vendor/gems/thrift/lib/cpp/src/transport/TTransportUtils.h +287 -0
  207. data/vendor/gems/thrift/lib/cpp/src/transport/TZlibTransport.cpp +299 -0
  208. data/vendor/gems/thrift/lib/cpp/src/transport/TZlibTransport.h +219 -0
  209. data/vendor/gems/thrift/lib/cpp/thrift-nb.pc.in +30 -0
  210. data/vendor/gems/thrift/lib/cpp/thrift-z.pc.in +30 -0
  211. data/vendor/gems/thrift/lib/cpp/thrift.pc.in +29 -0
  212. data/vendor/gems/thrift/lib/csharp/Makefile.am +70 -0
  213. data/vendor/gems/thrift/lib/csharp/README +26 -0
  214. data/vendor/gems/thrift/lib/csharp/ThriftMSBuildTask/Properties/AssemblyInfo.cs +55 -0
  215. data/vendor/gems/thrift/lib/csharp/ThriftMSBuildTask/ThriftBuild.cs +242 -0
  216. data/vendor/gems/thrift/lib/csharp/ThriftMSBuildTask/ThriftMSBuildTask.csproj +62 -0
  217. data/vendor/gems/thrift/lib/csharp/src/Collections/THashSet.cs +142 -0
  218. data/vendor/gems/thrift/lib/csharp/src/Protocol/TBase.cs +34 -0
  219. data/vendor/gems/thrift/lib/csharp/src/Protocol/TBinaryProtocol.cs +392 -0
  220. data/vendor/gems/thrift/lib/csharp/src/Protocol/TField.cs +58 -0
  221. data/vendor/gems/thrift/lib/csharp/src/Protocol/TList.cs +50 -0
  222. data/vendor/gems/thrift/lib/csharp/src/Protocol/TMap.cs +58 -0
  223. data/vendor/gems/thrift/lib/csharp/src/Protocol/TMessage.cs +58 -0
  224. data/vendor/gems/thrift/lib/csharp/src/Protocol/TMessageType.cs +31 -0
  225. data/vendor/gems/thrift/lib/csharp/src/Protocol/TProtocol.cs +87 -0
  226. data/vendor/gems/thrift/lib/csharp/src/Protocol/TProtocolException.cs +61 -0
  227. data/vendor/gems/thrift/lib/csharp/src/Protocol/TProtocolFactory.cs +29 -0
  228. data/vendor/gems/thrift/lib/csharp/src/Protocol/TProtocolUtil.cs +94 -0
  229. data/vendor/gems/thrift/lib/csharp/src/Protocol/TSet.cs +50 -0
  230. data/vendor/gems/thrift/lib/csharp/src/Protocol/TStruct.cs +42 -0
  231. data/vendor/gems/thrift/lib/csharp/src/Protocol/TType.cs +40 -0
  232. data/vendor/gems/thrift/lib/csharp/src/Server/TServer.cs +135 -0
  233. data/vendor/gems/thrift/lib/csharp/src/Server/TSimpleServer.cs +148 -0
  234. data/vendor/gems/thrift/lib/csharp/src/Server/TThreadPoolServer.cs +186 -0
  235. data/vendor/gems/thrift/lib/csharp/src/Server/TThreadedServer.cs +234 -0
  236. data/vendor/gems/thrift/lib/csharp/src/TApplicationException.cs +131 -0
  237. data/vendor/gems/thrift/lib/csharp/src/TProcessor.cs +29 -0
  238. data/vendor/gems/thrift/lib/csharp/src/Thrift.csproj +73 -0
  239. data/vendor/gems/thrift/lib/csharp/src/Thrift.sln +35 -0
  240. data/vendor/gems/thrift/lib/csharp/src/Transport/TBufferedTransport.cs +100 -0
  241. data/vendor/gems/thrift/lib/csharp/src/Transport/TServerSocket.cs +157 -0
  242. data/vendor/gems/thrift/lib/csharp/src/Transport/TServerTransport.cs +39 -0
  243. data/vendor/gems/thrift/lib/csharp/src/Transport/TSocket.cs +144 -0
  244. data/vendor/gems/thrift/lib/csharp/src/Transport/TStreamTransport.cs +103 -0
  245. data/vendor/gems/thrift/lib/csharp/src/Transport/TTransport.cs +66 -0
  246. data/vendor/gems/thrift/lib/csharp/src/Transport/TTransportException.cs +64 -0
  247. data/vendor/gems/thrift/lib/csharp/src/Transport/TTransportFactory.cs +38 -0
  248. data/vendor/gems/thrift/lib/erl/Makefile +37 -0
  249. data/vendor/gems/thrift/lib/erl/README +56 -0
  250. data/vendor/gems/thrift/lib/erl/build/beamver +59 -0
  251. data/vendor/gems/thrift/lib/erl/build/buildtargets.mk +15 -0
  252. data/vendor/gems/thrift/lib/erl/build/colors.mk +24 -0
  253. data/vendor/gems/thrift/lib/erl/build/docs.mk +12 -0
  254. data/vendor/gems/thrift/lib/erl/build/mime.types +98 -0
  255. data/vendor/gems/thrift/lib/erl/build/otp.mk +146 -0
  256. data/vendor/gems/thrift/lib/erl/build/otp_subdir.mk +85 -0
  257. data/vendor/gems/thrift/lib/erl/build/raw_test.mk +29 -0
  258. data/vendor/gems/thrift/lib/erl/include/thrift_constants.hrl +54 -0
  259. data/vendor/gems/thrift/lib/erl/include/thrift_protocol.hrl +31 -0
  260. data/vendor/gems/thrift/lib/erl/src/Makefile +116 -0
  261. data/vendor/gems/thrift/lib/erl/src/test_handler.erl +26 -0
  262. data/vendor/gems/thrift/lib/erl/src/test_service.erl +29 -0
  263. data/vendor/gems/thrift/lib/erl/src/thrift.app.src +44 -0
  264. data/vendor/gems/thrift/lib/erl/src/thrift.appup.src +1 -0
  265. data/vendor/gems/thrift/lib/erl/src/thrift_base64_transport.erl +64 -0
  266. data/vendor/gems/thrift/lib/erl/src/thrift_binary_protocol.erl +325 -0
  267. data/vendor/gems/thrift/lib/erl/src/thrift_buffered_transport.erl +180 -0
  268. data/vendor/gems/thrift/lib/erl/src/thrift_client.erl +384 -0
  269. data/vendor/gems/thrift/lib/erl/src/thrift_disk_log_transport.erl +118 -0
  270. data/vendor/gems/thrift/lib/erl/src/thrift_file_transport.erl +87 -0
  271. data/vendor/gems/thrift/lib/erl/src/thrift_framed_transport.erl +208 -0
  272. data/vendor/gems/thrift/lib/erl/src/thrift_http_transport.erl +199 -0
  273. data/vendor/gems/thrift/lib/erl/src/thrift_memory_buffer.erl +164 -0
  274. data/vendor/gems/thrift/lib/erl/src/thrift_processor.erl +188 -0
  275. data/vendor/gems/thrift/lib/erl/src/thrift_protocol.erl +356 -0
  276. data/vendor/gems/thrift/lib/erl/src/thrift_server.erl +183 -0
  277. data/vendor/gems/thrift/lib/erl/src/thrift_service.erl +25 -0
  278. data/vendor/gems/thrift/lib/erl/src/thrift_socket_server.erl +249 -0
  279. data/vendor/gems/thrift/lib/erl/src/thrift_socket_transport.erl +119 -0
  280. data/vendor/gems/thrift/lib/erl/src/thrift_transport.erl +57 -0
  281. data/vendor/gems/thrift/lib/erl/vsn.mk +1 -0
  282. data/vendor/gems/thrift/lib/hs/README +82 -0
  283. data/vendor/gems/thrift/lib/hs/Setup.lhs +23 -0
  284. data/vendor/gems/thrift/lib/hs/TODO +2 -0
  285. data/vendor/gems/thrift/lib/hs/Thrift.cabal +20 -0
  286. data/vendor/gems/thrift/lib/hs/src/Thrift.hs +111 -0
  287. data/vendor/gems/thrift/lib/hs/src/Thrift/Protocol.hs +191 -0
  288. data/vendor/gems/thrift/lib/hs/src/Thrift/Protocol/Binary.hs +147 -0
  289. data/vendor/gems/thrift/lib/hs/src/Thrift/Server.hs +65 -0
  290. data/vendor/gems/thrift/lib/hs/src/Thrift/Transport.hs +60 -0
  291. data/vendor/gems/thrift/lib/hs/src/Thrift/Transport/Handle.hs +58 -0
  292. data/vendor/gems/thrift/lib/java/Makefile.am +38 -0
  293. data/vendor/gems/thrift/lib/java/README +43 -0
  294. data/vendor/gems/thrift/lib/java/build.xml +195 -0
  295. data/vendor/gems/thrift/lib/java/ivy.xml +8 -0
  296. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/IntRangeSet.java +171 -0
  297. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TApplicationException.java +123 -0
  298. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TBase.java +66 -0
  299. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TBaseHelper.java +102 -0
  300. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TByteArrayOutputStream.java +46 -0
  301. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TDeserializer.java +94 -0
  302. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TException.java +45 -0
  303. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TFieldRequirementType.java +30 -0
  304. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TProcessor.java +32 -0
  305. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TProcessorFactory.java +39 -0
  306. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TSerializer.java +110 -0
  307. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/meta_data/FieldMetaData.java +69 -0
  308. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/meta_data/FieldValueMetaData.java +42 -0
  309. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/meta_data/ListMetaData.java +29 -0
  310. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/meta_data/MapMetaData.java +31 -0
  311. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/meta_data/SetMetaData.java +29 -0
  312. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/meta_data/StructMetaData.java +31 -0
  313. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TBase64Utils.java +128 -0
  314. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TBinaryProtocol.java +331 -0
  315. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TCompactProtocol.java +741 -0
  316. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TField.java +48 -0
  317. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TJSONProtocol.java +927 -0
  318. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TList.java +38 -0
  319. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TMap.java +40 -0
  320. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TMessage.java +48 -0
  321. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TMessageType.java +31 -0
  322. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TProtocol.java +146 -0
  323. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TProtocolException.java +81 -0
  324. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TProtocolFactory.java +30 -0
  325. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TProtocolUtil.java +158 -0
  326. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TSet.java +42 -0
  327. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TSimpleJSONProtocol.java +384 -0
  328. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TStruct.java +36 -0
  329. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TType.java +40 -0
  330. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/server/THsHaServer.java +304 -0
  331. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/server/TNonblockingServer.java +772 -0
  332. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/server/TServer.java +126 -0
  333. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/server/TSimpleServer.java +145 -0
  334. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/server/TThreadPoolServer.java +271 -0
  335. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/transport/TFramedTransport.java +126 -0
  336. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/transport/THttpClient.java +157 -0
  337. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/transport/TIOStreamTransport.java +159 -0
  338. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/transport/TMemoryBuffer.java +98 -0
  339. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/transport/TNonblockingServerSocket.java +160 -0
  340. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/transport/TNonblockingServerTransport.java +31 -0
  341. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/transport/TNonblockingSocket.java +213 -0
  342. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/transport/TNonblockingTransport.java +31 -0
  343. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/transport/TServerSocket.java +145 -0
  344. metadata +348 -37
  345. data/vendor/gems/trollop/FAQ.txt +0 -35
  346. data/vendor/gems/trollop/History.txt +0 -84
  347. data/vendor/gems/trollop/Manifest.txt +0 -7
  348. data/vendor/gems/trollop/README.txt +0 -38
  349. data/vendor/gems/trollop/Rakefile +0 -36
  350. data/vendor/gems/trollop/lib/trollop.rb +0 -695
  351. data/vendor/gems/trollop/release-script.txt +0 -13
  352. data/vendor/gems/trollop/test/test_trollop.rb +0 -957
  353. data/vendor/gems/trollop/www/index.html +0 -167
@@ -0,0 +1,77 @@
1
+ /*
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+
20
+ #include <cerrno>
21
+ #include <exception>
22
+
23
+ #include <transport/TFDTransport.h>
24
+
25
+ #include <unistd.h>
26
+
27
+ using namespace std;
28
+
29
+ namespace apache { namespace thrift { namespace transport {
30
+
31
+ void TFDTransport::close() {
32
+ if (!isOpen()) {
33
+ return;
34
+ }
35
+
36
+ int rv = ::close(fd_);
37
+ int errno_copy = errno;
38
+ fd_ = -1;
39
+ // Have to check uncaught_exception because this is called in the destructor.
40
+ if (rv < 0 && !std::uncaught_exception()) {
41
+ throw TTransportException(TTransportException::UNKNOWN,
42
+ "TFDTransport::close()",
43
+ errno_copy);
44
+ }
45
+ }
46
+
47
+ uint32_t TFDTransport::read(uint8_t* buf, uint32_t len) {
48
+ ssize_t rv = ::read(fd_, buf, len);
49
+ if (rv < 0) {
50
+ int errno_copy = errno;
51
+ throw TTransportException(TTransportException::UNKNOWN,
52
+ "TFDTransport::read()",
53
+ errno_copy);
54
+ }
55
+ return rv;
56
+ }
57
+
58
+ void TFDTransport::write(const uint8_t* buf, uint32_t len) {
59
+ while (len > 0) {
60
+ ssize_t rv = ::write(fd_, buf, len);
61
+
62
+ if (rv < 0) {
63
+ int errno_copy = errno;
64
+ throw TTransportException(TTransportException::UNKNOWN,
65
+ "TFDTransport::write()",
66
+ errno_copy);
67
+ } else if (rv == 0) {
68
+ throw TTransportException(TTransportException::END_OF_FILE,
69
+ "TFDTransport::write()");
70
+ }
71
+
72
+ buf += rv;
73
+ len -= rv;
74
+ }
75
+ }
76
+
77
+ }}} // apache::thrift::transport
@@ -0,0 +1,73 @@
1
+ /*
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+
20
+ #ifndef _THRIFT_TRANSPORT_TFDTRANSPORT_H_
21
+ #define _THRIFT_TRANSPORT_TFDTRANSPORT_H_ 1
22
+
23
+ #include <string>
24
+ #include <sys/time.h>
25
+
26
+ #include "TTransport.h"
27
+ #include "TServerSocket.h"
28
+
29
+ namespace apache { namespace thrift { namespace transport {
30
+
31
+ /**
32
+ * Dead-simple wrapper around a file descriptor.
33
+ *
34
+ */
35
+ class TFDTransport : public TTransport {
36
+ public:
37
+ enum ClosePolicy
38
+ { NO_CLOSE_ON_DESTROY = 0
39
+ , CLOSE_ON_DESTROY = 1
40
+ };
41
+
42
+ TFDTransport(int fd, ClosePolicy close_policy = NO_CLOSE_ON_DESTROY)
43
+ : fd_(fd)
44
+ , close_policy_(close_policy)
45
+ {}
46
+
47
+ ~TFDTransport() {
48
+ if (close_policy_ == CLOSE_ON_DESTROY) {
49
+ close();
50
+ }
51
+ }
52
+
53
+ bool isOpen() { return fd_ >= 0; }
54
+
55
+ void open() {}
56
+
57
+ void close();
58
+
59
+ uint32_t read(uint8_t* buf, uint32_t len);
60
+
61
+ void write(const uint8_t* buf, uint32_t len);
62
+
63
+ void setFD(int fd) { fd_ = fd; }
64
+ int getFD() { return fd_; }
65
+
66
+ protected:
67
+ int fd_;
68
+ ClosePolicy close_policy_;
69
+ };
70
+
71
+ }}} // apache::thrift::transport
72
+
73
+ #endif // #ifndef _THRIFT_TRANSPORT_TFDTRANSPORT_H_
@@ -0,0 +1,953 @@
1
+ /*
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+
20
+ #ifdef HAVE_CONFIG_H
21
+ #include "config.h"
22
+ #endif
23
+
24
+ #include "TFileTransport.h"
25
+ #include "TTransportUtils.h"
26
+
27
+ #include <pthread.h>
28
+ #ifdef HAVE_SYS_TIME_H
29
+ #include <sys/time.h>
30
+ #else
31
+ #include <time.h>
32
+ #endif
33
+ #include <fcntl.h>
34
+ #include <errno.h>
35
+ #include <unistd.h>
36
+ #ifdef HAVE_STRINGS_H
37
+ #include <strings.h>
38
+ #endif
39
+ #include <cstdlib>
40
+ #include <cstring>
41
+ #include <iostream>
42
+ #include <sys/stat.h>
43
+
44
+ namespace apache { namespace thrift { namespace transport {
45
+
46
+ using boost::shared_ptr;
47
+ using namespace std;
48
+ using namespace apache::thrift::protocol;
49
+
50
+ #ifndef HAVE_CLOCK_GETTIME
51
+
52
+ /**
53
+ * Fake clock_gettime for systems like darwin
54
+ *
55
+ */
56
+ #define CLOCK_REALTIME 0
57
+ static int clock_gettime(int clk_id /*ignored*/, struct timespec *tp) {
58
+ struct timeval now;
59
+
60
+ int rv = gettimeofday(&now, NULL);
61
+ if (rv != 0) {
62
+ return rv;
63
+ }
64
+
65
+ tp->tv_sec = now.tv_sec;
66
+ tp->tv_nsec = now.tv_usec * 1000;
67
+ return 0;
68
+ }
69
+ #endif
70
+
71
+ TFileTransport::TFileTransport(string path, bool readOnly)
72
+ : readState_()
73
+ , readBuff_(NULL)
74
+ , currentEvent_(NULL)
75
+ , readBuffSize_(DEFAULT_READ_BUFF_SIZE)
76
+ , readTimeout_(NO_TAIL_READ_TIMEOUT)
77
+ , chunkSize_(DEFAULT_CHUNK_SIZE)
78
+ , eventBufferSize_(DEFAULT_EVENT_BUFFER_SIZE)
79
+ , flushMaxUs_(DEFAULT_FLUSH_MAX_US)
80
+ , flushMaxBytes_(DEFAULT_FLUSH_MAX_BYTES)
81
+ , maxEventSize_(DEFAULT_MAX_EVENT_SIZE)
82
+ , maxCorruptedEvents_(DEFAULT_MAX_CORRUPTED_EVENTS)
83
+ , eofSleepTime_(DEFAULT_EOF_SLEEP_TIME_US)
84
+ , corruptedEventSleepTime_(DEFAULT_CORRUPTED_SLEEP_TIME_US)
85
+ , writerThreadId_(0)
86
+ , dequeueBuffer_(NULL)
87
+ , enqueueBuffer_(NULL)
88
+ , closing_(false)
89
+ , forceFlush_(false)
90
+ , filename_(path)
91
+ , fd_(0)
92
+ , bufferAndThreadInitialized_(false)
93
+ , offset_(0)
94
+ , lastBadChunk_(0)
95
+ , numCorruptedEventsInChunk_(0)
96
+ , readOnly_(readOnly)
97
+ {
98
+ // initialize all the condition vars/mutexes
99
+ pthread_mutex_init(&mutex_, NULL);
100
+ pthread_cond_init(&notFull_, NULL);
101
+ pthread_cond_init(&notEmpty_, NULL);
102
+ pthread_cond_init(&flushed_, NULL);
103
+
104
+ openLogFile();
105
+ }
106
+
107
+ void TFileTransport::resetOutputFile(int fd, string filename, int64_t offset) {
108
+ filename_ = filename;
109
+ offset_ = offset;
110
+
111
+ // check if current file is still open
112
+ if (fd_ > 0) {
113
+ // flush any events in the queue
114
+ flush();
115
+ GlobalOutput.printf("error, current file (%s) not closed", filename_.c_str());
116
+ if (-1 == ::close(fd_)) {
117
+ int errno_copy = errno;
118
+ GlobalOutput.perror("TFileTransport: resetOutputFile() ::close() ", errno_copy);
119
+ throw TTransportException(TTransportException::UNKNOWN, "TFileTransport: error in file close", errno_copy);
120
+ }
121
+ }
122
+
123
+ if (fd) {
124
+ fd_ = fd;
125
+ } else {
126
+ // open file if the input fd is 0
127
+ openLogFile();
128
+ }
129
+ }
130
+
131
+
132
+ TFileTransport::~TFileTransport() {
133
+ // flush the buffer if a writer thread is active
134
+ if (writerThreadId_ > 0) {
135
+ // reduce the flush timeout so that closing is quicker
136
+ setFlushMaxUs(300*1000);
137
+
138
+ // flush output buffer
139
+ flush();
140
+
141
+ // set state to closing
142
+ closing_ = true;
143
+
144
+ // TODO: make sure event queue is empty
145
+ // currently only the write buffer is flushed
146
+ // we dont actually wait until the queue is empty. This shouldn't be a big
147
+ // deal in the common case because writing is quick
148
+
149
+ pthread_join(writerThreadId_, NULL);
150
+ writerThreadId_ = 0;
151
+ }
152
+
153
+ if (dequeueBuffer_) {
154
+ delete dequeueBuffer_;
155
+ dequeueBuffer_ = NULL;
156
+ }
157
+
158
+ if (enqueueBuffer_) {
159
+ delete enqueueBuffer_;
160
+ enqueueBuffer_ = NULL;
161
+ }
162
+
163
+ if (readBuff_) {
164
+ delete[] readBuff_;
165
+ readBuff_ = NULL;
166
+ }
167
+
168
+ if (currentEvent_) {
169
+ delete currentEvent_;
170
+ currentEvent_ = NULL;
171
+ }
172
+
173
+ // close logfile
174
+ if (fd_ > 0) {
175
+ if(-1 == ::close(fd_)) {
176
+ GlobalOutput.perror("TFileTransport: ~TFileTransport() ::close() ", errno);
177
+ }
178
+ }
179
+ }
180
+
181
+ bool TFileTransport::initBufferAndWriteThread() {
182
+ if (bufferAndThreadInitialized_) {
183
+ T_ERROR("Trying to double-init TFileTransport");
184
+ return false;
185
+ }
186
+
187
+ if (writerThreadId_ == 0) {
188
+ if (pthread_create(&writerThreadId_, NULL, startWriterThread, (void *)this) != 0) {
189
+ T_ERROR("Could not create writer thread");
190
+ return false;
191
+ }
192
+ }
193
+
194
+ dequeueBuffer_ = new TFileTransportBuffer(eventBufferSize_);
195
+ enqueueBuffer_ = new TFileTransportBuffer(eventBufferSize_);
196
+ bufferAndThreadInitialized_ = true;
197
+
198
+ return true;
199
+ }
200
+
201
+ void TFileTransport::write(const uint8_t* buf, uint32_t len) {
202
+ if (readOnly_) {
203
+ throw TTransportException("TFileTransport: attempting to write to file opened readonly");
204
+ }
205
+
206
+ enqueueEvent(buf, len, false);
207
+ }
208
+
209
+ void TFileTransport::enqueueEvent(const uint8_t* buf, uint32_t eventLen, bool blockUntilFlush) {
210
+ // can't enqueue more events if file is going to close
211
+ if (closing_) {
212
+ return;
213
+ }
214
+
215
+ // make sure that event size is valid
216
+ if ( (maxEventSize_ > 0) && (eventLen > maxEventSize_) ) {
217
+ T_ERROR("msg size is greater than max event size: %u > %u\n", eventLen, maxEventSize_);
218
+ return;
219
+ }
220
+
221
+ if (eventLen == 0) {
222
+ T_ERROR("cannot enqueue an empty event");
223
+ return;
224
+ }
225
+
226
+ eventInfo* toEnqueue = new eventInfo();
227
+ toEnqueue->eventBuff_ = (uint8_t *)std::malloc((sizeof(uint8_t) * eventLen) + 4);
228
+ // first 4 bytes is the event length
229
+ memcpy(toEnqueue->eventBuff_, (void*)(&eventLen), 4);
230
+ // actual event contents
231
+ memcpy(toEnqueue->eventBuff_ + 4, buf, eventLen);
232
+ toEnqueue->eventSize_ = eventLen + 4;
233
+
234
+ // lock mutex
235
+ pthread_mutex_lock(&mutex_);
236
+
237
+ // make sure that enqueue buffer is initialized and writer thread is running
238
+ if (!bufferAndThreadInitialized_) {
239
+ if (!initBufferAndWriteThread()) {
240
+ delete toEnqueue;
241
+ pthread_mutex_unlock(&mutex_);
242
+ return;
243
+ }
244
+ }
245
+
246
+ // Can't enqueue while buffer is full
247
+ while (enqueueBuffer_->isFull()) {
248
+ pthread_cond_wait(&notFull_, &mutex_);
249
+ }
250
+
251
+ // add to the buffer
252
+ if (!enqueueBuffer_->addEvent(toEnqueue)) {
253
+ delete toEnqueue;
254
+ pthread_mutex_unlock(&mutex_);
255
+ return;
256
+ }
257
+
258
+ // signal anybody who's waiting for the buffer to be non-empty
259
+ pthread_cond_signal(&notEmpty_);
260
+
261
+ if (blockUntilFlush) {
262
+ pthread_cond_wait(&flushed_, &mutex_);
263
+ }
264
+
265
+ // this really should be a loop where it makes sure it got flushed
266
+ // because condition variables can get triggered by the os for no reason
267
+ // it is probably a non-factor for the time being
268
+ pthread_mutex_unlock(&mutex_);
269
+ }
270
+
271
+ bool TFileTransport::swapEventBuffers(struct timespec* deadline) {
272
+ pthread_mutex_lock(&mutex_);
273
+ if (deadline != NULL) {
274
+ // if we were handed a deadline time struct, do a timed wait
275
+ pthread_cond_timedwait(&notEmpty_, &mutex_, deadline);
276
+ } else {
277
+ // just wait until the buffer gets an item
278
+ pthread_cond_wait(&notEmpty_, &mutex_);
279
+ }
280
+
281
+ bool swapped = false;
282
+
283
+ // could be empty if we timed out
284
+ if (!enqueueBuffer_->isEmpty()) {
285
+ TFileTransportBuffer *temp = enqueueBuffer_;
286
+ enqueueBuffer_ = dequeueBuffer_;
287
+ dequeueBuffer_ = temp;
288
+
289
+ swapped = true;
290
+ }
291
+
292
+ // unlock the mutex and signal if required
293
+ pthread_mutex_unlock(&mutex_);
294
+
295
+ if (swapped) {
296
+ pthread_cond_signal(&notFull_);
297
+ }
298
+
299
+ return swapped;
300
+ }
301
+
302
+
303
+ void TFileTransport::writerThread() {
304
+ // open file if it is not open
305
+ if(!fd_) {
306
+ openLogFile();
307
+ }
308
+
309
+ // set the offset to the correct value (EOF)
310
+ try {
311
+ seekToEnd();
312
+ } catch (TException &te) {
313
+ }
314
+
315
+ // throw away any partial events
316
+ offset_ += readState_.lastDispatchPtr_;
317
+ ftruncate(fd_, offset_);
318
+ readState_.resetAllValues();
319
+
320
+ // Figure out the next time by which a flush must take place
321
+
322
+ struct timespec ts_next_flush;
323
+ getNextFlushTime(&ts_next_flush);
324
+ uint32_t unflushed = 0;
325
+
326
+ while(1) {
327
+ // this will only be true when the destructor is being invoked
328
+ if(closing_) {
329
+ // empty out both the buffers
330
+ if (enqueueBuffer_->isEmpty() && dequeueBuffer_->isEmpty()) {
331
+ if (-1 == ::close(fd_)) {
332
+ int errno_copy = errno;
333
+ GlobalOutput.perror("TFileTransport: writerThread() ::close() ", errno_copy);
334
+ throw TTransportException(TTransportException::UNKNOWN, "TFileTransport: error in file close", errno_copy);
335
+ }
336
+ // just be safe and sync to disk
337
+ fsync(fd_);
338
+ fd_ = 0;
339
+ pthread_exit(NULL);
340
+ return;
341
+ }
342
+ }
343
+
344
+ if (swapEventBuffers(&ts_next_flush)) {
345
+ eventInfo* outEvent;
346
+ while (NULL != (outEvent = dequeueBuffer_->getNext())) {
347
+ if (!outEvent) {
348
+ T_DEBUG_L(1, "Got an empty event");
349
+ return;
350
+ }
351
+
352
+ // sanity check on event
353
+ if ((maxEventSize_ > 0) && (outEvent->eventSize_ > maxEventSize_)) {
354
+ T_ERROR("msg size is greater than max event size: %u > %u\n", outEvent->eventSize_, maxEventSize_);
355
+ continue;
356
+ }
357
+
358
+ // If chunking is required, then make sure that msg does not cross chunk boundary
359
+ if ((outEvent->eventSize_ > 0) && (chunkSize_ != 0)) {
360
+
361
+ // event size must be less than chunk size
362
+ if(outEvent->eventSize_ > chunkSize_) {
363
+ T_ERROR("TFileTransport: event size(%u) is greater than chunk size(%u): skipping event",
364
+ outEvent->eventSize_, chunkSize_);
365
+ continue;
366
+ }
367
+
368
+ int64_t chunk1 = offset_/chunkSize_;
369
+ int64_t chunk2 = (offset_ + outEvent->eventSize_ - 1)/chunkSize_;
370
+
371
+ // if adding this event will cross a chunk boundary, pad the chunk with zeros
372
+ if (chunk1 != chunk2) {
373
+ // refetch the offset to keep in sync
374
+ offset_ = lseek(fd_, 0, SEEK_CUR);
375
+ int32_t padding = (int32_t)((offset_/chunkSize_ + 1)*chunkSize_ - offset_);
376
+
377
+ uint8_t zeros[padding];
378
+ bzero(zeros, padding);
379
+ if (-1 == ::write(fd_, zeros, padding)) {
380
+ int errno_copy = errno;
381
+ GlobalOutput.perror("TFileTransport: writerThread() error while padding zeros ", errno_copy);
382
+ throw TTransportException(TTransportException::UNKNOWN, "TFileTransport: error while padding zeros", errno_copy);
383
+ }
384
+ unflushed += padding;
385
+ offset_ += padding;
386
+ }
387
+ }
388
+
389
+ // write the dequeued event to the file
390
+ if (outEvent->eventSize_ > 0) {
391
+ if (-1 == ::write(fd_, outEvent->eventBuff_, outEvent->eventSize_)) {
392
+ int errno_copy = errno;
393
+ GlobalOutput.perror("TFileTransport: error while writing event ", errno_copy);
394
+ throw TTransportException(TTransportException::UNKNOWN, "TFileTransport: error while writing event", errno_copy);
395
+ }
396
+
397
+ unflushed += outEvent->eventSize_;
398
+ offset_ += outEvent->eventSize_;
399
+ }
400
+ }
401
+ dequeueBuffer_->reset();
402
+ }
403
+
404
+ bool flushTimeElapsed = false;
405
+ struct timespec current_time;
406
+ clock_gettime(CLOCK_REALTIME, &current_time);
407
+
408
+ if (current_time.tv_sec > ts_next_flush.tv_sec ||
409
+ (current_time.tv_sec == ts_next_flush.tv_sec && current_time.tv_nsec > ts_next_flush.tv_nsec)) {
410
+ flushTimeElapsed = true;
411
+ getNextFlushTime(&ts_next_flush);
412
+ }
413
+
414
+ // couple of cases from which a flush could be triggered
415
+ if ((flushTimeElapsed && unflushed > 0) ||
416
+ unflushed > flushMaxBytes_ ||
417
+ forceFlush_) {
418
+
419
+ // sync (force flush) file to disk
420
+ fsync(fd_);
421
+ unflushed = 0;
422
+
423
+ // notify anybody waiting for flush completion
424
+ forceFlush_ = false;
425
+ pthread_cond_broadcast(&flushed_);
426
+ }
427
+ }
428
+ }
429
+
430
+ void TFileTransport::flush() {
431
+ // file must be open for writing for any flushing to take place
432
+ if (writerThreadId_ <= 0) {
433
+ return;
434
+ }
435
+ // wait for flush to take place
436
+ pthread_mutex_lock(&mutex_);
437
+
438
+ forceFlush_ = true;
439
+
440
+ while (forceFlush_) {
441
+ pthread_cond_wait(&flushed_, &mutex_);
442
+ }
443
+
444
+ pthread_mutex_unlock(&mutex_);
445
+ }
446
+
447
+
448
+ uint32_t TFileTransport::readAll(uint8_t* buf, uint32_t len) {
449
+ uint32_t have = 0;
450
+ uint32_t get = 0;
451
+
452
+ while (have < len) {
453
+ get = read(buf+have, len-have);
454
+ if (get <= 0) {
455
+ throw TEOFException();
456
+ }
457
+ have += get;
458
+ }
459
+
460
+ return have;
461
+ }
462
+
463
+ uint32_t TFileTransport::read(uint8_t* buf, uint32_t len) {
464
+ // check if there an event is ready to be read
465
+ if (!currentEvent_) {
466
+ currentEvent_ = readEvent();
467
+ }
468
+
469
+ // did not manage to read an event from the file. This could have happened
470
+ // if the timeout expired or there was some other error
471
+ if (!currentEvent_) {
472
+ return 0;
473
+ }
474
+
475
+ // read as much of the current event as possible
476
+ int32_t remaining = currentEvent_->eventSize_ - currentEvent_->eventBuffPos_;
477
+ if (remaining <= (int32_t)len) {
478
+ // copy over anything thats remaining
479
+ if (remaining > 0) {
480
+ memcpy(buf,
481
+ currentEvent_->eventBuff_ + currentEvent_->eventBuffPos_,
482
+ remaining);
483
+ }
484
+ delete(currentEvent_);
485
+ currentEvent_ = NULL;
486
+ return remaining;
487
+ }
488
+
489
+ // read as much as possible
490
+ memcpy(buf, currentEvent_->eventBuff_ + currentEvent_->eventBuffPos_, len);
491
+ currentEvent_->eventBuffPos_ += len;
492
+ return len;
493
+ }
494
+
495
+ eventInfo* TFileTransport::readEvent() {
496
+ int readTries = 0;
497
+
498
+ if (!readBuff_) {
499
+ readBuff_ = new uint8_t[readBuffSize_];
500
+ }
501
+
502
+ while (1) {
503
+ // read from the file if read buffer is exhausted
504
+ if (readState_.bufferPtr_ == readState_.bufferLen_) {
505
+ // advance the offset pointer
506
+ offset_ += readState_.bufferLen_;
507
+ readState_.bufferLen_ = ::read(fd_, readBuff_, readBuffSize_);
508
+ // if (readState_.bufferLen_) {
509
+ // T_DEBUG_L(1, "Amount read: %u (offset: %lu)", readState_.bufferLen_, offset_);
510
+ // }
511
+ readState_.bufferPtr_ = 0;
512
+ readState_.lastDispatchPtr_ = 0;
513
+
514
+ // read error
515
+ if (readState_.bufferLen_ == -1) {
516
+ readState_.resetAllValues();
517
+ GlobalOutput("TFileTransport: error while reading from file");
518
+ throw TTransportException("TFileTransport: error while reading from file");
519
+ } else if (readState_.bufferLen_ == 0) { // EOF
520
+ // wait indefinitely if there is no timeout
521
+ if (readTimeout_ == TAIL_READ_TIMEOUT) {
522
+ usleep(eofSleepTime_);
523
+ continue;
524
+ } else if (readTimeout_ == NO_TAIL_READ_TIMEOUT) {
525
+ // reset state
526
+ readState_.resetState(0);
527
+ return NULL;
528
+ } else if (readTimeout_ > 0) {
529
+ // timeout already expired once
530
+ if (readTries > 0) {
531
+ readState_.resetState(0);
532
+ return NULL;
533
+ } else {
534
+ usleep(readTimeout_ * 1000);
535
+ readTries++;
536
+ continue;
537
+ }
538
+ }
539
+ }
540
+ }
541
+
542
+ readTries = 0;
543
+
544
+ // attempt to read an event from the buffer
545
+ while(readState_.bufferPtr_ < readState_.bufferLen_) {
546
+ if (readState_.readingSize_) {
547
+ if(readState_.eventSizeBuffPos_ == 0) {
548
+ if ( (offset_ + readState_.bufferPtr_)/chunkSize_ !=
549
+ ((offset_ + readState_.bufferPtr_ + 3)/chunkSize_)) {
550
+ // skip one byte towards chunk boundary
551
+ // T_DEBUG_L(1, "Skipping a byte");
552
+ readState_.bufferPtr_++;
553
+ continue;
554
+ }
555
+ }
556
+
557
+ readState_.eventSizeBuff_[readState_.eventSizeBuffPos_++] =
558
+ readBuff_[readState_.bufferPtr_++];
559
+ if (readState_.eventSizeBuffPos_ == 4) {
560
+ // 0 length event indicates padding
561
+ if (*((uint32_t *)(readState_.eventSizeBuff_)) == 0) {
562
+ // T_DEBUG_L(1, "Got padding");
563
+ readState_.resetState(readState_.lastDispatchPtr_);
564
+ continue;
565
+ }
566
+ // got a valid event
567
+ readState_.readingSize_ = false;
568
+ if (readState_.event_) {
569
+ delete(readState_.event_);
570
+ }
571
+ readState_.event_ = new eventInfo();
572
+ readState_.event_->eventSize_ = *((uint32_t *)(readState_.eventSizeBuff_));
573
+
574
+ // check if the event is corrupted and perform recovery if required
575
+ if (isEventCorrupted()) {
576
+ performRecovery();
577
+ // start from the top
578
+ break;
579
+ }
580
+ }
581
+ } else {
582
+ if (!readState_.event_->eventBuff_) {
583
+ readState_.event_->eventBuff_ = new uint8_t[readState_.event_->eventSize_];
584
+ readState_.event_->eventBuffPos_ = 0;
585
+ }
586
+ // take either the entire event or the remaining bytes in the buffer
587
+ int reclaimBuffer = min((uint32_t)(readState_.bufferLen_ - readState_.bufferPtr_),
588
+ readState_.event_->eventSize_ - readState_.event_->eventBuffPos_);
589
+
590
+ // copy data from read buffer into event buffer
591
+ memcpy(readState_.event_->eventBuff_ + readState_.event_->eventBuffPos_,
592
+ readBuff_ + readState_.bufferPtr_,
593
+ reclaimBuffer);
594
+
595
+ // increment position ptrs
596
+ readState_.event_->eventBuffPos_ += reclaimBuffer;
597
+ readState_.bufferPtr_ += reclaimBuffer;
598
+
599
+ // check if the event has been read in full
600
+ if (readState_.event_->eventBuffPos_ == readState_.event_->eventSize_) {
601
+ // set the completed event to the current event
602
+ eventInfo* completeEvent = readState_.event_;
603
+ completeEvent->eventBuffPos_ = 0;
604
+
605
+ readState_.event_ = NULL;
606
+ readState_.resetState(readState_.bufferPtr_);
607
+
608
+ // exit criteria
609
+ return completeEvent;
610
+ }
611
+ }
612
+ }
613
+
614
+ }
615
+ }
616
+
617
+ bool TFileTransport::isEventCorrupted() {
618
+ // an error is triggered if:
619
+ if ( (maxEventSize_ > 0) && (readState_.event_->eventSize_ > maxEventSize_)) {
620
+ // 1. Event size is larger than user-speficied max-event size
621
+ T_ERROR("Read corrupt event. Event size(%u) greater than max event size (%u)",
622
+ readState_.event_->eventSize_, maxEventSize_);
623
+ return true;
624
+ } else if (readState_.event_->eventSize_ > chunkSize_) {
625
+ // 2. Event size is larger than chunk size
626
+ T_ERROR("Read corrupt event. Event size(%u) greater than chunk size (%u)",
627
+ readState_.event_->eventSize_, chunkSize_);
628
+ return true;
629
+ } else if( ((offset_ + readState_.bufferPtr_ - 4)/chunkSize_) !=
630
+ ((offset_ + readState_.bufferPtr_ + readState_.event_->eventSize_ - 1)/chunkSize_) ) {
631
+ // 3. size indicates that event crosses chunk boundary
632
+ T_ERROR("Read corrupt event. Event crosses chunk boundary. Event size:%u Offset:%ld",
633
+ readState_.event_->eventSize_, offset_ + readState_.bufferPtr_ + 4);
634
+ return true;
635
+ }
636
+
637
+ return false;
638
+ }
639
+
640
+ void TFileTransport::performRecovery() {
641
+ // perform some kickass recovery
642
+ uint32_t curChunk = getCurChunk();
643
+ if (lastBadChunk_ == curChunk) {
644
+ numCorruptedEventsInChunk_++;
645
+ } else {
646
+ lastBadChunk_ = curChunk;
647
+ numCorruptedEventsInChunk_ = 1;
648
+ }
649
+
650
+ if (numCorruptedEventsInChunk_ < maxCorruptedEvents_) {
651
+ // maybe there was an error in reading the file from disk
652
+ // seek to the beginning of chunk and try again
653
+ seekToChunk(curChunk);
654
+ } else {
655
+
656
+ // just skip ahead to the next chunk if we not already at the last chunk
657
+ if (curChunk != (getNumChunks() - 1)) {
658
+ seekToChunk(curChunk + 1);
659
+ } else if (readTimeout_ == TAIL_READ_TIMEOUT) {
660
+ // if tailing the file, wait until there is enough data to start
661
+ // the next chunk
662
+ while(curChunk == (getNumChunks() - 1)) {
663
+ usleep(DEFAULT_CORRUPTED_SLEEP_TIME_US);
664
+ }
665
+ seekToChunk(curChunk + 1);
666
+ } else {
667
+ // pretty hosed at this stage, rewind the file back to the last successful
668
+ // point and punt on the error
669
+ readState_.resetState(readState_.lastDispatchPtr_);
670
+ currentEvent_ = NULL;
671
+ char errorMsg[1024];
672
+ sprintf(errorMsg, "TFileTransport: log file corrupted at offset: %lu",
673
+ offset_ + readState_.lastDispatchPtr_);
674
+ GlobalOutput(errorMsg);
675
+ throw TTransportException(errorMsg);
676
+ }
677
+ }
678
+
679
+ }
680
+
681
+ void TFileTransport::seekToChunk(int32_t chunk) {
682
+ if (fd_ <= 0) {
683
+ throw TTransportException("File not open");
684
+ }
685
+
686
+ int32_t numChunks = getNumChunks();
687
+
688
+ // file is empty, seeking to chunk is pointless
689
+ if (numChunks == 0) {
690
+ return;
691
+ }
692
+
693
+ // negative indicates reverse seek (from the end)
694
+ if (chunk < 0) {
695
+ chunk += numChunks;
696
+ }
697
+
698
+ // too large a value for reverse seek, just seek to beginning
699
+ if (chunk < 0) {
700
+ T_DEBUG("Incorrect value for reverse seek. Seeking to beginning...", chunk)
701
+ chunk = 0;
702
+ }
703
+
704
+ // cannot seek past EOF
705
+ bool seekToEnd = false;
706
+ uint32_t minEndOffset = 0;
707
+ if (chunk >= numChunks) {
708
+ T_DEBUG("Trying to seek past EOF. Seeking to EOF instead...");
709
+ seekToEnd = true;
710
+ chunk = numChunks - 1;
711
+ // this is the min offset to process events till
712
+ minEndOffset = lseek(fd_, 0, SEEK_END);
713
+ }
714
+
715
+ off_t newOffset = off_t(chunk) * chunkSize_;
716
+ offset_ = lseek(fd_, newOffset, SEEK_SET);
717
+ readState_.resetAllValues();
718
+ currentEvent_ = NULL;
719
+ if (offset_ == -1) {
720
+ GlobalOutput("TFileTransport: lseek error in seekToChunk");
721
+ throw TTransportException("TFileTransport: lseek error in seekToChunk");
722
+ }
723
+
724
+ // seek to EOF if user wanted to go to last chunk
725
+ if (seekToEnd) {
726
+ uint32_t oldReadTimeout = getReadTimeout();
727
+ setReadTimeout(NO_TAIL_READ_TIMEOUT);
728
+ // keep on reading unti the last event at point of seekChunk call
729
+ while (readEvent() && ((offset_ + readState_.bufferPtr_) < minEndOffset)) {};
730
+ setReadTimeout(oldReadTimeout);
731
+ }
732
+
733
+ }
734
+
735
+ void TFileTransport::seekToEnd() {
736
+ seekToChunk(getNumChunks());
737
+ }
738
+
739
+ uint32_t TFileTransport::getNumChunks() {
740
+ if (fd_ <= 0) {
741
+ return 0;
742
+ }
743
+
744
+ struct stat f_info;
745
+ int rv = fstat(fd_, &f_info);
746
+
747
+ if (rv < 0) {
748
+ int errno_copy = errno;
749
+ throw TTransportException(TTransportException::UNKNOWN,
750
+ "TFileTransport::getNumChunks() (fstat)",
751
+ errno_copy);
752
+ }
753
+
754
+ if (f_info.st_size > 0) {
755
+ return ((f_info.st_size)/chunkSize_) + 1;
756
+ }
757
+
758
+ // empty file has no chunks
759
+ return 0;
760
+ }
761
+
762
+ uint32_t TFileTransport::getCurChunk() {
763
+ return offset_/chunkSize_;
764
+ }
765
+
766
+ // Utility Functions
767
+ void TFileTransport::openLogFile() {
768
+ mode_t mode = readOnly_ ? S_IRUSR | S_IRGRP | S_IROTH : S_IRUSR | S_IWUSR| S_IRGRP | S_IROTH;
769
+ int flags = readOnly_ ? O_RDONLY : O_RDWR | O_CREAT | O_APPEND;
770
+ fd_ = ::open(filename_.c_str(), flags, mode);
771
+ offset_ = 0;
772
+
773
+ // make sure open call was successful
774
+ if(fd_ == -1) {
775
+ int errno_copy = errno;
776
+ GlobalOutput.perror("TFileTransport: openLogFile() ::open() file: " + filename_, errno_copy);
777
+ throw TTransportException(TTransportException::NOT_OPEN, filename_, errno_copy);
778
+ }
779
+
780
+ }
781
+
782
+ void TFileTransport::getNextFlushTime(struct timespec* ts_next_flush) {
783
+ clock_gettime(CLOCK_REALTIME, ts_next_flush);
784
+ ts_next_flush->tv_nsec += (flushMaxUs_ % 1000000) * 1000;
785
+ if (ts_next_flush->tv_nsec > 1000000000) {
786
+ ts_next_flush->tv_nsec -= 1000000000;
787
+ ts_next_flush->tv_sec += 1;
788
+ }
789
+ ts_next_flush->tv_sec += flushMaxUs_ / 1000000;
790
+ }
791
+
792
+ TFileTransportBuffer::TFileTransportBuffer(uint32_t size)
793
+ : bufferMode_(WRITE)
794
+ , writePoint_(0)
795
+ , readPoint_(0)
796
+ , size_(size)
797
+ {
798
+ buffer_ = new eventInfo*[size];
799
+ }
800
+
801
+ TFileTransportBuffer::~TFileTransportBuffer() {
802
+ if (buffer_) {
803
+ for (uint32_t i = 0; i < writePoint_; i++) {
804
+ delete buffer_[i];
805
+ }
806
+ delete[] buffer_;
807
+ buffer_ = NULL;
808
+ }
809
+ }
810
+
811
+ bool TFileTransportBuffer::addEvent(eventInfo *event) {
812
+ if (bufferMode_ == READ) {
813
+ GlobalOutput("Trying to write to a buffer in read mode");
814
+ }
815
+ if (writePoint_ < size_) {
816
+ buffer_[writePoint_++] = event;
817
+ return true;
818
+ } else {
819
+ // buffer is full
820
+ return false;
821
+ }
822
+ }
823
+
824
+ eventInfo* TFileTransportBuffer::getNext() {
825
+ if (bufferMode_ == WRITE) {
826
+ bufferMode_ = READ;
827
+ }
828
+ if (readPoint_ < writePoint_) {
829
+ return buffer_[readPoint_++];
830
+ } else {
831
+ // no more entries
832
+ return NULL;
833
+ }
834
+ }
835
+
836
+ void TFileTransportBuffer::reset() {
837
+ if (bufferMode_ == WRITE || writePoint_ > readPoint_) {
838
+ T_DEBUG("Resetting a buffer with unread entries");
839
+ }
840
+ // Clean up the old entries
841
+ for (uint32_t i = 0; i < writePoint_; i++) {
842
+ delete buffer_[i];
843
+ }
844
+ bufferMode_ = WRITE;
845
+ writePoint_ = 0;
846
+ readPoint_ = 0;
847
+ }
848
+
849
+ bool TFileTransportBuffer::isFull() {
850
+ return writePoint_ == size_;
851
+ }
852
+
853
+ bool TFileTransportBuffer::isEmpty() {
854
+ return writePoint_ == 0;
855
+ }
856
+
857
+ TFileProcessor::TFileProcessor(shared_ptr<TProcessor> processor,
858
+ shared_ptr<TProtocolFactory> protocolFactory,
859
+ shared_ptr<TFileReaderTransport> inputTransport):
860
+ processor_(processor),
861
+ inputProtocolFactory_(protocolFactory),
862
+ outputProtocolFactory_(protocolFactory),
863
+ inputTransport_(inputTransport) {
864
+
865
+ // default the output transport to a null transport (common case)
866
+ outputTransport_ = shared_ptr<TNullTransport>(new TNullTransport());
867
+ }
868
+
869
+ TFileProcessor::TFileProcessor(shared_ptr<TProcessor> processor,
870
+ shared_ptr<TProtocolFactory> inputProtocolFactory,
871
+ shared_ptr<TProtocolFactory> outputProtocolFactory,
872
+ shared_ptr<TFileReaderTransport> inputTransport):
873
+ processor_(processor),
874
+ inputProtocolFactory_(inputProtocolFactory),
875
+ outputProtocolFactory_(outputProtocolFactory),
876
+ inputTransport_(inputTransport) {
877
+
878
+ // default the output transport to a null transport (common case)
879
+ outputTransport_ = shared_ptr<TNullTransport>(new TNullTransport());
880
+ }
881
+
882
+ TFileProcessor::TFileProcessor(shared_ptr<TProcessor> processor,
883
+ shared_ptr<TProtocolFactory> protocolFactory,
884
+ shared_ptr<TFileReaderTransport> inputTransport,
885
+ shared_ptr<TTransport> outputTransport):
886
+ processor_(processor),
887
+ inputProtocolFactory_(protocolFactory),
888
+ outputProtocolFactory_(protocolFactory),
889
+ inputTransport_(inputTransport),
890
+ outputTransport_(outputTransport) {};
891
+
892
+ void TFileProcessor::process(uint32_t numEvents, bool tail) {
893
+ shared_ptr<TProtocol> inputProtocol = inputProtocolFactory_->getProtocol(inputTransport_);
894
+ shared_ptr<TProtocol> outputProtocol = outputProtocolFactory_->getProtocol(outputTransport_);
895
+
896
+ // set the read timeout to 0 if tailing is required
897
+ int32_t oldReadTimeout = inputTransport_->getReadTimeout();
898
+ if (tail) {
899
+ // save old read timeout so it can be restored
900
+ inputTransport_->setReadTimeout(TFileTransport::TAIL_READ_TIMEOUT);
901
+ }
902
+
903
+ uint32_t numProcessed = 0;
904
+ while(1) {
905
+ // bad form to use exceptions for flow control but there is really
906
+ // no other way around it
907
+ try {
908
+ processor_->process(inputProtocol, outputProtocol);
909
+ numProcessed++;
910
+ if ( (numEvents > 0) && (numProcessed == numEvents)) {
911
+ return;
912
+ }
913
+ } catch (TEOFException& teof) {
914
+ if (!tail) {
915
+ break;
916
+ }
917
+ } catch (TException &te) {
918
+ cerr << te.what() << endl;
919
+ break;
920
+ }
921
+ }
922
+
923
+ // restore old read timeout
924
+ if (tail) {
925
+ inputTransport_->setReadTimeout(oldReadTimeout);
926
+ }
927
+
928
+ }
929
+
930
+ void TFileProcessor::processChunk() {
931
+ shared_ptr<TProtocol> inputProtocol = inputProtocolFactory_->getProtocol(inputTransport_);
932
+ shared_ptr<TProtocol> outputProtocol = outputProtocolFactory_->getProtocol(outputTransport_);
933
+
934
+ uint32_t curChunk = inputTransport_->getCurChunk();
935
+
936
+ while(1) {
937
+ // bad form to use exceptions for flow control but there is really
938
+ // no other way around it
939
+ try {
940
+ processor_->process(inputProtocol, outputProtocol);
941
+ if (curChunk != inputTransport_->getCurChunk()) {
942
+ break;
943
+ }
944
+ } catch (TEOFException& teof) {
945
+ break;
946
+ } catch (TException &te) {
947
+ cerr << te.what() << endl;
948
+ break;
949
+ }
950
+ }
951
+ }
952
+
953
+ }}} // apache::thrift::transport