ajax.js 71 KB

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