ajax.js 47 KB

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