ajax.js 45 KB

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