ajax.js 44 KB

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