ajax.js 49 KB

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