You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

148 lines
4.2KB

  1. # import sys
  2. # sys.path.extend(["..", "../util"])
  3. # from util.AliyunSdk import AliyunVodSdk
  4. # from concurrency.CommonThread import Common
  5. from kafka import KafkaProducer
  6. import json
  7. import threading
  8. topicName = 'dsp-alg-online-tasks'
  9. # eBody = {
  10. # "request_id": "d4c909912ac741ce81ccef03fd1b2ec45",
  11. # "models": [
  12. # {
  13. # "code": "001",
  14. # "categories": [{
  15. # "id": "0",
  16. # "config": {}
  17. # },
  18. # {
  19. # "id": "1",
  20. # "config": {}
  21. # },
  22. # {
  23. # "id": "2",
  24. # "config": {}
  25. # },
  26. # {
  27. # "id": "3",
  28. # "config": {}
  29. # },
  30. # {
  31. # "id": "4",
  32. # "config": {}
  33. # },
  34. # {
  35. # "id": "5",
  36. # "config": {}
  37. # }
  38. # ]
  39. # }],
  40. # "command": "start",
  41. # "pull_url": "rtmp://live.play.t-aaron.com/live/THSAr",
  42. # "push_url": "rtmp://live.push.t-aaron.com/live/THSAs",
  43. # "results_base_dir": "P20220802133841159"
  44. # }
  45. # producer = KafkaProducer(bootstrap_servers=['192.168.11.242:9092'],
  46. # value_serializer=lambda m: json.dumps(m).encode('utf-8'))
  47. # future = producer.send(topicName, key=b'd4c909912ac741ce81ccef03fd1b2ec45', value=eBody)
  48. # result = future.get(timeout=10)
  49. # print(result)
  50. # topicName = 'dsp-alg-image-tasks'
  51. eBody = {
  52. "request_id": "d4c909912ac741ce81ccef03fd1b2ec46",
  53. "models": [
  54. {
  55. "code": "001",
  56. "categories": [
  57. {
  58. "id": "0",
  59. "config": {}
  60. },
  61. {
  62. "id": "1",
  63. "config": {}
  64. },
  65. {
  66. "id": "2",
  67. "config": {}
  68. },
  69. {
  70. "id": "3",
  71. "config": {}
  72. },
  73. {
  74. "id": "4",
  75. "config": {}
  76. },
  77. {
  78. "id": "5",
  79. "config": {}
  80. },
  81. {
  82. "id": "6",
  83. "config": {}
  84. },
  85. {
  86. "id": "7",
  87. "config": {}
  88. }
  89. ]
  90. }],
  91. "command": "start",
  92. "image_urls": ["https://ta-tech-image.oss-cn-shanghai.aliyuncs.com/imagedir/cmn5kvdl23l_1669862645395.bmp"],
  93. "results_base_dir": "P20220802133841159"
  94. }
  95. # topicName = 'dsp-alg-offline-tasks'
  96. # eBody = {
  97. # "request_id": "d4c909912ac741ce81ccef03fd1b2ec46",
  98. # "models": [
  99. # {
  100. # "code": "001",
  101. # "categories": [
  102. # {
  103. # "id": "0",
  104. # "config": {}
  105. # },
  106. # {
  107. # "id": "1",
  108. # "config": {}
  109. # },
  110. # {
  111. # "id": "2",
  112. # "config": {}
  113. # },
  114. # {
  115. # "id": "3",
  116. # "config": {}
  117. # },
  118. # {
  119. # "id": "4",
  120. # "config": {}
  121. # },
  122. # {
  123. # "id": "5",
  124. # "config": {}
  125. # },
  126. # {
  127. # "id": "6",
  128. # "config": {}
  129. # },
  130. # {
  131. # "id": "7",
  132. # "config": {}
  133. # }
  134. # ]
  135. # }],
  136. # "command": "start",
  137. # "original_url": "https://vod.play.t-aaron.com/0bc905ef5651439da2bfba8427fe467e/a76a7ebb6e3b44ef9c0c7820c7e9c574-f2d7ee90cba11aa91971d58e06d295d2-4k.mp4",
  138. # "original_type": ".mp4",
  139. # "push_url": "rtmp://live.push.t-aaron.com/live/THSAr",
  140. # "results_base_dir": "P20220802133841159"
  141. # }
  142. producer = KafkaProducer(bootstrap_servers=['101.132.127.1:19094','101.132.127.1:29094','101.132.127.1:39094'],
  143. value_serializer=lambda m: json.dumps(m).encode('utf-8'))
  144. future = producer.send(topicName, key=b'd4c909912ac741ce81ccef03fd1b2ec46', value=eBody)
  145. result = future.get(timeout=10)
  146. # print(result)