ajax.js 66 KB

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