ajax.js 47 KB

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