ajax.js 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606
  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/background_operations/list_on_start.json'
  35. },
  36. 'alerts.get_by_host': {
  37. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=alerts',
  38. 'mock': '/data/background_operations/list_on_start.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': '',
  657. 'type': 'GET',
  658. 'format': function (data, opt) {
  659. return {
  660. };
  661. }
  662. },
  663. 'settings.post.user_pref': {
  664. 'real': '/persist',
  665. 'mock': '',
  666. 'type': 'POST',
  667. 'format': function (data) {
  668. return {
  669. data: JSON.stringify(data.keyValuePair)
  670. }
  671. }
  672. },
  673. 'cluster.load_cluster_name': {
  674. 'real': '/clusters',
  675. 'mock': '/data/clusters/info.json',
  676. 'format': function (data, opt) {
  677. return {
  678. async: false
  679. };
  680. }
  681. },
  682. 'cluster.state': {
  683. 'type': 'POST',
  684. 'real': '/persist/',
  685. 'mock': '',
  686. 'format': function (data, opt) {
  687. return {
  688. async: false,
  689. data: JSON.stringify(data.keyValuePair)
  690. };
  691. }
  692. },
  693. 'cluster.update_upgrade_version': {
  694. 'real': '/stacks2/HDP/versions?fields=stackServices/StackServices,Versions',
  695. 'mock': '/data/wizard/stack/stacks.json',
  696. 'format': function (data, opt) {
  697. return {
  698. async: false
  699. };
  700. }
  701. },
  702. 'cluster.load_repositories': {
  703. 'real': '/stacks2/{stackName}/versions/{stackVersion}/operatingSystems?fields=repositories/*',
  704. 'mock': '',
  705. 'type': 'GET',
  706. 'format': function (data, opt) {
  707. return {
  708. data: data.data
  709. };
  710. }
  711. },
  712. 'admin.high_availability.stop_all_services': {
  713. 'real': '/clusters/{clusterName}/services',
  714. 'mock': '',
  715. 'format': function (data, opt) {
  716. return {
  717. type: 'PUT',
  718. data: JSON.stringify({
  719. "RequestInfo": {
  720. "context": "Stop all services"
  721. },
  722. "Body": {
  723. "ServiceInfo": {
  724. "state": "INSTALLED"
  725. }
  726. }
  727. })
  728. }
  729. }
  730. },
  731. 'admin.high_availability.start_all_services': {
  732. 'real': '/clusters/{clusterName}/services',
  733. 'mock': '',
  734. 'format': function (data, opt) {
  735. return {
  736. type: 'PUT',
  737. data: JSON.stringify({
  738. "RequestInfo": {
  739. "context": "Start all services"
  740. },
  741. "Body": {
  742. "ServiceInfo": {
  743. "state": "STARTED"
  744. }
  745. }
  746. })
  747. }
  748. }
  749. },
  750. 'admin.high_availability.polling': {
  751. 'real': '/clusters/{clusterName}/requests/{requestId}?fields=tasks/*',
  752. 'mock': '',
  753. 'type': 'GET'
  754. },
  755. 'admin.high_availability.getNnCheckPointStatus': {
  756. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/NAMENODE',
  757. 'mock': '',
  758. 'type': 'GET'
  759. },
  760. 'admin.high_availability.getJnCheckPointStatus': {
  761. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/JOURNALNODE?fields=metrics',
  762. 'mock': ''
  763. },
  764. 'admin.high_availability.getHostComponent': {
  765. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  766. 'mock': ''
  767. },
  768. 'admin.high_availability.create_component': {
  769. 'real': '/clusters/{clusterName}/hosts?Hosts/host_name={hostName}',
  770. 'mock': '',
  771. 'type': 'POST',
  772. 'format': function (data) {
  773. return {
  774. data: JSON.stringify({
  775. "host_components": [
  776. {
  777. "HostRoles": {
  778. "component_name": data.componentName
  779. }
  780. }
  781. ]
  782. })
  783. }
  784. }
  785. },
  786. 'admin.high_availability.create_journalnode': {
  787. 'real': '/clusters/{clusterName}/services?ServiceInfo/service_name=HDFS',
  788. 'mock': '',
  789. 'type': 'POST',
  790. 'format': function (data) {
  791. return {
  792. data: JSON.stringify({
  793. "components": [
  794. {
  795. "ServiceComponentInfo": {
  796. "component_name": "JOURNALNODE"
  797. }
  798. }
  799. ]
  800. })
  801. }
  802. }
  803. },
  804. 'admin.high_availability.create_zkfc': {
  805. 'real': '/clusters/{clusterName}/services?ServiceInfo/service_name=HDFS',
  806. 'mock': '',
  807. 'type': 'POST',
  808. 'format': function (data) {
  809. return {
  810. data: JSON.stringify({
  811. "components": [
  812. {
  813. "ServiceComponentInfo": {
  814. "component_name": "ZKFC"
  815. }
  816. }
  817. ]
  818. })
  819. }
  820. }
  821. },
  822. 'admin.high_availability.install_component': {
  823. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  824. 'mock': '',
  825. 'type': 'PUT',
  826. 'format': function (data) {
  827. return {
  828. data: JSON.stringify({
  829. RequestInfo: {
  830. "context": "Install " + data.displayName
  831. },
  832. Body: {
  833. "HostRoles": {
  834. "state": "INSTALLED"
  835. }
  836. }
  837. })
  838. }
  839. }
  840. },
  841. 'admin.high_availability.start_component': {
  842. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  843. 'mock': '',
  844. 'type': 'PUT',
  845. 'format': function (data) {
  846. return {
  847. data: JSON.stringify({
  848. RequestInfo: {
  849. "context": "Start " + data.displayName
  850. },
  851. Body: {
  852. "HostRoles": {
  853. "state": "STARTED"
  854. }
  855. }
  856. })
  857. }
  858. }
  859. },
  860. 'admin.high_availability.maintenance_mode': {
  861. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  862. 'mock': '',
  863. 'type': 'PUT',
  864. 'format': function () {
  865. return {
  866. data: JSON.stringify({
  867. "HostRoles": {
  868. "state": "MAINTENANCE"
  869. }
  870. })
  871. }
  872. }
  873. },
  874. 'admin.high_availability.stop_component': {
  875. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  876. 'mock': '',
  877. 'type': 'PUT',
  878. 'format': function (data) {
  879. return {
  880. data: JSON.stringify({
  881. RequestInfo: {
  882. "context": "Stop " + data.displayName
  883. },
  884. Body: {
  885. "HostRoles": {
  886. "state": "INSTALLED"
  887. }
  888. }
  889. })
  890. }
  891. }
  892. },
  893. 'admin.high_availability.load_configs': {
  894. 'real': '/clusters/{clusterName}/configurations?(type=core-site&tag={coreSiteTag})|(type=hdfs-site&tag={hdfsSiteTag})',
  895. 'mock': '',
  896. 'type': 'GET'
  897. },
  898. 'admin.high_availability.save_configs': {
  899. 'real': '/clusters/{clusterName}',
  900. 'mock': '',
  901. 'type': 'PUT',
  902. 'format': function (data) {
  903. return {
  904. async: false,
  905. data: JSON.stringify({
  906. Clusters: {
  907. desired_config: {
  908. "type": data.siteName,
  909. "tag": 'version' + (new Date).getTime(),
  910. "properties": data.properties
  911. }
  912. }
  913. })
  914. }
  915. }
  916. },
  917. 'admin.high_availability.load_hbase_configs': {
  918. 'real': '/clusters/{clusterName}/configurations?type=hbase-site&tag={hbaseSiteTag}',
  919. 'mock': '',
  920. 'type': 'GET'
  921. },
  922. 'admin.high_availability.delete_component': {
  923. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  924. 'mock': '',
  925. 'type': 'DELETE'
  926. },
  927. 'admin.security.cluster_configs': {
  928. 'real': '/clusters/{clusterName}',
  929. 'mock': '',
  930. 'format': function (data, opt) {
  931. return {
  932. timeout: 10000
  933. };
  934. }
  935. },
  936. 'admin.delete_host': {
  937. 'real': '/clusters/{clusterName}/hosts/{hostName}',
  938. 'mock': '',
  939. 'type': 'DELETE'
  940. },
  941. 'admin.get.all_configurations': {
  942. 'real': '/clusters/{clusterName}/configurations?{urlParams}',
  943. 'mock': '',
  944. 'format': function (data, opt) {
  945. return {
  946. timeout: 10000
  947. };
  948. }
  949. },
  950. 'admin.security.apply_configurations': {
  951. 'real': '/clusters/{clusterName}',
  952. 'mock': '',
  953. 'format': function (data, opt) {
  954. return {
  955. type: 'PUT',
  956. timeout: 10000,
  957. data: data.configData
  958. };
  959. }
  960. },
  961. 'admin.security.apply_configuration': {
  962. 'real': '/clusters/{clusterName}',
  963. 'mock': '',
  964. 'format': function (data, opt) {
  965. return {
  966. type: 'PUT',
  967. async: false,
  968. timeout: 5000,
  969. data: JSON.stringify(data.clusterData)
  970. };
  971. }
  972. },
  973. 'admin.security.add.cluster_configs': {
  974. 'real': '/clusters/{clusterName}' + '?fields=Clusters/desired_configs',
  975. 'mock': '',
  976. 'format': function (data, opt) {
  977. return {
  978. timeout: 10000
  979. };
  980. }
  981. },
  982. 'admin.stack_upgrade.run_upgrade': {
  983. 'real': '/clusters/{clusterName}',
  984. 'mock': '',
  985. 'format': function (data, opt) {
  986. return {
  987. type: 'PUT',
  988. async: false,
  989. data: data.data
  990. };
  991. }
  992. },
  993. 'admin.stack_upgrade.stop_services': {
  994. 'real': '/clusters/{clusterName}/services?ServiceInfo/state=STARTED',
  995. 'mock': '',
  996. 'format': function (data, opt) {
  997. return {
  998. type: 'PUT',
  999. async: false,
  1000. data: data.data
  1001. };
  1002. }
  1003. },
  1004. 'admin.stack_upgrade.do_poll': {
  1005. 'real': '/clusters/{cluster}/requests/{requestId}?fields=tasks/*',
  1006. 'mock': '/data/wizard/{mock}'
  1007. },
  1008. 'wizard.advanced_repositories.valid_url': {
  1009. 'real': '/stacks2/{stackName}/versions/{stackVersion}/operatingSystems/{osType}/repositories/{nameVersionCombo}',
  1010. 'mock': '',
  1011. 'type': 'PUT',
  1012. 'format': function (data) {
  1013. return {
  1014. async: true,
  1015. data: JSON.stringify(data.data)
  1016. }
  1017. }
  1018. },
  1019. 'wizard.install_services.add_host_controller.is_retry': {
  1020. 'real': '/clusters/{cluster}/host_components',
  1021. 'mock': '',
  1022. 'format': function (data, opt) {
  1023. return {
  1024. type: 'PUT',
  1025. async: false,
  1026. data: data.data
  1027. };
  1028. }
  1029. },
  1030. 'wizard.install_services.add_host_controller.not_is_retry': {
  1031. 'real': '/clusters/{cluster}/host_components',
  1032. 'mock': '',
  1033. 'format': function (data, opt) {
  1034. return {
  1035. type: 'PUT',
  1036. async: false,
  1037. data: data.data
  1038. };
  1039. }
  1040. },
  1041. 'wizard.install_services.installer_controller.is_retry': {
  1042. 'real': '/clusters/{cluster}/host_components?HostRoles/state=INSTALLED',
  1043. 'mock': '/data/wizard/deploy/2_hosts/poll_1.json',
  1044. 'type': 'PUT',
  1045. 'format': function (data, opt) {
  1046. return {
  1047. async: false,
  1048. data: data.data
  1049. };
  1050. }
  1051. },
  1052. 'wizard.install_services.installer_controller.not_is_retry': {
  1053. 'real': '/clusters/{cluster}/services?ServiceInfo/state=INIT',
  1054. 'mock': '/data/wizard/deploy/2_hosts/poll_1.json',
  1055. 'type': 'PUT',
  1056. 'format': function (data, opt) {
  1057. return {
  1058. async: false,
  1059. data: data.data
  1060. };
  1061. }
  1062. },
  1063. 'wizard.install_services.add_service_controller.get_failed_host_components': {
  1064. 'real': '/clusters/{clusterName}/host_components?fields=HostRoles/state,component/ServiceComponentInfo/service_name',
  1065. 'mock': '',
  1066. 'format': function (data, opt) {
  1067. return {
  1068. async: false
  1069. };
  1070. }
  1071. },
  1072. 'wizard.service_components': {
  1073. 'real': '{stackUrl}/stackServices?fields=StackServices',
  1074. 'mock': '/data/wizard/stack/hdp/version/{stackVersion}.json',
  1075. 'format': function (data, opt) {
  1076. return {
  1077. timeout: 10000,
  1078. async: false
  1079. };
  1080. }
  1081. },
  1082. 'wizard.step9.installer.launch_start_services': {
  1083. 'real': '/clusters/{cluster}/services?ServiceInfo/state=INSTALLED&params/run_smoke_test=true&params/reconfigure_client=false',
  1084. 'mock': '/data/wizard/deploy/5_hosts/poll_6.json',
  1085. 'format': function (data, opt) {
  1086. var data = {
  1087. type: 'PUT',
  1088. async: false,
  1089. data: data.data
  1090. };
  1091. if (App.testMode) {
  1092. data.type = 'GET';
  1093. }
  1094. return data;
  1095. }
  1096. },
  1097. 'wizard.step9.add_host.launch_start_services': {
  1098. 'real': '/clusters/{cluster}/host_components',
  1099. 'mock': '/data/wizard/deploy/5_hosts/poll_6.json',
  1100. 'format': function (data, opt) {
  1101. return {
  1102. type: 'PUT',
  1103. async: false,
  1104. data: data.data
  1105. };
  1106. }
  1107. },
  1108. 'wizard.step8.delete_cluster': {
  1109. 'real': '/clusters/{name}',
  1110. 'mock': '',
  1111. 'format': function (data, opt) {
  1112. return {
  1113. type: 'DELETE',
  1114. async: false
  1115. };
  1116. }
  1117. },
  1118. 'wizard.step8.existing_cluster_names': {
  1119. 'real': '/clusters',
  1120. 'mock': '',
  1121. 'format': function (data, opt) {
  1122. return {
  1123. async: false
  1124. };
  1125. }
  1126. },
  1127. 'wizard.step3.host_info': {
  1128. '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',
  1129. 'mock': '/data/wizard/bootstrap/two_hosts_information.json',
  1130. 'format': function (data, opt) {
  1131. return {
  1132. contentType: 'application/json'
  1133. };
  1134. }
  1135. },
  1136. 'wizard.step3.rerun_checks': {
  1137. 'real': '/hosts?fields=Hosts/last_agent_env',
  1138. 'mock': '/data/wizard/bootstrap/two_hosts_information.json',
  1139. 'format': function (data, opt) {
  1140. return {
  1141. contentType: 'application/json'
  1142. };
  1143. }
  1144. },
  1145. 'wizard.step3.bootstrap': {
  1146. 'real': '/bootstrap/{bootRequestId}',
  1147. 'mock': '/data/wizard/bootstrap/poll_{numPolls}.json'
  1148. },
  1149. 'wizard.step3.is_hosts_registered': {
  1150. 'real': '/hosts',
  1151. 'mock': '/data/wizard/bootstrap/single_host_registration.json'
  1152. },
  1153. 'wizard.stacks': {
  1154. 'real': '/stacks2',
  1155. 'mock': '/data/wizard/stack/stacks2.json',
  1156. 'format': function (data) {
  1157. return {
  1158. async: false
  1159. };
  1160. }
  1161. },
  1162. 'wizard.stacks_versions': {
  1163. 'real': '/stacks2/{stackName}/versions?fields=Versions,operatingSystems/repositories/Repositories',
  1164. 'mock': '/data/wizard/stack/{stackName}_versions.json',
  1165. 'format': function (data) {
  1166. return {
  1167. async: false
  1168. };
  1169. }
  1170. },
  1171. 'wizard.launch_bootstrap': {
  1172. 'real': '/bootstrap',
  1173. 'mock': '/data/wizard/bootstrap/bootstrap.json',
  1174. 'type': 'POST',
  1175. 'format': function (data) {
  1176. return {
  1177. async: false,
  1178. contentType: 'application/json',
  1179. data: data.bootStrapData
  1180. }
  1181. }
  1182. },
  1183. 'router.login': {
  1184. 'real': '/users/{loginName}',
  1185. 'mock': '/data/users/user_{usr}.json',
  1186. 'format': function (data, opt) {
  1187. var statusCode = jQuery.extend({}, require('data/statusCodes'));
  1188. statusCode['403'] = function () {
  1189. console.log("Error code 403: Forbidden.");
  1190. }
  1191. return {
  1192. statusCode: statusCode
  1193. };
  1194. }
  1195. },
  1196. 'router.login2': {
  1197. 'real': '/clusters',
  1198. 'mock': '/data/clusters/info.json'
  1199. },
  1200. 'router.logoff': {
  1201. 'real': '/logout',
  1202. 'mock': ''
  1203. },
  1204. 'router.set_ambari_stacks': {
  1205. 'real': '/stacks',
  1206. 'mock': '/data/wizard/stack/stacks.json',
  1207. 'format': function (data, opt) {
  1208. return {
  1209. async: false
  1210. };
  1211. }
  1212. },
  1213. 'router.authentication': {
  1214. 'real': '/clusters',
  1215. 'mock': '/data/clusters/info.json',
  1216. 'format': function (data, opt) {
  1217. return {
  1218. async: false
  1219. };
  1220. }
  1221. },
  1222. 'ambari.service': {
  1223. 'real': '/services/AMBARI/components/AMBARI_SERVER',
  1224. 'mock': ''
  1225. },
  1226. 'dashboard.get.user_pref': {
  1227. 'real': '/persist/{key}',
  1228. 'mock': '',
  1229. 'format': function (data, opt) {
  1230. return {
  1231. async: false
  1232. };
  1233. }
  1234. },
  1235. 'dashboard.post.user_pref': {
  1236. 'real': '/persist',
  1237. 'mock': '',
  1238. 'type': 'POST',
  1239. 'format': function (data) {
  1240. return {
  1241. async: false,
  1242. data: JSON.stringify(data.keyValuePair)
  1243. }
  1244. }
  1245. },
  1246. 'config_groups.create': {
  1247. 'real': '/clusters/{clusterName}/config_groups',
  1248. 'mock': '',
  1249. 'format': function (data) {
  1250. return {
  1251. async: false,
  1252. type: 'POST',
  1253. data: JSON.stringify([{
  1254. "ConfigGroup": {
  1255. "group_name": data.group_name,
  1256. "tag": data.service_id,
  1257. "description": data.description,
  1258. "desired_configs": data.desired_configs,
  1259. "hosts": data.hosts
  1260. }
  1261. }])
  1262. }
  1263. }
  1264. },
  1265. 'config_groups.update': {
  1266. 'real': '/clusters/{clusterName}/config_groups/{id}',
  1267. 'mock': '',
  1268. 'format': function (data) {
  1269. return {
  1270. async: true,
  1271. type: 'PUT',
  1272. data: JSON.stringify(data.data)
  1273. }
  1274. }
  1275. },
  1276. 'rolling_restart.post': {
  1277. 'real': '/clusters/{clusterName}/request_schedules',
  1278. 'mock': '',
  1279. 'format' : function(data) {
  1280. var hostIndex = 0;
  1281. var batchSize = data.batchSize;
  1282. var hostComponents = data.restartHostComponents;
  1283. var length = hostComponents.length;
  1284. var batches = [];
  1285. var batchCount = Math.ceil(length / batchSize);
  1286. var sampleHostComponent = hostComponents.objectAt(0);
  1287. var componentName = sampleHostComponent.get('componentName');
  1288. var componentDisplayName = App.format.role(componentName);
  1289. var serviceName = sampleHostComponent.get('service.serviceName');
  1290. for ( var count = 0; count < batchCount; count++) {
  1291. var hostNames = [];
  1292. for ( var hc = 0; hc < batchSize && hostIndex < length; hc++) {
  1293. hostNames.push(hostComponents.objectAt(hostIndex++).get('host.hostName'));
  1294. }
  1295. if (hostNames.length > 0) {
  1296. batches.push({
  1297. "order_id" : count + 1,
  1298. "type" : "POST",
  1299. "uri" : App.apiPrefix + "/clusters/" + data.clusterName + "/requests",
  1300. "RequestBodyInfo" : {
  1301. "RequestInfo" : {
  1302. "context" : Em.I18n.t('rollingrestart.rest.context').format(componentDisplayName, (count + 1), batchCount),
  1303. "command" : "RESTART",
  1304. "service_name" : serviceName,
  1305. "component_name" : componentName,
  1306. "hosts" : hostNames.join(",")
  1307. }
  1308. }
  1309. });
  1310. }
  1311. }
  1312. return {
  1313. type : 'POST',
  1314. data : JSON.stringify([ {
  1315. "RequestSchedule" : {
  1316. "batch" : [ {
  1317. "requests" : batches
  1318. }, {
  1319. "batch_settings" : {
  1320. "batch_separation_in_seconds" : data.intervalTimeSeconds,
  1321. "task_failure_tolerance" : data.tolerateSize
  1322. }
  1323. } ]
  1324. }
  1325. } ])
  1326. }
  1327. }
  1328. },
  1329. 'restart.service.hostComponents' : {
  1330. 'real' : '/clusters/{clusterName}/requests',
  1331. 'mock' : '',
  1332. 'format' : function(data) {
  1333. var componentDisplayName = App.format.role(data.componentName);
  1334. var serviceDisplayName = App.Service.DisplayNames[data.serviceName];
  1335. return {
  1336. type : 'POST',
  1337. data : JSON.stringify({
  1338. "RequestInfo" : {
  1339. "context" : Em.I18n.t('restart.service.rest.context').format(serviceDisplayName, componentDisplayName),
  1340. "command" : "RESTART",
  1341. "service_name" : data.serviceName,
  1342. "component_name" : data.componentName,
  1343. "hosts" : data.hosts
  1344. }
  1345. })
  1346. }
  1347. }
  1348. },
  1349. 'mirroring.get_all_datasets': {
  1350. 'real': 'falcon/entities/list/feed',
  1351. 'mock': '/data/mirroring/datasets.json'
  1352. },
  1353. 'mirroring.get_dataset_definition': {
  1354. 'real': 'falcon/entities/definition/feed/{dataset}',
  1355. 'mock': '/data/mirroring/{dataset}_definition.xml',
  1356. 'format': function (data) {
  1357. return {
  1358. dataType: 'xml'
  1359. }
  1360. }
  1361. },
  1362. 'mirroring.dataset.get_all_instances': {
  1363. 'real': 'falcon/instance/status/feed/{dataset}',
  1364. 'mock': '/data/mirroring/{dataset}_instances.json'
  1365. }
  1366. };
  1367. /**
  1368. * Replace data-placeholders to its values
  1369. *
  1370. * @param {String} url
  1371. * @param {Object} data
  1372. * @return {String}
  1373. */
  1374. var formatUrl = function (url, data) {
  1375. if (!url) return null;
  1376. var keys = url.match(/\{\w+\}/g);
  1377. keys = (keys === null) ? [] : keys;
  1378. if (keys) {
  1379. keys.forEach(function (key) {
  1380. var raw_key = key.substr(1, key.length - 2);
  1381. var replace;
  1382. if (!data || !data[raw_key]) {
  1383. replace = '';
  1384. }
  1385. else {
  1386. replace = data[raw_key];
  1387. }
  1388. url = url.replace(new RegExp(key, 'g'), replace);
  1389. });
  1390. }
  1391. return url;
  1392. };
  1393. /**
  1394. * this = object from config
  1395. * @return {Object}
  1396. */
  1397. var formatRequest = function (data) {
  1398. var opt = {
  1399. type: this.type || 'GET',
  1400. timeout: App.timeout,
  1401. dataType: 'json',
  1402. statusCode: require('data/statusCodes')
  1403. };
  1404. if (App.testMode) {
  1405. opt.url = formatUrl(this.mock ? this.mock : '', data);
  1406. opt.type = 'GET';
  1407. }
  1408. else {
  1409. opt.url = App.apiPrefix + formatUrl(this.real, data);
  1410. }
  1411. if (this.format) {
  1412. jQuery.extend(opt, this.format(data, opt));
  1413. }
  1414. return opt;
  1415. };
  1416. /**
  1417. * Wrapper for all ajax requests
  1418. *
  1419. * @type {Object}
  1420. */
  1421. var ajax = Em.Object.extend({
  1422. /**
  1423. * Send ajax request
  1424. *
  1425. * @param {Object} config
  1426. * @return Object jquery ajax object
  1427. *
  1428. * config fields:
  1429. * name - url-key in the urls-object *required*
  1430. * sender - object that send request (need for proper callback initialization) *required*
  1431. * data - object with data for url-format
  1432. * beforeSend - method-name for ajax beforeSend response callback
  1433. * success - method-name for ajax success response callback
  1434. * error - method-name for ajax error response callback
  1435. * callback - callback from <code>App.updater.run</code> library
  1436. */
  1437. send: function (config) {
  1438. console.warn('============== ajax ==============', config.name, config.data);
  1439. if (!config.sender) {
  1440. console.warn('Ajax sender should be defined!');
  1441. return null;
  1442. }
  1443. // default parameters
  1444. var params = {
  1445. clusterName: App.get('clusterName')
  1446. };
  1447. // extend default parameters with provided
  1448. if (config.data) {
  1449. jQuery.extend(params, config.data);
  1450. }
  1451. var opt = {};
  1452. if (!urls[config.name]) {
  1453. console.warn('Invalid name provided!');
  1454. return null;
  1455. }
  1456. opt = formatRequest.call(urls[config.name], params);
  1457. opt.context = this;
  1458. // object sender should be provided for processing beforeSend, success and error responses
  1459. opt.beforeSend = function (xhr) {
  1460. if (config.beforeSend) {
  1461. config.sender[config.beforeSend](opt, xhr, params);
  1462. }
  1463. };
  1464. opt.success = function (data, textStatus, xhr) {
  1465. console.log("TRACE: The url is: " + opt.url);
  1466. if (config.success) {
  1467. config.sender[config.success](data, opt, params);
  1468. }
  1469. };
  1470. opt.error = function (request, ajaxOptions, error) {
  1471. if (config.error) {
  1472. config.sender[config.error](request, ajaxOptions, error, opt);
  1473. } else {
  1474. this.defaultErrorHandler(request, opt.url, opt.type);
  1475. }
  1476. };
  1477. opt.complete = function () {
  1478. if (config.callback) {
  1479. config.callback();
  1480. }
  1481. };
  1482. if ($.mocho) {
  1483. opt.url = 'http://' + $.hostName + opt.url;
  1484. }
  1485. return $.ajax(opt);
  1486. },
  1487. // A single instance of App.ModalPopup view
  1488. modalPopup: null,
  1489. /**
  1490. * defaultErrorHandler function is referred from App.ajax.send function and App.HttpClient.defaultErrorHandler function
  1491. * @jqXHR {jqXHR Object}
  1492. * @url {string}
  1493. * @method {String} Http method
  1494. * @showStatus {number} HTTP response code which should be shown. Default is 500.
  1495. */
  1496. defaultErrorHandler: function (jqXHR, url, method, showStatus) {
  1497. method = method || 'GET';
  1498. var self = this;
  1499. var api = " received on " + method + " method for API: " + url;
  1500. var showMessage = true;
  1501. try {
  1502. var json = $.parseJSON(jqXHR.responseText);
  1503. var message = json.message;
  1504. } catch (err) {
  1505. }
  1506. if (showStatus === null) {
  1507. showStatus = 500;
  1508. }
  1509. if (message === undefined) {
  1510. showMessage = false;
  1511. }
  1512. var statusCode = jqXHR.status + " status code";
  1513. if (jqXHR.status === showStatus && !this.modalPopup) {
  1514. this.modalPopup = App.ModalPopup.show({
  1515. header: jqXHR.statusText,
  1516. secondary: false,
  1517. onPrimary: function () {
  1518. this.hide();
  1519. self.modalPopup = null;
  1520. },
  1521. bodyClass: Ember.View.extend({
  1522. classNames: ['api-error'],
  1523. templateName: require('templates/utils/ajax'),
  1524. api: api,
  1525. statusCode: statusCode,
  1526. message: message,
  1527. showMessage: showMessage
  1528. })
  1529. });
  1530. }
  1531. }
  1532. });
  1533. /**
  1534. * Add few access-methods for test purposes
  1535. */
  1536. if ($.mocho) {
  1537. ajax.reopen({
  1538. /**
  1539. * Don't use it anywhere except tests!
  1540. * @deprecated
  1541. * @returns {Array}
  1542. */
  1543. fakeGetUrlNames: function() {
  1544. var names = [];
  1545. for (var name in urls) {
  1546. names.push(name);
  1547. }
  1548. return names;
  1549. },
  1550. /**
  1551. * Don't use it anywhere except tests!
  1552. * @deprecated
  1553. * @param name
  1554. * @returns {*}
  1555. */
  1556. fakeGetUrl: function(name) {
  1557. return urls[name];
  1558. },
  1559. /**
  1560. * Don't use it anywhere except tests!
  1561. * @deprecated
  1562. * @param url
  1563. * @param data
  1564. * @returns {String}
  1565. */
  1566. fakeFormatUrl: function(url, data) {
  1567. return formatUrl(url, data);
  1568. },
  1569. /**
  1570. * Don't use it anywhere except tests!
  1571. * @deprecated
  1572. * @param urlObj
  1573. * @param data
  1574. * @returns {Object}
  1575. */
  1576. fakeFormatRequest: function(urlObj, data) {
  1577. return formatRequest.call(urlObj, data);
  1578. }
  1579. });
  1580. }
  1581. App.ajax = ajax.create({});