ajax.js 45 KB

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