ajax.js 60 KB

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