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. async: false,
  491. timeout: 10000
  492. };
  493. }
  494. },
  495. 'cluster.load_cluster_name': {
  496. 'real': '/clusters',
  497. 'mock': '/data/clusters/info.json',
  498. 'format': function (data, opt) {
  499. return {
  500. async: false
  501. };
  502. }
  503. },
  504. 'cluster.state': {
  505. 'type': 'POST',
  506. 'real': '/persist/',
  507. 'mock':'',
  508. 'format': function (data, opt) {
  509. return {
  510. async: false,
  511. data: JSON.stringify(data.key),
  512. newValue: data.newVal
  513. };
  514. }
  515. },
  516. 'cluster.update_upgrade_version': {
  517. 'real': '/stacks2/HDP/versions?fields=stackServices/StackServices,Versions',
  518. 'mock': '/data/wizard/stack/stacks.json',
  519. 'format': function (data, opt) {
  520. return {
  521. async: false
  522. };
  523. }
  524. },
  525. 'admin.high_availability.stop_all_services': {
  526. 'real': '/clusters/{clusterName}/services?ServiceInfo/state=STARTED',
  527. 'mock': '',
  528. 'format': function (data, opt) {
  529. return {
  530. type: 'PUT',
  531. data: JSON.stringify({
  532. "RequestInfo": {
  533. "context": "Stop all services"
  534. },
  535. "Body": {
  536. "ServiceInfo": {
  537. "state": "INSTALLED"
  538. }
  539. }
  540. })
  541. }
  542. }
  543. },
  544. 'admin.high_availability.start_all_services': {
  545. 'real': '/clusters/{clusterName}/services?ServiceInfo/state=INSTALLED',
  546. 'mock': '',
  547. 'format': function (data, opt) {
  548. return {
  549. type: 'PUT',
  550. data: JSON.stringify({
  551. "RequestInfo": {
  552. "context": "Start all services"
  553. },
  554. "Body": {
  555. "ServiceInfo": {
  556. "state": "STARTED"
  557. }
  558. }
  559. })
  560. }
  561. }
  562. },
  563. 'admin.high_availability.polling': {
  564. 'real': '/clusters/{clusterName}/requests/{requestId}?fields=tasks/*',
  565. 'mock': '',
  566. 'type': 'GET'
  567. },
  568. 'admin.high_availability.getNnCheckPointStatus': {
  569. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/NAMENODE',
  570. 'mock': '',
  571. 'type': 'GET'
  572. },
  573. 'admin.high_availability.getJnCheckPointStatus': {
  574. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/JOURNALNODE?fields=metrics',
  575. 'mock': ''
  576. },
  577. 'admin.high_availability.getHostComponent': {
  578. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  579. 'mock': ''
  580. },
  581. 'admin.high_availability.create_component': {
  582. 'real': '/clusters/{clusterName}/hosts?Hosts/host_name={hostName}',
  583. 'mock': '',
  584. 'type': 'POST',
  585. 'format': function (data) {
  586. return {
  587. data: JSON.stringify({
  588. "host_components": [
  589. {
  590. "HostRoles": {
  591. "component_name": data.componentName
  592. }
  593. }
  594. ]
  595. })
  596. }
  597. }
  598. },
  599. 'admin.high_availability.create_journalnode': {
  600. 'real': '/clusters/{clusterName}/services?ServiceInfo/service_name=HDFS',
  601. 'mock': '',
  602. 'type': 'POST',
  603. 'format': function (data) {
  604. return {
  605. data: JSON.stringify({
  606. "components": [
  607. {
  608. "ServiceComponentInfo": {
  609. "component_name": "JOURNALNODE"
  610. }
  611. }
  612. ]
  613. })
  614. }
  615. }
  616. },
  617. 'admin.high_availability.create_zkfc': {
  618. 'real': '/clusters/{clusterName}/services?ServiceInfo/service_name=HDFS',
  619. 'mock': '',
  620. 'type': 'POST',
  621. 'format': function (data) {
  622. return {
  623. data: JSON.stringify({
  624. "components": [
  625. {
  626. "ServiceComponentInfo": {
  627. "component_name": "ZKFC"
  628. }
  629. }
  630. ]
  631. })
  632. }
  633. }
  634. },
  635. 'admin.high_availability.install_component': {
  636. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  637. 'mock': '',
  638. 'type': 'PUT',
  639. 'format': function (data) {
  640. return {
  641. data: JSON.stringify({
  642. RequestInfo: {
  643. "context": "Install " + data.displayName
  644. },
  645. Body: {
  646. "HostRoles": {
  647. "state": "INSTALLED"
  648. }
  649. }
  650. })
  651. }
  652. }
  653. },
  654. 'admin.high_availability.start_component': {
  655. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  656. 'mock': '',
  657. 'type': 'PUT',
  658. 'format': function (data) {
  659. return {
  660. data: JSON.stringify({
  661. RequestInfo: {
  662. "context": "Start " + data.displayName
  663. },
  664. Body: {
  665. "HostRoles": {
  666. "state": "STARTED"
  667. }
  668. }
  669. })
  670. }
  671. }
  672. },
  673. 'admin.high_availability.maintenance_mode': {
  674. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  675. 'mock': '',
  676. 'type': 'PUT',
  677. 'format': function () {
  678. return {
  679. data: JSON.stringify({
  680. "HostRoles": {
  681. "state": "MAINTENANCE"
  682. }
  683. })
  684. }
  685. }
  686. },
  687. 'admin.high_availability.stop_component': {
  688. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  689. 'mock': '',
  690. 'type': 'PUT',
  691. 'format': function (data) {
  692. return {
  693. data: JSON.stringify({
  694. RequestInfo: {
  695. "context": "Stop " + data.displayName
  696. },
  697. Body: {
  698. "HostRoles": {
  699. "state": "INSTALLED"
  700. }
  701. }
  702. })
  703. }
  704. }
  705. },
  706. 'admin.high_availability.load_configs': {
  707. 'real': '/clusters/{clusterName}/configurations?(type=core-site&tag={coreSiteTag})|(type=hdfs-site&tag={hdfsSiteTag})',
  708. 'mock': '',
  709. 'type': 'GET'
  710. },
  711. 'admin.high_availability.save_configs': {
  712. 'real': '/clusters/{clusterName}',
  713. 'mock': '',
  714. 'type': 'PUT',
  715. 'format': function (data) {
  716. return {
  717. async: false,
  718. data: JSON.stringify({
  719. Clusters: {
  720. desired_config: {
  721. "type": data.siteName,
  722. "tag": 'version' + (new Date).getTime(),
  723. "properties": data.properties
  724. }
  725. }
  726. })
  727. }
  728. }
  729. },
  730. 'admin.high_availability.load_hbase_configs': {
  731. 'real': '/clusters/{clusterName}/configurations?type=hbase-site&tag={hbaseSiteTag}',
  732. 'mock': '',
  733. 'type': 'GET'
  734. },
  735. 'admin.high_availability.delete_component': {
  736. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  737. 'mock': '',
  738. 'type': 'DELETE'
  739. },
  740. 'admin.security.cluster_configs': {
  741. 'real': '/clusters/{clusterName}',
  742. 'mock':'',
  743. 'format': function (data, opt) {
  744. return {
  745. timeout: 10000
  746. };
  747. }
  748. },
  749. 'admin.delete_host': {
  750. 'real': '/clusters/{clusterName}/hosts/{hostName}',
  751. 'mock': '',
  752. 'type': 'DELETE'
  753. },
  754. 'admin.security.all_configurations': {
  755. 'real': '/clusters/{clusterName}/configurations?{urlParams}',
  756. 'mock':'',
  757. 'format': function (data, opt) {
  758. return {
  759. timeout: 10000
  760. };
  761. }
  762. },
  763. 'admin.security.apply_configurations': {
  764. 'real': '/clusters/{clusterName}',
  765. 'mock':'',
  766. 'format': function (data, opt) {
  767. return {
  768. type: 'PUT',
  769. timeout: 10000,
  770. data:data.configData
  771. };
  772. }
  773. },
  774. 'admin.security.apply_configuration': {
  775. 'real': '/clusters/{clusterName}',
  776. 'mock':'',
  777. 'format': function (data, opt) {
  778. return {
  779. type: 'PUT',
  780. async: false,
  781. timeout: 5000,
  782. data: JSON.stringify(data.clusterData)
  783. };
  784. }
  785. },
  786. 'admin.security.add.cluster_configs': {
  787. 'real': '/clusters/{clusterName}' + '?fields=Clusters/desired_configs',
  788. 'mock':'',
  789. 'format': function (data, opt) {
  790. return {
  791. timeout: 10000
  792. };
  793. }
  794. },
  795. 'admin.stack_upgrade.run_upgrade': {
  796. 'real': '/clusters/{clusterName}',
  797. 'mock':'',
  798. 'format': function (data, opt) {
  799. return {
  800. type: 'PUT',
  801. async: false,
  802. data: data.data
  803. };
  804. }
  805. },
  806. 'admin.stack_upgrade.stop_services': {
  807. 'real': '/clusters/{clusterName}/services?ServiceInfo/state=STARTED',
  808. 'mock':'',
  809. 'format': function (data, opt) {
  810. return {
  811. type: 'PUT',
  812. async: false,
  813. data: data.data
  814. };
  815. }
  816. },
  817. 'admin.stack_upgrade.do_poll': {
  818. 'real': '/clusters/{cluster}/requests/{requestId}?fields=tasks/*',
  819. 'mock': '/data/wizard/{mock}'
  820. },
  821. 'wizard.install_services.add_host_controller.is_retry': {
  822. 'real': '/clusters/{cluster}/host_components',
  823. 'mock':'',
  824. 'format': function (data, opt) {
  825. return {
  826. type: 'PUT',
  827. async: false,
  828. data: data.data
  829. };
  830. }
  831. },
  832. 'wizard.install_services.add_host_controller.not_is_retry': {
  833. 'real': '/clusters/{cluster}/host_components',
  834. 'mock':'',
  835. 'format': function (data, opt) {
  836. return {
  837. type: 'PUT',
  838. async: false,
  839. data: data.data
  840. };
  841. }
  842. },
  843. 'wizard.install_services.installer_controller.is_retry': {
  844. 'real': '/clusters/{cluster}/host_components?HostRoles/state=INSTALLED',
  845. 'mock': '/data/wizard/deploy/2_hosts/poll_1.json',
  846. 'type': 'PUT',
  847. 'format': function (data, opt) {
  848. return {
  849. async: false,
  850. data: data.data
  851. };
  852. }
  853. },
  854. 'wizard.install_services.installer_controller.not_is_retry': {
  855. 'real': '/clusters/{cluster}/services?ServiceInfo/state=INIT',
  856. 'mock': '/data/wizard/deploy/2_hosts/poll_1.json',
  857. 'type': 'PUT',
  858. 'format': function (data, opt) {
  859. return {
  860. async: false,
  861. data: data.data
  862. };
  863. }
  864. },
  865. 'wizard.service_components': {
  866. 'real': '{stackUrl}/stackServices?fields=StackServices',
  867. 'mock': '/data/wizard/stack/hdp/version/{stackVersion}.json',
  868. 'format': function (data, opt) {
  869. return {
  870. timeout: 10000,
  871. async: false
  872. };
  873. }
  874. },
  875. 'wizard.step9.installer.launch_start_services': {
  876. 'real': '/clusters/{cluster}/services?ServiceInfo/state=INSTALLED&params/run_smoke_test=true&params/reconfigure_client=false',
  877. 'mock': '/data/wizard/deploy/5_hosts/poll_6.json',
  878. 'format': function (data, opt) {
  879. var data = {
  880. type: 'PUT',
  881. async: false,
  882. data: data.data
  883. };
  884. if (App.testMode) {
  885. data.type = 'GET';
  886. }
  887. return data;
  888. }
  889. },
  890. 'wizard.step9.add_host.launch_start_services': {
  891. 'real': '/clusters/{cluster}/host_components',
  892. 'mock': '/data/wizard/deploy/5_hosts/poll_6.json',
  893. 'format': function (data, opt) {
  894. return {
  895. type: 'PUT',
  896. async: false,
  897. data: data.data
  898. };
  899. }
  900. },
  901. 'wizard.step8.delete_cluster': {
  902. 'real': '/clusters/{name}',
  903. 'mock':'',
  904. 'format': function (data, opt) {
  905. return {
  906. type: 'DELETE',
  907. async: false
  908. };
  909. }
  910. },
  911. 'wizard.step8.existing_cluster_names': {
  912. 'real': '/clusters',
  913. 'mock':'',
  914. 'format': function (data, opt) {
  915. return {
  916. async: false
  917. };
  918. }
  919. },
  920. 'wizard.step3.host_info': {
  921. 'real': '/hosts?fields=Hosts/total_mem,Hosts/cpu_count,Hosts/disk_info,Hosts/last_agent_env,Hosts/host_name',
  922. 'mock': '/data/wizard/bootstrap/two_hosts_information.json',
  923. 'format': function (data, opt) {
  924. return {
  925. contentType: 'application/json'
  926. };
  927. }
  928. },
  929. 'wizard.step3.rerun_checks': {
  930. 'real': '/hosts?fields=Hosts/last_agent_env',
  931. 'mock': '/data/wizard/bootstrap/two_hosts_information.json',
  932. 'format': function (data, opt) {
  933. return {
  934. contentType: 'application/json'
  935. };
  936. }
  937. },
  938. 'wizard.step3.bootstrap': {
  939. 'real': '/bootstrap/{bootRequestId}',
  940. 'mock': '/data/wizard/bootstrap/poll_{numPolls}.json'
  941. },
  942. 'wizard.step3.is_hosts_registered': {
  943. 'real': '/hosts',
  944. 'mock': '/data/wizard/bootstrap/single_host_registration.json'
  945. },
  946. 'wizard.stacks': {
  947. 'real': '/stacks2',
  948. 'mock': '/data/wizard/stack/stacks2.json',
  949. 'format': function (data) {
  950. return {
  951. async: false
  952. };
  953. }
  954. },
  955. 'wizard.stacks_versions': {
  956. 'real': '/stacks2/{stackName}/versions?fields=Versions,operatingSystems/repositories/Repositories',
  957. 'mock': '/data/wizard/stack/{stackName}_versions.json',
  958. 'format': function (data) {
  959. return {
  960. async: false
  961. };
  962. }
  963. },
  964. 'wizard.launch_bootstrap': {
  965. 'real': '/bootstrap',
  966. 'mock': '/data/wizard/bootstrap/bootstrap.json',
  967. 'type': 'POST',
  968. 'format': function (data) {
  969. return {
  970. async: false,
  971. contentType: 'application/json',
  972. data: data.bootStrapData
  973. }
  974. }
  975. },
  976. 'router.login': {
  977. 'real': '/users/{loginName}',
  978. 'mock': '/data/users/user_{usr}.json',
  979. 'format': function (data, opt) {
  980. var statusCode = jQuery.extend({}, require('data/statusCodes'));
  981. statusCode['403'] = function () {
  982. console.log("Error code 403: Forbidden.");
  983. }
  984. return {
  985. statusCode: statusCode
  986. };
  987. }
  988. },
  989. 'router.login2': {
  990. 'real': '/clusters',
  991. 'mock': '/data/clusters/info.json'
  992. },
  993. 'router.logoff': {
  994. 'real': '/logout'
  995. },
  996. 'router.set_ambari_stacks': {
  997. 'real': '/stacks',
  998. 'mock': '/data/wizard/stack/stacks.json',
  999. 'format': function (data, opt) {
  1000. return {
  1001. async: false
  1002. };
  1003. }
  1004. },
  1005. 'router.authentication': {
  1006. 'real': '/clusters',
  1007. 'mock': '/data/clusters/info.json',
  1008. 'format': function (data, opt) {
  1009. return {
  1010. async: false
  1011. };
  1012. }
  1013. },
  1014. 'ambari.service': {
  1015. 'real': '/services/AMBARI/components/AMBARI_SERVER',
  1016. 'mock': ''
  1017. }
  1018. };
  1019. /**
  1020. * Replace data-placeholders to its values
  1021. *
  1022. * @param {String} url
  1023. * @param {Object} data
  1024. * @return {String}
  1025. */
  1026. var formatUrl = function (url, data) {
  1027. var keys = url.match(/\{\w+\}/g);
  1028. keys = (keys === null) ? [] : keys;
  1029. if (keys) {
  1030. keys.forEach(function (key) {
  1031. var raw_key = key.substr(1, key.length - 2);
  1032. var replace;
  1033. if (!data[raw_key]) {
  1034. replace = '';
  1035. }
  1036. else {
  1037. replace = data[raw_key];
  1038. }
  1039. url = url.replace(new RegExp(key, 'g'), replace);
  1040. });
  1041. }
  1042. return url;
  1043. };
  1044. /**
  1045. * this = object from config
  1046. * @return {Object}
  1047. */
  1048. var formatRequest = function (data) {
  1049. var opt = {
  1050. type: this.type || 'GET',
  1051. timeout: App.timeout,
  1052. dataType: 'json',
  1053. statusCode: require('data/statusCodes')
  1054. };
  1055. if (App.testMode) {
  1056. opt.url = formatUrl(this.mock?this.mock:'', data);
  1057. opt.type = 'GET';
  1058. }
  1059. else {
  1060. opt.url = App.apiPrefix + formatUrl(this.real, data);
  1061. }
  1062. if (this.format) {
  1063. jQuery.extend(opt, this.format(data, opt));
  1064. }
  1065. return opt;
  1066. };
  1067. /**
  1068. * Wrapper for all ajax requests
  1069. *
  1070. * @type {Object}
  1071. */
  1072. App.ajax = {
  1073. /**
  1074. * Send ajax request
  1075. *
  1076. * @param {Object} config
  1077. * @return Object jquery ajax object
  1078. *
  1079. * config fields:
  1080. * name - url-key in the urls-object *required*
  1081. * sender - object that send request (need for proper callback initialization) *required*
  1082. * data - object with data for url-format
  1083. * beforeSend - method-name for ajax beforeSend response callback
  1084. * success - method-name for ajax success response callback
  1085. * error - method-name for ajax error response callback
  1086. * deferred - A flag that will call jquery.when for asynchronous call. This should be used instead of setting async to false
  1087. * callback - callback from <code>App.updater.run</code> library
  1088. */
  1089. send: function (config) {
  1090. console.warn('============== ajax ==============', config.name, config.data);
  1091. if (!config.sender) {
  1092. console.warn('Ajax sender should be defined!');
  1093. return null;
  1094. }
  1095. // default parameters
  1096. var params = {
  1097. clusterName: App.get('clusterName')
  1098. };
  1099. // extend default parameters with provided
  1100. if (config.data) {
  1101. jQuery.extend(params, config.data);
  1102. }
  1103. var opt = {};
  1104. opt = formatRequest.call(urls[config.name], params);
  1105. opt.context = this;
  1106. // object sender should be provided for processing beforeSend, success and error responses
  1107. opt.beforeSend = function (xhr) {
  1108. if (config.beforeSend) {
  1109. config.sender[config.beforeSend](opt, xhr, params);
  1110. }
  1111. };
  1112. opt.success = function (data) {
  1113. console.log("TRACE: The url is: " + opt.url);
  1114. if (config.success) {
  1115. config.sender[config.success](data, opt, params);
  1116. }
  1117. };
  1118. opt.error = function (request, ajaxOptions, error) {
  1119. if (config.error) {
  1120. config.sender[config.error](request, ajaxOptions, error, opt);
  1121. } else {
  1122. this.defaultErrorHandler(request,opt.url,opt.type);
  1123. }
  1124. };
  1125. opt.complete = function () {
  1126. if (config.callback) {
  1127. config.callback();
  1128. }
  1129. };
  1130. if ($.mocho) {
  1131. opt.url = 'http://' + $.hostName + opt.url;
  1132. }
  1133. if (config.deferred === true) {
  1134. var successCallback = opt.success;
  1135. var errorCallback = opt.error;
  1136. delete opt['success'];
  1137. delete opt['error'];
  1138. delete opt['async'];
  1139. $.when($.ajax(opt)).then(successCallback,errorCallback);
  1140. } else {
  1141. return $.ajax(opt);
  1142. }
  1143. },
  1144. // A single instance of App.ModalPopup view
  1145. modalPopup: null,
  1146. /**
  1147. * defaultErrorHandler function is referred from App.ajax.send function and App.HttpClient.defaultErrorHandler function
  1148. * @jqXHR {jqXHR Object}
  1149. * @url {string}
  1150. * @method {String} Http method
  1151. * @showStatus {number} HTTP response code which should be shown. Default is 500.
  1152. */
  1153. defaultErrorHandler: function(jqXHR,url,method,showStatus) {
  1154. method = method || 'GET';
  1155. var self = this;
  1156. var api = " received on " + method + " method for API: " + url;
  1157. var showMessage = true;
  1158. try {
  1159. var json = $.parseJSON(jqXHR.responseText);
  1160. var message = json.message;
  1161. } catch (err) {
  1162. }
  1163. if (showStatus === null) {
  1164. showStatus = 500;
  1165. }
  1166. if (message === undefined) {
  1167. showMessage = false;
  1168. }
  1169. var statusCode = jqXHR.status + " status code";
  1170. if (jqXHR.status === showStatus && !this.modalPopup) {
  1171. this.modalPopup = App.ModalPopup.show({
  1172. header: jqXHR.statusText,
  1173. secondary: false,
  1174. onPrimary: function () {
  1175. this.hide();
  1176. self.modalPopup = null;
  1177. },
  1178. bodyClass: Ember.View.extend({
  1179. classNames: ['api-error'],
  1180. template: Ember.Handlebars.compile(['<span class="text-error">{{view.statusCode}}</span><span>{{view.api}}</span>',
  1181. '{{#if view.showMessage}}',
  1182. '<br><br><pre><strong>Error message: </strong><span class="text-error">{{view.message}}</span></pre>',
  1183. '{{/if}}'].join('\n')),
  1184. api: api,
  1185. statusCode: statusCode,
  1186. message: message,
  1187. showMessage: showMessage
  1188. })
  1189. });
  1190. }
  1191. }
  1192. };