ajax.js 69 KB

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