ajax.js 44 KB

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