ajax.js 46 KB

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