ajax.js 49 KB

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