ajax.js 48 KB

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