ajax.js 44 KB

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