ajax.js 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205
  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}',
  159. 'mock': '/data/clusters/cluster.json'
  160. },
  161. 'config.tags.sync': {
  162. 'real': '/clusters/{clusterName}',
  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}',
  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.getNnCheckPointStatus.sync': {
  573. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/NAMENODE',
  574. 'mock': '',
  575. 'format': function (data, opt) {
  576. return {
  577. async: false
  578. };
  579. }
  580. },
  581. 'admin.high_availability.getJnCheckPointStatus': {
  582. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/JOURNALNODE?fields=metrics',
  583. 'mock': ''
  584. },
  585. 'admin.high_availability.getHostComponent': {
  586. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  587. 'mock': ''
  588. },
  589. 'admin.high_availability.create_component': {
  590. 'real': '/clusters/{clusterName}/hosts?Hosts/host_name={hostName}',
  591. 'mock': '',
  592. 'type': 'POST',
  593. 'format': function (data) {
  594. return {
  595. data: JSON.stringify({
  596. "host_components": [
  597. {
  598. "HostRoles": {
  599. "component_name": data.componentName
  600. }
  601. }
  602. ]
  603. })
  604. }
  605. }
  606. },
  607. 'admin.high_availability.create_journalnode': {
  608. 'real': '/clusters/{clusterName}/services?ServiceInfo/service_name=HDFS',
  609. 'mock': '',
  610. 'type': 'POST',
  611. 'format': function (data) {
  612. return {
  613. data: JSON.stringify({
  614. "components": [
  615. {
  616. "ServiceComponentInfo": {
  617. "component_name": "JOURNALNODE"
  618. }
  619. }
  620. ]
  621. })
  622. }
  623. }
  624. },
  625. 'admin.high_availability.create_zkfc': {
  626. 'real': '/clusters/{clusterName}/services?ServiceInfo/service_name=HDFS',
  627. 'mock': '',
  628. 'type': 'POST',
  629. 'format': function (data) {
  630. return {
  631. data: JSON.stringify({
  632. "components": [
  633. {
  634. "ServiceComponentInfo": {
  635. "component_name": "ZKFC"
  636. }
  637. }
  638. ]
  639. })
  640. }
  641. }
  642. },
  643. 'admin.high_availability.install_component': {
  644. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  645. 'mock': '',
  646. 'type': 'PUT',
  647. 'format': function (data) {
  648. return {
  649. data: JSON.stringify({
  650. RequestInfo: {
  651. "context": "Install " + data.displayName
  652. },
  653. Body: {
  654. "HostRoles": {
  655. "state": "INSTALLED"
  656. }
  657. }
  658. })
  659. }
  660. }
  661. },
  662. 'admin.high_availability.start_component': {
  663. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  664. 'mock': '',
  665. 'type': 'PUT',
  666. 'format': function (data) {
  667. return {
  668. data: JSON.stringify({
  669. RequestInfo: {
  670. "context": "Start " + data.displayName
  671. },
  672. Body: {
  673. "HostRoles": {
  674. "state": "STARTED"
  675. }
  676. }
  677. })
  678. }
  679. }
  680. },
  681. 'admin.high_availability.maintenance_mode': {
  682. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  683. 'mock': '',
  684. 'type': 'PUT',
  685. 'format': function () {
  686. return {
  687. data: JSON.stringify({
  688. "HostRoles": {
  689. "state": "MAINTENANCE"
  690. }
  691. })
  692. }
  693. }
  694. },
  695. 'admin.high_availability.stop_component': {
  696. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  697. 'mock': '',
  698. 'type': 'PUT',
  699. 'format': function (data) {
  700. return {
  701. data: JSON.stringify({
  702. RequestInfo: {
  703. "context": "Stop " + data.displayName
  704. },
  705. Body: {
  706. "HostRoles": {
  707. "state": "INSTALLED"
  708. }
  709. }
  710. })
  711. }
  712. }
  713. },
  714. 'admin.high_availability.load_configs': {
  715. 'real': '/clusters/{clusterName}/configurations?(type=core-site&tag={coreSiteTag})|(type=hdfs-site&tag={hdfsSiteTag})',
  716. 'mock': '',
  717. 'type': 'GET'
  718. },
  719. 'admin.high_availability.save_configs': {
  720. 'real': '/clusters/{clusterName}',
  721. 'mock': '',
  722. 'type': 'PUT',
  723. 'format': function (data) {
  724. return {
  725. async: false,
  726. data: JSON.stringify({
  727. Clusters: {
  728. desired_config: {
  729. "type": data.siteName,
  730. "tag": 'version' + (new Date).getTime(),
  731. "properties": data.properties
  732. }
  733. }
  734. })
  735. }
  736. }
  737. },
  738. 'admin.high_availability.load_hbase_configs': {
  739. 'real': '/clusters/{clusterName}/configurations?type=hbase-site&tag={hbaseSiteTag}',
  740. 'mock': '',
  741. 'type': 'GET'
  742. },
  743. 'admin.high_availability.delete_component': {
  744. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  745. 'mock': '',
  746. 'type': 'DELETE'
  747. },
  748. 'admin.security.cluster_configs': {
  749. 'real': '/clusters/{clusterName}',
  750. 'mock': '',
  751. 'format': function (data, opt) {
  752. return {
  753. timeout: 10000
  754. };
  755. }
  756. },
  757. 'admin.delete_host': {
  758. 'real': '/clusters/{clusterName}/hosts/{hostName}',
  759. 'mock': '',
  760. 'type': 'DELETE'
  761. },
  762. 'admin.security.all_configurations': {
  763. 'real': '/clusters/{clusterName}/configurations?{urlParams}',
  764. 'mock': '',
  765. 'format': function (data, opt) {
  766. return {
  767. async: false,
  768. timeout: 10000
  769. };
  770. }
  771. },
  772. 'admin.security.apply_configurations': {
  773. 'real': '/clusters/{clusterName}',
  774. 'mock': '',
  775. 'format': function (data, opt) {
  776. return {
  777. type: 'PUT',
  778. timeout: 10000,
  779. data: data.configData
  780. };
  781. }
  782. },
  783. 'admin.security.apply_configuration': {
  784. 'real': '/clusters/{clusterName}',
  785. 'mock': '',
  786. 'format': function (data, opt) {
  787. return {
  788. type: 'PUT',
  789. async: false,
  790. timeout: 5000,
  791. data: JSON.stringify(data.clusterData)
  792. };
  793. }
  794. },
  795. 'admin.security.add.cluster_configs': {
  796. 'real': '/clusters/{clusterName}' + '?fields=Clusters/desired_configs',
  797. 'mock': '',
  798. 'format': function (data, opt) {
  799. return {
  800. timeout: 10000
  801. };
  802. }
  803. },
  804. 'admin.stack_upgrade.run_upgrade': {
  805. 'real': '/clusters/{clusterName}',
  806. 'mock': '',
  807. 'format': function (data, opt) {
  808. return {
  809. type: 'PUT',
  810. async: false,
  811. data: data.data
  812. };
  813. }
  814. },
  815. 'admin.stack_upgrade.stop_services': {
  816. 'real': '/clusters/{clusterName}/services?ServiceInfo/state=STARTED',
  817. 'mock': '',
  818. 'format': function (data, opt) {
  819. return {
  820. type: 'PUT',
  821. async: false,
  822. data: data.data
  823. };
  824. }
  825. },
  826. 'admin.stack_upgrade.do_poll': {
  827. 'real': '/clusters/{cluster}/requests/{requestId}?fields=tasks/*',
  828. 'mock': '/data/wizard/{mock}'
  829. },
  830. 'wizard.install_services.add_host_controller.is_retry': {
  831. 'real': '/clusters/{cluster}/host_components',
  832. 'mock': '',
  833. 'format': function (data, opt) {
  834. return {
  835. type: 'PUT',
  836. async: false,
  837. data: data.data
  838. };
  839. }
  840. },
  841. 'wizard.install_services.add_host_controller.not_is_retry': {
  842. 'real': '/clusters/{cluster}/host_components',
  843. 'mock': '',
  844. 'format': function (data, opt) {
  845. return {
  846. type: 'PUT',
  847. async: false,
  848. data: data.data
  849. };
  850. }
  851. },
  852. 'wizard.install_services.installer_controller.is_retry': {
  853. 'real': '/clusters/{cluster}/host_components?HostRoles/state=INSTALLED',
  854. 'mock': '/data/wizard/deploy/2_hosts/poll_1.json',
  855. 'type': 'PUT',
  856. 'format': function (data, opt) {
  857. return {
  858. async: false,
  859. data: data.data
  860. };
  861. }
  862. },
  863. 'wizard.install_services.installer_controller.not_is_retry': {
  864. 'real': '/clusters/{cluster}/services?ServiceInfo/state=INIT',
  865. 'mock': '/data/wizard/deploy/2_hosts/poll_1.json',
  866. 'type': 'PUT',
  867. 'format': function (data, opt) {
  868. return {
  869. async: false,
  870. data: data.data
  871. };
  872. }
  873. },
  874. 'wizard.service_components': {
  875. 'real': '{stackUrl}/stackServices?fields=StackServices',
  876. 'mock': '/data/wizard/stack/hdp/version/{stackVersion}.json',
  877. 'format': function (data, opt) {
  878. return {
  879. timeout: 10000,
  880. async: false
  881. };
  882. }
  883. },
  884. 'wizard.step9.installer.launch_start_services': {
  885. 'real': '/clusters/{cluster}/services?ServiceInfo/state=INSTALLED&params/run_smoke_test=true&params/reconfigure_client=false',
  886. 'mock': '/data/wizard/deploy/5_hosts/poll_6.json',
  887. 'format': function (data, opt) {
  888. var data = {
  889. type: 'PUT',
  890. async: false,
  891. data: data.data
  892. };
  893. if (App.testMode) {
  894. data.type = 'GET';
  895. }
  896. return data;
  897. }
  898. },
  899. 'wizard.step9.add_host.launch_start_services': {
  900. 'real': '/clusters/{cluster}/host_components',
  901. 'mock': '/data/wizard/deploy/5_hosts/poll_6.json',
  902. 'format': function (data, opt) {
  903. return {
  904. type: 'PUT',
  905. async: false,
  906. data: data.data
  907. };
  908. }
  909. },
  910. 'wizard.step8.delete_cluster': {
  911. 'real': '/clusters/{name}',
  912. 'mock': '',
  913. 'format': function (data, opt) {
  914. return {
  915. type: 'DELETE',
  916. async: false
  917. };
  918. }
  919. },
  920. 'wizard.step8.existing_cluster_names': {
  921. 'real': '/clusters',
  922. 'mock': '',
  923. 'format': function (data, opt) {
  924. return {
  925. async: false
  926. };
  927. }
  928. },
  929. 'wizard.step3.host_info': {
  930. 'real': '/hosts?fields=Hosts/total_mem,Hosts/cpu_count,Hosts/disk_info,Hosts/last_agent_env,Hosts/host_name',
  931. 'mock': '/data/wizard/bootstrap/two_hosts_information.json',
  932. 'format': function (data, opt) {
  933. return {
  934. contentType: 'application/json'
  935. };
  936. }
  937. },
  938. 'wizard.step3.rerun_checks': {
  939. 'real': '/hosts?fields=Hosts/last_agent_env',
  940. 'mock': '/data/wizard/bootstrap/two_hosts_information.json',
  941. 'format': function (data, opt) {
  942. return {
  943. contentType: 'application/json'
  944. };
  945. }
  946. },
  947. 'wizard.step3.bootstrap': {
  948. 'real': '/bootstrap/{bootRequestId}',
  949. 'mock': '/data/wizard/bootstrap/poll_{numPolls}.json'
  950. },
  951. 'wizard.step3.is_hosts_registered': {
  952. 'real': '/hosts',
  953. 'mock': '/data/wizard/bootstrap/single_host_registration.json'
  954. },
  955. 'wizard.stacks': {
  956. 'real': '/stacks2',
  957. 'mock': '/data/wizard/stack/stacks2.json',
  958. 'format': function (data) {
  959. return {
  960. async: false
  961. };
  962. }
  963. },
  964. 'wizard.stacks_versions': {
  965. 'real': '/stacks2/{stackName}/versions?fields=Versions,operatingSystems/repositories/Repositories',
  966. 'mock': '/data/wizard/stack/{stackName}_versions.json',
  967. 'format': function (data) {
  968. return {
  969. async: false
  970. };
  971. }
  972. },
  973. 'wizard.launch_bootstrap': {
  974. 'real': '/bootstrap',
  975. 'mock': '/data/wizard/bootstrap/bootstrap.json',
  976. 'type': 'POST',
  977. 'format': function (data) {
  978. return {
  979. async: false,
  980. contentType: 'application/json',
  981. data: data.bootStrapData
  982. }
  983. }
  984. },
  985. 'router.login': {
  986. 'real': '/users/{loginName}',
  987. 'mock': '/data/users/user_{usr}.json',
  988. 'format': function (data, opt) {
  989. var statusCode = jQuery.extend({}, require('data/statusCodes'));
  990. statusCode['403'] = function () {
  991. console.log("Error code 403: Forbidden.");
  992. }
  993. return {
  994. statusCode: statusCode
  995. };
  996. }
  997. },
  998. 'router.login2': {
  999. 'real': '/clusters',
  1000. 'mock': '/data/clusters/info.json'
  1001. },
  1002. 'router.logoff': {
  1003. 'real': '/logout'
  1004. },
  1005. 'router.set_ambari_stacks': {
  1006. 'real': '/stacks',
  1007. 'mock': '/data/wizard/stack/stacks.json',
  1008. 'format': function (data, opt) {
  1009. return {
  1010. async: false
  1011. };
  1012. }
  1013. },
  1014. 'router.authentication': {
  1015. 'real': '/clusters',
  1016. 'mock': '/data/clusters/info.json',
  1017. 'format': function (data, opt) {
  1018. return {
  1019. async: false
  1020. };
  1021. }
  1022. },
  1023. 'ambari.service': {
  1024. 'real': '/services/AMBARI/components/AMBARI_SERVER',
  1025. 'mock': ''
  1026. }
  1027. };
  1028. /**
  1029. * Replace data-placeholders to its values
  1030. *
  1031. * @param {String} url
  1032. * @param {Object} data
  1033. * @return {String}
  1034. */
  1035. var formatUrl = function (url, data) {
  1036. var keys = url.match(/\{\w+\}/g);
  1037. keys = (keys === null) ? [] : keys;
  1038. if (keys) {
  1039. keys.forEach(function (key) {
  1040. var raw_key = key.substr(1, key.length - 2);
  1041. var replace;
  1042. if (!data[raw_key]) {
  1043. replace = '';
  1044. }
  1045. else {
  1046. replace = data[raw_key];
  1047. }
  1048. url = url.replace(new RegExp(key, 'g'), replace);
  1049. });
  1050. }
  1051. return url;
  1052. };
  1053. /**
  1054. * this = object from config
  1055. * @return {Object}
  1056. */
  1057. var formatRequest = function (data) {
  1058. var opt = {
  1059. type: this.type || 'GET',
  1060. timeout: App.timeout,
  1061. dataType: 'json',
  1062. statusCode: require('data/statusCodes')
  1063. };
  1064. if (App.testMode) {
  1065. opt.url = formatUrl(this.mock ? this.mock : '', data);
  1066. opt.type = 'GET';
  1067. }
  1068. else {
  1069. opt.url = App.apiPrefix + formatUrl(this.real, data);
  1070. }
  1071. if (this.format) {
  1072. jQuery.extend(opt, this.format(data, opt));
  1073. }
  1074. return opt;
  1075. };
  1076. /**
  1077. * Wrapper for all ajax requests
  1078. *
  1079. * @type {Object}
  1080. */
  1081. App.ajax = {
  1082. /**
  1083. * Send ajax request
  1084. *
  1085. * @param {Object} config
  1086. * @return Object jquery ajax object
  1087. *
  1088. * config fields:
  1089. * name - url-key in the urls-object *required*
  1090. * sender - object that send request (need for proper callback initialization) *required*
  1091. * data - object with data for url-format
  1092. * beforeSend - method-name for ajax beforeSend response callback
  1093. * success - method-name for ajax success response callback
  1094. * error - method-name for ajax error response callback
  1095. * callback - callback from <code>App.updater.run</code> library
  1096. */
  1097. send: function (config) {
  1098. console.warn('============== ajax ==============', config.name, config.data);
  1099. if (!config.sender) {
  1100. console.warn('Ajax sender should be defined!');
  1101. return null;
  1102. }
  1103. // default parameters
  1104. var params = {
  1105. clusterName: App.get('clusterName')
  1106. };
  1107. // extend default parameters with provided
  1108. if (config.data) {
  1109. jQuery.extend(params, config.data);
  1110. }
  1111. var opt = {};
  1112. opt = formatRequest.call(urls[config.name], params);
  1113. opt.context = this;
  1114. // object sender should be provided for processing beforeSend, success and error responses
  1115. opt.beforeSend = function (xhr) {
  1116. if (config.beforeSend) {
  1117. config.sender[config.beforeSend](opt, xhr, params);
  1118. }
  1119. };
  1120. opt.success = function (data) {
  1121. console.log("TRACE: The url is: " + opt.url);
  1122. if (config.success) {
  1123. config.sender[config.success](data, opt, params);
  1124. }
  1125. };
  1126. opt.error = function (request, ajaxOptions, error) {
  1127. if (config.error) {
  1128. config.sender[config.error](request, ajaxOptions, error, opt);
  1129. } else {
  1130. this.defaultErrorHandler(request, opt.url, opt.type);
  1131. }
  1132. };
  1133. opt.complete = function () {
  1134. if (config.callback) {
  1135. config.callback();
  1136. }
  1137. };
  1138. if ($.mocho) {
  1139. opt.url = 'http://' + $.hostName + opt.url;
  1140. }
  1141. return $.ajax(opt);
  1142. },
  1143. // A single instance of App.ModalPopup view
  1144. modalPopup: null,
  1145. /**
  1146. * defaultErrorHandler function is referred from App.ajax.send function and App.HttpClient.defaultErrorHandler function
  1147. * @jqXHR {jqXHR Object}
  1148. * @url {string}
  1149. * @method {String} Http method
  1150. * @showStatus {number} HTTP response code which should be shown. Default is 500.
  1151. */
  1152. defaultErrorHandler: function (jqXHR, url, method, showStatus) {
  1153. method = method || 'GET';
  1154. var self = this;
  1155. var api = " received on " + method + " method for API: " + url;
  1156. var showMessage = true;
  1157. try {
  1158. var json = $.parseJSON(jqXHR.responseText);
  1159. var message = json.message;
  1160. } catch (err) {
  1161. }
  1162. if (showStatus === null) {
  1163. showStatus = 500;
  1164. }
  1165. if (message === undefined) {
  1166. showMessage = false;
  1167. }
  1168. var statusCode = jqXHR.status + " status code";
  1169. if (jqXHR.status === showStatus && !this.modalPopup) {
  1170. this.modalPopup = App.ModalPopup.show({
  1171. header: jqXHR.statusText,
  1172. secondary: false,
  1173. onPrimary: function () {
  1174. this.hide();
  1175. self.modalPopup = null;
  1176. },
  1177. bodyClass: Ember.View.extend({
  1178. classNames: ['api-error'],
  1179. template: Ember.Handlebars.compile(['<span class="text-error">{{view.statusCode}}</span><span>{{view.api}}</span>',
  1180. '{{#if view.showMessage}}',
  1181. '<br><br><pre><strong>Error message: </strong><span class="text-error">{{view.message}}</span></pre>',
  1182. '{{/if}}'].join('\n')),
  1183. api: api,
  1184. statusCode: statusCode,
  1185. message: message,
  1186. showMessage: showMessage
  1187. })
  1188. });
  1189. }
  1190. }
  1191. };