ajax.js 62 KB

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