ajax.js 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906
  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. May be called with one or two parameters (data, opt). 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. 'alerts.get_by_service': {
  33. 'real': '/clusters/{clusterName}/services/{serviceName}?fields=alerts',
  34. 'mock': '/data/alerts/HDP2/service_alerts.json'
  35. },
  36. 'alerts.get_by_host': {
  37. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=alerts',
  38. 'mock': '/data/alerts/HDP2/host_alerts.json'
  39. },
  40. 'background_operations.get_most_recent': {
  41. 'real': '/clusters/{clusterName}/requests?to=end&page_size=10&fields=Requests',
  42. 'mock': '/data/background_operations/list_on_start.json',
  43. 'testInProduction': true
  44. },
  45. 'background_operations.get_by_request': {
  46. 'real': '/clusters/{clusterName}/requests/{requestId}?fields=*,tasks/Tasks/command,tasks/Tasks/command_detail,tasks/Tasks/start_time,tasks/Tasks/end_time,tasks/Tasks/exit_code,tasks/Tasks/host_name,tasks/Tasks/id,tasks/Tasks/role,tasks/Tasks/status&minimal_response=true',
  47. 'mock': '/data/background_operations/task_by_request{requestId}.json',
  48. 'testInProduction': true,
  49. 'format': function (data) {
  50. return {
  51. async: !data.sync
  52. };
  53. }
  54. },
  55. 'background_operations.get_by_task': {
  56. 'real': '/clusters/{clusterName}/requests/{requestId}/tasks/{taskId}',
  57. 'mock': '/data/background_operations/list_on_start.json',
  58. 'testInProduction': true,
  59. 'format': function (data) {
  60. return {
  61. async: !data.sync
  62. };
  63. }
  64. },
  65. 'service.item.start_stop': {
  66. 'real': '/clusters/{clusterName}/services/{serviceName}',
  67. 'mock': '/data/wizard/deploy/poll_1.json',
  68. 'format': function (data) {
  69. return {
  70. type: 'PUT',
  71. data: JSON.stringify({
  72. RequestInfo: {
  73. "context": data.requestInfo
  74. },
  75. Body: {
  76. ServiceInfo: {
  77. state: data.state
  78. }
  79. }
  80. })
  81. };
  82. }
  83. },
  84. 'service.item.smoke': {
  85. 'real': '/clusters/{clusterName}/requests',
  86. 'mock': '/data/wizard/deploy/poll_1.json',
  87. 'format': function (data) {
  88. return {
  89. 'type': 'POST',
  90. data: JSON.stringify({
  91. RequestInfo: {
  92. "context": data.displayName + " Service Check",
  93. "command" : data.actionName,
  94. "service_name" : data.serviceName
  95. }
  96. })
  97. };
  98. }
  99. },
  100. 'service.item.passive': {
  101. 'real': '/clusters/{clusterName}/services/{serviceName}',
  102. 'mock': '',
  103. 'format': function (data) {
  104. return {
  105. type: 'PUT',
  106. data: JSON.stringify({
  107. RequestInfo: {
  108. "context": data.requestInfo
  109. },
  110. Body: {
  111. ServiceInfo: {
  112. maintenance_state: data.passive_state
  113. }
  114. }
  115. })
  116. };
  117. }
  118. },
  119. 'service.stale_host_components.start_stop': {
  120. 'real': '/clusters/{clusterName}/host_components?' +
  121. 'HostRoles/stale_configs=true&HostRoles/component_name.in({componentNames})',
  122. 'mock': '/data/wizard/deploy/poll_1.json',
  123. 'format': function (data) {
  124. return {
  125. type: 'PUT',
  126. data: JSON.stringify({
  127. RequestInfo: {
  128. "context": data.requestInfo
  129. },
  130. Body: {
  131. HostRoles: {
  132. state: data.state
  133. }
  134. }
  135. })
  136. };
  137. }
  138. },
  139. 'service.load_config_groups': {
  140. 'real': '/clusters/{clusterName}/config_groups?ConfigGroup/tag={serviceName}&fields=*',
  141. 'mock': '/data/configurations/config_group.json'
  142. },
  143. 'reassign.stop_services': {
  144. 'real': '/clusters/{clusterName}/services',
  145. 'mock': '',
  146. 'format': function() {
  147. return {
  148. type: 'PUT',
  149. data: JSON.stringify({
  150. "RequestInfo": {
  151. "context": "Stop all services"
  152. },
  153. "Body": {
  154. "ServiceInfo": {
  155. "state": "INSTALLED"
  156. }
  157. }
  158. })
  159. }
  160. }
  161. },
  162. 'reassign.start_services': {
  163. 'real': '/clusters/{clusterName}/services?params/run_smoke_test=true',
  164. 'mock': '',
  165. 'format': function() {
  166. return {
  167. type: 'PUT',
  168. data: JSON.stringify({
  169. "RequestInfo": {
  170. "context": "Start all services"
  171. },
  172. "Body": {
  173. "ServiceInfo": {
  174. "state": "STARTED"
  175. }
  176. }
  177. })
  178. }
  179. }
  180. },
  181. 'reassign.maintenance_mode': {
  182. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  183. 'mock': '',
  184. 'type': 'PUT',
  185. 'format': function () {
  186. return {
  187. data: JSON.stringify(
  188. {
  189. "HostRoles": {
  190. "state": "DISABLED"
  191. }
  192. }
  193. )
  194. }
  195. }
  196. },
  197. 'reassign.remove_component': {
  198. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  199. 'mock': '',
  200. 'type': 'DELETE'
  201. },
  202. 'reassign.load_configs': {
  203. 'real': '/clusters/{clusterName}/configurations?{urlParams}',
  204. 'mock': ''
  205. },
  206. 'reassign.save_configs': {
  207. 'real': '/clusters/{clusterName}',
  208. 'mock': '',
  209. 'type': 'PUT',
  210. 'format': function (data) {
  211. return {
  212. async: false,
  213. data: JSON.stringify({
  214. Clusters: {
  215. desired_config: {
  216. "type": data.siteName,
  217. "tag": 'version' + (new Date).getTime(),
  218. "properties": data.properties
  219. }
  220. }
  221. })
  222. }
  223. }
  224. },
  225. 'host_component.passive': {
  226. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  227. 'mock': '',
  228. 'type': 'PUT',
  229. 'format': function(data) {
  230. return {
  231. data: JSON.stringify({
  232. RequestInfo: {
  233. "context": data.requestInfo
  234. },
  235. Body: {
  236. HostRoles: {
  237. maintenance_state: data.passive_state
  238. }
  239. }
  240. })
  241. };
  242. }
  243. },
  244. 'config.advanced': {
  245. 'real': '{stack2VersionUrl}/stackServices/{serviceName}/configurations?fields=*',
  246. 'mock': '/data/wizard/stack/hdp/version{stackVersion}/{serviceName}.json',
  247. 'format': function() {
  248. return {
  249. async: false
  250. };
  251. }
  252. },
  253. 'config.advanced.global': {
  254. 'real': '{stack2VersionUrl}/stackServices?fields=configurations/StackConfigurations/type',
  255. 'mock': '/data/wizard/stack/hdp/version1.3.0/global.json',
  256. 'format': function() {
  257. return {
  258. async: false
  259. };
  260. }
  261. },
  262. 'config.tags': {
  263. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs',
  264. 'mock': '/data/clusters/cluster.json'
  265. },
  266. 'config.tags_and_groups': {
  267. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs,config_groups/*',
  268. 'mock': '/data/clusters/tags_and_groups.json'
  269. },
  270. 'config.tags.sync': {
  271. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs',
  272. 'mock': '/data/clusters/cluster.json',
  273. 'format': function() {
  274. return {
  275. async: false
  276. };
  277. }
  278. },
  279. 'config_groups.all_fields': {
  280. 'real': '/clusters/{clusterName}/config_groups?fields=*',
  281. 'mock': ''
  282. },
  283. 'config_groups.get_config_group_by_id': {
  284. 'real': '/clusters/{clusterName}/config_groups/{id}',
  285. 'mock': ''
  286. },
  287. 'config_groups.update_config_group': {
  288. 'real': '/clusters/{clusterName}/config_groups/{id}',
  289. 'mock': '',
  290. 'type': 'PUT',
  291. 'format': function (data) {
  292. return {
  293. async: false,
  294. data: JSON.stringify(
  295. [
  296. data.configGroup
  297. ]
  298. )
  299. }
  300. }
  301. },
  302. 'config_groups.delete_config_group': {
  303. 'real': '/clusters/{clusterName}/config_groups/{id}',
  304. 'mock': '',
  305. 'type': 'DELETE'
  306. },
  307. 'config.on_site': {
  308. 'real': '/clusters/{clusterName}/configurations?{params}',
  309. 'mock': '/data/configurations/cluster_level_configs.json?{params}',
  310. 'format': function() {
  311. return {
  312. async: false
  313. };
  314. }
  315. },
  316. 'config.host_overrides': {
  317. 'real': '/clusters/{clusterName}/configurations?{params}',
  318. 'mock': '/data/configurations/host_level_overrides_configs.json?{params}',
  319. 'format': function() {
  320. return {
  321. async: false
  322. };
  323. }
  324. },
  325. 'host.host_component.action': {
  326. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  327. 'mock': '',
  328. 'type': 'PUT',
  329. 'format': function (data) {
  330. return {
  331. data: JSON.stringify({
  332. RequestInfo: {
  333. "context": data.context
  334. },
  335. Body: {
  336. "HostRoles": {
  337. "state": data.state
  338. }
  339. }
  340. })
  341. }
  342. }
  343. },
  344. 'host.host_component.slave_desired_admin_state': {
  345. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}/?fields=HostRoles/desired_admin_state',
  346. 'mock': ''
  347. },
  348. 'host.host_component.decommission_status': {
  349. 'real': '/clusters/{clusterName}/services/{serviceName}/components/{componentName}/?fields=ServiceComponentInfo',
  350. 'mock': ''
  351. },
  352. 'host.host_component.decommission_slave': {
  353. 'real' : '/clusters/{clusterName}/requests',
  354. 'mock' : '',
  355. 'format' : function(data) {
  356. return {
  357. type : 'POST',
  358. data : JSON.stringify({
  359. RequestInfo: {
  360. 'context': data.context,
  361. 'command': data.command,
  362. 'service_name': data.serviceName,
  363. 'component_name': data.componentName,
  364. 'parameters': {
  365. 'slave_type': data.slaveType,
  366. 'excluded_hosts': data.hostName
  367. }
  368. }
  369. })
  370. }
  371. }
  372. },
  373. 'host.host_component.recommission_and_restart': {
  374. 'real': '/clusters/{clusterName}/request_schedules',
  375. 'mock': '',
  376. 'format' : function(data) {
  377. return {
  378. type : 'POST',
  379. data : JSON.stringify([ {
  380. "RequestSchedule" : {
  381. "batch" : [ {
  382. "requests" : data.batches
  383. }, {
  384. "batch_settings" : {
  385. "batch_separation_in_seconds" : data.intervalTimeSeconds,
  386. "task_failure_tolerance" : data.tolerateSize
  387. }
  388. } ]
  389. }
  390. } ])
  391. }
  392. }
  393. },
  394. 'host.host_component.recommission_slave' : {
  395. 'real' : '/clusters/{clusterName}/requests',
  396. 'mock' : '',
  397. 'format' : function(data) {
  398. return {
  399. type : 'POST',
  400. data : JSON.stringify({
  401. RequestInfo: {
  402. context: data.context,
  403. command: data.command,
  404. service_name: data.serviceName,
  405. component_name: data.componentName,
  406. parameters: {
  407. slave_type: data.slaveType,
  408. included_hosts: data.hostName
  409. }
  410. }
  411. })
  412. }
  413. }
  414. },
  415. 'host.stale_host_components.start_stop': {
  416. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components?HostRoles/stale_configs=true&' +
  417. 'HostRoles/component_name.in({componentNames})',
  418. 'mock': '',
  419. 'type': 'PUT',
  420. 'format': function (data) {
  421. return {
  422. data: JSON.stringify({
  423. RequestInfo: {
  424. "context": data.context
  425. },
  426. Body: {
  427. "HostRoles": {
  428. "state": data.state
  429. }
  430. }
  431. })
  432. }
  433. }
  434. },
  435. 'host.delete': {
  436. 'real': '/clusters/{clusterName}/hosts/{hostName}',
  437. 'mock': '',
  438. 'type': 'DELETE',
  439. 'format': function() {
  440. return {
  441. async: false
  442. }
  443. }
  444. },
  445. 'hosts.metrics': {
  446. 'real': '/clusters/{clusterName}/hosts?fields={metricName}',
  447. 'mock': '/data/cluster_metrics/cpu_1hr.json'
  448. },
  449. 'hosts.metrics.host_component': {
  450. 'real': '/clusters/{clusterName}/services/{serviceName}/components/{componentName}?fields=host_components/{metricName}',
  451. 'mock': '/data/cluster_metrics/cpu_1hr.json'
  452. },
  453. 'service.metrics.flume.channel_fill_percent': {
  454. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/CHANNEL/*/ChannelFillPercentage[{fromSeconds},{toSeconds},{stepSeconds}]',
  455. 'mock': '/data/services/metrics/flume/channelFillPct.json',
  456. 'testInProduction': true
  457. },
  458. 'service.metrics.flume.channel_size': {
  459. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/CHANNEL/*/ChannelSize[{fromSeconds},{toSeconds},{stepSeconds}]',
  460. 'mock': '/data/services/metrics/flume/channelSize.json',
  461. 'testInProduction': true
  462. },
  463. 'service.metrics.flume.sink_drain_success': {
  464. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/SINK/*/EventDrainSuccessCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  465. 'mock': '/data/services/metrics/flume/sinkDrainSuccessCount.json',
  466. 'testInProduction': true
  467. },
  468. 'service.metrics.flume.sink_connection_failed': {
  469. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/SINK/*/ConnectionFailedCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  470. 'mock': '/data/services/metrics/flume/sinkConnectionFailedCount.json',
  471. 'testInProduction': true
  472. },
  473. 'service.metrics.flume.gc': {
  474. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  475. 'mock': '/data/services/metrics/flume/jvmGcTime.json',
  476. 'testInProduction': true
  477. },
  478. 'service.metrics.flume.jvm_heap_used': {
  479. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/jvm/memHeapUsedM[{fromSeconds},{toSeconds},{stepSeconds}]',
  480. 'mock': '/data/services/metrics/flume/jvmMemHeapUsedM.json',
  481. 'testInProduction': true
  482. },
  483. 'service.metrics.flume.jvm_threads_runnable': {
  484. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/jvm/threadsRunnable[{fromSeconds},{toSeconds},{stepSeconds}]',
  485. 'mock': '/data/services/metrics/flume/jvmThreadsRunnable.json',
  486. 'testInProduction': true
  487. },
  488. 'service.metrics.flume.cpu_user': {
  489. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/cpu/cpu_user[{fromSeconds},{toSeconds},{stepSeconds}]',
  490. 'mock': '',
  491. 'testInProduction': true
  492. },
  493. 'service.metrics.flume.source_accepted': {
  494. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/SOURCE/*/EventAcceptedCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  495. 'mock': '/data/services/metrics/flume/sourceEventAccepted.json',
  496. 'testInProduction': true
  497. },
  498. 'service.metrics.hbase.cluster_requests': {
  499. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/cluster_requests[{fromSeconds},{toSeconds},{stepSeconds}]',
  500. 'mock': '/data/services/metrics/hbase/cluster_requests.json',
  501. 'testInProduction': true
  502. },
  503. 'service.metrics.hbase.hlog_split_size': {
  504. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/splitSize_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  505. 'mock': '/data/services/metrics/hbase/hlog_split_size.json',
  506. 'testInProduction': true
  507. },
  508. 'service.metrics.hbase.hlog_split_time': {
  509. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/splitTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  510. 'mock': '/data/services/metrics/hbase/hlog_split_time.json',
  511. 'testInProduction': true
  512. },
  513. 'service.metrics.hbase.regionserver_queuesize': {
  514. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/flushQueueSize[{fromSeconds},{toSeconds},{stepSeconds}],metrics/hbase/regionserver/compactionQueueSize[{fromSeconds},{toSeconds},{stepSeconds}]',
  515. 'mock': '/data/services/metrics/hbase/regionserver_queuesize.json',
  516. 'testInProduction': true
  517. },
  518. 'service.metrics.hbase.regionserver_regions': {
  519. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/regions[{fromSeconds},{toSeconds},{stepSeconds}]',
  520. 'mock': '/data/services/metrics/hbase/regionserver_regions.json',
  521. 'testInProduction': true
  522. },
  523. 'service.metrics.hbase.regionserver_rw_requests': {
  524. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/readRequestsCount[{fromSeconds},{toSeconds},{stepSeconds}],metrics/hbase/regionserver/writeRequestsCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  525. 'mock': '/data/services/metrics/hbase/regionserver_rw_requests.json',
  526. 'testInProduction': true
  527. },
  528. 'service.metrics.mapreduce.gc': {
  529. 'real': '/clusters/{clusterName}/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  530. 'mock': '/data/services/metrics/mapreduce/gc.json',
  531. 'testInProduction': true
  532. },
  533. 'service.metrics.mapreduce.jobs_status': {
  534. '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}]',
  535. 'mock': '/data/services/metrics/mapreduce/jobs_status.json',
  536. 'testInProduction': true
  537. },
  538. 'service.metrics.mapreduce.jobs_heap': {
  539. '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}]',
  540. 'mock': '/data/services/metrics/mapreduce/jvm_heap.json',
  541. 'testInProduction': true
  542. },
  543. 'service.metrics.mapreduce.jobs_threads': {
  544. '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}]',
  545. 'mock': '/data/services/metrics/mapreduce/jvm_threads.json',
  546. 'testInProduction': true
  547. },
  548. 'service.metrics.mapreduce.map_slots': {
  549. '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}]',
  550. 'mock': '/data/services/metrics/mapreduce/map_slots.json',
  551. 'testInProduction': true
  552. },
  553. 'service.metrics.mapreduce.reduce_slots': {
  554. '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}]',
  555. 'mock': '/data/services/metrics/mapreduce/reduce_slots.json',
  556. 'testInProduction': true
  557. },
  558. 'service.metrics.mapreduce.rpc': {
  559. 'real': '/clusters/{clusterName}/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  560. 'mock': '/data/services/metrics/mapreduce/rpc.json',
  561. 'testInProduction': true
  562. },
  563. 'service.metrics.mapreduce.tasks_running_waiting': {
  564. '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}]',
  565. 'mock': '/data/services/metrics/mapreduce/tasks_running_waiting.json',
  566. 'testInProduction': true
  567. },
  568. 'service.metrics.hdfs.block_status': {
  569. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/dfs/FSNamesystem/PendingReplicationBlocks[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/FSNamesystem/UnderReplicatedBlocks[{fromSeconds},{toSeconds},{stepSeconds}]',
  570. 'mock': '/data/services/metrics/hdfs/block_status.json',
  571. 'testInProduction': true
  572. },
  573. 'service.metrics.hdfs.file_operations': {
  574. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/dfs/namenode/FileInfoOps[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/namenode/CreateFileOps[{fromSeconds},{toSeconds},{stepSeconds}]',
  575. 'mock': '/data/services/metrics/hdfs/file_operations.json',
  576. 'testInProduction': true
  577. },
  578. 'service.metrics.hdfs.gc': {
  579. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  580. 'mock': '/data/services/metrics/hdfs/gc.json',
  581. 'testInProduction': true
  582. },
  583. 'service.metrics.hdfs.io': {
  584. 'real': '/clusters/{clusterName}/services/HDFS/components/DATANODE?fields=metrics/dfs/datanode/bytes_written[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/datanode/bytes_read[{fromSeconds},{toSeconds},{stepSeconds}]',
  585. 'mock': '/data/services/metrics/hdfs/io.json',
  586. 'testInProduction': true
  587. },
  588. 'service.metrics.hdfs.jvm_heap': {
  589. '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}]',
  590. 'mock': '/data/services/metrics/hdfs/jvm_heap.json',
  591. 'testInProduction': true
  592. },
  593. 'service.metrics.hdfs.jvm_threads': {
  594. '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}]',
  595. 'mock': '/data/services/metrics/hdfs/jvm_threads.json',
  596. 'testInProduction': true
  597. },
  598. 'service.metrics.hdfs.rpc': {
  599. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  600. 'mock': '/data/services/metrics/hdfs/rpc.json',
  601. 'testInProduction': true
  602. },
  603. 'service.metrics.hdfs.space_utilization': {
  604. '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}]',
  605. 'mock': '/data/services/metrics/hdfs/space_utilization.json',
  606. 'testInProduction': true
  607. },
  608. 'service.start_stop': {
  609. 'real': '/clusters/{clusterName}/services?params/run_smoke_test=true',
  610. 'mock': '/data/mirroring/poll/poll_6.json',
  611. 'format': function (data) {
  612. return {
  613. type: 'PUT',
  614. async: false,
  615. data: data.data
  616. };
  617. }
  618. },
  619. 'service.metrics.yarn.gc': {
  620. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  621. 'mock': '/data/services/metrics/yarn/gc.json',
  622. 'testInProduction': true
  623. },
  624. 'service.metrics.yarn.jobs_threads': {
  625. '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}]',
  626. 'mock': '/data/services/metrics/yarn/jvm_threads.json',
  627. 'testInProduction': true
  628. },
  629. 'service.metrics.yarn.rpc': {
  630. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  631. 'mock': '/data/services/metrics/yarn/rpc.json',
  632. 'testInProduction': true
  633. },
  634. 'service.metrics.yarn.jobs_heap': {
  635. '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}]',
  636. 'mock': '/data/services/metrics/yarn/jvm_heap.json',
  637. 'testInProduction': true
  638. },
  639. 'service.metrics.yarn.queue.allocated': {
  640. '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}]',
  641. 'mock': '',
  642. 'testInProduction': true
  643. },
  644. 'service.metrics.yarn.queue.allocated.container': {
  645. '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}]',
  646. 'mock': '',
  647. 'testInProduction': true
  648. },
  649. 'service.metrics.yarn.node.manager.statuses': {
  650. '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}]',
  651. 'mock': '',
  652. 'testInProduction': true
  653. },
  654. 'service.metrics.yarn.queue.memory.resource': {
  655. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=',
  656. 'mock': '',
  657. 'format': function (data, opt) {
  658. var field1 = 'metrics/yarn/Queue/{queueName}/AllocatedMB[{fromSeconds},{toSeconds},{stepSeconds}]';
  659. var field2 = 'metrics/yarn/Queue/{queueName}/AvailableMB[{fromSeconds},{toSeconds},{stepSeconds}]';
  660. if (opt.url != null && data.queueNames != null && data.queueNames.length > 0) {
  661. data.queueNames.forEach(function (q) {
  662. data.queueName = q;
  663. opt.url += (formatUrl(field1, data) + ",");
  664. opt.url += (formatUrl(field2, data) + ",");
  665. });
  666. } else {
  667. opt.url += (formatUrl(field1, data) + ",");
  668. opt.url += (formatUrl(field2, data) + ",");
  669. }
  670. },
  671. 'testInProduction': true
  672. },
  673. 'service.metrics.yarn.queue.apps.states.current': {
  674. '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}]',
  675. 'mock': '',
  676. 'testInProduction': true
  677. },
  678. 'service.metrics.yarn.queue.apps.states.finished': {
  679. '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}]',
  680. 'mock': '',
  681. 'testInProduction': true
  682. },
  683. 'dashboard.cluster_metrics.cpu': {
  684. 'real': '/clusters/{clusterName}/?fields=metrics/cpu[{fromSeconds},{toSeconds},{stepSeconds}]',
  685. 'mock': '/data/cluster_metrics/cpu_1hr.json',
  686. 'testInProduction': true
  687. },
  688. 'dashboard.cluster_metrics.load': {
  689. 'real': '/clusters/{clusterName}/?fields=metrics/load[{fromSeconds},{toSeconds},{stepSeconds}]',
  690. 'mock': '/data/cluster_metrics/load_1hr.json',
  691. 'testInProduction': true
  692. },
  693. 'dashboard.cluster_metrics.memory': {
  694. 'real': '/clusters/{clusterName}/?fields=metrics/memory[{fromSeconds},{toSeconds},{stepSeconds}]',
  695. 'mock': '/data/cluster_metrics/memory_1hr.json',
  696. 'testInProduction': true
  697. },
  698. 'dashboard.cluster_metrics.network': {
  699. 'real': '/clusters/{clusterName}/?fields=metrics/network[{fromSeconds},{toSeconds},{stepSeconds}]',
  700. 'mock': '/data/cluster_metrics/network_1hr.json',
  701. 'testInProduction': true
  702. },
  703. 'host.metrics.cpu': {
  704. '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}]',
  705. 'mock': '/data/hosts/metrics/cpu.json',
  706. 'testInProduction': true
  707. },
  708. 'host.metrics.disk': {
  709. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/disk/disk_total[{fromSeconds},{toSeconds},{stepSeconds}],metrics/disk/disk_free[{fromSeconds},{toSeconds},{stepSeconds}]',
  710. 'mock': '/data/hosts/metrics/disk.json',
  711. 'testInProduction': true
  712. },
  713. 'host.metrics.load': {
  714. '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}]',
  715. 'mock': '/data/hosts/metrics/load.json',
  716. 'testInProduction': true
  717. },
  718. 'host.metrics.memory': {
  719. '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}]',
  720. 'mock': '/data/hosts/metrics/memory.json',
  721. 'testInProduction': true
  722. },
  723. 'host.metrics.network': {
  724. '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}]',
  725. 'mock': '/data/hosts/metrics/network.json',
  726. 'testInProduction': true
  727. },
  728. 'host.metrics.processes': {
  729. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/process/proc_total[{fromSeconds},{toSeconds},{stepSeconds}],metrics/process/proc_run[{fromSeconds},{toSeconds},{stepSeconds}]',
  730. 'mock': '/data/hosts/metrics/processes.json',
  731. 'testInProduction': true
  732. },
  733. 'host.service_config_hosts_overrides': {
  734. 'real': '/clusters/{clusterName}/configurations?{urlParams}',
  735. 'mock': '',
  736. 'format': function() {
  737. return {
  738. async: false,
  739. timeout: 10000
  740. };
  741. }
  742. },
  743. 'admin.security_status': {
  744. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs',
  745. 'mock': '',
  746. 'format': function() {
  747. return {
  748. timeout: 10000
  749. };
  750. }
  751. },
  752. 'settings.get.user_pref': {
  753. 'real': '/persist/{key}',
  754. 'mock': '/data/user_settings/{key}.json',
  755. 'format': function(data) {
  756. return {
  757. async: data.async
  758. };
  759. }
  760. },
  761. 'settings.post.user_pref': {
  762. 'real': '/persist',
  763. 'mock': '',
  764. 'type': 'POST',
  765. 'format': function (data) {
  766. return {
  767. async: data.async,
  768. data: JSON.stringify(data.keyValuePair)
  769. }
  770. }
  771. },
  772. 'cluster.load_cluster_name': {
  773. 'real': '/clusters',
  774. 'mock': '/data/clusters/info.json',
  775. 'format': function() {
  776. return {
  777. async: false
  778. };
  779. }
  780. },
  781. 'cluster.state': {
  782. 'type': 'POST',
  783. 'real': '/persist/',
  784. 'mock': '',
  785. 'format': function(data) {
  786. return {
  787. async: false,
  788. data: JSON.stringify(data.keyValuePair)
  789. };
  790. }
  791. },
  792. 'cluster.update_upgrade_version': {
  793. 'real': '/stacks2/HDP/versions?fields=stackServices/StackServices,Versions',
  794. 'mock': '/data/wizard/stack/stacks.json',
  795. 'format': function() {
  796. return {
  797. async: false
  798. };
  799. }
  800. },
  801. 'cluster.load_repositories': {
  802. 'real': '/stacks2/{stackName}/versions/{stackVersion}/operatingSystems?fields=repositories/*',
  803. 'mock': '',
  804. 'type': 'GET',
  805. 'format': function (data) {
  806. return {
  807. data: data.data
  808. };
  809. }
  810. },
  811. 'admin.high_availability.stop_all_services': {
  812. 'real': '/clusters/{clusterName}/services',
  813. 'mock': '',
  814. 'format': function() {
  815. return {
  816. type: 'PUT',
  817. data: JSON.stringify({
  818. "RequestInfo": {
  819. "context": "Stop all services"
  820. },
  821. "Body": {
  822. "ServiceInfo": {
  823. "state": "INSTALLED"
  824. }
  825. }
  826. })
  827. }
  828. }
  829. },
  830. 'admin.high_availability.start_all_services': {
  831. 'real': '/clusters/{clusterName}/services',
  832. 'mock': '',
  833. 'format': function() {
  834. return {
  835. type: 'PUT',
  836. data: JSON.stringify({
  837. "RequestInfo": {
  838. "context": "Start all services"
  839. },
  840. "Body": {
  841. "ServiceInfo": {
  842. "state": "STARTED"
  843. }
  844. }
  845. })
  846. }
  847. }
  848. },
  849. 'admin.high_availability.polling': {
  850. 'real': '/clusters/{clusterName}/requests/{requestId}?fields=tasks/*',
  851. 'mock': '',
  852. 'type': 'GET'
  853. },
  854. 'admin.high_availability.getNnCheckPointStatus': {
  855. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/NAMENODE',
  856. 'mock': '',
  857. 'type': 'GET'
  858. },
  859. 'admin.high_availability.getJnCheckPointStatus': {
  860. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/JOURNALNODE?fields=metrics',
  861. 'mock': ''
  862. },
  863. 'admin.high_availability.getHostComponent': {
  864. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  865. 'mock': ''
  866. },
  867. 'admin.high_availability.create_component': {
  868. 'real': '/clusters/{clusterName}/hosts?Hosts/host_name={hostName}',
  869. 'mock': '',
  870. 'type': 'POST',
  871. 'format': function (data) {
  872. return {
  873. data: JSON.stringify({
  874. "host_components": [
  875. {
  876. "HostRoles": {
  877. "component_name": data.componentName
  878. }
  879. }
  880. ]
  881. })
  882. }
  883. }
  884. },
  885. 'admin.high_availability.create_journalnode': {
  886. 'real': '/clusters/{clusterName}/services?ServiceInfo/service_name=HDFS',
  887. 'mock': '',
  888. 'type': 'POST',
  889. 'format': function() {
  890. return {
  891. data: JSON.stringify({
  892. "components": [
  893. {
  894. "ServiceComponentInfo": {
  895. "component_name": "JOURNALNODE"
  896. }
  897. }
  898. ]
  899. })
  900. }
  901. }
  902. },
  903. 'admin.high_availability.create_zkfc': {
  904. 'real': '/clusters/{clusterName}/services?ServiceInfo/service_name=HDFS',
  905. 'mock': '',
  906. 'type': 'POST',
  907. 'format': function() {
  908. return {
  909. data: JSON.stringify({
  910. "components": [
  911. {
  912. "ServiceComponentInfo": {
  913. "component_name": "ZKFC"
  914. }
  915. }
  916. ]
  917. })
  918. }
  919. }
  920. },
  921. 'admin.high_availability.install_component': {
  922. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  923. 'mock': '',
  924. 'type': 'PUT',
  925. 'format': function (data) {
  926. return {
  927. data: JSON.stringify({
  928. RequestInfo: {
  929. "context": "Install " + data.displayName
  930. },
  931. Body: {
  932. "HostRoles": {
  933. "state": "INSTALLED"
  934. }
  935. }
  936. })
  937. }
  938. }
  939. },
  940. 'admin.high_availability.start_component': {
  941. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  942. 'mock': '',
  943. 'type': 'PUT',
  944. 'format': function (data) {
  945. return {
  946. data: JSON.stringify({
  947. RequestInfo: {
  948. "context": "Start " + data.displayName
  949. },
  950. Body: {
  951. "HostRoles": {
  952. "state": "STARTED"
  953. }
  954. }
  955. })
  956. }
  957. }
  958. },
  959. 'admin.high_availability.maintenance_mode': {
  960. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  961. 'mock': '',
  962. 'type': 'PUT',
  963. 'format': function () {
  964. return {
  965. data: JSON.stringify({
  966. "HostRoles": {
  967. "state": "DISABLED"
  968. }
  969. })
  970. }
  971. }
  972. },
  973. 'admin.high_availability.stop_component': {
  974. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  975. 'mock': '',
  976. 'type': 'PUT',
  977. 'format': function (data) {
  978. return {
  979. data: JSON.stringify({
  980. RequestInfo: {
  981. "context": "Stop " + data.displayName
  982. },
  983. Body: {
  984. "HostRoles": {
  985. "state": "INSTALLED"
  986. }
  987. }
  988. })
  989. }
  990. }
  991. },
  992. 'admin.high_availability.load_configs': {
  993. 'real': '/clusters/{clusterName}/configurations?(type=core-site&tag={coreSiteTag})|(type=hdfs-site&tag={hdfsSiteTag})',
  994. 'mock': '',
  995. 'type': 'GET'
  996. },
  997. 'admin.high_availability.save_configs': {
  998. 'real': '/clusters/{clusterName}',
  999. 'mock': '',
  1000. 'type': 'PUT',
  1001. 'format': function (data) {
  1002. return {
  1003. async: false,
  1004. data: JSON.stringify({
  1005. Clusters: {
  1006. desired_config: {
  1007. "type": data.siteName,
  1008. "tag": 'version' + (new Date).getTime(),
  1009. "properties": data.properties
  1010. }
  1011. }
  1012. })
  1013. }
  1014. }
  1015. },
  1016. 'admin.high_availability.load_hbase_configs': {
  1017. 'real': '/clusters/{clusterName}/configurations?type=hbase-site&tag={hbaseSiteTag}',
  1018. 'mock': '',
  1019. 'type': 'GET'
  1020. },
  1021. 'admin.delete_component': {
  1022. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  1023. 'mock': '',
  1024. 'type': 'DELETE'
  1025. },
  1026. 'admin.security.cluster_configs': {
  1027. 'real': '/clusters/{clusterName}',
  1028. 'mock': '',
  1029. 'format': function() {
  1030. return {
  1031. timeout: 10000
  1032. };
  1033. }
  1034. },
  1035. 'admin.delete_host': {
  1036. 'real': '/clusters/{clusterName}/hosts/{hostName}',
  1037. 'mock': '',
  1038. 'type': 'DELETE'
  1039. },
  1040. 'admin.get.all_configurations': {
  1041. 'real': '/clusters/{clusterName}/configurations?{urlParams}',
  1042. 'mock': '',
  1043. 'format': function() {
  1044. return {
  1045. timeout: 10000
  1046. };
  1047. }
  1048. },
  1049. 'admin.security.apply_configurations': {
  1050. 'real': '/clusters/{clusterName}',
  1051. 'mock': '',
  1052. 'format': function (data) {
  1053. return {
  1054. type: 'PUT',
  1055. timeout: 10000,
  1056. data: data.configData
  1057. };
  1058. }
  1059. },
  1060. 'admin.security.apply_configuration': {
  1061. 'real': '/clusters/{clusterName}',
  1062. 'mock': '',
  1063. 'format': function(data) {
  1064. return {
  1065. type: 'PUT',
  1066. async: false,
  1067. timeout: 5000,
  1068. data: JSON.stringify(data.clusterData)
  1069. };
  1070. }
  1071. },
  1072. 'admin.security.add.cluster_configs': {
  1073. 'real': '/clusters/{clusterName}' + '?fields=Clusters/desired_configs',
  1074. 'mock': '',
  1075. 'format': function() {
  1076. return {
  1077. timeout: 10000
  1078. };
  1079. }
  1080. },
  1081. 'admin.stack_upgrade.run_upgrade': {
  1082. 'real': '/clusters/{clusterName}',
  1083. 'mock': '',
  1084. 'format': function () {
  1085. return {
  1086. type: 'PUT',
  1087. async: false,
  1088. data: data.data
  1089. };
  1090. }
  1091. },
  1092. 'admin.stack_upgrade.stop_services': {
  1093. 'real': '/clusters/{clusterName}/services?ServiceInfo/state=STARTED',
  1094. 'mock': '',
  1095. 'format': function () {
  1096. return {
  1097. type: 'PUT',
  1098. async: false,
  1099. data: data.data
  1100. };
  1101. }
  1102. },
  1103. 'admin.stack_upgrade.do_poll': {
  1104. 'real': '/clusters/{cluster}/requests/{requestId}?fields=tasks/*',
  1105. 'mock': '/data/wizard/{mock}'
  1106. },
  1107. 'wizard.advanced_repositories.valid_url': {
  1108. 'real': '/stacks2/{stackName}/versions/{stackVersion}/operatingSystems/{osType}/repositories/{nameVersionCombo}',
  1109. 'mock': '',
  1110. 'type': 'PUT',
  1111. 'format': function (data) {
  1112. return {
  1113. async: true,
  1114. data: JSON.stringify(data.data)
  1115. }
  1116. }
  1117. },
  1118. 'wizard.install_services.add_host_controller.is_retry': {
  1119. 'real': '/clusters/{cluster}/host_components',
  1120. 'mock': '',
  1121. 'format': function (data) {
  1122. return {
  1123. type: 'PUT',
  1124. async: false,
  1125. data: data.data
  1126. };
  1127. }
  1128. },
  1129. 'wizard.install_services.add_host_controller.not_is_retry': {
  1130. 'real': '/clusters/{cluster}/host_components',
  1131. 'mock': '',
  1132. 'format': function(data) {
  1133. return {
  1134. type: 'PUT',
  1135. async: false,
  1136. data: data.data
  1137. };
  1138. }
  1139. },
  1140. 'wizard.install_services.installer_controller.is_retry': {
  1141. 'real': '/clusters/{cluster}/host_components?HostRoles/state=INSTALLED',
  1142. 'mock': '/data/wizard/deploy/2_hosts/poll_1.json',
  1143. 'type': 'PUT',
  1144. 'format': function (data) {
  1145. return {
  1146. async: false,
  1147. data: data.data
  1148. };
  1149. }
  1150. },
  1151. 'wizard.install_services.installer_controller.not_is_retry': {
  1152. 'real': '/clusters/{cluster}/services?ServiceInfo/state=INIT',
  1153. 'mock': '/data/wizard/deploy/2_hosts/poll_1.json',
  1154. 'type': 'PUT',
  1155. 'format': function (data) {
  1156. return {
  1157. async: false,
  1158. data: data.data
  1159. };
  1160. }
  1161. },
  1162. 'wizard.install_services.add_service_controller.get_failed_host_components': {
  1163. 'real': '/clusters/{clusterName}/host_components?fields=HostRoles/state,component/ServiceComponentInfo/service_name',
  1164. 'mock': '',
  1165. 'format': function() {
  1166. return {
  1167. async: false
  1168. };
  1169. }
  1170. },
  1171. 'wizard.service_components': {
  1172. 'real': '{stackUrl}/stackServices?fields=StackServices',
  1173. 'mock': '/data/wizard/stack/hdp/version/{stackVersion}.json',
  1174. 'format': function() {
  1175. return {
  1176. timeout: 10000,
  1177. async: false
  1178. };
  1179. }
  1180. },
  1181. 'wizard.step9.installer.get_host_status': {
  1182. 'real': '/clusters/{cluster}/hosts?fields=Hosts/host_state,host_components/HostRoles/state',
  1183. 'mock': '/data/wizard/deploy/5_hosts/get_host_status.json',
  1184. 'format': function () {
  1185. return {
  1186. async: false
  1187. };
  1188. }
  1189. },
  1190. 'wizard.step9.installer.launch_start_services': {
  1191. 'real': '/clusters/{cluster}/services?ServiceInfo/state=INSTALLED&params/run_smoke_test=true&params/reconfigure_client=false',
  1192. 'mock': '/data/wizard/deploy/5_hosts/poll_6.json',
  1193. 'format': function (data) {
  1194. var d = {
  1195. type: 'PUT',
  1196. async: false,
  1197. data: data.data
  1198. };
  1199. if (App.testMode) {
  1200. d.type = 'GET';
  1201. }
  1202. return d;
  1203. }
  1204. },
  1205. 'wizard.step9.add_host.launch_start_services': {
  1206. 'real': '/clusters/{cluster}/host_components',
  1207. 'mock': '/data/wizard/deploy/5_hosts/poll_6.json',
  1208. 'format': function (data) {
  1209. return {
  1210. type: 'PUT',
  1211. async: false,
  1212. data: data.data
  1213. };
  1214. }
  1215. },
  1216. 'wizard.step8.delete_cluster': {
  1217. 'real': '/clusters/{name}',
  1218. 'mock': '',
  1219. 'format': function() {
  1220. return {
  1221. type: 'DELETE',
  1222. async: false
  1223. };
  1224. }
  1225. },
  1226. 'wizard.step8.existing_cluster_names': {
  1227. 'real': '/clusters',
  1228. 'mock': '',
  1229. 'format': function() {
  1230. return {
  1231. async: false
  1232. };
  1233. }
  1234. },
  1235. 'wizard.step3.host_info': {
  1236. 'real': '/hosts?fields=Hosts/total_mem,Hosts/cpu_count,Hosts/disk_info,Hosts/last_agent_env,Hosts/host_name,Hosts/os_type,Hosts/os_arch,Hosts/ip',
  1237. 'mock': '/data/wizard/bootstrap/two_hosts_information.json',
  1238. 'format': function() {
  1239. return {
  1240. contentType: 'application/json'
  1241. };
  1242. }
  1243. },
  1244. 'wizard.step3.rerun_checks': {
  1245. 'real': '/hosts?fields=Hosts/last_agent_env',
  1246. 'mock': '/data/wizard/bootstrap/two_hosts_information.json',
  1247. 'format': function() {
  1248. return {
  1249. contentType: 'application/json'
  1250. };
  1251. }
  1252. },
  1253. 'wizard.step3.bootstrap': {
  1254. 'real': '/bootstrap/{bootRequestId}',
  1255. 'mock': '/data/wizard/bootstrap/poll_{numPolls}.json'
  1256. },
  1257. 'wizard.step3.is_hosts_registered': {
  1258. 'real': '/hosts',
  1259. 'mock': '/data/wizard/bootstrap/single_host_registration.json'
  1260. },
  1261. 'wizard.stacks': {
  1262. 'real': '/stacks2',
  1263. 'mock': '/data/wizard/stack/stacks2.json',
  1264. 'format': function() {
  1265. return {
  1266. async: false
  1267. };
  1268. }
  1269. },
  1270. 'wizard.stacks_versions': {
  1271. 'real': '/stacks2/{stackName}/versions?fields=Versions,operatingSystems/repositories/Repositories',
  1272. 'mock': '/data/wizard/stack/{stackName}_versions.json',
  1273. 'format': function() {
  1274. return {
  1275. async: false
  1276. };
  1277. }
  1278. },
  1279. 'wizard.launch_bootstrap': {
  1280. 'real': '/bootstrap',
  1281. 'mock': '/data/wizard/bootstrap/bootstrap.json',
  1282. 'type': 'POST',
  1283. 'format': function (data) {
  1284. return {
  1285. async: false,
  1286. contentType: 'application/json',
  1287. data: data.bootStrapData
  1288. }
  1289. }
  1290. },
  1291. 'router.login': {
  1292. 'real': '/users/{loginName}',
  1293. 'mock': '/data/users/user_{usr}.json',
  1294. 'format': function (data) {
  1295. var statusCode = jQuery.extend({}, require('data/statusCodes'));
  1296. statusCode['403'] = function () {
  1297. console.log("Error code 403: Forbidden.");
  1298. };
  1299. return {
  1300. statusCode: statusCode
  1301. };
  1302. }
  1303. },
  1304. 'router.login2': {
  1305. 'real': '/clusters',
  1306. 'mock': '/data/clusters/info.json'
  1307. },
  1308. 'router.logoff': {
  1309. 'real': '/logout',
  1310. 'mock': ''
  1311. },
  1312. 'router.set_ambari_stacks': {
  1313. 'real': '/stacks',
  1314. 'mock': '/data/wizard/stack/stacks.json',
  1315. 'format': function() {
  1316. return {
  1317. async: false
  1318. };
  1319. }
  1320. },
  1321. 'router.authentication': {
  1322. 'real': '/clusters',
  1323. 'mock': '/data/clusters/info.json',
  1324. 'format': function() {
  1325. return {
  1326. async: false
  1327. };
  1328. }
  1329. },
  1330. 'ambari.service': {
  1331. 'real': '/services/AMBARI/components/AMBARI_SERVER',
  1332. 'mock': ''
  1333. },
  1334. 'ambari.service.load_server_clock': {
  1335. 'real': '/services/AMBARI/components/AMBARI_SERVER?fields=RootServiceComponents/server_clock',
  1336. 'mock': ''
  1337. },
  1338. 'config_groups.create': {
  1339. 'real': '/clusters/{clusterName}/config_groups',
  1340. 'mock': '',
  1341. 'format': function (data) {
  1342. return {
  1343. async: false,
  1344. type: 'POST',
  1345. data: JSON.stringify([{
  1346. "ConfigGroup": {
  1347. "group_name": data.group_name,
  1348. "tag": data.service_id,
  1349. "description": data.description,
  1350. "desired_configs": data.desired_configs,
  1351. "hosts": data.hosts
  1352. }
  1353. }])
  1354. }
  1355. }
  1356. },
  1357. 'config_groups.update': {
  1358. 'real': '/clusters/{clusterName}/config_groups/{id}',
  1359. 'mock': '',
  1360. 'format': function (data) {
  1361. return {
  1362. async: true,
  1363. type: 'PUT',
  1364. data: JSON.stringify(data.data)
  1365. }
  1366. }
  1367. },
  1368. 'rolling_restart.post': {
  1369. 'real': '/clusters/{clusterName}/request_schedules',
  1370. 'mock': '',
  1371. 'format' : function(data) {
  1372. return {
  1373. type : 'POST',
  1374. data : JSON.stringify([ {
  1375. "RequestSchedule" : {
  1376. "batch" : [ {
  1377. "requests" : data.batches
  1378. }, {
  1379. "batch_settings" : {
  1380. "batch_separation_in_seconds" : data.intervalTimeSeconds,
  1381. "task_failure_tolerance" : data.tolerateSize
  1382. }
  1383. } ]
  1384. }
  1385. } ])
  1386. }
  1387. }
  1388. },
  1389. 'request_schedule.delete': {
  1390. 'real': '/clusters/{clusterName}/request_schedules/{request_schedule_id}',
  1391. 'mock': '',
  1392. 'format' : function() {
  1393. return {
  1394. type : 'DELETE'
  1395. }
  1396. }
  1397. },
  1398. 'request_schedule.get': {
  1399. 'real': '/clusters/{clusterName}/request_schedules/{request_schedule_id}',
  1400. 'mock': ''
  1401. },
  1402. 'restart.hostComponents': {
  1403. 'real':'/clusters/{clusterName}/requests',
  1404. 'mock':'',
  1405. 'format': function(data) {
  1406. return {
  1407. type : 'POST',
  1408. data : JSON.stringify({
  1409. "RequestInfo": {
  1410. "command": "RESTART",
  1411. "context": data.context
  1412. },
  1413. "Requests/resource_filters": data.resource_filters
  1414. })
  1415. }
  1416. }
  1417. },
  1418. 'mirroring.get_all_entities': {
  1419. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/list/{type}?fields=status&user.name=ambari-qa',
  1420. 'mock': '/data/mirroring/{type}s.xml',
  1421. 'apiPrefix': '',
  1422. 'format': function () {
  1423. return {
  1424. dataType: 'xml'
  1425. }
  1426. }
  1427. },
  1428. 'mirroring.get_definition': {
  1429. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/definition/{type}/{name}?user.name=ambari-qa',
  1430. 'mock': '/data/mirroring/{name}_definition.xml',
  1431. 'apiPrefix': '',
  1432. 'format': function () {
  1433. return {
  1434. cache: true,
  1435. dataType: 'xml'
  1436. }
  1437. }
  1438. },
  1439. 'mirroring.dataset.get_all_instances': {
  1440. 'real': '/proxy?url=http://{falconServer}:15000/api/instance/status/feed/{dataset}?start={start}&end={end}&user.name=ambari-qa',
  1441. 'mock': '/data/mirroring/{dataset}_instances.json',
  1442. 'apiPrefix': ''
  1443. },
  1444. 'mirroring.create_new_dataset': {
  1445. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/submitAndSchedule/feed?user.name=ambari-qa',
  1446. 'mock': '/data/mirroring/succeeded.json',
  1447. 'apiPrefix': '',
  1448. 'type': 'POST',
  1449. 'format': function (data) {
  1450. return {
  1451. contentType: 'text/xml',
  1452. dataType: 'xml',
  1453. data: data.dataset,
  1454. headers: {
  1455. 'AmbariProxy-Content-Type': 'text/xml'
  1456. }
  1457. }
  1458. }
  1459. },
  1460. 'mirroring.submit_entity': {
  1461. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/submit/{type}?user.name=ambari-qa',
  1462. 'mock': '/data/mirroring/succeeded.json',
  1463. 'apiPrefix': '',
  1464. 'type': 'POST',
  1465. 'format': function (data) {
  1466. return {
  1467. contentType: 'text/xml',
  1468. dataType: 'xml',
  1469. data: data.entity,
  1470. headers: {
  1471. 'AmbariProxy-Content-Type': 'text/xml'
  1472. }
  1473. }
  1474. }
  1475. },
  1476. 'mirroring.update_entity': {
  1477. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/update/{type}/{name}?user.name=ambari-qa',
  1478. 'mock': '/data/mirroring/succeeded.json',
  1479. 'apiPrefix': '',
  1480. 'type': 'POST',
  1481. 'format': function (data) {
  1482. return {
  1483. contentType: 'text/xml',
  1484. dataType: 'xml',
  1485. data: data.entity,
  1486. headers: {
  1487. 'AmbariProxy-Content-Type': 'text/xml'
  1488. }
  1489. }
  1490. }
  1491. },
  1492. 'mirroring.delete_entity': {
  1493. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/delete/{type}/{name}?user.name=ambari-qa',
  1494. 'mock': '/data/mirroring/succeeded.json',
  1495. 'apiPrefix': '',
  1496. 'type': 'DELETE',
  1497. 'format': function () {
  1498. return {
  1499. dataType: 'xml'
  1500. }
  1501. }
  1502. },
  1503. 'mirroring.suspend_entity': {
  1504. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/suspend/{type}/{name}?user.name=ambari-qa',
  1505. 'mock': '/data/mirroring/succeeded.json',
  1506. 'apiPrefix': '',
  1507. 'type': 'POST',
  1508. 'format': function (data) {
  1509. return {
  1510. dataType: 'xml',
  1511. data: data.entity
  1512. }
  1513. }
  1514. },
  1515. 'mirroring.schedule_entity': {
  1516. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/resume/{type}/{name}?user.name=ambari-qa',
  1517. 'mock': '/data/mirroring/succeeded.json',
  1518. 'apiPrefix': '',
  1519. 'type': 'POST',
  1520. 'format': function () {
  1521. return {
  1522. dataType: 'xml'
  1523. }
  1524. }
  1525. },
  1526. 'mirroring.suspend_instance': {
  1527. 'real': '/proxy?url=http://{falconServer}:15000/api/instance/suspend/feed/{feed}?start={name}&user.name=ambari-qa',
  1528. 'mock': '/data/mirroring/succeeded.json',
  1529. 'apiPrefix': '',
  1530. 'type': 'POST'
  1531. },
  1532. 'mirroring.resume_instance': {
  1533. 'real': '/proxy?url=http://{falconServer}:15000/api/instance/resume/feed/{feed}?start={name}&user.name=ambari-qa',
  1534. 'mock': '/data/mirroring/succeeded.json',
  1535. 'apiPrefix': '',
  1536. 'type': 'POST'
  1537. },
  1538. 'mirroring.kill_instance': {
  1539. 'real': '/proxy?url=http://{falconServer}:15000/api/instance/kill/feed/{feed}?start={name}&user.name=ambari-qa',
  1540. 'mock': '/data/mirroring/succeeded.json',
  1541. 'apiPrefix': '',
  1542. 'type': 'POST'
  1543. },
  1544. 'bulk_request.host_components': {
  1545. 'real': '/clusters/{clusterName}/host_components',
  1546. 'mock': '',
  1547. 'format': function(data) {
  1548. return {
  1549. type: 'PUT',
  1550. data: JSON.stringify({
  1551. RequestInfo: {
  1552. context: data.requestInfo,
  1553. query: 'HostRoles/component_name=' + data.componentName + '&HostRoles/host_name.in(' + data.hostNames + ')&HostRoles/maintenance_state=OFF'
  1554. },
  1555. Body: {
  1556. HostRoles: {
  1557. state: data.state
  1558. }
  1559. }
  1560. })
  1561. }
  1562. }
  1563. },
  1564. 'bulk_request.hosts.all_components': {
  1565. 'real': '/clusters/{clusterName}/host_components',
  1566. 'mock': '',
  1567. 'format': function(data) {
  1568. return {
  1569. type: 'PUT',
  1570. data: JSON.stringify({
  1571. RequestInfo: {
  1572. context: data.requestInfo,
  1573. query: data.query
  1574. },
  1575. Body: {
  1576. HostRoles: {
  1577. state: data.state
  1578. }
  1579. }
  1580. })
  1581. }
  1582. }
  1583. },
  1584. 'bulk_request.decommission': {
  1585. 'real' : '/clusters/{clusterName}/requests',
  1586. 'mock' : '',
  1587. 'format': function(data) {
  1588. return {
  1589. type: 'POST',
  1590. data: JSON.stringify({
  1591. 'RequestInfo': {
  1592. 'context': data.context,
  1593. 'command': 'DECOMMISSION',
  1594. 'service_name': data.serviceName,
  1595. 'component_name': data.componentName,
  1596. 'parameters': data.parameters
  1597. }
  1598. })
  1599. }
  1600. }
  1601. },
  1602. 'bulk_request.hosts.passive_state': {
  1603. 'real': '/clusters/{clusterName}/hosts',
  1604. 'mock': '',
  1605. 'format': function(data) {
  1606. return {
  1607. type: 'PUT',
  1608. data: JSON.stringify({
  1609. RequestInfo: {
  1610. context: data.requestInfo,
  1611. query: 'Hosts/host_name.in(' + data.hostNames + ')'
  1612. },
  1613. Body: {
  1614. Hosts: {
  1615. maintenance_state: data.passive_state
  1616. }
  1617. }
  1618. })
  1619. }
  1620. }
  1621. },
  1622. 'bulk_request.hosts.all_components.passive_state': {
  1623. 'real': '/clusters/{clusterName}/host_components',
  1624. 'mock': '',
  1625. 'format': function(data) {
  1626. return {
  1627. type: 'PUT',
  1628. data: JSON.stringify({
  1629. RequestInfo: {
  1630. context: data.requestInfo,
  1631. query: data.query
  1632. },
  1633. Body: {
  1634. HostRoles: {
  1635. maintenance_state: data.passive_state
  1636. }
  1637. }
  1638. })
  1639. }
  1640. }
  1641. },
  1642. 'jobs.tezDag.NametoID': {
  1643. 'real': '/proxy?url=http://{historyServerHostName}:{ahsWebPort}/ws/v1/timeline/TEZ_DAG_ID?primaryFilter=dagName:{tezDagName}',
  1644. 'mock': '/data/jobs/tezDag-name-to-id.json',
  1645. 'apiPrefix': ''
  1646. },
  1647. 'jobs.tezDag.tezDagId': {
  1648. 'real': '/proxy?url=http://{historyServerHostName}:{ahsWebPort}/ws/v1/timeline/TEZ_DAG_ID/{tezDagId}?fields=relatedentities',
  1649. 'mock': '/data/jobs/tezDag.json',
  1650. 'apiPrefix': ''
  1651. },
  1652. 'jobs.tezDag.tezDagVertexId': {
  1653. 'real': '/proxy?url=http://{historyServerHostName}:{ahsWebPort}/ws/v1/timeline/TEZ_VERTEX_ID/{tezDagVertexId}?fields=otherinfo',
  1654. 'mock': '/data/jobs/tezDagVertex.json',
  1655. 'apiPrefix': ''
  1656. }
  1657. };
  1658. /**
  1659. * Replace data-placeholders to its values
  1660. *
  1661. * @param {String} url
  1662. * @param {Object} data
  1663. * @return {String}
  1664. */
  1665. var formatUrl = function (url, data) {
  1666. if (!url) return null;
  1667. var keys = url.match(/\{\w+\}/g);
  1668. keys = (keys === null) ? [] : keys;
  1669. if (keys) {
  1670. keys.forEach(function (key) {
  1671. var raw_key = key.substr(1, key.length - 2);
  1672. var replace;
  1673. if (!data || !data[raw_key]) {
  1674. replace = '';
  1675. }
  1676. else {
  1677. replace = data[raw_key];
  1678. }
  1679. url = url.replace(new RegExp(key, 'g'), replace);
  1680. });
  1681. }
  1682. return url;
  1683. };
  1684. /**
  1685. * this = object from config
  1686. * @return {Object}
  1687. */
  1688. var formatRequest = function (data) {
  1689. var opt = {
  1690. type: this.type || 'GET',
  1691. timeout: App.timeout,
  1692. dataType: 'json',
  1693. statusCode: require('data/statusCodes')
  1694. };
  1695. if (App.testMode) {
  1696. opt.url = formatUrl(this.mock ? this.mock : '', data);
  1697. opt.type = 'GET';
  1698. }
  1699. else {
  1700. var prefix = this.apiPrefix != null ? this.apiPrefix : App.apiPrefix;
  1701. opt.url = prefix + formatUrl(this.real, data);
  1702. }
  1703. if (this.format) {
  1704. jQuery.extend(opt, this.format(data, opt));
  1705. }
  1706. return opt;
  1707. };
  1708. /**
  1709. * Wrapper for all ajax requests
  1710. *
  1711. * @type {Object}
  1712. */
  1713. var ajax = Em.Object.extend({
  1714. /**
  1715. * Send ajax request
  1716. *
  1717. * @param {Object} config
  1718. * @return {$.ajax} jquery ajax object
  1719. *
  1720. * config fields:
  1721. * name - url-key in the urls-object *required*
  1722. * sender - object that send request (need for proper callback initialization) *required*
  1723. * data - object with data for url-format
  1724. * beforeSend - method-name for ajax beforeSend response callback
  1725. * success - method-name for ajax success response callback
  1726. * error - method-name for ajax error response callback
  1727. * callback - callback from <code>App.updater.run</code> library
  1728. */
  1729. send: function (config) {
  1730. console.warn('============== ajax ==============', config.name, config.data);
  1731. if (!config.sender) {
  1732. console.warn('Ajax sender should be defined!');
  1733. return null;
  1734. }
  1735. // default parameters
  1736. var params = {
  1737. clusterName: App.get('clusterName')
  1738. };
  1739. // extend default parameters with provided
  1740. if (config.data) {
  1741. jQuery.extend(params, config.data);
  1742. }
  1743. var opt = {};
  1744. if (!urls[config.name]) {
  1745. console.warn('Invalid name provided!');
  1746. return null;
  1747. }
  1748. opt = formatRequest.call(urls[config.name], params);
  1749. opt.context = this;
  1750. // object sender should be provided for processing beforeSend, success and error responses
  1751. opt.beforeSend = function (xhr) {
  1752. if (config.beforeSend) {
  1753. config.sender[config.beforeSend](opt, xhr, params);
  1754. }
  1755. };
  1756. opt.success = function (data) {
  1757. console.log("TRACE: The url is: " + opt.url);
  1758. if (config.success) {
  1759. config.sender[config.success](data, opt, params);
  1760. }
  1761. };
  1762. opt.error = function (request, ajaxOptions, error) {
  1763. if (config.error) {
  1764. config.sender[config.error](request, ajaxOptions, error, opt);
  1765. } else {
  1766. this.defaultErrorHandler(request, opt.url, opt.type);
  1767. }
  1768. };
  1769. opt.complete = function () {
  1770. if (config.callback) {
  1771. config.callback();
  1772. }
  1773. };
  1774. if ($.mocho) {
  1775. opt.url = 'http://' + $.hostName + opt.url;
  1776. }
  1777. return $.ajax(opt);
  1778. },
  1779. // A single instance of App.ModalPopup view
  1780. modalPopup: null,
  1781. /**
  1782. * defaultErrorHandler function is referred from App.ajax.send function and App.HttpClient.defaultErrorHandler function
  1783. * @jqXHR {jqXHR Object}
  1784. * @url {string}
  1785. * @method {String} Http method
  1786. * @showStatus {number} HTTP response code which should be shown. Default is 500.
  1787. */
  1788. defaultErrorHandler: function (jqXHR, url, method, showStatus) {
  1789. method = method || 'GET';
  1790. var self = this;
  1791. var api = " received on " + method + " method for API: " + url;
  1792. var showMessage = true;
  1793. try {
  1794. var json = $.parseJSON(jqXHR.responseText);
  1795. var message = json.message;
  1796. } catch (err) {
  1797. }
  1798. if (showStatus === null) {
  1799. showStatus = 500;
  1800. }
  1801. if (message === undefined) {
  1802. showMessage = false;
  1803. }
  1804. var statusCode = jqXHR.status + " status code";
  1805. if (jqXHR.status === showStatus && !this.modalPopup) {
  1806. this.modalPopup = App.ModalPopup.show({
  1807. header: jqXHR.statusText,
  1808. secondary: false,
  1809. onPrimary: function () {
  1810. this.hide();
  1811. self.modalPopup = null;
  1812. },
  1813. bodyClass: Ember.View.extend({
  1814. classNames: ['api-error'],
  1815. templateName: require('templates/utils/ajax'),
  1816. api: api,
  1817. statusCode: statusCode,
  1818. message: message,
  1819. showMessage: showMessage
  1820. })
  1821. });
  1822. }
  1823. }
  1824. });
  1825. /**
  1826. * Add few access-methods for test purposes
  1827. */
  1828. if ($.mocho) {
  1829. ajax.reopen({
  1830. /**
  1831. * Don't use it anywhere except tests!
  1832. * @returns {Array}
  1833. */
  1834. fakeGetUrlNames: function() {
  1835. return Em.keys(urls);
  1836. },
  1837. /**
  1838. * Don't use it anywhere except tests!
  1839. * @param name
  1840. * @returns {*}
  1841. */
  1842. fakeGetUrl: function(name) {
  1843. return urls[name];
  1844. },
  1845. /**
  1846. * Don't use it anywhere except tests!
  1847. * @param url
  1848. * @param data
  1849. * @returns {String}
  1850. */
  1851. fakeFormatUrl: function(url, data) {
  1852. return formatUrl(url, data);
  1853. },
  1854. /**
  1855. * Don't use it anywhere except tests!
  1856. * @param urlObj
  1857. * @param data
  1858. * @returns {Object}
  1859. */
  1860. fakeFormatRequest: function(urlObj, data) {
  1861. return formatRequest.call(urlObj, data);
  1862. }
  1863. });
  1864. }
  1865. App.ajax = ajax.create({});