JobSubmissionService.py 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. #
  2. # Autogenerated by Thrift
  3. #
  4. # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  5. #
  6. from thrift.Thrift import *
  7. from ttypes import *
  8. from thrift.Thrift import TProcessor
  9. from thrift.transport import TTransport
  10. from thrift.protocol import TBinaryProtocol, TProtocol
  11. try:
  12. from thrift.protocol import fastbinary
  13. except:
  14. fastbinary = None
  15. class Iface(object):
  16. def submit(self, plan):
  17. """
  18. Parameters:
  19. - plan
  20. """
  21. pass
  22. def get_job_data(self, handle):
  23. """
  24. Parameters:
  25. - handle
  26. """
  27. pass
  28. class Client(Iface):
  29. def __init__(self, iprot, oprot=None):
  30. self._iprot = self._oprot = iprot
  31. if oprot != None:
  32. self._oprot = oprot
  33. self._seqid = 0
  34. def submit(self, plan):
  35. """
  36. Parameters:
  37. - plan
  38. """
  39. self.send_submit(plan)
  40. return self.recv_submit()
  41. def send_submit(self, plan):
  42. self._oprot.writeMessageBegin('submit', TMessageType.CALL, self._seqid)
  43. args = submit_args()
  44. args.plan = plan
  45. args.write(self._oprot)
  46. self._oprot.writeMessageEnd()
  47. self._oprot.trans.flush()
  48. def recv_submit(self, ):
  49. (fname, mtype, rseqid) = self._iprot.readMessageBegin()
  50. if mtype == TMessageType.EXCEPTION:
  51. x = TApplicationException()
  52. x.read(self._iprot)
  53. self._iprot.readMessageEnd()
  54. raise x
  55. result = submit_result()
  56. result.read(self._iprot)
  57. self._iprot.readMessageEnd()
  58. if result.success != None:
  59. return result.success
  60. if result.error != None:
  61. raise result.error
  62. raise TApplicationException(TApplicationException.MISSING_RESULT, "submit failed: unknown result");
  63. def get_job_data(self, handle):
  64. """
  65. Parameters:
  66. - handle
  67. """
  68. self.send_get_job_data(handle)
  69. return self.recv_get_job_data()
  70. def send_get_job_data(self, handle):
  71. self._oprot.writeMessageBegin('get_job_data', TMessageType.CALL, self._seqid)
  72. args = get_job_data_args()
  73. args.handle = handle
  74. args.write(self._oprot)
  75. self._oprot.writeMessageEnd()
  76. self._oprot.trans.flush()
  77. def recv_get_job_data(self, ):
  78. (fname, mtype, rseqid) = self._iprot.readMessageBegin()
  79. if mtype == TMessageType.EXCEPTION:
  80. x = TApplicationException()
  81. x.read(self._iprot)
  82. self._iprot.readMessageEnd()
  83. raise x
  84. result = get_job_data_result()
  85. result.read(self._iprot)
  86. self._iprot.readMessageEnd()
  87. if result.success != None:
  88. return result.success
  89. if result.error != None:
  90. raise result.error
  91. raise TApplicationException(TApplicationException.MISSING_RESULT, "get_job_data failed: unknown result");
  92. class Processor(Iface, TProcessor):
  93. def __init__(self, handler):
  94. self._handler = handler
  95. self._processMap = {}
  96. self._processMap["submit"] = Processor.process_submit
  97. self._processMap["get_job_data"] = Processor.process_get_job_data
  98. def process(self, iprot, oprot):
  99. (name, type, seqid) = iprot.readMessageBegin()
  100. if name not in self._processMap:
  101. iprot.skip(TType.STRUCT)
  102. iprot.readMessageEnd()
  103. x = TApplicationException(TApplicationException.UNKNOWN_METHOD, 'Unknown function %s' % (name))
  104. oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid)
  105. x.write(oprot)
  106. oprot.writeMessageEnd()
  107. oprot.trans.flush()
  108. return
  109. else:
  110. self._processMap[name](self, seqid, iprot, oprot)
  111. return True
  112. def process_submit(self, seqid, iprot, oprot):
  113. args = submit_args()
  114. args.read(iprot)
  115. iprot.readMessageEnd()
  116. result = submit_result()
  117. try:
  118. result.success = self._handler.submit(args.plan)
  119. except SubmissionError, error:
  120. result.error = error
  121. oprot.writeMessageBegin("submit", TMessageType.REPLY, seqid)
  122. result.write(oprot)
  123. oprot.writeMessageEnd()
  124. oprot.trans.flush()
  125. def process_get_job_data(self, seqid, iprot, oprot):
  126. args = get_job_data_args()
  127. args.read(iprot)
  128. iprot.readMessageEnd()
  129. result = get_job_data_result()
  130. try:
  131. result.success = self._handler.get_job_data(args.handle)
  132. except SubmissionError, error:
  133. result.error = error
  134. oprot.writeMessageBegin("get_job_data", TMessageType.REPLY, seqid)
  135. result.write(oprot)
  136. oprot.writeMessageEnd()
  137. oprot.trans.flush()
  138. # HELPER FUNCTIONS AND STRUCTURES
  139. class submit_args(object):
  140. """
  141. Attributes:
  142. - plan
  143. """
  144. thrift_spec = (
  145. None, # 0
  146. (1, TType.STRUCT, 'plan', (SubmissionPlan, SubmissionPlan.thrift_spec), None, ), # 1
  147. )
  148. def __init__(self, plan=None,):
  149. self.plan = plan
  150. def read(self, iprot):
  151. if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
  152. fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
  153. return
  154. iprot.readStructBegin()
  155. while True:
  156. (fname, ftype, fid) = iprot.readFieldBegin()
  157. if ftype == TType.STOP:
  158. break
  159. if fid == 1:
  160. if ftype == TType.STRUCT:
  161. self.plan = SubmissionPlan()
  162. self.plan.read(iprot)
  163. else:
  164. iprot.skip(ftype)
  165. else:
  166. iprot.skip(ftype)
  167. iprot.readFieldEnd()
  168. iprot.readStructEnd()
  169. def write(self, oprot):
  170. if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
  171. oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
  172. return
  173. oprot.writeStructBegin('submit_args')
  174. if self.plan != None:
  175. oprot.writeFieldBegin('plan', TType.STRUCT, 1)
  176. self.plan.write(oprot)
  177. oprot.writeFieldEnd()
  178. oprot.writeFieldStop()
  179. oprot.writeStructEnd()
  180. def validate(self):
  181. return
  182. def __repr__(self):
  183. L = ['%s=%r' % (key, value)
  184. for key, value in self.__dict__.iteritems()]
  185. return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
  186. def __eq__(self, other):
  187. return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
  188. def __ne__(self, other):
  189. return not (self == other)
  190. class submit_result(object):
  191. """
  192. Attributes:
  193. - success
  194. - error
  195. """
  196. thrift_spec = (
  197. (0, TType.STRUCT, 'success', (SubmissionHandle, SubmissionHandle.thrift_spec), None, ), # 0
  198. (1, TType.STRUCT, 'error', (SubmissionError, SubmissionError.thrift_spec), None, ), # 1
  199. )
  200. def __init__(self, success=None, error=None,):
  201. self.success = success
  202. self.error = error
  203. def read(self, iprot):
  204. if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
  205. fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
  206. return
  207. iprot.readStructBegin()
  208. while True:
  209. (fname, ftype, fid) = iprot.readFieldBegin()
  210. if ftype == TType.STOP:
  211. break
  212. if fid == 0:
  213. if ftype == TType.STRUCT:
  214. self.success = SubmissionHandle()
  215. self.success.read(iprot)
  216. else:
  217. iprot.skip(ftype)
  218. elif fid == 1:
  219. if ftype == TType.STRUCT:
  220. self.error = SubmissionError()
  221. self.error.read(iprot)
  222. else:
  223. iprot.skip(ftype)
  224. else:
  225. iprot.skip(ftype)
  226. iprot.readFieldEnd()
  227. iprot.readStructEnd()
  228. def write(self, oprot):
  229. if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
  230. oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
  231. return
  232. oprot.writeStructBegin('submit_result')
  233. if self.success != None:
  234. oprot.writeFieldBegin('success', TType.STRUCT, 0)
  235. self.success.write(oprot)
  236. oprot.writeFieldEnd()
  237. if self.error != None:
  238. oprot.writeFieldBegin('error', TType.STRUCT, 1)
  239. self.error.write(oprot)
  240. oprot.writeFieldEnd()
  241. oprot.writeFieldStop()
  242. oprot.writeStructEnd()
  243. def validate(self):
  244. return
  245. def __repr__(self):
  246. L = ['%s=%r' % (key, value)
  247. for key, value in self.__dict__.iteritems()]
  248. return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
  249. def __eq__(self, other):
  250. return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
  251. def __ne__(self, other):
  252. return not (self == other)
  253. class get_job_data_args(object):
  254. """
  255. Attributes:
  256. - handle
  257. """
  258. thrift_spec = (
  259. None, # 0
  260. (1, TType.STRUCT, 'handle', (SubmissionHandle, SubmissionHandle.thrift_spec), None, ), # 1
  261. )
  262. def __init__(self, handle=None,):
  263. self.handle = handle
  264. def read(self, iprot):
  265. if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
  266. fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
  267. return
  268. iprot.readStructBegin()
  269. while True:
  270. (fname, ftype, fid) = iprot.readFieldBegin()
  271. if ftype == TType.STOP:
  272. break
  273. if fid == 1:
  274. if ftype == TType.STRUCT:
  275. self.handle = SubmissionHandle()
  276. self.handle.read(iprot)
  277. else:
  278. iprot.skip(ftype)
  279. else:
  280. iprot.skip(ftype)
  281. iprot.readFieldEnd()
  282. iprot.readStructEnd()
  283. def write(self, oprot):
  284. if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
  285. oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
  286. return
  287. oprot.writeStructBegin('get_job_data_args')
  288. if self.handle != None:
  289. oprot.writeFieldBegin('handle', TType.STRUCT, 1)
  290. self.handle.write(oprot)
  291. oprot.writeFieldEnd()
  292. oprot.writeFieldStop()
  293. oprot.writeStructEnd()
  294. def validate(self):
  295. return
  296. def __repr__(self):
  297. L = ['%s=%r' % (key, value)
  298. for key, value in self.__dict__.iteritems()]
  299. return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
  300. def __eq__(self, other):
  301. return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
  302. def __ne__(self, other):
  303. return not (self == other)
  304. class get_job_data_result(object):
  305. """
  306. Attributes:
  307. - success
  308. - error
  309. """
  310. thrift_spec = (
  311. (0, TType.STRUCT, 'success', (JobData, JobData.thrift_spec), None, ), # 0
  312. (1, TType.STRUCT, 'error', (SubmissionError, SubmissionError.thrift_spec), None, ), # 1
  313. )
  314. def __init__(self, success=None, error=None,):
  315. self.success = success
  316. self.error = error
  317. def read(self, iprot):
  318. if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
  319. fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
  320. return
  321. iprot.readStructBegin()
  322. while True:
  323. (fname, ftype, fid) = iprot.readFieldBegin()
  324. if ftype == TType.STOP:
  325. break
  326. if fid == 0:
  327. if ftype == TType.STRUCT:
  328. self.success = JobData()
  329. self.success.read(iprot)
  330. else:
  331. iprot.skip(ftype)
  332. elif fid == 1:
  333. if ftype == TType.STRUCT:
  334. self.error = SubmissionError()
  335. self.error.read(iprot)
  336. else:
  337. iprot.skip(ftype)
  338. else:
  339. iprot.skip(ftype)
  340. iprot.readFieldEnd()
  341. iprot.readStructEnd()
  342. def write(self, oprot):
  343. if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
  344. oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
  345. return
  346. oprot.writeStructBegin('get_job_data_result')
  347. if self.success != None:
  348. oprot.writeFieldBegin('success', TType.STRUCT, 0)
  349. self.success.write(oprot)
  350. oprot.writeFieldEnd()
  351. if self.error != None:
  352. oprot.writeFieldBegin('error', TType.STRUCT, 1)
  353. self.error.write(oprot)
  354. oprot.writeFieldEnd()
  355. oprot.writeFieldStop()
  356. oprot.writeStructEnd()
  357. def validate(self):
  358. return
  359. def __repr__(self):
  360. L = ['%s=%r' % (key, value)
  361. for key, value in self.__dict__.iteritems()]
  362. return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
  363. def __eq__(self, other):
  364. return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
  365. def __ne__(self, other):
  366. return not (self == other)