ajax.js 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288
  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, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. /**
  20. * Config for each ajax-request
  21. *
  22. * Fields example:
  23. * mock - testMode url
  24. * real - real url (without API prefix)
  25. * type - request type (also may be defined in the format method)
  26. * format - function for processing ajax params after default formatRequest. Return ajax-params object
  27. * testInProduction - can this request be executed on production tests (used only in tests)
  28. *
  29. * @type {Object}
  30. */
  31. var urls = {
  32. 'background_operations.get_most_recent': {
  33. 'real': '/clusters/{clusterName}/requests?to=end&page_size=10&fields=Requests',
  34. 'mock': '/data/background_operations/list_on_start.json',
  35. 'testInProduction': true
  36. },
  37. 'background_operations.get_by_request': {
  38. 'real': '/clusters/{clusterName}/requests/{requestId}?fields=*,tasks/Tasks/command,tasks/Tasks/exit_code,tasks/Tasks/host_name,tasks/Tasks/id,tasks/Tasks/role,tasks/Tasks/status',
  39. 'mock': '/data/background_operations/task_by_request{requestId}.json',
  40. 'testInProduction': true,
  41. 'format': function (data) {
  42. return {
  43. async: !data.sync
  44. };
  45. }
  46. },
  47. 'background_operations.get_by_task': {
  48. 'real': '/clusters/{clusterName}/requests/{requestId}/tasks/{taskId}',
  49. 'mock': '/data/background_operations/list_on_start.json',
  50. 'testInProduction': true,
  51. 'format': function (data) {
  52. return {
  53. async: !data.sync
  54. };
  55. }
  56. },
  57. 'service.item.start_stop': {
  58. 'real': '/clusters/{clusterName}/services/{serviceName}?params/run_smoke_test=true',
  59. 'mock': '/data/wizard/deploy/poll_1.json',
  60. 'format': function (data, opt) {
  61. return {
  62. type: 'PUT',
  63. data: JSON.stringify({
  64. RequestInfo: {
  65. "context": data.requestInfo
  66. },
  67. Body: {
  68. ServiceInfo: {
  69. state: data.state
  70. }
  71. }
  72. })
  73. };
  74. }
  75. },
  76. 'service.item.smoke': {
  77. 'real': '/clusters/{clusterName}/requests',
  78. 'mock': '/data/wizard/deploy/poll_1.json',
  79. 'format': function (data) {
  80. return {
  81. 'type': 'POST',
  82. data: JSON.stringify({
  83. RequestInfo: {
  84. "context": data.displayName + " Smoke Test",
  85. "command" : data.actionName,
  86. "service_name" : data.serviceName
  87. }
  88. })
  89. };
  90. }
  91. },
  92. 'reassign.stop_services': {
  93. 'real': '/clusters/{clusterName}/services',
  94. 'mock': '',
  95. 'format': function (data, opt) {
  96. return {
  97. type: 'PUT',
  98. data: JSON.stringify({
  99. "RequestInfo": {
  100. "context": "Stop all services"
  101. },
  102. "Body": {
  103. "ServiceInfo": {
  104. "state": "INSTALLED"
  105. }
  106. }
  107. })
  108. }
  109. }
  110. },
  111. 'reassign.start_services': {
  112. 'real': '/clusters/{clusterName}/services?params/run_smoke_test=true',
  113. 'mock': '',
  114. 'format': function (data, opt) {
  115. return {
  116. type: 'PUT',
  117. data: JSON.stringify({
  118. "RequestInfo": {
  119. "context": "Start all services"
  120. },
  121. "Body": {
  122. "ServiceInfo": {
  123. "state": "STARTED"
  124. }
  125. }
  126. })
  127. }
  128. }
  129. },
  130. 'reassign.maintenance_mode': {
  131. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  132. 'mock': '',
  133. 'type': 'PUT',
  134. 'format': function () {
  135. return {
  136. data: JSON.stringify(
  137. {
  138. "HostRoles": {
  139. "state": "MAINTENANCE"
  140. }
  141. }
  142. )
  143. }
  144. }
  145. },
  146. 'reassign.remove_component': {
  147. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  148. 'mock': '',
  149. 'type': 'DELETE'
  150. },
  151. 'reassign.load_configs': {
  152. 'real': '/clusters/{clusterName}/configurations?{urlParams}',
  153. 'mock': ''
  154. },
  155. 'reassign.save_configs': {
  156. 'real': '/clusters/{clusterName}',
  157. 'mock': '',
  158. 'type': 'PUT',
  159. 'format': function (data) {
  160. return {
  161. async: false,
  162. data: JSON.stringify({
  163. Clusters: {
  164. desired_config: {
  165. "type": data.siteName,
  166. "tag": 'version' + (new Date).getTime(),
  167. "properties": data.properties
  168. }
  169. }
  170. })
  171. }
  172. }
  173. },
  174. 'config.advanced': {
  175. 'real': '{stack2VersionUrl}/stackServices/{serviceName}/configurations?fields=*',
  176. 'mock': '/data/wizard/stack/hdp/version{stackVersion}/{serviceName}.json',
  177. 'format': function (data) {
  178. return {
  179. async: false
  180. };
  181. }
  182. },
  183. 'config.advanced.global': {
  184. 'real': '{stack2VersionUrl}/stackServices?fields=configurations/StackConfigurations/type',
  185. 'mock': '/data/wizard/stack/hdp/version1.3.0/global.json',
  186. 'format': function (data) {
  187. return {
  188. async: false
  189. };
  190. }
  191. },
  192. 'config.tags': {
  193. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs',
  194. 'mock': '/data/clusters/cluster.json'
  195. },
  196. 'config.tags.sync': {
  197. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs',
  198. 'mock': '/data/clusters/cluster.json',
  199. 'format': function (data) {
  200. return {
  201. async: false
  202. };
  203. }
  204. },
  205. 'config.on_site': {
  206. 'real': '/clusters/{clusterName}/configurations?{params}',
  207. 'mock': '/data/configurations/cluster_level_configs.json?{params}',
  208. 'format': function (data) {
  209. return {
  210. async: false
  211. };
  212. }
  213. },
  214. 'config.host_overrides': {
  215. 'real': '/clusters/{clusterName}/configurations?{params}',
  216. 'mock': '/data/configurations/host_level_overrides_configs.json?{params}',
  217. 'format': function (data) {
  218. return {
  219. async: false
  220. };
  221. }
  222. },
  223. 'service.metrics.flume.channel_fill_percent': {
  224. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/CHANNEL/*/ChannelFillPercentage[{fromSeconds},{toSeconds},{stepSeconds}]',
  225. 'mock': '/data/services/metrics/flume/channelFillPct.json',
  226. 'testInProduction': true
  227. },
  228. 'service.metrics.flume.channel_size': {
  229. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/CHANNEL/*/ChannelSize[{fromSeconds},{toSeconds},{stepSeconds}]',
  230. 'mock': '/data/services/metrics/flume/channelSize.json',
  231. 'testInProduction': true
  232. },
  233. 'service.metrics.flume.sink_drain_success': {
  234. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/SINK/*/EventDrainSuccessCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  235. 'mock': '/data/services/metrics/flume/sinkDrainSuccessCount.json',
  236. 'testInProduction': true
  237. },
  238. 'service.metrics.flume.sink_connection_failed': {
  239. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/SINK/*/ConnectionFailedCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  240. 'mock': '/data/services/metrics/flume/sinkConnectionFailedCount.json',
  241. 'testInProduction': true
  242. },
  243. 'service.metrics.flume.gc': {
  244. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  245. 'mock': '/data/services/metrics/flume/jvmGcTime.json',
  246. 'testInProduction': true
  247. },
  248. 'service.metrics.flume.jvm_heap_used': {
  249. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/jvm/memHeapUsedM[{fromSeconds},{toSeconds},{stepSeconds}]',
  250. 'mock': '/data/services/metrics/flume/jvmMemHeapUsedM.json',
  251. 'testInProduction': true
  252. },
  253. 'service.metrics.flume.jvm_threads_runnable': {
  254. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/jvm/threadsRunnable[{fromSeconds},{toSeconds},{stepSeconds}]',
  255. 'mock': '/data/services/metrics/flume/jvmThreadsRunnable.json',
  256. 'testInProduction': true
  257. },
  258. 'service.metrics.flume.cpu_user': {
  259. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/cpu/cpu_user[{fromSeconds},{toSeconds},{stepSeconds}]',
  260. 'mock': '',
  261. 'testInProduction': true
  262. },
  263. 'service.metrics.flume.source_accepted': {
  264. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/SOURCE/*/EventAcceptedCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  265. 'mock': '/data/services/metrics/flume/sourceEventAccepted.json',
  266. 'testInProduction': true
  267. },
  268. 'service.metrics.hbase.cluster_requests': {
  269. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/cluster_requests[{fromSeconds},{toSeconds},{stepSeconds}]',
  270. 'mock': '/data/services/metrics/hbase/cluster_requests.json',
  271. 'testInProduction': true
  272. },
  273. 'service.metrics.hbase.hlog_split_size': {
  274. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/splitSize_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  275. 'mock': '/data/services/metrics/hbase/hlog_split_size.json',
  276. 'testInProduction': true
  277. },
  278. 'service.metrics.hbase.hlog_split_time': {
  279. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/splitTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  280. 'mock': '/data/services/metrics/hbase/hlog_split_time.json',
  281. 'testInProduction': true
  282. },
  283. 'service.metrics.hbase.regionserver_queuesize': {
  284. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/flushQueueSize[{fromSeconds},{toSeconds},{stepSeconds}],metrics/hbase/regionserver/compactionQueueSize[{fromSeconds},{toSeconds},{stepSeconds}]',
  285. 'mock': '/data/services/metrics/hbase/regionserver_queuesize.json',
  286. 'testInProduction': true
  287. },
  288. 'service.metrics.hbase.regionserver_regions': {
  289. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/regions[{fromSeconds},{toSeconds},{stepSeconds}]',
  290. 'mock': '/data/services/metrics/hbase/regionserver_regions.json',
  291. 'testInProduction': true
  292. },
  293. 'service.metrics.hbase.regionserver_rw_requests': {
  294. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/readRequestsCount[{fromSeconds},{toSeconds},{stepSeconds}],metrics/hbase/regionserver/writeRequestsCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  295. 'mock': '/data/services/metrics/hbase/regionserver_rw_requests.json',
  296. 'testInProduction': true
  297. },
  298. 'service.metrics.mapreduce.gc': {
  299. 'real': '/clusters/{clusterName}/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  300. 'mock': '/data/services/metrics/mapreduce/gc.json',
  301. 'testInProduction': true
  302. },
  303. 'service.metrics.mapreduce.jobs_status': {
  304. 'real': '/clusters/{clusterName}/services/MAPREDUCE/components/JOBTRACKER?fields=metrics/mapred/jobtracker/jobs_completed[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/jobs_preparing[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/jobs_failed[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/jobs_submitted[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/jobs_failed[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/jobs_running[{fromSeconds},{toSeconds},{stepSeconds}]',
  305. 'mock': '/data/services/metrics/mapreduce/jobs_status.json',
  306. 'testInProduction': true
  307. },
  308. 'service.metrics.mapreduce.jobs_heap': {
  309. 'real': '/clusters/{clusterName}/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/jvm/memNonHeapUsedM[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/memNonHeapCommittedM[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/memHeapUsedM[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/memHeapCommittedM[{fromSeconds},{toSeconds},{stepSeconds}]',
  310. 'mock': '/data/services/metrics/mapreduce/jvm_heap.json',
  311. 'testInProduction': true
  312. },
  313. 'service.metrics.mapreduce.jobs_threads': {
  314. 'real': '/clusters/{clusterName}/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/jvm/threadsRunnable[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/threadsBlocked[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/threadsWaiting[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/threadsTimedWaiting[{fromSeconds},{toSeconds},{stepSeconds}]',
  315. 'mock': '/data/services/metrics/mapreduce/jvm_threads.json',
  316. 'testInProduction': true
  317. },
  318. 'service.metrics.mapreduce.map_slots': {
  319. 'real': '/clusters/{clusterName}/services/MAPREDUCE/components/JOBTRACKER?fields=metrics/mapred/jobtracker/occupied_map_slots[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/reserved_map_slots[{fromSeconds},{toSeconds},{stepSeconds}]',
  320. 'mock': '/data/services/metrics/mapreduce/map_slots.json',
  321. 'testInProduction': true
  322. },
  323. 'service.metrics.mapreduce.reduce_slots': {
  324. 'real': '/clusters/{clusterName}/services/MAPREDUCE/components/JOBTRACKER?fields=metrics/mapred/jobtracker/occupied_reduce_slots[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/reserved_reduce_slots[{fromSeconds},{toSeconds},{stepSeconds}]',
  325. 'mock': '/data/services/metrics/mapreduce/reduce_slots.json',
  326. 'testInProduction': true
  327. },
  328. 'service.metrics.mapreduce.rpc': {
  329. 'real': '/clusters/{clusterName}/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  330. 'mock': '/data/services/metrics/mapreduce/rpc.json',
  331. 'testInProduction': true
  332. },
  333. 'service.metrics.mapreduce.tasks_running_waiting': {
  334. 'real': '/clusters/{clusterName}/services/MAPREDUCE/components/JOBTRACKER?fields=metrics/mapred/jobtracker/running_maps[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/running_reduces[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/waiting_maps[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/waiting_reduces[{fromSeconds},{toSeconds},{stepSeconds}]',
  335. 'mock': '/data/services/metrics/mapreduce/tasks_running_waiting.json',
  336. 'testInProduction': true
  337. },
  338. 'service.metrics.hdfs.block_status': {
  339. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/dfs/FSNamesystem/PendingReplicationBlocks[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/FSNamesystem/UnderReplicatedBlocks[{fromSeconds},{toSeconds},{stepSeconds}]',
  340. 'mock': '/data/services/metrics/hdfs/block_status.json',
  341. 'testInProduction': true
  342. },
  343. 'service.metrics.hdfs.file_operations': {
  344. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/dfs/namenode/FileInfoOps[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/namenode/CreateFileOps[{fromSeconds},{toSeconds},{stepSeconds}]',
  345. 'mock': '/data/services/metrics/hdfs/file_operations.json',
  346. 'testInProduction': true
  347. },
  348. 'service.metrics.hdfs.gc': {
  349. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  350. 'mock': '/data/services/metrics/hdfs/gc.json',
  351. 'testInProduction': true
  352. },
  353. 'service.metrics.hdfs.io': {
  354. 'real': '/clusters/{clusterName}/services/HDFS/components/DATANODE?fields=metrics/dfs/datanode/bytes_written[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/datanode/bytes_read[{fromSeconds},{toSeconds},{stepSeconds}]',
  355. 'mock': '/data/services/metrics/hdfs/io.json',
  356. 'testInProduction': true
  357. },
  358. 'service.metrics.hdfs.jvm_heap': {
  359. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/jvm/memNonHeapUsedM[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/memNonHeapCommittedM[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/memHeapUsedM[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/memHeapCommittedM[{fromSeconds},{toSeconds},{stepSeconds}]',
  360. 'mock': '/data/services/metrics/hdfs/jvm_heap.json',
  361. 'testInProduction': true
  362. },
  363. 'service.metrics.hdfs.jvm_threads': {
  364. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/jvm/threadsRunnable[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/threadsBlocked[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/threadsWaiting[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/threadsTimedWaiting[{fromSeconds},{toSeconds},{stepSeconds}]',
  365. 'mock': '/data/services/metrics/hdfs/jvm_threads.json',
  366. 'testInProduction': true
  367. },
  368. 'service.metrics.hdfs.rpc': {
  369. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  370. 'mock': '/data/services/metrics/hdfs/rpc.json',
  371. 'testInProduction': true
  372. },
  373. 'service.metrics.hdfs.space_utilization': {
  374. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/dfs/FSNamesystem/CapacityRemainingGB[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/FSNamesystem/CapacityUsedGB[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/FSNamesystem/CapacityTotalGB[{fromSeconds},{toSeconds},{stepSeconds}]',
  375. 'mock': '/data/services/metrics/hdfs/space_utilization.json',
  376. 'testInProduction': true
  377. },
  378. 'service.start_stop': {
  379. 'real': '/clusters/{clusterName}/services?params/run_smoke_test=true',
  380. 'mock': '/data/mirroring/poll/poll_6.json',
  381. 'format': function (data, opt) {
  382. return {
  383. type: 'PUT',
  384. async: false,
  385. data: data.data
  386. };
  387. }
  388. },
  389. 'service.metrics.yarn.gc': {
  390. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  391. 'mock': '/data/services/metrics/yarn/gc.json',
  392. 'testInProduction': true
  393. },
  394. 'service.metrics.yarn.jobs_threads': {
  395. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/jvm/threadsRunnable[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/threadsBlocked[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/threadsWaiting[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/threadsTimedWaiting[{fromSeconds},{toSeconds},{stepSeconds}]',
  396. 'mock': '/data/services/metrics/yarn/jvm_threads.json',
  397. 'testInProduction': true
  398. },
  399. 'service.metrics.yarn.rpc': {
  400. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  401. 'mock': '/data/services/metrics/yarn/rpc.json',
  402. 'testInProduction': true
  403. },
  404. 'service.metrics.yarn.jobs_heap': {
  405. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/jvm/memNonHeapUsedM[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/memNonHeapCommittedM[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/memHeapUsedM[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/memHeapCommittedM[{fromSeconds},{toSeconds},{stepSeconds}]',
  406. 'mock': '/data/services/metrics/yarn/jvm_heap.json',
  407. 'testInProduction': true
  408. },
  409. 'service.metrics.yarn.queue.allocated': {
  410. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/yarn/Queue/root/AvailableMB[{fromSeconds},{toSeconds},{stepSeconds}],metrics/yarn/Queue/root/PendingMB[{fromSeconds},{toSeconds},{stepSeconds}],metrics/yarn/Queue/root/AllocatedMB[{fromSeconds},{toSeconds},{stepSeconds}]',
  411. 'mock': '',
  412. 'testInProduction': true
  413. },
  414. 'service.metrics.yarn.queue.allocated.container': {
  415. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/yarn/Queue/root/AllocatedContainers[{fromSeconds},{toSeconds},{stepSeconds}],metrics/yarn/Queue/root/ReservedContainers[{fromSeconds},{toSeconds},{stepSeconds}],metrics/yarn/Queue/root/PendingContainers[{fromSeconds},{toSeconds},{stepSeconds}]',
  416. 'mock': '',
  417. 'testInProduction': true
  418. },
  419. 'service.metrics.yarn.node.manager.statuses': {
  420. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/yarn/ClusterMetrics/NumActiveNMs[{fromSeconds},{toSeconds},{stepSeconds}],metrics/yarn/ClusterMetrics/NumDecommissionedNMs[{fromSeconds},{toSeconds},{stepSeconds}],metrics/yarn/ClusterMetrics/NumLostNMs[{fromSeconds},{toSeconds},{stepSeconds}],metrics/yarn/ClusterMetrics/NumRebootedNMs[{fromSeconds},{toSeconds},{stepSeconds}],metrics/yarn/ClusterMetrics/NumUnhealthyNMs[{fromSeconds},{toSeconds},{stepSeconds}]',
  421. 'mock': '',
  422. 'testInProduction': true
  423. },
  424. 'service.metrics.yarn.queue.memory.resource': {
  425. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=',
  426. 'mock': '',
  427. 'format': function (data, opt) {
  428. var field1 = 'metrics/yarn/Queue/{queueName}/AllocatedMB[{fromSeconds},{toSeconds},{stepSeconds}]';
  429. var field2 = 'metrics/yarn/Queue/{queueName}/AvailableMB[{fromSeconds},{toSeconds},{stepSeconds}]';
  430. if (opt.url != null && data.queueNames != null) {
  431. data.queueNames.forEach(function (q) {
  432. data.queueName = q;
  433. opt.url += (formatUrl(field1, data) + ",");
  434. opt.url += (formatUrl(field2, data) + ",");
  435. });
  436. }
  437. },
  438. 'testInProduction': true
  439. },
  440. 'service.metrics.yarn.queue.apps.states.current': {
  441. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/yarn/Queue/root/AppsPending[{fromSeconds},{toSeconds},{stepSeconds}],metrics/yarn/Queue/root/AppsRunning[{fromSeconds},{toSeconds},{stepSeconds}]',
  442. 'mock': '',
  443. 'testInProduction': true
  444. },
  445. 'service.metrics.yarn.queue.apps.states.finished': {
  446. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/yarn/Queue/root/AppsKilled[{fromSeconds},{toSeconds},{stepSeconds}],metrics/yarn/Queue/root/AppsFailed[{fromSeconds},{toSeconds},{stepSeconds}],metrics/yarn/Queue/root/AppsSubmitted[{fromSeconds},{toSeconds},{stepSeconds}],metrics/yarn/Queue/root/AppsCompleted[{fromSeconds},{toSeconds},{stepSeconds}]',
  447. 'mock': '',
  448. 'testInProduction': true
  449. },
  450. 'dashboard.cluster_metrics.cpu': {
  451. 'real': '/clusters/{clusterName}/?fields=metrics/cpu[{fromSeconds},{toSeconds},{stepSeconds}]',
  452. 'mock': '/data/cluster_metrics/cpu_1hr.json',
  453. 'testInProduction': true
  454. },
  455. 'dashboard.cluster_metrics.load': {
  456. 'real': '/clusters/{clusterName}/?fields=metrics/load[{fromSeconds},{toSeconds},{stepSeconds}]',
  457. 'mock': '/data/cluster_metrics/load_1hr.json',
  458. 'testInProduction': true
  459. },
  460. 'dashboard.cluster_metrics.memory': {
  461. 'real': '/clusters/{clusterName}/?fields=metrics/memory[{fromSeconds},{toSeconds},{stepSeconds}]',
  462. 'mock': '/data/cluster_metrics/memory_1hr.json',
  463. 'testInProduction': true
  464. },
  465. 'dashboard.cluster_metrics.network': {
  466. 'real': '/clusters/{clusterName}/?fields=metrics/network[{fromSeconds},{toSeconds},{stepSeconds}]',
  467. 'mock': '/data/cluster_metrics/network_1hr.json',
  468. 'testInProduction': true
  469. },
  470. 'host.metrics.cpu': {
  471. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/cpu/cpu_user[{fromSeconds},{toSeconds},{stepSeconds}],metrics/cpu/cpu_wio[{fromSeconds},{toSeconds},{stepSeconds}],metrics/cpu/cpu_nice[{fromSeconds},{toSeconds},{stepSeconds}],metrics/cpu/cpu_aidle[{fromSeconds},{toSeconds},{stepSeconds}],metrics/cpu/cpu_system[{fromSeconds},{toSeconds},{stepSeconds}],metrics/cpu/cpu_idle[{fromSeconds},{toSeconds},{stepSeconds}]',
  472. 'mock': '/data/hosts/metrics/cpu.json',
  473. 'testInProduction': true
  474. },
  475. 'host.metrics.disk': {
  476. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/disk/disk_total[{fromSeconds},{toSeconds},{stepSeconds}],metrics/disk/disk_free[{fromSeconds},{toSeconds},{stepSeconds}]',
  477. 'mock': '/data/hosts/metrics/disk.json',
  478. 'testInProduction': true
  479. },
  480. 'host.metrics.load': {
  481. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/load/load_fifteen[{fromSeconds},{toSeconds},{stepSeconds}],metrics/load/load_one[{fromSeconds},{toSeconds},{stepSeconds}],metrics/load/load_five[{fromSeconds},{toSeconds},{stepSeconds}]',
  482. 'mock': '/data/hosts/metrics/load.json',
  483. 'testInProduction': true
  484. },
  485. 'host.metrics.memory': {
  486. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/memory/swap_free[{fromSeconds},{toSeconds},{stepSeconds}],metrics/memory/mem_shared[{fromSeconds},{toSeconds},{stepSeconds}],metrics/memory/mem_free[{fromSeconds},{toSeconds},{stepSeconds}],metrics/memory/mem_cached[{fromSeconds},{toSeconds},{stepSeconds}],metrics/memory/mem_buffers[{fromSeconds},{toSeconds},{stepSeconds}]',
  487. 'mock': '/data/hosts/metrics/memory.json',
  488. 'testInProduction': true
  489. },
  490. 'host.metrics.network': {
  491. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/network/bytes_in[{fromSeconds},{toSeconds},{stepSeconds}],metrics/network/bytes_out[{fromSeconds},{toSeconds},{stepSeconds}],metrics/network/pkts_in[{fromSeconds},{toSeconds},{stepSeconds}],metrics/network/pkts_out[{fromSeconds},{toSeconds},{stepSeconds}]',
  492. 'mock': '/data/hosts/metrics/network.json',
  493. 'testInProduction': true
  494. },
  495. 'host.metrics.processes': {
  496. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/process/proc_total[{fromSeconds},{toSeconds},{stepSeconds}],metrics/process/proc_run[{fromSeconds},{toSeconds},{stepSeconds}]',
  497. 'mock': '/data/hosts/metrics/processes.json',
  498. 'testInProduction': true
  499. },
  500. 'host.service_config_hosts_overrides': {
  501. 'real': '/clusters/{clusterName}/configurations?{urlParams}',
  502. 'mock': '',
  503. 'format': function (data, opt) {
  504. return {
  505. async: false,
  506. timeout: 10000
  507. };
  508. }
  509. },
  510. 'admin.security_status': {
  511. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs',
  512. 'mock': '',
  513. 'format': function (data, opt) {
  514. return {
  515. timeout: 10000
  516. };
  517. }
  518. },
  519. 'cluster.load_cluster_name': {
  520. 'real': '/clusters',
  521. 'mock': '/data/clusters/info.json',
  522. 'format': function (data, opt) {
  523. return {
  524. async: false
  525. };
  526. }
  527. },
  528. 'cluster.state': {
  529. 'type': 'POST',
  530. 'real': '/persist/',
  531. 'mock': '',
  532. 'format': function (data, opt) {
  533. return {
  534. async: false,
  535. data: JSON.stringify(data.key),
  536. newValue: data.newVal
  537. };
  538. }
  539. },
  540. 'cluster.update_upgrade_version': {
  541. 'real': '/stacks2/HDP/versions?fields=stackServices/StackServices,Versions',
  542. 'mock': '/data/wizard/stack/stacks.json',
  543. 'format': function (data, opt) {
  544. return {
  545. async: false
  546. };
  547. }
  548. },
  549. 'cluster.load_repositories': {
  550. 'real': '/stacks2/{stackName}/versions/{stackVersion}/operatingSystems?fields=repositories/*',
  551. 'mock': '',
  552. 'type': 'GET',
  553. 'format': function (data, opt) {
  554. return {
  555. async: false
  556. };
  557. }
  558. },
  559. 'admin.high_availability.stop_all_services': {
  560. 'real': '/clusters/{clusterName}/services',
  561. 'mock': '',
  562. 'format': function (data, opt) {
  563. return {
  564. type: 'PUT',
  565. data: JSON.stringify({
  566. "RequestInfo": {
  567. "context": "Stop all services"
  568. },
  569. "Body": {
  570. "ServiceInfo": {
  571. "state": "INSTALLED"
  572. }
  573. }
  574. })
  575. }
  576. }
  577. },
  578. 'admin.high_availability.start_all_services': {
  579. 'real': '/clusters/{clusterName}/services',
  580. 'mock': '',
  581. 'format': function (data, opt) {
  582. return {
  583. type: 'PUT',
  584. data: JSON.stringify({
  585. "RequestInfo": {
  586. "context": "Start all services"
  587. },
  588. "Body": {
  589. "ServiceInfo": {
  590. "state": "STARTED"
  591. }
  592. }
  593. })
  594. }
  595. }
  596. },
  597. 'admin.high_availability.polling': {
  598. 'real': '/clusters/{clusterName}/requests/{requestId}?fields=tasks/*',
  599. 'mock': '',
  600. 'type': 'GET'
  601. },
  602. 'admin.high_availability.getNnCheckPointStatus': {
  603. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/NAMENODE',
  604. 'mock': '',
  605. 'type': 'GET'
  606. },
  607. 'admin.high_availability.getJnCheckPointStatus': {
  608. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/JOURNALNODE?fields=metrics',
  609. 'mock': ''
  610. },
  611. 'admin.high_availability.getHostComponent': {
  612. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  613. 'mock': ''
  614. },
  615. 'admin.high_availability.create_component': {
  616. 'real': '/clusters/{clusterName}/hosts?Hosts/host_name={hostName}',
  617. 'mock': '',
  618. 'type': 'POST',
  619. 'format': function (data) {
  620. return {
  621. data: JSON.stringify({
  622. "host_components": [
  623. {
  624. "HostRoles": {
  625. "component_name": data.componentName
  626. }
  627. }
  628. ]
  629. })
  630. }
  631. }
  632. },
  633. 'admin.high_availability.create_journalnode': {
  634. 'real': '/clusters/{clusterName}/services?ServiceInfo/service_name=HDFS',
  635. 'mock': '',
  636. 'type': 'POST',
  637. 'format': function (data) {
  638. return {
  639. data: JSON.stringify({
  640. "components": [
  641. {
  642. "ServiceComponentInfo": {
  643. "component_name": "JOURNALNODE"
  644. }
  645. }
  646. ]
  647. })
  648. }
  649. }
  650. },
  651. 'admin.high_availability.create_zkfc': {
  652. 'real': '/clusters/{clusterName}/services?ServiceInfo/service_name=HDFS',
  653. 'mock': '',
  654. 'type': 'POST',
  655. 'format': function (data) {
  656. return {
  657. data: JSON.stringify({
  658. "components": [
  659. {
  660. "ServiceComponentInfo": {
  661. "component_name": "ZKFC"
  662. }
  663. }
  664. ]
  665. })
  666. }
  667. }
  668. },
  669. 'admin.high_availability.install_component': {
  670. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  671. 'mock': '',
  672. 'type': 'PUT',
  673. 'format': function (data) {
  674. return {
  675. data: JSON.stringify({
  676. RequestInfo: {
  677. "context": "Install " + data.displayName
  678. },
  679. Body: {
  680. "HostRoles": {
  681. "state": "INSTALLED"
  682. }
  683. }
  684. })
  685. }
  686. }
  687. },
  688. 'admin.high_availability.start_component': {
  689. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  690. 'mock': '',
  691. 'type': 'PUT',
  692. 'format': function (data) {
  693. return {
  694. data: JSON.stringify({
  695. RequestInfo: {
  696. "context": "Start " + data.displayName
  697. },
  698. Body: {
  699. "HostRoles": {
  700. "state": "STARTED"
  701. }
  702. }
  703. })
  704. }
  705. }
  706. },
  707. 'admin.high_availability.maintenance_mode': {
  708. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  709. 'mock': '',
  710. 'type': 'PUT',
  711. 'format': function () {
  712. return {
  713. data: JSON.stringify({
  714. "HostRoles": {
  715. "state": "MAINTENANCE"
  716. }
  717. })
  718. }
  719. }
  720. },
  721. 'admin.high_availability.stop_component': {
  722. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  723. 'mock': '',
  724. 'type': 'PUT',
  725. 'format': function (data) {
  726. return {
  727. data: JSON.stringify({
  728. RequestInfo: {
  729. "context": "Stop " + data.displayName
  730. },
  731. Body: {
  732. "HostRoles": {
  733. "state": "INSTALLED"
  734. }
  735. }
  736. })
  737. }
  738. }
  739. },
  740. 'admin.high_availability.load_configs': {
  741. 'real': '/clusters/{clusterName}/configurations?(type=core-site&tag={coreSiteTag})|(type=hdfs-site&tag={hdfsSiteTag})',
  742. 'mock': '',
  743. 'type': 'GET'
  744. },
  745. 'admin.high_availability.save_configs': {
  746. 'real': '/clusters/{clusterName}',
  747. 'mock': '',
  748. 'type': 'PUT',
  749. 'format': function (data) {
  750. return {
  751. async: false,
  752. data: JSON.stringify({
  753. Clusters: {
  754. desired_config: {
  755. "type": data.siteName,
  756. "tag": 'version' + (new Date).getTime(),
  757. "properties": data.properties
  758. }
  759. }
  760. })
  761. }
  762. }
  763. },
  764. 'admin.high_availability.load_hbase_configs': {
  765. 'real': '/clusters/{clusterName}/configurations?type=hbase-site&tag={hbaseSiteTag}',
  766. 'mock': '',
  767. 'type': 'GET'
  768. },
  769. 'admin.high_availability.delete_component': {
  770. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  771. 'mock': '',
  772. 'type': 'DELETE'
  773. },
  774. 'admin.security.cluster_configs': {
  775. 'real': '/clusters/{clusterName}',
  776. 'mock': '',
  777. 'format': function (data, opt) {
  778. return {
  779. timeout: 10000
  780. };
  781. }
  782. },
  783. 'admin.delete_host': {
  784. 'real': '/clusters/{clusterName}/hosts/{hostName}',
  785. 'mock': '',
  786. 'type': 'DELETE'
  787. },
  788. 'admin.security.all_configurations': {
  789. 'real': '/clusters/{clusterName}/configurations?{urlParams}',
  790. 'mock': '',
  791. 'format': function (data, opt) {
  792. return {
  793. timeout: 10000
  794. };
  795. }
  796. },
  797. 'admin.security.apply_configurations': {
  798. 'real': '/clusters/{clusterName}',
  799. 'mock': '',
  800. 'format': function (data, opt) {
  801. return {
  802. type: 'PUT',
  803. timeout: 10000,
  804. data: data.configData
  805. };
  806. }
  807. },
  808. 'admin.security.apply_configuration': {
  809. 'real': '/clusters/{clusterName}',
  810. 'mock': '',
  811. 'format': function (data, opt) {
  812. return {
  813. type: 'PUT',
  814. async: false,
  815. timeout: 5000,
  816. data: JSON.stringify(data.clusterData)
  817. };
  818. }
  819. },
  820. 'admin.security.add.cluster_configs': {
  821. 'real': '/clusters/{clusterName}' + '?fields=Clusters/desired_configs',
  822. 'mock': '',
  823. 'format': function (data, opt) {
  824. return {
  825. timeout: 10000
  826. };
  827. }
  828. },
  829. 'admin.stack_upgrade.run_upgrade': {
  830. 'real': '/clusters/{clusterName}',
  831. 'mock': '',
  832. 'format': function (data, opt) {
  833. return {
  834. type: 'PUT',
  835. async: false,
  836. data: data.data
  837. };
  838. }
  839. },
  840. 'admin.stack_upgrade.stop_services': {
  841. 'real': '/clusters/{clusterName}/services?ServiceInfo/state=STARTED',
  842. 'mock': '',
  843. 'format': function (data, opt) {
  844. return {
  845. type: 'PUT',
  846. async: false,
  847. data: data.data
  848. };
  849. }
  850. },
  851. 'admin.stack_upgrade.do_poll': {
  852. 'real': '/clusters/{cluster}/requests/{requestId}?fields=tasks/*',
  853. 'mock': '/data/wizard/{mock}'
  854. },
  855. 'wizard.advanced_repositories.valid_url': {
  856. 'real': '/stacks2/{stackName}/versions/{stackVersion}/operatingSystems/{osType}/repositories/{nameVersionCombo}',
  857. 'mock': '',
  858. 'type': 'PUT',
  859. 'format': function (data) {
  860. return {
  861. async: true,
  862. data: JSON.stringify(data.data)
  863. }
  864. }
  865. },
  866. 'wizard.install_services.add_host_controller.is_retry': {
  867. 'real': '/clusters/{cluster}/host_components',
  868. 'mock': '',
  869. 'format': function (data, opt) {
  870. return {
  871. type: 'PUT',
  872. async: false,
  873. data: data.data
  874. };
  875. }
  876. },
  877. 'wizard.install_services.add_host_controller.not_is_retry': {
  878. 'real': '/clusters/{cluster}/host_components',
  879. 'mock': '',
  880. 'format': function (data, opt) {
  881. return {
  882. type: 'PUT',
  883. async: false,
  884. data: data.data
  885. };
  886. }
  887. },
  888. 'wizard.install_services.installer_controller.is_retry': {
  889. 'real': '/clusters/{cluster}/host_components?HostRoles/state=INSTALLED',
  890. 'mock': '/data/wizard/deploy/2_hosts/poll_1.json',
  891. 'type': 'PUT',
  892. 'format': function (data, opt) {
  893. return {
  894. async: false,
  895. data: data.data
  896. };
  897. }
  898. },
  899. 'wizard.install_services.installer_controller.not_is_retry': {
  900. 'real': '/clusters/{cluster}/services?ServiceInfo/state=INIT',
  901. 'mock': '/data/wizard/deploy/2_hosts/poll_1.json',
  902. 'type': 'PUT',
  903. 'format': function (data, opt) {
  904. return {
  905. async: false,
  906. data: data.data
  907. };
  908. }
  909. },
  910. 'wizard.install_services.add_service_controller.get_failed_host_components': {
  911. 'real': '/clusters/{clusterName}/host_components?fields=HostRoles/state,component/ServiceComponentInfo/service_name',
  912. 'mock': '',
  913. 'format': function (data, opt) {
  914. return {
  915. async: false
  916. };
  917. }
  918. },
  919. 'wizard.service_components': {
  920. 'real': '{stackUrl}/stackServices?fields=StackServices',
  921. 'mock': '/data/wizard/stack/hdp/version/{stackVersion}.json',
  922. 'format': function (data, opt) {
  923. return {
  924. timeout: 10000,
  925. async: false
  926. };
  927. }
  928. },
  929. 'wizard.step9.installer.launch_start_services': {
  930. 'real': '/clusters/{cluster}/services?ServiceInfo/state=INSTALLED&params/run_smoke_test=true&params/reconfigure_client=false',
  931. 'mock': '/data/wizard/deploy/5_hosts/poll_6.json',
  932. 'format': function (data, opt) {
  933. var data = {
  934. type: 'PUT',
  935. async: false,
  936. data: data.data
  937. };
  938. if (App.testMode) {
  939. data.type = 'GET';
  940. }
  941. return data;
  942. }
  943. },
  944. 'wizard.step9.add_host.launch_start_services': {
  945. 'real': '/clusters/{cluster}/host_components',
  946. 'mock': '/data/wizard/deploy/5_hosts/poll_6.json',
  947. 'format': function (data, opt) {
  948. return {
  949. type: 'PUT',
  950. async: false,
  951. data: data.data
  952. };
  953. }
  954. },
  955. 'wizard.step8.delete_cluster': {
  956. 'real': '/clusters/{name}',
  957. 'mock': '',
  958. 'format': function (data, opt) {
  959. return {
  960. type: 'DELETE',
  961. async: false
  962. };
  963. }
  964. },
  965. 'wizard.step8.existing_cluster_names': {
  966. 'real': '/clusters',
  967. 'mock': '',
  968. 'format': function (data, opt) {
  969. return {
  970. async: false
  971. };
  972. }
  973. },
  974. 'wizard.step3.host_info': {
  975. 'real': '/hosts?fields=Hosts/total_mem,Hosts/cpu_count,Hosts/disk_info,Hosts/last_agent_env,Hosts/host_name,Hosts/os_type',
  976. 'mock': '/data/wizard/bootstrap/two_hosts_information.json',
  977. 'format': function (data, opt) {
  978. return {
  979. contentType: 'application/json'
  980. };
  981. }
  982. },
  983. 'wizard.step3.rerun_checks': {
  984. 'real': '/hosts?fields=Hosts/last_agent_env',
  985. 'mock': '/data/wizard/bootstrap/two_hosts_information.json',
  986. 'format': function (data, opt) {
  987. return {
  988. contentType: 'application/json'
  989. };
  990. }
  991. },
  992. 'wizard.step3.bootstrap': {
  993. 'real': '/bootstrap/{bootRequestId}',
  994. 'mock': '/data/wizard/bootstrap/poll_{numPolls}.json'
  995. },
  996. 'wizard.step3.is_hosts_registered': {
  997. 'real': '/hosts',
  998. 'mock': '/data/wizard/bootstrap/single_host_registration.json'
  999. },
  1000. 'wizard.stacks': {
  1001. 'real': '/stacks2',
  1002. 'mock': '/data/wizard/stack/stacks2.json',
  1003. 'format': function (data) {
  1004. return {
  1005. async: false
  1006. };
  1007. }
  1008. },
  1009. 'wizard.stacks_versions': {
  1010. 'real': '/stacks2/{stackName}/versions?fields=Versions,operatingSystems/repositories/Repositories',
  1011. 'mock': '/data/wizard/stack/{stackName}_versions.json',
  1012. 'format': function (data) {
  1013. return {
  1014. async: false
  1015. };
  1016. }
  1017. },
  1018. 'wizard.launch_bootstrap': {
  1019. 'real': '/bootstrap',
  1020. 'mock': '/data/wizard/bootstrap/bootstrap.json',
  1021. 'type': 'POST',
  1022. 'format': function (data) {
  1023. return {
  1024. async: false,
  1025. contentType: 'application/json',
  1026. data: data.bootStrapData
  1027. }
  1028. }
  1029. },
  1030. 'router.login': {
  1031. 'real': '/users/{loginName}',
  1032. 'mock': '/data/users/user_{usr}.json',
  1033. 'format': function (data, opt) {
  1034. var statusCode = jQuery.extend({}, require('data/statusCodes'));
  1035. statusCode['403'] = function () {
  1036. console.log("Error code 403: Forbidden.");
  1037. }
  1038. return {
  1039. statusCode: statusCode
  1040. };
  1041. }
  1042. },
  1043. 'router.login2': {
  1044. 'real': '/clusters',
  1045. 'mock': '/data/clusters/info.json'
  1046. },
  1047. 'router.logoff': {
  1048. 'real': '/logout'
  1049. },
  1050. 'router.set_ambari_stacks': {
  1051. 'real': '/stacks',
  1052. 'mock': '/data/wizard/stack/stacks.json',
  1053. 'format': function (data, opt) {
  1054. return {
  1055. async: false
  1056. };
  1057. }
  1058. },
  1059. 'router.authentication': {
  1060. 'real': '/clusters',
  1061. 'mock': '/data/clusters/info.json',
  1062. 'format': function (data, opt) {
  1063. return {
  1064. async: false
  1065. };
  1066. }
  1067. },
  1068. 'ambari.service': {
  1069. 'real': '/services/AMBARI/components/AMBARI_SERVER',
  1070. 'mock': ''
  1071. },
  1072. 'dashboard.get.user_pref': {
  1073. 'real': '/persist/{key}',
  1074. 'mock': '',
  1075. 'format': function (data, opt) {
  1076. return {
  1077. async: false
  1078. };
  1079. }
  1080. },
  1081. 'dashboard.post.user_pref': {
  1082. 'real': '/persist',
  1083. 'mock': '',
  1084. 'type': 'POST',
  1085. 'format': function (data) {
  1086. return {
  1087. async: false,
  1088. data: JSON.stringify(data.keyValuePair)
  1089. }
  1090. }
  1091. },
  1092. 'config_groups.create': {
  1093. 'real': '/clusters/{clusterName}/config_groups',
  1094. 'mock': '',
  1095. 'format': function (data) {
  1096. return {
  1097. async: false,
  1098. type: 'POST',
  1099. data: JSON.stringify([{
  1100. "ConfigGroup": {
  1101. "group_name": data.group_name,
  1102. "tag": data.service_id,
  1103. "description": data.description
  1104. }
  1105. }])
  1106. }
  1107. }
  1108. }
  1109. };
  1110. /**
  1111. * Replace data-placeholders to its values
  1112. *
  1113. * @param {String} url
  1114. * @param {Object} data
  1115. * @return {String}
  1116. */
  1117. var formatUrl = function (url, data) {
  1118. var keys = url.match(/\{\w+\}/g);
  1119. keys = (keys === null) ? [] : keys;
  1120. if (keys) {
  1121. keys.forEach(function (key) {
  1122. var raw_key = key.substr(1, key.length - 2);
  1123. var replace;
  1124. if (!data[raw_key]) {
  1125. replace = '';
  1126. }
  1127. else {
  1128. replace = data[raw_key];
  1129. }
  1130. url = url.replace(new RegExp(key, 'g'), replace);
  1131. });
  1132. }
  1133. return url;
  1134. };
  1135. /**
  1136. * this = object from config
  1137. * @return {Object}
  1138. */
  1139. var formatRequest = function (data) {
  1140. var opt = {
  1141. type: this.type || 'GET',
  1142. timeout: App.timeout,
  1143. dataType: 'json',
  1144. statusCode: require('data/statusCodes')
  1145. };
  1146. if (App.testMode) {
  1147. opt.url = formatUrl(this.mock ? this.mock : '', data);
  1148. opt.type = 'GET';
  1149. }
  1150. else {
  1151. opt.url = App.apiPrefix + formatUrl(this.real, data);
  1152. }
  1153. if (this.format) {
  1154. jQuery.extend(opt, this.format(data, opt));
  1155. }
  1156. return opt;
  1157. };
  1158. /**
  1159. * Wrapper for all ajax requests
  1160. *
  1161. * @type {Object}
  1162. */
  1163. App.ajax = {
  1164. /**
  1165. * Send ajax request
  1166. *
  1167. * @param {Object} config
  1168. * @return Object jquery ajax object
  1169. *
  1170. * config fields:
  1171. * name - url-key in the urls-object *required*
  1172. * sender - object that send request (need for proper callback initialization) *required*
  1173. * data - object with data for url-format
  1174. * beforeSend - method-name for ajax beforeSend response callback
  1175. * success - method-name for ajax success response callback
  1176. * error - method-name for ajax error response callback
  1177. * callback - callback from <code>App.updater.run</code> library
  1178. */
  1179. send: function (config) {
  1180. console.warn('============== ajax ==============', config.name, config.data);
  1181. if (!config.sender) {
  1182. console.warn('Ajax sender should be defined!');
  1183. return null;
  1184. }
  1185. // default parameters
  1186. var params = {
  1187. clusterName: App.get('clusterName')
  1188. };
  1189. // extend default parameters with provided
  1190. if (config.data) {
  1191. jQuery.extend(params, config.data);
  1192. }
  1193. var opt = {};
  1194. opt = formatRequest.call(urls[config.name], params);
  1195. opt.context = this;
  1196. // object sender should be provided for processing beforeSend, success and error responses
  1197. opt.beforeSend = function (xhr) {
  1198. if (config.beforeSend) {
  1199. config.sender[config.beforeSend](opt, xhr, params);
  1200. }
  1201. };
  1202. opt.success = function (data) {
  1203. console.log("TRACE: The url is: " + opt.url);
  1204. if (config.success) {
  1205. config.sender[config.success](data, opt, params);
  1206. }
  1207. };
  1208. opt.error = function (request, ajaxOptions, error) {
  1209. if (config.error) {
  1210. config.sender[config.error](request, ajaxOptions, error, opt);
  1211. } else {
  1212. this.defaultErrorHandler(request, opt.url, opt.type);
  1213. }
  1214. };
  1215. opt.complete = function () {
  1216. if (config.callback) {
  1217. config.callback();
  1218. }
  1219. };
  1220. if ($.mocho) {
  1221. opt.url = 'http://' + $.hostName + opt.url;
  1222. }
  1223. return $.ajax(opt);
  1224. },
  1225. // A single instance of App.ModalPopup view
  1226. modalPopup: null,
  1227. /**
  1228. * defaultErrorHandler function is referred from App.ajax.send function and App.HttpClient.defaultErrorHandler function
  1229. * @jqXHR {jqXHR Object}
  1230. * @url {string}
  1231. * @method {String} Http method
  1232. * @showStatus {number} HTTP response code which should be shown. Default is 500.
  1233. */
  1234. defaultErrorHandler: function (jqXHR, url, method, showStatus) {
  1235. method = method || 'GET';
  1236. var self = this;
  1237. var api = " received on " + method + " method for API: " + url;
  1238. var showMessage = true;
  1239. try {
  1240. var json = $.parseJSON(jqXHR.responseText);
  1241. var message = json.message;
  1242. } catch (err) {
  1243. }
  1244. if (showStatus === null) {
  1245. showStatus = 500;
  1246. }
  1247. if (message === undefined) {
  1248. showMessage = false;
  1249. }
  1250. var statusCode = jqXHR.status + " status code";
  1251. if (jqXHR.status === showStatus && !this.modalPopup) {
  1252. this.modalPopup = App.ModalPopup.show({
  1253. header: jqXHR.statusText,
  1254. secondary: false,
  1255. onPrimary: function () {
  1256. this.hide();
  1257. self.modalPopup = null;
  1258. },
  1259. bodyClass: Ember.View.extend({
  1260. classNames: ['api-error'],
  1261. template: Ember.Handlebars.compile(['<span class="text-error">{{view.statusCode}}</span><span>{{view.api}}</span>',
  1262. '{{#if view.showMessage}}',
  1263. '<br><br><pre><strong>Error message: </strong><span class="text-error">{{view.message}}</span></pre>',
  1264. '{{/if}}'].join('\n')),
  1265. api: api,
  1266. statusCode: statusCode,
  1267. message: message,
  1268. showMessage: showMessage
  1269. })
  1270. });
  1271. }
  1272. }
  1273. };