ajax.js 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621
  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. Return ajax-params object
  27. * testInProduction - can this request be executed on production tests (used only in tests)
  28. *
  29. * @type {Object}
  30. */
  31. var urls = {
  32. 'alerts.get_by_service': {
  33. 'real': '/clusters/{clusterName}/services/{serviceName}?fields=alerts',
  34. 'mock': '/data/alerts/HDP2/service_alerts.json'
  35. },
  36. 'alerts.get_by_host': {
  37. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=alerts',
  38. 'mock': '/data/alerts/HDP2/host_alerts.json'
  39. },
  40. 'background_operations.get_most_recent': {
  41. 'real': '/clusters/{clusterName}/requests?to=end&page_size=10&fields=Requests',
  42. 'mock': '/data/background_operations/list_on_start.json',
  43. 'testInProduction': true
  44. },
  45. 'background_operations.get_by_request': {
  46. 'real': '/clusters/{clusterName}/requests/{requestId}?fields=*,tasks/Tasks/command,tasks/Tasks/exit_code,tasks/Tasks/host_name,tasks/Tasks/id,tasks/Tasks/role,tasks/Tasks/status',
  47. 'mock': '/data/background_operations/task_by_request{requestId}.json',
  48. 'testInProduction': true,
  49. 'format': function (data) {
  50. return {
  51. async: !data.sync
  52. };
  53. }
  54. },
  55. 'background_operations.get_by_task': {
  56. 'real': '/clusters/{clusterName}/requests/{requestId}/tasks/{taskId}',
  57. 'mock': '/data/background_operations/list_on_start.json',
  58. 'testInProduction': true,
  59. 'format': function (data) {
  60. return {
  61. async: !data.sync
  62. };
  63. }
  64. },
  65. 'service.item.start_stop': {
  66. 'real': '/clusters/{clusterName}/services/{serviceName}',
  67. 'mock': '/data/wizard/deploy/poll_1.json',
  68. 'format': function (data, opt) {
  69. return {
  70. type: 'PUT',
  71. data: JSON.stringify({
  72. RequestInfo: {
  73. "context": data.requestInfo
  74. },
  75. Body: {
  76. ServiceInfo: {
  77. state: data.state
  78. }
  79. }
  80. })
  81. };
  82. }
  83. },
  84. 'service.item.smoke': {
  85. 'real': '/clusters/{clusterName}/requests',
  86. 'mock': '/data/wizard/deploy/poll_1.json',
  87. 'format': function (data) {
  88. return {
  89. 'type': 'POST',
  90. data: JSON.stringify({
  91. RequestInfo: {
  92. "context": data.displayName + " Service Check",
  93. "command" : data.actionName,
  94. "service_name" : data.serviceName
  95. }
  96. })
  97. };
  98. }
  99. },
  100. 'service.stale_host_components.start_stop': {
  101. 'real': '/clusters/{clusterName}/host_components?' +
  102. 'HostRoles/stale_configs=true&HostRoles/component_name.in({componentNames})',
  103. 'mock': '/data/wizard/deploy/poll_1.json',
  104. 'format': function (data, opt) {
  105. return {
  106. type: 'PUT',
  107. data: JSON.stringify({
  108. RequestInfo: {
  109. "context": data.requestInfo
  110. },
  111. Body: {
  112. HostRoles: {
  113. state: data.state
  114. }
  115. }
  116. })
  117. };
  118. }
  119. },
  120. 'service.load_config_groups': {
  121. 'real': '/clusters/{clusterName}/config_groups?ConfigGroup/tag={serviceName}&fields=*',
  122. 'mock': ''
  123. },
  124. 'reassign.stop_services': {
  125. 'real': '/clusters/{clusterName}/services',
  126. 'mock': '',
  127. 'format': function (data, opt) {
  128. return {
  129. type: 'PUT',
  130. data: JSON.stringify({
  131. "RequestInfo": {
  132. "context": "Stop all services"
  133. },
  134. "Body": {
  135. "ServiceInfo": {
  136. "state": "INSTALLED"
  137. }
  138. }
  139. })
  140. }
  141. }
  142. },
  143. 'reassign.start_services': {
  144. 'real': '/clusters/{clusterName}/services?params/run_smoke_test=true',
  145. 'mock': '',
  146. 'format': function (data, opt) {
  147. return {
  148. type: 'PUT',
  149. data: JSON.stringify({
  150. "RequestInfo": {
  151. "context": "Start all services"
  152. },
  153. "Body": {
  154. "ServiceInfo": {
  155. "state": "STARTED"
  156. }
  157. }
  158. })
  159. }
  160. }
  161. },
  162. 'reassign.maintenance_mode': {
  163. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  164. 'mock': '',
  165. 'type': 'PUT',
  166. 'format': function () {
  167. return {
  168. data: JSON.stringify(
  169. {
  170. "HostRoles": {
  171. "state": "MAINTENANCE"
  172. }
  173. }
  174. )
  175. }
  176. }
  177. },
  178. 'reassign.remove_component': {
  179. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  180. 'mock': '',
  181. 'type': 'DELETE'
  182. },
  183. 'reassign.load_configs': {
  184. 'real': '/clusters/{clusterName}/configurations?{urlParams}',
  185. 'mock': ''
  186. },
  187. 'reassign.save_configs': {
  188. 'real': '/clusters/{clusterName}',
  189. 'mock': '',
  190. 'type': 'PUT',
  191. 'format': function (data) {
  192. return {
  193. async: false,
  194. data: JSON.stringify({
  195. Clusters: {
  196. desired_config: {
  197. "type": data.siteName,
  198. "tag": 'version' + (new Date).getTime(),
  199. "properties": data.properties
  200. }
  201. }
  202. })
  203. }
  204. }
  205. },
  206. 'host_component.maintenance_mode': {
  207. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  208. 'mock': '',
  209. 'type': 'PUT',
  210. 'format': function (data, opt) {
  211. return {
  212. data: JSON.stringify({
  213. RequestInfo: {
  214. "context": data.requestInfo
  215. },
  216. Body: {
  217. HostRoles: {
  218. state: data.state
  219. }
  220. }
  221. })
  222. };
  223. }
  224. },
  225. 'config.advanced': {
  226. 'real': '{stack2VersionUrl}/stackServices/{serviceName}/configurations?fields=*',
  227. 'mock': '/data/wizard/stack/hdp/version{stackVersion}/{serviceName}.json',
  228. 'format': function (data) {
  229. return {
  230. async: false
  231. };
  232. }
  233. },
  234. 'config.advanced.global': {
  235. 'real': '{stack2VersionUrl}/stackServices?fields=configurations/StackConfigurations/type',
  236. 'mock': '/data/wizard/stack/hdp/version1.3.0/global.json',
  237. 'format': function (data) {
  238. return {
  239. async: false
  240. };
  241. }
  242. },
  243. 'config.tags': {
  244. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs',
  245. 'mock': '/data/clusters/cluster.json'
  246. },
  247. 'config.tags_and_groups': {
  248. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs,config_groups/*',
  249. 'mock': '/data/clusters/tags_and_groups.json'
  250. },
  251. 'config.tags.sync': {
  252. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs',
  253. 'mock': '/data/clusters/cluster.json',
  254. 'format': function (data) {
  255. return {
  256. async: false
  257. };
  258. }
  259. },
  260. 'config_groups.all_fields': {
  261. 'real': '/clusters/{clusterName}/config_groups?fields=*',
  262. 'mock': ''
  263. },
  264. 'config_groups.get_config_group_by_id': {
  265. 'real': '/clusters/{clusterName}/config_groups/{id}',
  266. 'mock': ''
  267. },
  268. 'config_groups.update_config_group': {
  269. 'real': '/clusters/{clusterName}/config_groups/{id}',
  270. 'mock': '',
  271. 'type': 'PUT',
  272. 'format': function (data) {
  273. return {
  274. async: false,
  275. data: JSON.stringify(
  276. [
  277. data.configGroup
  278. ]
  279. )
  280. }
  281. }
  282. },
  283. 'config_groups.delete_config_group': {
  284. 'real': '/clusters/{clusterName}/config_groups/{id}',
  285. 'mock': '',
  286. 'type': 'DELETE'
  287. },
  288. 'config.on_site': {
  289. 'real': '/clusters/{clusterName}/configurations?{params}',
  290. 'mock': '/data/configurations/cluster_level_configs.json?{params}',
  291. 'format': function (data) {
  292. return {
  293. async: false
  294. };
  295. }
  296. },
  297. 'config.host_overrides': {
  298. 'real': '/clusters/{clusterName}/configurations?{params}',
  299. 'mock': '/data/configurations/host_level_overrides_configs.json?{params}',
  300. 'format': function (data) {
  301. return {
  302. async: false
  303. };
  304. }
  305. },
  306. 'host.host_component.action': {
  307. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  308. 'mock': '',
  309. 'type': 'PUT',
  310. 'format': function (data) {
  311. return {
  312. data: JSON.stringify({
  313. RequestInfo: {
  314. "context": data.context
  315. },
  316. Body: {
  317. "HostRoles": {
  318. "state": data.state
  319. }
  320. }
  321. })
  322. }
  323. }
  324. },
  325. 'host.stale_host_components.start_stop': {
  326. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components?HostRoles/stale_configs=true&' +
  327. 'HostRoles/component_name.in({componentNames})',
  328. 'mock': '',
  329. 'type': 'PUT',
  330. 'format': function (data) {
  331. return {
  332. data: JSON.stringify({
  333. RequestInfo: {
  334. "context": data.context
  335. },
  336. Body: {
  337. "HostRoles": {
  338. "state": data.state
  339. }
  340. }
  341. })
  342. }
  343. }
  344. },
  345. 'host.delete': {
  346. 'real': '/clusters/{clusterName}/hosts/{hostName}',
  347. 'mock': '',
  348. 'type': 'DELETE',
  349. 'format': function (data) {
  350. return {
  351. async: false
  352. }
  353. }
  354. },
  355. 'service.metrics.flume.channel_fill_percent': {
  356. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/CHANNEL/*/ChannelFillPercentage[{fromSeconds},{toSeconds},{stepSeconds}]',
  357. 'mock': '/data/services/metrics/flume/channelFillPct.json',
  358. 'testInProduction': true
  359. },
  360. 'service.metrics.flume.channel_size': {
  361. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/CHANNEL/*/ChannelSize[{fromSeconds},{toSeconds},{stepSeconds}]',
  362. 'mock': '/data/services/metrics/flume/channelSize.json',
  363. 'testInProduction': true
  364. },
  365. 'service.metrics.flume.sink_drain_success': {
  366. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/SINK/*/EventDrainSuccessCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  367. 'mock': '/data/services/metrics/flume/sinkDrainSuccessCount.json',
  368. 'testInProduction': true
  369. },
  370. 'service.metrics.flume.sink_connection_failed': {
  371. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/SINK/*/ConnectionFailedCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  372. 'mock': '/data/services/metrics/flume/sinkConnectionFailedCount.json',
  373. 'testInProduction': true
  374. },
  375. 'service.metrics.flume.gc': {
  376. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  377. 'mock': '/data/services/metrics/flume/jvmGcTime.json',
  378. 'testInProduction': true
  379. },
  380. 'service.metrics.flume.jvm_heap_used': {
  381. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/jvm/memHeapUsedM[{fromSeconds},{toSeconds},{stepSeconds}]',
  382. 'mock': '/data/services/metrics/flume/jvmMemHeapUsedM.json',
  383. 'testInProduction': true
  384. },
  385. 'service.metrics.flume.jvm_threads_runnable': {
  386. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/jvm/threadsRunnable[{fromSeconds},{toSeconds},{stepSeconds}]',
  387. 'mock': '/data/services/metrics/flume/jvmThreadsRunnable.json',
  388. 'testInProduction': true
  389. },
  390. 'service.metrics.flume.cpu_user': {
  391. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/cpu/cpu_user[{fromSeconds},{toSeconds},{stepSeconds}]',
  392. 'mock': '',
  393. 'testInProduction': true
  394. },
  395. 'service.metrics.flume.source_accepted': {
  396. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/SOURCE/*/EventAcceptedCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  397. 'mock': '/data/services/metrics/flume/sourceEventAccepted.json',
  398. 'testInProduction': true
  399. },
  400. 'service.metrics.hbase.cluster_requests': {
  401. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/cluster_requests[{fromSeconds},{toSeconds},{stepSeconds}]',
  402. 'mock': '/data/services/metrics/hbase/cluster_requests.json',
  403. 'testInProduction': true
  404. },
  405. 'service.metrics.hbase.hlog_split_size': {
  406. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/splitSize_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  407. 'mock': '/data/services/metrics/hbase/hlog_split_size.json',
  408. 'testInProduction': true
  409. },
  410. 'service.metrics.hbase.hlog_split_time': {
  411. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/splitTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  412. 'mock': '/data/services/metrics/hbase/hlog_split_time.json',
  413. 'testInProduction': true
  414. },
  415. 'service.metrics.hbase.regionserver_queuesize': {
  416. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/flushQueueSize[{fromSeconds},{toSeconds},{stepSeconds}],metrics/hbase/regionserver/compactionQueueSize[{fromSeconds},{toSeconds},{stepSeconds}]',
  417. 'mock': '/data/services/metrics/hbase/regionserver_queuesize.json',
  418. 'testInProduction': true
  419. },
  420. 'service.metrics.hbase.regionserver_regions': {
  421. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/regions[{fromSeconds},{toSeconds},{stepSeconds}]',
  422. 'mock': '/data/services/metrics/hbase/regionserver_regions.json',
  423. 'testInProduction': true
  424. },
  425. 'service.metrics.hbase.regionserver_rw_requests': {
  426. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/readRequestsCount[{fromSeconds},{toSeconds},{stepSeconds}],metrics/hbase/regionserver/writeRequestsCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  427. 'mock': '/data/services/metrics/hbase/regionserver_rw_requests.json',
  428. 'testInProduction': true
  429. },
  430. 'service.metrics.mapreduce.gc': {
  431. 'real': '/clusters/{clusterName}/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  432. 'mock': '/data/services/metrics/mapreduce/gc.json',
  433. 'testInProduction': true
  434. },
  435. 'service.metrics.mapreduce.jobs_status': {
  436. '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}]',
  437. 'mock': '/data/services/metrics/mapreduce/jobs_status.json',
  438. 'testInProduction': true
  439. },
  440. 'service.metrics.mapreduce.jobs_heap': {
  441. '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}]',
  442. 'mock': '/data/services/metrics/mapreduce/jvm_heap.json',
  443. 'testInProduction': true
  444. },
  445. 'service.metrics.mapreduce.jobs_threads': {
  446. '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}]',
  447. 'mock': '/data/services/metrics/mapreduce/jvm_threads.json',
  448. 'testInProduction': true
  449. },
  450. 'service.metrics.mapreduce.map_slots': {
  451. '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}]',
  452. 'mock': '/data/services/metrics/mapreduce/map_slots.json',
  453. 'testInProduction': true
  454. },
  455. 'service.metrics.mapreduce.reduce_slots': {
  456. '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}]',
  457. 'mock': '/data/services/metrics/mapreduce/reduce_slots.json',
  458. 'testInProduction': true
  459. },
  460. 'service.metrics.mapreduce.rpc': {
  461. 'real': '/clusters/{clusterName}/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  462. 'mock': '/data/services/metrics/mapreduce/rpc.json',
  463. 'testInProduction': true
  464. },
  465. 'service.metrics.mapreduce.tasks_running_waiting': {
  466. '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}]',
  467. 'mock': '/data/services/metrics/mapreduce/tasks_running_waiting.json',
  468. 'testInProduction': true
  469. },
  470. 'service.metrics.hdfs.block_status': {
  471. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/dfs/FSNamesystem/PendingReplicationBlocks[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/FSNamesystem/UnderReplicatedBlocks[{fromSeconds},{toSeconds},{stepSeconds}]',
  472. 'mock': '/data/services/metrics/hdfs/block_status.json',
  473. 'testInProduction': true
  474. },
  475. 'service.metrics.hdfs.file_operations': {
  476. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/dfs/namenode/FileInfoOps[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/namenode/CreateFileOps[{fromSeconds},{toSeconds},{stepSeconds}]',
  477. 'mock': '/data/services/metrics/hdfs/file_operations.json',
  478. 'testInProduction': true
  479. },
  480. 'service.metrics.hdfs.gc': {
  481. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  482. 'mock': '/data/services/metrics/hdfs/gc.json',
  483. 'testInProduction': true
  484. },
  485. 'service.metrics.hdfs.io': {
  486. 'real': '/clusters/{clusterName}/services/HDFS/components/DATANODE?fields=metrics/dfs/datanode/bytes_written[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/datanode/bytes_read[{fromSeconds},{toSeconds},{stepSeconds}]',
  487. 'mock': '/data/services/metrics/hdfs/io.json',
  488. 'testInProduction': true
  489. },
  490. 'service.metrics.hdfs.jvm_heap': {
  491. '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}]',
  492. 'mock': '/data/services/metrics/hdfs/jvm_heap.json',
  493. 'testInProduction': true
  494. },
  495. 'service.metrics.hdfs.jvm_threads': {
  496. '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}]',
  497. 'mock': '/data/services/metrics/hdfs/jvm_threads.json',
  498. 'testInProduction': true
  499. },
  500. 'service.metrics.hdfs.rpc': {
  501. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  502. 'mock': '/data/services/metrics/hdfs/rpc.json',
  503. 'testInProduction': true
  504. },
  505. 'service.metrics.hdfs.space_utilization': {
  506. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/dfs/FSNamesystem/CapacityRemainingGB[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/FSNamesystem/CapacityUsedGB[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/FSNamesystem/CapacityTotalGB[{fromSeconds},{toSeconds},{stepSeconds}]',
  507. 'mock': '/data/services/metrics/hdfs/space_utilization.json',
  508. 'testInProduction': true
  509. },
  510. 'service.start_stop': {
  511. 'real': '/clusters/{clusterName}/services?params/run_smoke_test=true',
  512. 'mock': '/data/mirroring/poll/poll_6.json',
  513. 'format': function (data, opt) {
  514. return {
  515. type: 'PUT',
  516. async: false,
  517. data: data.data
  518. };
  519. }
  520. },
  521. 'service.metrics.yarn.gc': {
  522. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  523. 'mock': '/data/services/metrics/yarn/gc.json',
  524. 'testInProduction': true
  525. },
  526. 'service.metrics.yarn.jobs_threads': {
  527. '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}]',
  528. 'mock': '/data/services/metrics/yarn/jvm_threads.json',
  529. 'testInProduction': true
  530. },
  531. 'service.metrics.yarn.rpc': {
  532. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  533. 'mock': '/data/services/metrics/yarn/rpc.json',
  534. 'testInProduction': true
  535. },
  536. 'service.metrics.yarn.jobs_heap': {
  537. '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}]',
  538. 'mock': '/data/services/metrics/yarn/jvm_heap.json',
  539. 'testInProduction': true
  540. },
  541. 'service.metrics.yarn.queue.allocated': {
  542. '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}]',
  543. 'mock': '',
  544. 'testInProduction': true
  545. },
  546. 'service.metrics.yarn.queue.allocated.container': {
  547. '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}]',
  548. 'mock': '',
  549. 'testInProduction': true
  550. },
  551. 'service.metrics.yarn.node.manager.statuses': {
  552. '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}]',
  553. 'mock': '',
  554. 'testInProduction': true
  555. },
  556. 'service.metrics.yarn.queue.memory.resource': {
  557. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=',
  558. 'mock': '',
  559. 'format': function (data, opt) {
  560. var field1 = 'metrics/yarn/Queue/{queueName}/AllocatedMB[{fromSeconds},{toSeconds},{stepSeconds}]';
  561. var field2 = 'metrics/yarn/Queue/{queueName}/AvailableMB[{fromSeconds},{toSeconds},{stepSeconds}]';
  562. if (opt.url != null && data.queueNames != null && data.queueNames.length > 0) {
  563. data.queueNames.forEach(function (q) {
  564. data.queueName = q;
  565. opt.url += (formatUrl(field1, data) + ",");
  566. opt.url += (formatUrl(field2, data) + ",");
  567. });
  568. } else {
  569. opt.url += (formatUrl(field1, data) + ",");
  570. opt.url += (formatUrl(field2, data) + ",");
  571. }
  572. },
  573. 'testInProduction': true
  574. },
  575. 'service.metrics.yarn.queue.apps.states.current': {
  576. '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}]',
  577. 'mock': '',
  578. 'testInProduction': true
  579. },
  580. 'service.metrics.yarn.queue.apps.states.finished': {
  581. '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}]',
  582. 'mock': '',
  583. 'testInProduction': true
  584. },
  585. 'dashboard.cluster_metrics.cpu': {
  586. 'real': '/clusters/{clusterName}/?fields=metrics/cpu[{fromSeconds},{toSeconds},{stepSeconds}]',
  587. 'mock': '/data/cluster_metrics/cpu_1hr.json',
  588. 'testInProduction': true
  589. },
  590. 'dashboard.cluster_metrics.load': {
  591. 'real': '/clusters/{clusterName}/?fields=metrics/load[{fromSeconds},{toSeconds},{stepSeconds}]',
  592. 'mock': '/data/cluster_metrics/load_1hr.json',
  593. 'testInProduction': true
  594. },
  595. 'dashboard.cluster_metrics.memory': {
  596. 'real': '/clusters/{clusterName}/?fields=metrics/memory[{fromSeconds},{toSeconds},{stepSeconds}]',
  597. 'mock': '/data/cluster_metrics/memory_1hr.json',
  598. 'testInProduction': true
  599. },
  600. 'dashboard.cluster_metrics.network': {
  601. 'real': '/clusters/{clusterName}/?fields=metrics/network[{fromSeconds},{toSeconds},{stepSeconds}]',
  602. 'mock': '/data/cluster_metrics/network_1hr.json',
  603. 'testInProduction': true
  604. },
  605. 'host.metrics.cpu': {
  606. '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}]',
  607. 'mock': '/data/hosts/metrics/cpu.json',
  608. 'testInProduction': true
  609. },
  610. 'host.metrics.disk': {
  611. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/disk/disk_total[{fromSeconds},{toSeconds},{stepSeconds}],metrics/disk/disk_free[{fromSeconds},{toSeconds},{stepSeconds}]',
  612. 'mock': '/data/hosts/metrics/disk.json',
  613. 'testInProduction': true
  614. },
  615. 'host.metrics.load': {
  616. '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}]',
  617. 'mock': '/data/hosts/metrics/load.json',
  618. 'testInProduction': true
  619. },
  620. 'host.metrics.memory': {
  621. '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}]',
  622. 'mock': '/data/hosts/metrics/memory.json',
  623. 'testInProduction': true
  624. },
  625. 'host.metrics.network': {
  626. '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}]',
  627. 'mock': '/data/hosts/metrics/network.json',
  628. 'testInProduction': true
  629. },
  630. 'host.metrics.processes': {
  631. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/process/proc_total[{fromSeconds},{toSeconds},{stepSeconds}],metrics/process/proc_run[{fromSeconds},{toSeconds},{stepSeconds}]',
  632. 'mock': '/data/hosts/metrics/processes.json',
  633. 'testInProduction': true
  634. },
  635. 'host.service_config_hosts_overrides': {
  636. 'real': '/clusters/{clusterName}/configurations?{urlParams}',
  637. 'mock': '',
  638. 'format': function (data, opt) {
  639. return {
  640. async: false,
  641. timeout: 10000
  642. };
  643. }
  644. },
  645. 'admin.security_status': {
  646. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs',
  647. 'mock': '',
  648. 'format': function (data, opt) {
  649. return {
  650. timeout: 10000
  651. };
  652. }
  653. },
  654. 'settings.get.user_pref': {
  655. 'real': '/persist/{key}',
  656. 'mock': '/data/user_settings/user_pref.json'
  657. },
  658. 'settings.post.user_pref': {
  659. 'real': '/persist',
  660. 'mock': '',
  661. 'type': 'POST',
  662. 'format': function (data) {
  663. return {
  664. data: JSON.stringify(data.keyValuePair)
  665. }
  666. }
  667. },
  668. 'cluster.load_cluster_name': {
  669. 'real': '/clusters',
  670. 'mock': '/data/clusters/info.json',
  671. 'format': function (data, opt) {
  672. return {
  673. async: false
  674. };
  675. }
  676. },
  677. 'cluster.state': {
  678. 'type': 'POST',
  679. 'real': '/persist/',
  680. 'mock': '',
  681. 'format': function (data, opt) {
  682. return {
  683. async: false,
  684. data: JSON.stringify(data.keyValuePair)
  685. };
  686. }
  687. },
  688. 'cluster.update_upgrade_version': {
  689. 'real': '/stacks2/HDP/versions?fields=stackServices/StackServices,Versions',
  690. 'mock': '/data/wizard/stack/stacks.json',
  691. 'format': function (data, opt) {
  692. return {
  693. async: false
  694. };
  695. }
  696. },
  697. 'cluster.load_repositories': {
  698. 'real': '/stacks2/{stackName}/versions/{stackVersion}/operatingSystems?fields=repositories/*',
  699. 'mock': '',
  700. 'type': 'GET',
  701. 'format': function (data, opt) {
  702. return {
  703. data: data.data
  704. };
  705. }
  706. },
  707. 'admin.high_availability.stop_all_services': {
  708. 'real': '/clusters/{clusterName}/services',
  709. 'mock': '',
  710. 'format': function (data, opt) {
  711. return {
  712. type: 'PUT',
  713. data: JSON.stringify({
  714. "RequestInfo": {
  715. "context": "Stop all services"
  716. },
  717. "Body": {
  718. "ServiceInfo": {
  719. "state": "INSTALLED"
  720. }
  721. }
  722. })
  723. }
  724. }
  725. },
  726. 'admin.high_availability.start_all_services': {
  727. 'real': '/clusters/{clusterName}/services',
  728. 'mock': '',
  729. 'format': function (data, opt) {
  730. return {
  731. type: 'PUT',
  732. data: JSON.stringify({
  733. "RequestInfo": {
  734. "context": "Start all services"
  735. },
  736. "Body": {
  737. "ServiceInfo": {
  738. "state": "STARTED"
  739. }
  740. }
  741. })
  742. }
  743. }
  744. },
  745. 'admin.high_availability.polling': {
  746. 'real': '/clusters/{clusterName}/requests/{requestId}?fields=tasks/*',
  747. 'mock': '',
  748. 'type': 'GET'
  749. },
  750. 'admin.high_availability.getNnCheckPointStatus': {
  751. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/NAMENODE',
  752. 'mock': '',
  753. 'type': 'GET'
  754. },
  755. 'admin.high_availability.getJnCheckPointStatus': {
  756. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/JOURNALNODE?fields=metrics',
  757. 'mock': ''
  758. },
  759. 'admin.high_availability.getHostComponent': {
  760. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  761. 'mock': ''
  762. },
  763. 'admin.high_availability.create_component': {
  764. 'real': '/clusters/{clusterName}/hosts?Hosts/host_name={hostName}',
  765. 'mock': '',
  766. 'type': 'POST',
  767. 'format': function (data) {
  768. return {
  769. data: JSON.stringify({
  770. "host_components": [
  771. {
  772. "HostRoles": {
  773. "component_name": data.componentName
  774. }
  775. }
  776. ]
  777. })
  778. }
  779. }
  780. },
  781. 'admin.high_availability.create_journalnode': {
  782. 'real': '/clusters/{clusterName}/services?ServiceInfo/service_name=HDFS',
  783. 'mock': '',
  784. 'type': 'POST',
  785. 'format': function (data) {
  786. return {
  787. data: JSON.stringify({
  788. "components": [
  789. {
  790. "ServiceComponentInfo": {
  791. "component_name": "JOURNALNODE"
  792. }
  793. }
  794. ]
  795. })
  796. }
  797. }
  798. },
  799. 'admin.high_availability.create_zkfc': {
  800. 'real': '/clusters/{clusterName}/services?ServiceInfo/service_name=HDFS',
  801. 'mock': '',
  802. 'type': 'POST',
  803. 'format': function (data) {
  804. return {
  805. data: JSON.stringify({
  806. "components": [
  807. {
  808. "ServiceComponentInfo": {
  809. "component_name": "ZKFC"
  810. }
  811. }
  812. ]
  813. })
  814. }
  815. }
  816. },
  817. 'admin.high_availability.install_component': {
  818. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  819. 'mock': '',
  820. 'type': 'PUT',
  821. 'format': function (data) {
  822. return {
  823. data: JSON.stringify({
  824. RequestInfo: {
  825. "context": "Install " + data.displayName
  826. },
  827. Body: {
  828. "HostRoles": {
  829. "state": "INSTALLED"
  830. }
  831. }
  832. })
  833. }
  834. }
  835. },
  836. 'admin.high_availability.start_component': {
  837. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  838. 'mock': '',
  839. 'type': 'PUT',
  840. 'format': function (data) {
  841. return {
  842. data: JSON.stringify({
  843. RequestInfo: {
  844. "context": "Start " + data.displayName
  845. },
  846. Body: {
  847. "HostRoles": {
  848. "state": "STARTED"
  849. }
  850. }
  851. })
  852. }
  853. }
  854. },
  855. 'admin.high_availability.maintenance_mode': {
  856. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  857. 'mock': '',
  858. 'type': 'PUT',
  859. 'format': function () {
  860. return {
  861. data: JSON.stringify({
  862. "HostRoles": {
  863. "state": "MAINTENANCE"
  864. }
  865. })
  866. }
  867. }
  868. },
  869. 'admin.high_availability.stop_component': {
  870. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  871. 'mock': '',
  872. 'type': 'PUT',
  873. 'format': function (data) {
  874. return {
  875. data: JSON.stringify({
  876. RequestInfo: {
  877. "context": "Stop " + data.displayName
  878. },
  879. Body: {
  880. "HostRoles": {
  881. "state": "INSTALLED"
  882. }
  883. }
  884. })
  885. }
  886. }
  887. },
  888. 'admin.high_availability.load_configs': {
  889. 'real': '/clusters/{clusterName}/configurations?(type=core-site&tag={coreSiteTag})|(type=hdfs-site&tag={hdfsSiteTag})',
  890. 'mock': '',
  891. 'type': 'GET'
  892. },
  893. 'admin.high_availability.save_configs': {
  894. 'real': '/clusters/{clusterName}',
  895. 'mock': '',
  896. 'type': 'PUT',
  897. 'format': function (data) {
  898. return {
  899. async: false,
  900. data: JSON.stringify({
  901. Clusters: {
  902. desired_config: {
  903. "type": data.siteName,
  904. "tag": 'version' + (new Date).getTime(),
  905. "properties": data.properties
  906. }
  907. }
  908. })
  909. }
  910. }
  911. },
  912. 'admin.high_availability.load_hbase_configs': {
  913. 'real': '/clusters/{clusterName}/configurations?type=hbase-site&tag={hbaseSiteTag}',
  914. 'mock': '',
  915. 'type': 'GET'
  916. },
  917. 'admin.high_availability.delete_component': {
  918. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  919. 'mock': '',
  920. 'type': 'DELETE'
  921. },
  922. 'admin.security.cluster_configs': {
  923. 'real': '/clusters/{clusterName}',
  924. 'mock': '',
  925. 'format': function (data, opt) {
  926. return {
  927. timeout: 10000
  928. };
  929. }
  930. },
  931. 'admin.delete_host': {
  932. 'real': '/clusters/{clusterName}/hosts/{hostName}',
  933. 'mock': '',
  934. 'type': 'DELETE'
  935. },
  936. 'admin.get.all_configurations': {
  937. 'real': '/clusters/{clusterName}/configurations?{urlParams}',
  938. 'mock': '',
  939. 'format': function (data, opt) {
  940. return {
  941. timeout: 10000
  942. };
  943. }
  944. },
  945. 'admin.security.apply_configurations': {
  946. 'real': '/clusters/{clusterName}',
  947. 'mock': '',
  948. 'format': function (data, opt) {
  949. return {
  950. type: 'PUT',
  951. timeout: 10000,
  952. data: data.configData
  953. };
  954. }
  955. },
  956. 'admin.security.apply_configuration': {
  957. 'real': '/clusters/{clusterName}',
  958. 'mock': '',
  959. 'format': function (data, opt) {
  960. return {
  961. type: 'PUT',
  962. async: false,
  963. timeout: 5000,
  964. data: JSON.stringify(data.clusterData)
  965. };
  966. }
  967. },
  968. 'admin.security.add.cluster_configs': {
  969. 'real': '/clusters/{clusterName}' + '?fields=Clusters/desired_configs',
  970. 'mock': '',
  971. 'format': function (data, opt) {
  972. return {
  973. timeout: 10000
  974. };
  975. }
  976. },
  977. 'admin.stack_upgrade.run_upgrade': {
  978. 'real': '/clusters/{clusterName}',
  979. 'mock': '',
  980. 'format': function (data, opt) {
  981. return {
  982. type: 'PUT',
  983. async: false,
  984. data: data.data
  985. };
  986. }
  987. },
  988. 'admin.stack_upgrade.stop_services': {
  989. 'real': '/clusters/{clusterName}/services?ServiceInfo/state=STARTED',
  990. 'mock': '',
  991. 'format': function (data, opt) {
  992. return {
  993. type: 'PUT',
  994. async: false,
  995. data: data.data
  996. };
  997. }
  998. },
  999. 'admin.stack_upgrade.do_poll': {
  1000. 'real': '/clusters/{cluster}/requests/{requestId}?fields=tasks/*',
  1001. 'mock': '/data/wizard/{mock}'
  1002. },
  1003. 'wizard.advanced_repositories.valid_url': {
  1004. 'real': '/stacks2/{stackName}/versions/{stackVersion}/operatingSystems/{osType}/repositories/{nameVersionCombo}',
  1005. 'mock': '',
  1006. 'type': 'PUT',
  1007. 'format': function (data) {
  1008. return {
  1009. async: true,
  1010. data: JSON.stringify(data.data)
  1011. }
  1012. }
  1013. },
  1014. 'wizard.install_services.add_host_controller.is_retry': {
  1015. 'real': '/clusters/{cluster}/host_components',
  1016. 'mock': '',
  1017. 'format': function (data, opt) {
  1018. return {
  1019. type: 'PUT',
  1020. async: false,
  1021. data: data.data
  1022. };
  1023. }
  1024. },
  1025. 'wizard.install_services.add_host_controller.not_is_retry': {
  1026. 'real': '/clusters/{cluster}/host_components',
  1027. 'mock': '',
  1028. 'format': function (data, opt) {
  1029. return {
  1030. type: 'PUT',
  1031. async: false,
  1032. data: data.data
  1033. };
  1034. }
  1035. },
  1036. 'wizard.install_services.installer_controller.is_retry': {
  1037. 'real': '/clusters/{cluster}/host_components?HostRoles/state=INSTALLED',
  1038. 'mock': '/data/wizard/deploy/2_hosts/poll_1.json',
  1039. 'type': 'PUT',
  1040. 'format': function (data, opt) {
  1041. return {
  1042. async: false,
  1043. data: data.data
  1044. };
  1045. }
  1046. },
  1047. 'wizard.install_services.installer_controller.not_is_retry': {
  1048. 'real': '/clusters/{cluster}/services?ServiceInfo/state=INIT',
  1049. 'mock': '/data/wizard/deploy/2_hosts/poll_1.json',
  1050. 'type': 'PUT',
  1051. 'format': function (data, opt) {
  1052. return {
  1053. async: false,
  1054. data: data.data
  1055. };
  1056. }
  1057. },
  1058. 'wizard.install_services.add_service_controller.get_failed_host_components': {
  1059. 'real': '/clusters/{clusterName}/host_components?fields=HostRoles/state,component/ServiceComponentInfo/service_name',
  1060. 'mock': '',
  1061. 'format': function (data, opt) {
  1062. return {
  1063. async: false
  1064. };
  1065. }
  1066. },
  1067. 'wizard.service_components': {
  1068. 'real': '{stackUrl}/stackServices?fields=StackServices',
  1069. 'mock': '/data/wizard/stack/hdp/version/{stackVersion}.json',
  1070. 'format': function (data, opt) {
  1071. return {
  1072. timeout: 10000,
  1073. async: false
  1074. };
  1075. }
  1076. },
  1077. 'wizard.step9.installer.launch_start_services': {
  1078. 'real': '/clusters/{cluster}/services?ServiceInfo/state=INSTALLED&params/run_smoke_test=true&params/reconfigure_client=false',
  1079. 'mock': '/data/wizard/deploy/5_hosts/poll_6.json',
  1080. 'format': function (data, opt) {
  1081. var data = {
  1082. type: 'PUT',
  1083. async: false,
  1084. data: data.data
  1085. };
  1086. if (App.testMode) {
  1087. data.type = 'GET';
  1088. }
  1089. return data;
  1090. }
  1091. },
  1092. 'wizard.step9.add_host.launch_start_services': {
  1093. 'real': '/clusters/{cluster}/host_components',
  1094. 'mock': '/data/wizard/deploy/5_hosts/poll_6.json',
  1095. 'format': function (data, opt) {
  1096. return {
  1097. type: 'PUT',
  1098. async: false,
  1099. data: data.data
  1100. };
  1101. }
  1102. },
  1103. 'wizard.step8.delete_cluster': {
  1104. 'real': '/clusters/{name}',
  1105. 'mock': '',
  1106. 'format': function (data, opt) {
  1107. return {
  1108. type: 'DELETE',
  1109. async: false
  1110. };
  1111. }
  1112. },
  1113. 'wizard.step8.existing_cluster_names': {
  1114. 'real': '/clusters',
  1115. 'mock': '',
  1116. 'format': function (data, opt) {
  1117. return {
  1118. async: false
  1119. };
  1120. }
  1121. },
  1122. 'wizard.step3.host_info': {
  1123. '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',
  1124. 'mock': '/data/wizard/bootstrap/two_hosts_information.json',
  1125. 'format': function (data, opt) {
  1126. return {
  1127. contentType: 'application/json'
  1128. };
  1129. }
  1130. },
  1131. 'wizard.step3.rerun_checks': {
  1132. 'real': '/hosts?fields=Hosts/last_agent_env',
  1133. 'mock': '/data/wizard/bootstrap/two_hosts_information.json',
  1134. 'format': function (data, opt) {
  1135. return {
  1136. contentType: 'application/json'
  1137. };
  1138. }
  1139. },
  1140. 'wizard.step3.bootstrap': {
  1141. 'real': '/bootstrap/{bootRequestId}',
  1142. 'mock': '/data/wizard/bootstrap/poll_{numPolls}.json'
  1143. },
  1144. 'wizard.step3.is_hosts_registered': {
  1145. 'real': '/hosts',
  1146. 'mock': '/data/wizard/bootstrap/single_host_registration.json'
  1147. },
  1148. 'wizard.stacks': {
  1149. 'real': '/stacks2',
  1150. 'mock': '/data/wizard/stack/stacks2.json',
  1151. 'format': function (data) {
  1152. return {
  1153. async: false
  1154. };
  1155. }
  1156. },
  1157. 'wizard.stacks_versions': {
  1158. 'real': '/stacks2/{stackName}/versions?fields=Versions,operatingSystems/repositories/Repositories',
  1159. 'mock': '/data/wizard/stack/{stackName}_versions.json',
  1160. 'format': function (data) {
  1161. return {
  1162. async: false
  1163. };
  1164. }
  1165. },
  1166. 'wizard.launch_bootstrap': {
  1167. 'real': '/bootstrap',
  1168. 'mock': '/data/wizard/bootstrap/bootstrap.json',
  1169. 'type': 'POST',
  1170. 'format': function (data) {
  1171. return {
  1172. async: false,
  1173. contentType: 'application/json',
  1174. data: data.bootStrapData
  1175. }
  1176. }
  1177. },
  1178. 'router.login': {
  1179. 'real': '/users/{loginName}',
  1180. 'mock': '/data/users/user_{usr}.json',
  1181. 'format': function (data, opt) {
  1182. var statusCode = jQuery.extend({}, require('data/statusCodes'));
  1183. statusCode['403'] = function () {
  1184. console.log("Error code 403: Forbidden.");
  1185. }
  1186. return {
  1187. statusCode: statusCode
  1188. };
  1189. }
  1190. },
  1191. 'router.login2': {
  1192. 'real': '/clusters',
  1193. 'mock': '/data/clusters/info.json'
  1194. },
  1195. 'router.logoff': {
  1196. 'real': '/logout',
  1197. 'mock': ''
  1198. },
  1199. 'router.set_ambari_stacks': {
  1200. 'real': '/stacks',
  1201. 'mock': '/data/wizard/stack/stacks.json',
  1202. 'format': function (data, opt) {
  1203. return {
  1204. async: false
  1205. };
  1206. }
  1207. },
  1208. 'router.authentication': {
  1209. 'real': '/clusters',
  1210. 'mock': '/data/clusters/info.json',
  1211. 'format': function (data, opt) {
  1212. return {
  1213. async: false
  1214. };
  1215. }
  1216. },
  1217. 'ambari.service': {
  1218. 'real': '/services/AMBARI/components/AMBARI_SERVER',
  1219. 'mock': ''
  1220. },
  1221. 'dashboard.get.user_pref': {
  1222. 'real': '/persist/{key}',
  1223. 'mock': '',
  1224. 'format': function (data, opt) {
  1225. return {
  1226. async: false
  1227. };
  1228. }
  1229. },
  1230. 'dashboard.post.user_pref': {
  1231. 'real': '/persist',
  1232. 'mock': '',
  1233. 'type': 'POST',
  1234. 'format': function (data) {
  1235. return {
  1236. async: false,
  1237. data: JSON.stringify(data.keyValuePair)
  1238. }
  1239. }
  1240. },
  1241. 'config_groups.create': {
  1242. 'real': '/clusters/{clusterName}/config_groups',
  1243. 'mock': '',
  1244. 'format': function (data) {
  1245. return {
  1246. async: false,
  1247. type: 'POST',
  1248. data: JSON.stringify([{
  1249. "ConfigGroup": {
  1250. "group_name": data.group_name,
  1251. "tag": data.service_id,
  1252. "description": data.description,
  1253. "desired_configs": data.desired_configs,
  1254. "hosts": data.hosts
  1255. }
  1256. }])
  1257. }
  1258. }
  1259. },
  1260. 'config_groups.update': {
  1261. 'real': '/clusters/{clusterName}/config_groups/{id}',
  1262. 'mock': '',
  1263. 'format': function (data) {
  1264. return {
  1265. async: true,
  1266. type: 'PUT',
  1267. data: JSON.stringify(data.data)
  1268. }
  1269. }
  1270. },
  1271. 'rolling_restart.post': {
  1272. 'real': '/clusters/{clusterName}/request_schedules',
  1273. 'mock': '',
  1274. 'format' : function(data) {
  1275. return {
  1276. type : 'POST',
  1277. data : JSON.stringify([ {
  1278. "RequestSchedule" : {
  1279. "batch" : [ {
  1280. "requests" : data.batches
  1281. }, {
  1282. "batch_settings" : {
  1283. "batch_separation_in_seconds" : data.intervalTimeSeconds,
  1284. "task_failure_tolerance" : data.tolerateSize
  1285. }
  1286. } ]
  1287. }
  1288. } ])
  1289. }
  1290. }
  1291. },
  1292. 'restart.service.hostComponents' : {
  1293. 'real' : '/clusters/{clusterName}/requests',
  1294. 'mock' : '',
  1295. 'format' : function(data) {
  1296. var componentDisplayName = App.format.role(data.componentName);
  1297. var serviceDisplayName = App.Service.DisplayNames[data.serviceName];
  1298. return {
  1299. type : 'POST',
  1300. data : JSON.stringify({
  1301. "RequestInfo" : {
  1302. "context" : Em.I18n.t('restart.service.rest.context').format(serviceDisplayName, componentDisplayName),
  1303. "command" : "RESTART",
  1304. "service_name" : data.serviceName,
  1305. "component_name" : data.componentName,
  1306. "hosts" : data.hosts
  1307. }
  1308. })
  1309. }
  1310. }
  1311. },
  1312. 'mirroring.get_all_datasets': {
  1313. 'real': 'falcon/entities/list/feed',
  1314. 'mock': '/data/mirroring/datasets.json'
  1315. },
  1316. 'mirroring.get_dataset_definition': {
  1317. 'real': 'falcon/entities/definition/feed/{dataset}',
  1318. 'mock': '/data/mirroring/{dataset}_definition.xml',
  1319. 'format': function (data) {
  1320. return {
  1321. dataType: 'xml'
  1322. }
  1323. }
  1324. },
  1325. 'mirroring.dataset.get_all_instances': {
  1326. 'real': 'falcon/instance/status/feed/{dataset}',
  1327. 'mock': '/data/mirroring/{dataset}_instances.json'
  1328. },
  1329. 'bulk_request.host_components': {
  1330. 'real': '/clusters/{clusterName}/host_components',
  1331. 'mock': '',
  1332. 'format': function(data) {
  1333. return {
  1334. type: 'PUT',
  1335. data: JSON.stringify({
  1336. RequestInfo: {
  1337. context: data.requestInfo,
  1338. query: 'HostRoles/component_name=' + data.componentName + '&HostRoles/host_name.in(' + data.hostNames + ')'
  1339. },
  1340. Body: {
  1341. HostRoles: {
  1342. state: data.state
  1343. }
  1344. }
  1345. })
  1346. }
  1347. }
  1348. },
  1349. 'bulk_request.decommission': {
  1350. 'real' : '/clusters/{clusterName}/requests',
  1351. 'mock' : '',
  1352. 'format': function(data) {
  1353. return {
  1354. type: 'POST',
  1355. data: JSON.stringify({
  1356. 'RequestInfo': {
  1357. 'context': data.context,
  1358. 'command': 'DECOMMISSION',
  1359. 'service_name': data.serviceName,
  1360. 'component_name': data.componentName,
  1361. 'parameters': data.parameters
  1362. }
  1363. })
  1364. }
  1365. }
  1366. },
  1367. 'mirroring.create_new_dataset': {
  1368. 'real': '/falcon/entities/submitAndSchedule/feed',
  1369. 'mock': '/data/mirroring/succeeded.json',
  1370. 'type': 'POST',
  1371. 'format': function (data) {
  1372. return {
  1373. contentType: 'text/xml',
  1374. data: data.dataset
  1375. }
  1376. }
  1377. }
  1378. };
  1379. /**
  1380. * Replace data-placeholders to its values
  1381. *
  1382. * @param {String} url
  1383. * @param {Object} data
  1384. * @return {String}
  1385. */
  1386. var formatUrl = function (url, data) {
  1387. if (!url) return null;
  1388. var keys = url.match(/\{\w+\}/g);
  1389. keys = (keys === null) ? [] : keys;
  1390. if (keys) {
  1391. keys.forEach(function (key) {
  1392. var raw_key = key.substr(1, key.length - 2);
  1393. var replace;
  1394. if (!data || !data[raw_key]) {
  1395. replace = '';
  1396. }
  1397. else {
  1398. replace = data[raw_key];
  1399. }
  1400. url = url.replace(new RegExp(key, 'g'), replace);
  1401. });
  1402. }
  1403. return url;
  1404. };
  1405. /**
  1406. * this = object from config
  1407. * @return {Object}
  1408. */
  1409. var formatRequest = function (data) {
  1410. var opt = {
  1411. type: this.type || 'GET',
  1412. timeout: App.timeout,
  1413. dataType: 'json',
  1414. statusCode: require('data/statusCodes')
  1415. };
  1416. if (App.testMode) {
  1417. opt.url = formatUrl(this.mock ? this.mock : '', data);
  1418. opt.type = 'GET';
  1419. }
  1420. else {
  1421. opt.url = App.apiPrefix + formatUrl(this.real, data);
  1422. }
  1423. if (this.format) {
  1424. jQuery.extend(opt, this.format(data, opt));
  1425. }
  1426. return opt;
  1427. };
  1428. /**
  1429. * Wrapper for all ajax requests
  1430. *
  1431. * @type {Object}
  1432. */
  1433. var ajax = Em.Object.extend({
  1434. /**
  1435. * Send ajax request
  1436. *
  1437. * @param {Object} config
  1438. * @return Object jquery ajax object
  1439. *
  1440. * config fields:
  1441. * name - url-key in the urls-object *required*
  1442. * sender - object that send request (need for proper callback initialization) *required*
  1443. * data - object with data for url-format
  1444. * beforeSend - method-name for ajax beforeSend response callback
  1445. * success - method-name for ajax success response callback
  1446. * error - method-name for ajax error response callback
  1447. * callback - callback from <code>App.updater.run</code> library
  1448. */
  1449. send: function (config) {
  1450. console.warn('============== ajax ==============', config.name, config.data);
  1451. if (!config.sender) {
  1452. console.warn('Ajax sender should be defined!');
  1453. return null;
  1454. }
  1455. // default parameters
  1456. var params = {
  1457. clusterName: App.get('clusterName')
  1458. };
  1459. // extend default parameters with provided
  1460. if (config.data) {
  1461. jQuery.extend(params, config.data);
  1462. }
  1463. var opt = {};
  1464. if (!urls[config.name]) {
  1465. console.warn('Invalid name provided!');
  1466. return null;
  1467. }
  1468. opt = formatRequest.call(urls[config.name], params);
  1469. opt.context = this;
  1470. // object sender should be provided for processing beforeSend, success and error responses
  1471. opt.beforeSend = function (xhr) {
  1472. if (config.beforeSend) {
  1473. config.sender[config.beforeSend](opt, xhr, params);
  1474. }
  1475. };
  1476. opt.success = function (data, textStatus, xhr) {
  1477. console.log("TRACE: The url is: " + opt.url);
  1478. if (config.success) {
  1479. config.sender[config.success](data, opt, params);
  1480. }
  1481. };
  1482. opt.error = function (request, ajaxOptions, error) {
  1483. if (config.error) {
  1484. config.sender[config.error](request, ajaxOptions, error, opt);
  1485. } else {
  1486. this.defaultErrorHandler(request, opt.url, opt.type);
  1487. }
  1488. };
  1489. opt.complete = function () {
  1490. if (config.callback) {
  1491. config.callback();
  1492. }
  1493. };
  1494. if ($.mocho) {
  1495. opt.url = 'http://' + $.hostName + opt.url;
  1496. }
  1497. return $.ajax(opt);
  1498. },
  1499. // A single instance of App.ModalPopup view
  1500. modalPopup: null,
  1501. /**
  1502. * defaultErrorHandler function is referred from App.ajax.send function and App.HttpClient.defaultErrorHandler function
  1503. * @jqXHR {jqXHR Object}
  1504. * @url {string}
  1505. * @method {String} Http method
  1506. * @showStatus {number} HTTP response code which should be shown. Default is 500.
  1507. */
  1508. defaultErrorHandler: function (jqXHR, url, method, showStatus) {
  1509. method = method || 'GET';
  1510. var self = this;
  1511. var api = " received on " + method + " method for API: " + url;
  1512. var showMessage = true;
  1513. try {
  1514. var json = $.parseJSON(jqXHR.responseText);
  1515. var message = json.message;
  1516. } catch (err) {
  1517. }
  1518. if (showStatus === null) {
  1519. showStatus = 500;
  1520. }
  1521. if (message === undefined) {
  1522. showMessage = false;
  1523. }
  1524. var statusCode = jqXHR.status + " status code";
  1525. if (jqXHR.status === showStatus && !this.modalPopup) {
  1526. this.modalPopup = App.ModalPopup.show({
  1527. header: jqXHR.statusText,
  1528. secondary: false,
  1529. onPrimary: function () {
  1530. this.hide();
  1531. self.modalPopup = null;
  1532. },
  1533. bodyClass: Ember.View.extend({
  1534. classNames: ['api-error'],
  1535. templateName: require('templates/utils/ajax'),
  1536. api: api,
  1537. statusCode: statusCode,
  1538. message: message,
  1539. showMessage: showMessage
  1540. })
  1541. });
  1542. }
  1543. }
  1544. });
  1545. /**
  1546. * Add few access-methods for test purposes
  1547. */
  1548. if ($.mocho) {
  1549. ajax.reopen({
  1550. /**
  1551. * Don't use it anywhere except tests!
  1552. * @deprecated
  1553. * @returns {Array}
  1554. */
  1555. fakeGetUrlNames: function() {
  1556. var names = [];
  1557. for (var name in urls) {
  1558. names.push(name);
  1559. }
  1560. return names;
  1561. },
  1562. /**
  1563. * Don't use it anywhere except tests!
  1564. * @deprecated
  1565. * @param name
  1566. * @returns {*}
  1567. */
  1568. fakeGetUrl: function(name) {
  1569. return urls[name];
  1570. },
  1571. /**
  1572. * Don't use it anywhere except tests!
  1573. * @deprecated
  1574. * @param url
  1575. * @param data
  1576. * @returns {String}
  1577. */
  1578. fakeFormatUrl: function(url, data) {
  1579. return formatUrl(url, data);
  1580. },
  1581. /**
  1582. * Don't use it anywhere except tests!
  1583. * @deprecated
  1584. * @param urlObj
  1585. * @param data
  1586. * @returns {Object}
  1587. */
  1588. fakeFormatRequest: function(urlObj, data) {
  1589. return formatRequest.call(urlObj, data);
  1590. }
  1591. });
  1592. }
  1593. App.ajax = ajax.create({});