ajax.js 45 KB

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