ajax.js 51 KB

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