ajax.js 53 KB

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