ajax.js 46 KB

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