ajax.js 46 KB

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