ajax.js 44 KB

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