ajax.js 44 KB

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