ajax.js 64 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955
  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. May be called with one or two parameters (data, opt). 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. 'alerts.get_by_service': {
  33. 'real': '/clusters/{clusterName}/services/{serviceName}?fields=alerts',
  34. 'mock': '/data/alerts/HDP2/service_alerts.json'
  35. },
  36. 'alerts.get_by_host': {
  37. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=alerts',
  38. 'mock': '/data/alerts/HDP2/host_alerts.json'
  39. },
  40. 'background_operations.get_most_recent': {
  41. 'real': '/clusters/{clusterName}/requests?to=end&page_size=10&fields=Requests',
  42. 'mock': '/data/background_operations/list_on_start.json',
  43. 'testInProduction': true
  44. },
  45. 'background_operations.get_by_request': {
  46. 'real': '/clusters/{clusterName}/requests/{requestId}?fields=*,tasks/Tasks/command,tasks/Tasks/command_detail,tasks/Tasks/start_time,tasks/Tasks/end_time,tasks/Tasks/exit_code,tasks/Tasks/host_name,tasks/Tasks/id,tasks/Tasks/role,tasks/Tasks/status&minimal_response=true',
  47. 'mock': '/data/background_operations/task_by_request{requestId}.json',
  48. 'testInProduction': true,
  49. 'format': function (data) {
  50. return {
  51. async: !data.sync
  52. };
  53. }
  54. },
  55. 'background_operations.get_by_task': {
  56. 'real': '/clusters/{clusterName}/requests/{requestId}/tasks/{taskId}',
  57. 'mock': '/data/background_operations/list_on_start.json',
  58. 'testInProduction': true,
  59. 'format': function (data) {
  60. return {
  61. async: !data.sync
  62. };
  63. }
  64. },
  65. 'service.item.start_stop': {
  66. 'real': '/clusters/{clusterName}/services/{serviceName}',
  67. 'mock': '/data/wizard/deploy/poll_1.json',
  68. 'format': function (data) {
  69. return {
  70. type: 'PUT',
  71. data: JSON.stringify({
  72. RequestInfo: {
  73. "context": data.requestInfo
  74. },
  75. Body: {
  76. ServiceInfo: {
  77. state: data.state
  78. }
  79. }
  80. })
  81. };
  82. }
  83. },
  84. 'service.item.smoke': {
  85. 'real': '/clusters/{clusterName}/requests',
  86. 'mock': '/data/wizard/deploy/poll_1.json',
  87. 'format': function (data) {
  88. return {
  89. 'type': 'POST',
  90. data: JSON.stringify({
  91. "RequestInfo": {
  92. "context": data.displayName + " Service Check",
  93. "command" : data.actionName
  94. },
  95. "Requests/resource_filters": [{"service_name" : data.serviceName}]
  96. })
  97. };
  98. }
  99. },
  100. 'service.item.passive': {
  101. 'real': '/clusters/{clusterName}/services/{serviceName}',
  102. 'mock': '',
  103. 'format': function (data) {
  104. return {
  105. type: 'PUT',
  106. data: JSON.stringify({
  107. RequestInfo: {
  108. "context": data.requestInfo
  109. },
  110. Body: {
  111. ServiceInfo: {
  112. maintenance_state: data.passive_state
  113. }
  114. }
  115. })
  116. };
  117. }
  118. },
  119. 'service.stale_host_components.start_stop': {
  120. 'real': '/clusters/{clusterName}/host_components?' +
  121. 'HostRoles/stale_configs=true&HostRoles/component_name.in({componentNames})',
  122. 'mock': '/data/wizard/deploy/poll_1.json',
  123. 'format': function (data) {
  124. return {
  125. type: 'PUT',
  126. data: JSON.stringify({
  127. RequestInfo: {
  128. "context": data.requestInfo
  129. },
  130. Body: {
  131. HostRoles: {
  132. state: data.state
  133. }
  134. }
  135. })
  136. };
  137. }
  138. },
  139. 'service.load_config_groups': {
  140. 'real': '/clusters/{clusterName}/config_groups?ConfigGroup/tag={serviceName}&fields=*',
  141. 'mock': '/data/configurations/config_group.json'
  142. },
  143. 'reassign.stop_services': {
  144. 'real': '/clusters/{clusterName}/services',
  145. 'mock': '',
  146. 'format': function() {
  147. return {
  148. type: 'PUT',
  149. data: JSON.stringify({
  150. "RequestInfo": {
  151. "context": "Stop all services"
  152. },
  153. "Body": {
  154. "ServiceInfo": {
  155. "state": "INSTALLED"
  156. }
  157. }
  158. })
  159. }
  160. }
  161. },
  162. 'reassign.stop_YMR2_services': {
  163. 'real': '/clusters/{clusterName}/services?ServiceInfo/service_name.in({servicesList})',
  164. 'mock': '',
  165. 'format': function() {
  166. return {
  167. type: 'PUT',
  168. data: JSON.stringify({
  169. "RequestInfo": {
  170. "context": "Stop without HDFS"
  171. },
  172. "Body": {
  173. "ServiceInfo": {
  174. "state": "INSTALLED"
  175. }
  176. }
  177. })
  178. }
  179. }
  180. },
  181. 'reassign.start_services': {
  182. 'real': '/clusters/{clusterName}/services?params/run_smoke_test=true',
  183. 'mock': '',
  184. 'format': function() {
  185. return {
  186. type: 'PUT',
  187. data: JSON.stringify({
  188. "RequestInfo": {
  189. "context": "Start all services"
  190. },
  191. "Body": {
  192. "ServiceInfo": {
  193. "state": "STARTED"
  194. }
  195. }
  196. })
  197. }
  198. }
  199. },
  200. 'reassign.start_YMR2_services': {
  201. 'real': '/clusters/{clusterName}/services/?ServiceInfo/service_name.in({servicesList})',
  202. 'mock': '',
  203. 'format': function() {
  204. return {
  205. type: 'PUT',
  206. data: JSON.stringify({
  207. "RequestInfo": {
  208. "context": "Start without HDFS"
  209. },
  210. "Body": {
  211. "ServiceInfo": {
  212. "state": "STARTED"
  213. }
  214. }
  215. })
  216. }
  217. }
  218. },
  219. 'reassign.maintenance_mode': {
  220. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  221. 'mock': '',
  222. 'type': 'PUT',
  223. 'format': function () {
  224. return {
  225. data: JSON.stringify(
  226. {
  227. "HostRoles": {
  228. "state": "DISABLED"
  229. }
  230. }
  231. )
  232. }
  233. }
  234. },
  235. 'reassign.remove_component': {
  236. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  237. 'mock': '',
  238. 'type': 'DELETE'
  239. },
  240. 'reassign.load_configs': {
  241. 'real': '/clusters/{clusterName}/configurations?{urlParams}',
  242. 'mock': ''
  243. },
  244. 'reassign.save_configs': {
  245. 'real': '/clusters/{clusterName}',
  246. 'mock': '',
  247. 'type': 'PUT',
  248. 'format': function (data) {
  249. return {
  250. async: false,
  251. data: JSON.stringify({
  252. Clusters: {
  253. desired_config: {
  254. "type": data.siteName,
  255. "tag": 'version' + (new Date).getTime(),
  256. "properties": data.properties
  257. }
  258. }
  259. })
  260. }
  261. }
  262. },
  263. 'host_component.passive': {
  264. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  265. 'mock': '',
  266. 'type': 'PUT',
  267. 'format': function(data) {
  268. return {
  269. data: JSON.stringify({
  270. RequestInfo: {
  271. "context": data.requestInfo
  272. },
  273. Body: {
  274. HostRoles: {
  275. maintenance_state: data.passive_state
  276. }
  277. }
  278. })
  279. };
  280. }
  281. },
  282. 'config.cluster_configuration.put': {
  283. 'real': '/clusters/{cluster}',
  284. 'mock': '',
  285. 'format': function(data) {
  286. return {
  287. type: 'PUT',
  288. async: false,
  289. dataType: 'text',
  290. data: data.data
  291. }
  292. }
  293. },
  294. 'config.advanced': {
  295. 'real': '{stack2VersionUrl}/stackServices/{serviceName}/configurations?fields=*',
  296. 'mock': '/data/wizard/stack/hdp/version{stackVersion}/{serviceName}.json'
  297. },
  298. 'config.advanced.global': {
  299. 'real': '{stack2VersionUrl}/stackServices?fields=configurations/StackConfigurations/type',
  300. 'mock': '/data/wizard/stack/hdp/version1.3.0/global.json',
  301. 'format': function() {
  302. return {
  303. async: false
  304. };
  305. }
  306. },
  307. 'config.tags': {
  308. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs',
  309. 'mock': '/data/clusters/cluster.json'
  310. },
  311. 'config.tags_and_groups': {
  312. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs,config_groups/*',
  313. 'mock': '/data/clusters/tags_and_groups.json'
  314. },
  315. 'config.tags.sync': {
  316. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs',
  317. 'mock': '/data/clusters/cluster.json',
  318. 'format': function() {
  319. return {
  320. async: false
  321. };
  322. }
  323. },
  324. 'config_groups.all_fields': {
  325. 'real': '/clusters/{clusterName}/config_groups?fields=*',
  326. 'mock': ''
  327. },
  328. 'config_groups.get_config_group_by_id': {
  329. 'real': '/clusters/{clusterName}/config_groups/{id}',
  330. 'mock': ''
  331. },
  332. 'config_groups.update_config_group': {
  333. 'real': '/clusters/{clusterName}/config_groups/{id}',
  334. 'mock': '',
  335. 'type': 'PUT',
  336. 'format': function (data) {
  337. return {
  338. async: false,
  339. data: JSON.stringify(
  340. [
  341. data.configGroup
  342. ]
  343. )
  344. }
  345. }
  346. },
  347. 'config_groups.delete_config_group': {
  348. 'real': '/clusters/{clusterName}/config_groups/{id}',
  349. 'mock': '',
  350. 'type': 'DELETE'
  351. },
  352. 'config.on_site': {
  353. 'real': '/clusters/{clusterName}/configurations?{params}',
  354. 'mock': '/data/configurations/cluster_level_configs.json?{params}',
  355. 'format': function() {
  356. return {
  357. async: false
  358. };
  359. }
  360. },
  361. 'config.host_overrides': {
  362. 'real': '/clusters/{clusterName}/configurations?{params}',
  363. 'mock': '/data/configurations/host_level_overrides_configs.json?{params}',
  364. 'format': function() {
  365. return {
  366. async: false
  367. };
  368. }
  369. },
  370. 'host.host_component.action': {
  371. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  372. 'mock': '',
  373. 'type': 'PUT',
  374. 'format': function (data) {
  375. return {
  376. data: JSON.stringify({
  377. RequestInfo: {
  378. "context": data.context
  379. },
  380. Body: {
  381. "HostRoles": {
  382. "state": data.state
  383. }
  384. }
  385. })
  386. }
  387. }
  388. },
  389. 'host.host_component.slave_desired_admin_state': {
  390. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}/?fields=HostRoles/desired_admin_state',
  391. 'mock': ''
  392. },
  393. 'host.host_component.decommission_status': {
  394. 'real': '/clusters/{clusterName}/services/{serviceName}/components/{componentName}/?fields=ServiceComponentInfo',
  395. 'mock': ''
  396. },
  397. 'host.host_component.decommission_status_datanode': {
  398. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}?fields=metrics/dfs/namenode',
  399. 'mock': ''
  400. },
  401. 'host.host_component.decommission_slave': {
  402. 'real' : '/clusters/{clusterName}/requests',
  403. 'mock' : '',
  404. 'format' : function(data) {
  405. return {
  406. type : 'POST',
  407. data : JSON.stringify({
  408. RequestInfo: {
  409. 'context': data.context,
  410. 'command': data.command,
  411. 'parameters': {
  412. 'slave_type': data.slaveType,
  413. 'excluded_hosts': data.hostName
  414. }
  415. },
  416. "Requests/resource_filters": [{"service_name" : data.serviceName, "component_name" : data.componentName}]
  417. })
  418. }
  419. }
  420. },
  421. 'host.host_component.recommission_and_restart': {
  422. 'real': '/clusters/{clusterName}/request_schedules',
  423. 'mock': '',
  424. 'format' : function(data) {
  425. return {
  426. type : 'POST',
  427. data : JSON.stringify([ {
  428. "RequestSchedule" : {
  429. "batch" : [ {
  430. "requests" : data.batches
  431. }, {
  432. "batch_settings" : {
  433. "batch_separation_in_seconds" : data.intervalTimeSeconds,
  434. "task_failure_tolerance" : data.tolerateSize
  435. }
  436. } ]
  437. }
  438. } ])
  439. }
  440. }
  441. },
  442. 'host.host_component.recommission_slave' : {
  443. 'real' : '/clusters/{clusterName}/requests',
  444. 'mock' : '',
  445. 'format' : function(data) {
  446. return {
  447. type : 'POST',
  448. data : JSON.stringify({
  449. RequestInfo: {
  450. context: data.context,
  451. command: data.command,
  452. parameters: {
  453. slave_type: data.slaveType,
  454. included_hosts: data.hostName
  455. }
  456. },
  457. "Requests/resource_filters": [{"service_name" : data.serviceName, "component_name" : data.componentName}]
  458. })
  459. }
  460. }
  461. },
  462. 'host.stale_host_components.start_stop': {
  463. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components?HostRoles/stale_configs=true&' +
  464. 'HostRoles/component_name.in({componentNames})',
  465. 'mock': '',
  466. 'type': 'PUT',
  467. 'format': function (data) {
  468. return {
  469. data: JSON.stringify({
  470. RequestInfo: {
  471. "context": data.context
  472. },
  473. Body: {
  474. "HostRoles": {
  475. "state": data.state
  476. }
  477. }
  478. })
  479. }
  480. }
  481. },
  482. 'host.delete': {
  483. 'real': '/clusters/{clusterName}/hosts/{hostName}',
  484. 'mock': '',
  485. 'type': 'DELETE',
  486. 'format': function() {
  487. return {
  488. async: false
  489. }
  490. }
  491. },
  492. 'hosts.metrics': {
  493. 'real': '/clusters/{clusterName}/hosts?fields={metricName}',
  494. 'mock': '/data/cluster_metrics/cpu_1hr.json'
  495. },
  496. 'hosts.metrics.host_component': {
  497. 'real': '/clusters/{clusterName}/services/{serviceName}/components/{componentName}?fields=host_components/{metricName}',
  498. 'mock': '/data/cluster_metrics/cpu_1hr.json'
  499. },
  500. 'service.metrics.flume.channel_fill_percent': {
  501. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/CHANNEL/*/ChannelFillPercentage[{fromSeconds},{toSeconds},{stepSeconds}]',
  502. 'mock': '/data/services/metrics/flume/channelFillPct.json',
  503. 'testInProduction': true
  504. },
  505. 'service.metrics.flume.channel_size': {
  506. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/CHANNEL/*/ChannelSize[{fromSeconds},{toSeconds},{stepSeconds}]',
  507. 'mock': '/data/services/metrics/flume/channelSize.json',
  508. 'testInProduction': true
  509. },
  510. 'service.metrics.flume.sink_drain_success': {
  511. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/SINK/*/EventDrainSuccessCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  512. 'mock': '/data/services/metrics/flume/sinkDrainSuccessCount.json',
  513. 'testInProduction': true
  514. },
  515. 'service.metrics.flume.sink_connection_failed': {
  516. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/SINK/*/ConnectionFailedCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  517. 'mock': '/data/services/metrics/flume/sinkConnectionFailedCount.json',
  518. 'testInProduction': true
  519. },
  520. 'service.metrics.flume.gc': {
  521. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  522. 'mock': '/data/services/metrics/flume/jvmGcTime.json',
  523. 'testInProduction': true
  524. },
  525. 'service.metrics.flume.jvm_heap_used': {
  526. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/jvm/memHeapUsedM[{fromSeconds},{toSeconds},{stepSeconds}]',
  527. 'mock': '/data/services/metrics/flume/jvmMemHeapUsedM.json',
  528. 'testInProduction': true
  529. },
  530. 'service.metrics.flume.jvm_threads_runnable': {
  531. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/jvm/threadsRunnable[{fromSeconds},{toSeconds},{stepSeconds}]',
  532. 'mock': '/data/services/metrics/flume/jvmThreadsRunnable.json',
  533. 'testInProduction': true
  534. },
  535. 'service.metrics.flume.cpu_user': {
  536. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/cpu/cpu_user[{fromSeconds},{toSeconds},{stepSeconds}]',
  537. 'mock': '',
  538. 'testInProduction': true
  539. },
  540. 'service.metrics.flume.source_accepted': {
  541. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/SOURCE/*/EventAcceptedCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  542. 'mock': '/data/services/metrics/flume/sourceEventAccepted.json',
  543. 'testInProduction': true
  544. },
  545. 'service.metrics.hbase.cluster_requests': {
  546. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/cluster_requests[{fromSeconds},{toSeconds},{stepSeconds}]',
  547. 'mock': '/data/services/metrics/hbase/cluster_requests.json',
  548. 'testInProduction': true
  549. },
  550. 'service.metrics.hbase.hlog_split_size': {
  551. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/splitSize_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  552. 'mock': '/data/services/metrics/hbase/hlog_split_size.json',
  553. 'testInProduction': true
  554. },
  555. 'service.metrics.hbase.hlog_split_time': {
  556. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/splitTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  557. 'mock': '/data/services/metrics/hbase/hlog_split_time.json',
  558. 'testInProduction': true
  559. },
  560. 'service.metrics.hbase.regionserver_queuesize': {
  561. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/flushQueueSize[{fromSeconds},{toSeconds},{stepSeconds}],metrics/hbase/regionserver/compactionQueueSize[{fromSeconds},{toSeconds},{stepSeconds}]',
  562. 'mock': '/data/services/metrics/hbase/regionserver_queuesize.json',
  563. 'testInProduction': true
  564. },
  565. 'service.metrics.hbase.regionserver_regions': {
  566. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/regions[{fromSeconds},{toSeconds},{stepSeconds}]',
  567. 'mock': '/data/services/metrics/hbase/regionserver_regions.json',
  568. 'testInProduction': true
  569. },
  570. 'service.metrics.hbase.regionserver_rw_requests': {
  571. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/readRequestsCount[{fromSeconds},{toSeconds},{stepSeconds}],metrics/hbase/regionserver/writeRequestsCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  572. 'mock': '/data/services/metrics/hbase/regionserver_rw_requests.json',
  573. 'testInProduction': true
  574. },
  575. 'service.metrics.mapreduce.gc': {
  576. 'real': '/clusters/{clusterName}/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  577. 'mock': '/data/services/metrics/mapreduce/gc.json',
  578. 'testInProduction': true
  579. },
  580. 'service.metrics.mapreduce.jobs_status': {
  581. '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}]',
  582. 'mock': '/data/services/metrics/mapreduce/jobs_status.json',
  583. 'testInProduction': true
  584. },
  585. 'service.metrics.mapreduce.jobs_heap': {
  586. '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}]',
  587. 'mock': '/data/services/metrics/mapreduce/jvm_heap.json',
  588. 'testInProduction': true
  589. },
  590. 'service.metrics.mapreduce.jobs_threads': {
  591. '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}]',
  592. 'mock': '/data/services/metrics/mapreduce/jvm_threads.json',
  593. 'testInProduction': true
  594. },
  595. 'service.metrics.mapreduce.map_slots': {
  596. '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}]',
  597. 'mock': '/data/services/metrics/mapreduce/map_slots.json',
  598. 'testInProduction': true
  599. },
  600. 'service.metrics.mapreduce.reduce_slots': {
  601. '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}]',
  602. 'mock': '/data/services/metrics/mapreduce/reduce_slots.json',
  603. 'testInProduction': true
  604. },
  605. 'service.metrics.mapreduce.rpc': {
  606. 'real': '/clusters/{clusterName}/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  607. 'mock': '/data/services/metrics/mapreduce/rpc.json',
  608. 'testInProduction': true
  609. },
  610. 'service.metrics.mapreduce.tasks_running_waiting': {
  611. '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}]',
  612. 'mock': '/data/services/metrics/mapreduce/tasks_running_waiting.json',
  613. 'testInProduction': true
  614. },
  615. 'service.metrics.hdfs.block_status': {
  616. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/dfs/FSNamesystem/PendingReplicationBlocks[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/FSNamesystem/UnderReplicatedBlocks[{fromSeconds},{toSeconds},{stepSeconds}]',
  617. 'mock': '/data/services/metrics/hdfs/block_status.json',
  618. 'testInProduction': true
  619. },
  620. 'service.metrics.hdfs.file_operations': {
  621. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/dfs/namenode/FileInfoOps[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/namenode/CreateFileOps[{fromSeconds},{toSeconds},{stepSeconds}]',
  622. 'mock': '/data/services/metrics/hdfs/file_operations.json',
  623. 'testInProduction': true
  624. },
  625. 'service.metrics.hdfs.gc': {
  626. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  627. 'mock': '/data/services/metrics/hdfs/gc.json',
  628. 'testInProduction': true
  629. },
  630. 'service.metrics.hdfs.io': {
  631. 'real': '/clusters/{clusterName}/services/HDFS/components/DATANODE?fields=metrics/dfs/datanode/bytes_written[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/datanode/bytes_read[{fromSeconds},{toSeconds},{stepSeconds}]',
  632. 'mock': '/data/services/metrics/hdfs/io.json',
  633. 'testInProduction': true
  634. },
  635. 'service.metrics.hdfs.jvm_heap': {
  636. '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}]',
  637. 'mock': '/data/services/metrics/hdfs/jvm_heap.json',
  638. 'testInProduction': true
  639. },
  640. 'service.metrics.hdfs.jvm_threads': {
  641. '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}]',
  642. 'mock': '/data/services/metrics/hdfs/jvm_threads.json',
  643. 'testInProduction': true
  644. },
  645. 'service.metrics.hdfs.rpc': {
  646. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  647. 'mock': '/data/services/metrics/hdfs/rpc.json',
  648. 'testInProduction': true
  649. },
  650. 'service.metrics.hdfs.space_utilization': {
  651. '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}]',
  652. 'mock': '/data/services/metrics/hdfs/space_utilization.json',
  653. 'testInProduction': true
  654. },
  655. 'service.start_stop': {
  656. 'real': '/clusters/{clusterName}/services?params/run_smoke_test=true',
  657. 'mock': '/data/mirroring/poll/poll_6.json',
  658. 'format': function (data) {
  659. return {
  660. type: 'PUT',
  661. async: false,
  662. data: data.data
  663. };
  664. }
  665. },
  666. 'service.metrics.yarn.gc': {
  667. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  668. 'mock': '/data/services/metrics/yarn/gc.json',
  669. 'testInProduction': true
  670. },
  671. 'service.metrics.yarn.jobs_threads': {
  672. '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}]',
  673. 'mock': '/data/services/metrics/yarn/jvm_threads.json',
  674. 'testInProduction': true
  675. },
  676. 'service.metrics.yarn.rpc': {
  677. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  678. 'mock': '/data/services/metrics/yarn/rpc.json',
  679. 'testInProduction': true
  680. },
  681. 'service.metrics.yarn.jobs_heap': {
  682. '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}]',
  683. 'mock': '/data/services/metrics/yarn/jvm_heap.json',
  684. 'testInProduction': true
  685. },
  686. 'service.metrics.yarn.queue.allocated': {
  687. '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}]',
  688. 'mock': '',
  689. 'testInProduction': true
  690. },
  691. 'service.metrics.yarn.queue.allocated.container': {
  692. '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}]',
  693. 'mock': '',
  694. 'testInProduction': true
  695. },
  696. 'service.metrics.yarn.node.manager.statuses': {
  697. '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}]',
  698. 'mock': '',
  699. 'testInProduction': true
  700. },
  701. 'service.metrics.yarn.queue.memory.resource': {
  702. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=',
  703. 'mock': '',
  704. 'format': function (data, opt) {
  705. var field1 = 'metrics/yarn/Queue/{queueName}/AllocatedMB[{fromSeconds},{toSeconds},{stepSeconds}]';
  706. var field2 = 'metrics/yarn/Queue/{queueName}/AvailableMB[{fromSeconds},{toSeconds},{stepSeconds}]';
  707. if (opt.url != null && data.queueNames != null && data.queueNames.length > 0) {
  708. data.queueNames.forEach(function (q) {
  709. data.queueName = q;
  710. opt.url += (formatUrl(field1, data) + ",");
  711. opt.url += (formatUrl(field2, data) + ",");
  712. });
  713. } else {
  714. opt.url += (formatUrl(field1, data) + ",");
  715. opt.url += (formatUrl(field2, data) + ",");
  716. }
  717. },
  718. 'testInProduction': true
  719. },
  720. 'service.metrics.yarn.queue.apps.states.current': {
  721. '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}]',
  722. 'mock': '',
  723. 'testInProduction': true
  724. },
  725. 'service.metrics.yarn.queue.apps.states.finished': {
  726. '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}]',
  727. 'mock': '',
  728. 'testInProduction': true
  729. },
  730. 'service.metrics.storm.nimbus': {
  731. 'real': '/clusters/{clusterName}/services/STORM/components/NIMBUS?fields={metricsTemplate}',
  732. 'mock': ''
  733. },
  734. 'dashboard.cluster_metrics.cpu': {
  735. 'real': '/clusters/{clusterName}/?fields=metrics/cpu[{fromSeconds},{toSeconds},{stepSeconds}]',
  736. 'mock': '/data/cluster_metrics/cpu_1hr.json',
  737. 'testInProduction': true
  738. },
  739. 'dashboard.cluster_metrics.load': {
  740. 'real': '/clusters/{clusterName}/?fields=metrics/load[{fromSeconds},{toSeconds},{stepSeconds}]',
  741. 'mock': '/data/cluster_metrics/load_1hr.json',
  742. 'testInProduction': true
  743. },
  744. 'dashboard.cluster_metrics.memory': {
  745. 'real': '/clusters/{clusterName}/?fields=metrics/memory[{fromSeconds},{toSeconds},{stepSeconds}]',
  746. 'mock': '/data/cluster_metrics/memory_1hr.json',
  747. 'testInProduction': true
  748. },
  749. 'dashboard.cluster_metrics.network': {
  750. 'real': '/clusters/{clusterName}/?fields=metrics/network[{fromSeconds},{toSeconds},{stepSeconds}]',
  751. 'mock': '/data/cluster_metrics/network_1hr.json',
  752. 'testInProduction': true
  753. },
  754. 'host.metrics.cpu': {
  755. '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}]',
  756. 'mock': '/data/hosts/metrics/cpu.json',
  757. 'testInProduction': true
  758. },
  759. 'host.metrics.disk': {
  760. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/disk/disk_total[{fromSeconds},{toSeconds},{stepSeconds}],metrics/disk/disk_free[{fromSeconds},{toSeconds},{stepSeconds}]',
  761. 'mock': '/data/hosts/metrics/disk.json',
  762. 'testInProduction': true
  763. },
  764. 'host.metrics.load': {
  765. '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}]',
  766. 'mock': '/data/hosts/metrics/load.json',
  767. 'testInProduction': true
  768. },
  769. 'host.metrics.memory': {
  770. '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}]',
  771. 'mock': '/data/hosts/metrics/memory.json',
  772. 'testInProduction': true
  773. },
  774. 'host.metrics.network': {
  775. '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}]',
  776. 'mock': '/data/hosts/metrics/network.json',
  777. 'testInProduction': true
  778. },
  779. 'host.metrics.processes': {
  780. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/process/proc_total[{fromSeconds},{toSeconds},{stepSeconds}],metrics/process/proc_run[{fromSeconds},{toSeconds},{stepSeconds}]',
  781. 'mock': '/data/hosts/metrics/processes.json',
  782. 'testInProduction': true
  783. },
  784. 'host.service_config_hosts_overrides': {
  785. 'real': '/clusters/{clusterName}/configurations?{urlParams}',
  786. 'mock': '',
  787. 'format': function() {
  788. return {
  789. async: false,
  790. timeout: 10000
  791. };
  792. }
  793. },
  794. 'admin.security_status': {
  795. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs',
  796. 'mock': '',
  797. 'format': function() {
  798. return {
  799. timeout: 10000
  800. };
  801. }
  802. },
  803. 'settings.get.user_pref': {
  804. 'real': '/persist/{key}',
  805. 'mock': '/data/user_settings/{key}.json',
  806. 'format': function(data) {
  807. return {
  808. async: data.async
  809. };
  810. }
  811. },
  812. 'settings.post.user_pref': {
  813. 'real': '/persist',
  814. 'mock': '',
  815. 'type': 'POST',
  816. 'format': function (data) {
  817. return {
  818. async: data.async,
  819. data: JSON.stringify(data.keyValuePair)
  820. }
  821. }
  822. },
  823. 'cluster.load_cluster_name': {
  824. 'real': '/clusters',
  825. 'mock': '/data/clusters/info.json',
  826. 'format': function() {
  827. return {
  828. async: false
  829. };
  830. }
  831. },
  832. 'cluster.state': {
  833. 'type': 'POST',
  834. 'real': '/persist/',
  835. 'mock': '',
  836. 'format': function(data) {
  837. return {
  838. async: false,
  839. data: JSON.stringify(data.keyValuePair)
  840. };
  841. }
  842. },
  843. 'cluster.update_upgrade_version': {
  844. 'real': '/stacks2/HDP/versions?fields=stackServices/StackServices,Versions',
  845. 'mock': '/data/wizard/stack/stacks.json',
  846. 'format': function() {
  847. return {
  848. async: false
  849. };
  850. }
  851. },
  852. 'cluster.load_repositories': {
  853. 'real': '/stacks2/{stackName}/versions/{stackVersion}/operatingSystems?fields=repositories/*',
  854. 'mock': '',
  855. 'type': 'GET',
  856. 'format': function (data) {
  857. return {
  858. data: data.data
  859. };
  860. }
  861. },
  862. 'admin.high_availability.stop_all_services': {
  863. 'real': '/clusters/{clusterName}/services',
  864. 'mock': '',
  865. 'format': function() {
  866. return {
  867. type: 'PUT',
  868. data: JSON.stringify({
  869. "RequestInfo": {
  870. "context": "Stop all services"
  871. },
  872. "Body": {
  873. "ServiceInfo": {
  874. "state": "INSTALLED"
  875. }
  876. }
  877. })
  878. }
  879. }
  880. },
  881. 'admin.high_availability.start_all_services': {
  882. 'real': '/clusters/{clusterName}/services',
  883. 'mock': '',
  884. 'format': function() {
  885. return {
  886. type: 'PUT',
  887. data: JSON.stringify({
  888. "RequestInfo": {
  889. "context": "Start all services"
  890. },
  891. "Body": {
  892. "ServiceInfo": {
  893. "state": "STARTED"
  894. }
  895. }
  896. })
  897. }
  898. }
  899. },
  900. 'admin.high_availability.polling': {
  901. 'real': '/clusters/{clusterName}/requests/{requestId}?fields=tasks/*',
  902. 'mock': '',
  903. 'type': 'GET'
  904. },
  905. 'admin.high_availability.getNnCheckPointStatus': {
  906. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/NAMENODE',
  907. 'mock': '',
  908. 'type': 'GET'
  909. },
  910. 'admin.high_availability.getJnCheckPointStatus': {
  911. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/JOURNALNODE?fields=metrics',
  912. 'mock': ''
  913. },
  914. 'admin.high_availability.getHostComponent': {
  915. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  916. 'mock': ''
  917. },
  918. 'admin.high_availability.create_component': {
  919. 'real': '/clusters/{clusterName}/hosts?Hosts/host_name={hostName}',
  920. 'mock': '',
  921. 'type': 'POST',
  922. 'format': function (data) {
  923. return {
  924. data: JSON.stringify({
  925. "host_components": [
  926. {
  927. "HostRoles": {
  928. "component_name": data.componentName
  929. }
  930. }
  931. ]
  932. })
  933. }
  934. }
  935. },
  936. 'admin.high_availability.create_journalnode': {
  937. 'real': '/clusters/{clusterName}/services?ServiceInfo/service_name=HDFS',
  938. 'mock': '',
  939. 'type': 'POST',
  940. 'format': function() {
  941. return {
  942. data: JSON.stringify({
  943. "components": [
  944. {
  945. "ServiceComponentInfo": {
  946. "component_name": "JOURNALNODE"
  947. }
  948. }
  949. ]
  950. })
  951. }
  952. }
  953. },
  954. 'admin.high_availability.create_zkfc': {
  955. 'real': '/clusters/{clusterName}/services?ServiceInfo/service_name=HDFS',
  956. 'mock': '',
  957. 'type': 'POST',
  958. 'format': function() {
  959. return {
  960. data: JSON.stringify({
  961. "components": [
  962. {
  963. "ServiceComponentInfo": {
  964. "component_name": "ZKFC"
  965. }
  966. }
  967. ]
  968. })
  969. }
  970. }
  971. },
  972. 'admin.high_availability.install_component': {
  973. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  974. 'mock': '',
  975. 'type': 'PUT',
  976. 'format': function (data) {
  977. return {
  978. data: JSON.stringify({
  979. RequestInfo: {
  980. "context": "Install " + data.displayName
  981. },
  982. Body: {
  983. "HostRoles": {
  984. "state": "INSTALLED"
  985. }
  986. }
  987. })
  988. }
  989. }
  990. },
  991. 'admin.high_availability.start_component': {
  992. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  993. 'mock': '',
  994. 'type': 'PUT',
  995. 'format': function (data) {
  996. return {
  997. data: JSON.stringify({
  998. RequestInfo: {
  999. "context": "Start " + data.displayName
  1000. },
  1001. Body: {
  1002. "HostRoles": {
  1003. "state": "STARTED"
  1004. }
  1005. }
  1006. })
  1007. }
  1008. }
  1009. },
  1010. 'admin.high_availability.maintenance_mode': {
  1011. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  1012. 'mock': '',
  1013. 'type': 'PUT',
  1014. 'format': function () {
  1015. return {
  1016. data: JSON.stringify({
  1017. "HostRoles": {
  1018. "state": "DISABLED"
  1019. }
  1020. })
  1021. }
  1022. }
  1023. },
  1024. 'admin.high_availability.stop_component': {
  1025. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  1026. 'mock': '',
  1027. 'type': 'PUT',
  1028. 'format': function (data) {
  1029. return {
  1030. data: JSON.stringify({
  1031. RequestInfo: {
  1032. "context": "Stop " + data.displayName
  1033. },
  1034. Body: {
  1035. "HostRoles": {
  1036. "state": "INSTALLED"
  1037. }
  1038. }
  1039. })
  1040. }
  1041. }
  1042. },
  1043. 'admin.high_availability.load_configs': {
  1044. 'real': '/clusters/{clusterName}/configurations?(type=core-site&tag={coreSiteTag})|(type=hdfs-site&tag={hdfsSiteTag})',
  1045. 'mock': '',
  1046. 'type': 'GET'
  1047. },
  1048. 'admin.high_availability.save_configs': {
  1049. 'real': '/clusters/{clusterName}',
  1050. 'mock': '',
  1051. 'type': 'PUT',
  1052. 'format': function (data) {
  1053. return {
  1054. async: false,
  1055. data: JSON.stringify({
  1056. Clusters: {
  1057. desired_config: {
  1058. "type": data.siteName,
  1059. "tag": 'version' + (new Date).getTime(),
  1060. "properties": data.properties
  1061. }
  1062. }
  1063. })
  1064. }
  1065. }
  1066. },
  1067. 'admin.high_availability.load_hbase_configs': {
  1068. 'real': '/clusters/{clusterName}/configurations?type=hbase-site&tag={hbaseSiteTag}',
  1069. 'mock': '',
  1070. 'type': 'GET'
  1071. },
  1072. 'admin.delete_component': {
  1073. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  1074. 'mock': '',
  1075. 'type': 'DELETE'
  1076. },
  1077. 'admin.security.cluster_configs': {
  1078. 'real': '/clusters/{clusterName}',
  1079. 'mock': '',
  1080. 'format': function() {
  1081. return {
  1082. timeout: 10000
  1083. };
  1084. }
  1085. },
  1086. 'admin.delete_host': {
  1087. 'real': '/clusters/{clusterName}/hosts/{hostName}',
  1088. 'mock': '',
  1089. 'type': 'DELETE'
  1090. },
  1091. 'admin.get.all_configurations': {
  1092. 'real': '/clusters/{clusterName}/configurations?{urlParams}',
  1093. 'mock': '',
  1094. 'format': function() {
  1095. return {
  1096. timeout: 10000
  1097. };
  1098. }
  1099. },
  1100. 'admin.security.apply_configurations': {
  1101. 'real': '/clusters/{clusterName}',
  1102. 'mock': '',
  1103. 'format': function (data) {
  1104. return {
  1105. type: 'PUT',
  1106. timeout: 10000,
  1107. data: data.configData
  1108. };
  1109. }
  1110. },
  1111. 'admin.security.apply_configuration': {
  1112. 'real': '/clusters/{clusterName}',
  1113. 'mock': '',
  1114. 'format': function(data) {
  1115. return {
  1116. type: 'PUT',
  1117. async: false,
  1118. timeout: 5000,
  1119. data: JSON.stringify(data.clusterData)
  1120. };
  1121. }
  1122. },
  1123. 'admin.security.add.cluster_configs': {
  1124. 'real': '/clusters/{clusterName}' + '?fields=Clusters/desired_configs',
  1125. 'mock': '',
  1126. 'format': function() {
  1127. return {
  1128. timeout: 10000
  1129. };
  1130. }
  1131. },
  1132. 'admin.stack_upgrade.run_upgrade': {
  1133. 'real': '/clusters/{clusterName}',
  1134. 'mock': '',
  1135. 'format': function (data) {
  1136. return {
  1137. type: 'PUT',
  1138. async: false,
  1139. data: data.data
  1140. };
  1141. }
  1142. },
  1143. 'admin.stack_upgrade.stop_services': {
  1144. 'real': '/clusters/{clusterName}/services?ServiceInfo/state=STARTED',
  1145. 'mock': '',
  1146. 'format': function (data) {
  1147. return {
  1148. type: 'PUT',
  1149. async: false,
  1150. data: data.data
  1151. };
  1152. }
  1153. },
  1154. 'admin.stack_upgrade.do_poll': {
  1155. 'real': '/clusters/{cluster}/requests/{requestId}?fields=tasks/*',
  1156. 'mock': '/data/wizard/{mock}'
  1157. },
  1158. 'wizard.advanced_repositories.valid_url': {
  1159. 'real': '/stacks2/{stackName}/versions/{stackVersion}/operatingSystems/{osType}/repositories/{nameVersionCombo}',
  1160. 'mock': '',
  1161. 'type': 'PUT',
  1162. 'format': function (data) {
  1163. return {
  1164. async: true,
  1165. data: JSON.stringify(data.data)
  1166. }
  1167. }
  1168. },
  1169. 'wizard.install_services.add_host_controller.is_retry': {
  1170. 'real': '/clusters/{cluster}/host_components',
  1171. 'mock': '',
  1172. 'format': function (data) {
  1173. return {
  1174. type: 'PUT',
  1175. async: false,
  1176. data: data.data
  1177. };
  1178. }
  1179. },
  1180. 'wizard.install_services.add_host_controller.not_is_retry': {
  1181. 'real': '/clusters/{cluster}/host_components',
  1182. 'mock': '',
  1183. 'format': function(data) {
  1184. return {
  1185. type: 'PUT',
  1186. async: false,
  1187. data: data.data
  1188. };
  1189. }
  1190. },
  1191. 'wizard.install_services.installer_controller.is_retry': {
  1192. 'real': '/clusters/{cluster}/host_components?HostRoles/state=INSTALLED',
  1193. 'mock': '/data/wizard/deploy/2_hosts/poll_1.json',
  1194. 'type': 'PUT',
  1195. 'format': function (data) {
  1196. return {
  1197. async: false,
  1198. data: data.data
  1199. };
  1200. }
  1201. },
  1202. 'wizard.install_services.installer_controller.not_is_retry': {
  1203. 'real': '/clusters/{cluster}/services?ServiceInfo/state=INIT',
  1204. 'mock': '/data/wizard/deploy/2_hosts/poll_1.json',
  1205. 'type': 'PUT',
  1206. 'format': function (data) {
  1207. return {
  1208. async: false,
  1209. data: data.data
  1210. };
  1211. }
  1212. },
  1213. 'wizard.install_services.add_service_controller.get_failed_host_components': {
  1214. 'real': '/clusters/{clusterName}/host_components?fields=HostRoles/state,component/ServiceComponentInfo/service_name',
  1215. 'mock': '',
  1216. 'format': function() {
  1217. return {
  1218. async: false
  1219. };
  1220. }
  1221. },
  1222. 'wizard.service_components': {
  1223. 'real': '{stackUrl}/stackServices?fields=StackServices',
  1224. 'mock': '/data/wizard/stack/hdp/version/{stackVersion}.json',
  1225. 'format': function() {
  1226. return {
  1227. timeout: 10000,
  1228. async: false
  1229. };
  1230. }
  1231. },
  1232. 'wizard.step9.installer.get_host_status': {
  1233. 'real': '/clusters/{cluster}/hosts?fields=Hosts/host_state,host_components/HostRoles/state',
  1234. 'mock': '/data/wizard/deploy/5_hosts/get_host_state.json',
  1235. 'format': function () {
  1236. return {
  1237. async: false
  1238. };
  1239. }
  1240. },
  1241. 'wizard.step9.installer.launch_start_services': {
  1242. 'real': '/clusters/{cluster}/services?ServiceInfo/state=INSTALLED&params/run_smoke_test=true&params/reconfigure_client=false',
  1243. 'mock': '/data/wizard/deploy/5_hosts/poll_6.json',
  1244. 'format': function (data) {
  1245. var d = {
  1246. type: 'PUT',
  1247. async: false,
  1248. data: data.data
  1249. };
  1250. if (App.testMode) {
  1251. d.type = 'GET';
  1252. }
  1253. return d;
  1254. }
  1255. },
  1256. 'wizard.step9.add_host.launch_start_services': {
  1257. 'real': '/clusters/{cluster}/host_components',
  1258. 'mock': '/data/wizard/deploy/5_hosts/poll_6.json',
  1259. 'format': function (data) {
  1260. return {
  1261. type: 'PUT',
  1262. async: false,
  1263. data: data.data
  1264. };
  1265. }
  1266. },
  1267. 'wizard.step8.delete_cluster': {
  1268. 'real': '/clusters/{name}',
  1269. 'mock': '',
  1270. 'format': function() {
  1271. return {
  1272. type: 'DELETE',
  1273. async: false
  1274. };
  1275. }
  1276. },
  1277. 'wizard.step8.existing_cluster_names': {
  1278. 'real': '/clusters',
  1279. 'mock': '',
  1280. 'format': function() {
  1281. return {
  1282. async: false
  1283. };
  1284. }
  1285. },
  1286. 'wizard.step3.host_info': {
  1287. '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',
  1288. 'mock': '/data/wizard/bootstrap/two_hosts_information.json',
  1289. 'format': function() {
  1290. return {
  1291. contentType: 'application/json'
  1292. };
  1293. }
  1294. },
  1295. 'wizard.step3.rerun_checks': {
  1296. 'real': '/hosts?fields=Hosts/last_agent_env',
  1297. 'mock': '/data/wizard/bootstrap/two_hosts_information.json',
  1298. 'format': function() {
  1299. return {
  1300. contentType: 'application/json'
  1301. };
  1302. }
  1303. },
  1304. 'wizard.step3.bootstrap': {
  1305. 'real': '/bootstrap/{bootRequestId}',
  1306. 'mock': '/data/wizard/bootstrap/poll_{numPolls}.json'
  1307. },
  1308. 'wizard.step3.is_hosts_registered': {
  1309. 'real': '/hosts',
  1310. 'mock': '/data/wizard/bootstrap/single_host_registration.json'
  1311. },
  1312. 'wizard.stacks': {
  1313. 'real': '/stacks2',
  1314. 'mock': '/data/wizard/stack/stacks2.json',
  1315. 'format': function() {
  1316. return {
  1317. async: false
  1318. };
  1319. }
  1320. },
  1321. 'wizard.stacks_versions': {
  1322. 'real': '/stacks2/{stackName}/versions?fields=Versions,operatingSystems/repositories/Repositories',
  1323. 'mock': '/data/wizard/stack/{stackName}_versions.json',
  1324. 'format': function() {
  1325. return {
  1326. async: false
  1327. };
  1328. }
  1329. },
  1330. 'wizard.launch_bootstrap': {
  1331. 'real': '/bootstrap',
  1332. 'mock': '/data/wizard/bootstrap/bootstrap.json',
  1333. 'type': 'POST',
  1334. 'format': function (data) {
  1335. return {
  1336. async: false,
  1337. contentType: 'application/json',
  1338. data: data.bootStrapData
  1339. }
  1340. }
  1341. },
  1342. 'router.login': {
  1343. 'real': '/users/{loginName}',
  1344. 'mock': '/data/users/user_{usr}.json',
  1345. 'format': function (data) {
  1346. var statusCode = jQuery.extend({}, require('data/statusCodes'));
  1347. statusCode['403'] = function () {
  1348. console.log("Error code 403: Forbidden.");
  1349. };
  1350. return {
  1351. statusCode: statusCode
  1352. };
  1353. }
  1354. },
  1355. 'router.login2': {
  1356. 'real': '/clusters',
  1357. 'mock': '/data/clusters/info.json'
  1358. },
  1359. 'router.logoff': {
  1360. 'real': '/logout',
  1361. 'mock': ''
  1362. },
  1363. 'router.set_ambari_stacks': {
  1364. 'real': '/stacks',
  1365. 'mock': '/data/wizard/stack/stacks.json',
  1366. 'format': function() {
  1367. return {
  1368. async: false
  1369. };
  1370. }
  1371. },
  1372. 'router.authentication': {
  1373. 'real': '/clusters',
  1374. 'mock': '/data/clusters/info.json',
  1375. 'format': function() {
  1376. return {
  1377. async: false
  1378. };
  1379. }
  1380. },
  1381. 'ambari.service': {
  1382. 'real': '/services/AMBARI/components/AMBARI_SERVER',
  1383. 'mock': '/data/services/ambari_server.json'
  1384. },
  1385. 'ambari.service.load_server_clock': {
  1386. 'real': '/services/AMBARI/components/AMBARI_SERVER?fields=RootServiceComponents/server_clock',
  1387. 'mock': ''
  1388. },
  1389. 'config_groups.create': {
  1390. 'real': '/clusters/{clusterName}/config_groups',
  1391. 'mock': '',
  1392. 'format': function (data) {
  1393. return {
  1394. async: false,
  1395. type: 'POST',
  1396. data: JSON.stringify([{
  1397. "ConfigGroup": {
  1398. "group_name": data.group_name,
  1399. "tag": data.service_id,
  1400. "description": data.description,
  1401. "desired_configs": data.desired_configs,
  1402. "hosts": data.hosts
  1403. }
  1404. }])
  1405. }
  1406. }
  1407. },
  1408. 'config_groups.update': {
  1409. 'real': '/clusters/{clusterName}/config_groups/{id}',
  1410. 'mock': '',
  1411. 'format': function (data) {
  1412. return {
  1413. async: true,
  1414. type: 'PUT',
  1415. data: JSON.stringify(data.data)
  1416. }
  1417. }
  1418. },
  1419. 'rolling_restart.post': {
  1420. 'real': '/clusters/{clusterName}/request_schedules',
  1421. 'mock': '',
  1422. 'format' : function(data) {
  1423. return {
  1424. type : 'POST',
  1425. data : JSON.stringify([ {
  1426. "RequestSchedule" : {
  1427. "batch" : [ {
  1428. "requests" : data.batches
  1429. }, {
  1430. "batch_settings" : {
  1431. "batch_separation_in_seconds" : data.intervalTimeSeconds,
  1432. "task_failure_tolerance" : data.tolerateSize
  1433. }
  1434. } ]
  1435. }
  1436. } ])
  1437. }
  1438. }
  1439. },
  1440. 'request_schedule.delete': {
  1441. 'real': '/clusters/{clusterName}/request_schedules/{request_schedule_id}',
  1442. 'mock': '',
  1443. 'format' : function() {
  1444. return {
  1445. type : 'DELETE'
  1446. }
  1447. }
  1448. },
  1449. 'request_schedule.get': {
  1450. 'real': '/clusters/{clusterName}/request_schedules/{request_schedule_id}',
  1451. 'mock': ''
  1452. },
  1453. 'restart.hostComponents': {
  1454. 'real':'/clusters/{clusterName}/requests',
  1455. 'mock':'',
  1456. 'format': function(data) {
  1457. return {
  1458. type : 'POST',
  1459. data : JSON.stringify({
  1460. "RequestInfo": {
  1461. "command": "RESTART",
  1462. "context": data.context
  1463. },
  1464. "Requests/resource_filters": data.resource_filters
  1465. })
  1466. }
  1467. }
  1468. },
  1469. 'mirroring.get_all_entities': {
  1470. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/list/{type}?fields=status&user.name=ambari-qa',
  1471. 'mock': '/data/mirroring/{type}s.xml',
  1472. 'apiPrefix': '',
  1473. 'format': function () {
  1474. return {
  1475. dataType: 'xml'
  1476. }
  1477. }
  1478. },
  1479. 'mirroring.get_definition': {
  1480. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/definition/{type}/{name}?user.name=ambari-qa',
  1481. 'mock': '/data/mirroring/{name}_definition.xml',
  1482. 'apiPrefix': '',
  1483. 'format': function () {
  1484. return {
  1485. cache: true,
  1486. dataType: 'xml'
  1487. }
  1488. }
  1489. },
  1490. 'mirroring.dataset.get_all_instances': {
  1491. 'real': '/proxy?url=http://{falconServer}:15000/api/instance/status/feed/{dataset}?start={start}&end={end}&user.name=ambari-qa',
  1492. 'mock': '/data/mirroring/{dataset}_instances.json',
  1493. 'apiPrefix': ''
  1494. },
  1495. 'mirroring.create_new_dataset': {
  1496. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/submitAndSchedule/feed?user.name=ambari-qa',
  1497. 'mock': '/data/mirroring/succeeded.json',
  1498. 'apiPrefix': '',
  1499. 'type': 'POST',
  1500. 'format': function (data) {
  1501. return {
  1502. contentType: 'text/xml',
  1503. dataType: 'xml',
  1504. data: data.dataset,
  1505. headers: {
  1506. 'AmbariProxy-Content-Type': 'text/xml'
  1507. }
  1508. }
  1509. }
  1510. },
  1511. 'mirroring.submit_entity': {
  1512. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/submit/{type}?user.name=ambari-qa',
  1513. 'mock': '/data/mirroring/succeeded.json',
  1514. 'apiPrefix': '',
  1515. 'type': 'POST',
  1516. 'format': function (data) {
  1517. return {
  1518. contentType: 'text/xml',
  1519. dataType: 'xml',
  1520. data: data.entity,
  1521. headers: {
  1522. 'AmbariProxy-Content-Type': 'text/xml'
  1523. }
  1524. }
  1525. }
  1526. },
  1527. 'mirroring.update_entity': {
  1528. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/update/{type}/{name}?user.name=ambari-qa',
  1529. 'mock': '/data/mirroring/succeeded.json',
  1530. 'apiPrefix': '',
  1531. 'type': 'POST',
  1532. 'format': function (data) {
  1533. return {
  1534. contentType: 'text/xml',
  1535. dataType: 'xml',
  1536. data: data.entity,
  1537. headers: {
  1538. 'AmbariProxy-Content-Type': 'text/xml'
  1539. }
  1540. }
  1541. }
  1542. },
  1543. 'mirroring.delete_entity': {
  1544. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/delete/{type}/{name}?user.name=ambari-qa',
  1545. 'mock': '/data/mirroring/succeeded.json',
  1546. 'apiPrefix': '',
  1547. 'type': 'DELETE',
  1548. 'format': function () {
  1549. return {
  1550. dataType: 'xml'
  1551. }
  1552. }
  1553. },
  1554. 'mirroring.suspend_entity': {
  1555. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/suspend/{type}/{name}?user.name=ambari-qa',
  1556. 'mock': '/data/mirroring/succeeded.json',
  1557. 'apiPrefix': '',
  1558. 'type': 'POST',
  1559. 'format': function (data) {
  1560. return {
  1561. dataType: 'xml',
  1562. data: data.entity
  1563. }
  1564. }
  1565. },
  1566. 'mirroring.schedule_entity': {
  1567. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/resume/{type}/{name}?user.name=ambari-qa',
  1568. 'mock': '/data/mirroring/succeeded.json',
  1569. 'apiPrefix': '',
  1570. 'type': 'POST',
  1571. 'format': function () {
  1572. return {
  1573. dataType: 'xml'
  1574. }
  1575. }
  1576. },
  1577. 'mirroring.suspend_instance': {
  1578. 'real': '/proxy?url=http://{falconServer}:15000/api/instance/suspend/feed/{feed}?start={name}&user.name=ambari-qa',
  1579. 'mock': '/data/mirroring/succeeded.json',
  1580. 'apiPrefix': '',
  1581. 'type': 'POST'
  1582. },
  1583. 'mirroring.resume_instance': {
  1584. 'real': '/proxy?url=http://{falconServer}:15000/api/instance/resume/feed/{feed}?start={name}&user.name=ambari-qa',
  1585. 'mock': '/data/mirroring/succeeded.json',
  1586. 'apiPrefix': '',
  1587. 'type': 'POST'
  1588. },
  1589. 'mirroring.kill_instance': {
  1590. 'real': '/proxy?url=http://{falconServer}:15000/api/instance/kill/feed/{feed}?start={name}&user.name=ambari-qa',
  1591. 'mock': '/data/mirroring/succeeded.json',
  1592. 'apiPrefix': '',
  1593. 'type': 'POST'
  1594. },
  1595. 'bulk_request.host_components': {
  1596. 'real': '/clusters/{clusterName}/host_components',
  1597. 'mock': '',
  1598. 'format': function(data) {
  1599. return {
  1600. type: 'PUT',
  1601. data: JSON.stringify({
  1602. RequestInfo: {
  1603. context: data.requestInfo,
  1604. query: 'HostRoles/component_name=' + data.componentName + '&HostRoles/host_name.in(' + data.hostNames + ')&HostRoles/maintenance_state=OFF'
  1605. },
  1606. Body: {
  1607. HostRoles: {
  1608. state: data.state
  1609. }
  1610. }
  1611. })
  1612. }
  1613. }
  1614. },
  1615. 'bulk_request.hosts.all_components': {
  1616. 'real': '/clusters/{clusterName}/host_components',
  1617. 'mock': '',
  1618. 'format': function(data) {
  1619. return {
  1620. type: 'PUT',
  1621. data: JSON.stringify({
  1622. RequestInfo: {
  1623. context: data.requestInfo,
  1624. query: data.query
  1625. },
  1626. Body: {
  1627. HostRoles: {
  1628. state: data.state
  1629. }
  1630. }
  1631. })
  1632. }
  1633. }
  1634. },
  1635. 'bulk_request.decommission': {
  1636. 'real' : '/clusters/{clusterName}/requests',
  1637. 'mock' : '',
  1638. 'format': function(data) {
  1639. return {
  1640. type: 'POST',
  1641. data: JSON.stringify({
  1642. 'RequestInfo': {
  1643. 'context': data.context,
  1644. 'command': 'DECOMMISSION',
  1645. 'parameters': data.parameters
  1646. },
  1647. "Requests/resource_filters": [{"service_name" : data.serviceName, "component_name" : data.componentName}]
  1648. })
  1649. }
  1650. }
  1651. },
  1652. 'bulk_request.hosts.passive_state': {
  1653. 'real': '/clusters/{clusterName}/hosts',
  1654. 'mock': '',
  1655. 'format': function(data) {
  1656. return {
  1657. type: 'PUT',
  1658. data: JSON.stringify({
  1659. RequestInfo: {
  1660. context: data.requestInfo,
  1661. query: 'Hosts/host_name.in(' + data.hostNames + ')'
  1662. },
  1663. Body: {
  1664. Hosts: {
  1665. maintenance_state: data.passive_state
  1666. }
  1667. }
  1668. })
  1669. }
  1670. }
  1671. },
  1672. 'bulk_request.hosts.all_components.passive_state': {
  1673. 'real': '/clusters/{clusterName}/host_components',
  1674. 'mock': '',
  1675. 'format': function(data) {
  1676. return {
  1677. type: 'PUT',
  1678. data: JSON.stringify({
  1679. RequestInfo: {
  1680. context: data.requestInfo,
  1681. query: data.query
  1682. },
  1683. Body: {
  1684. HostRoles: {
  1685. maintenance_state: data.passive_state
  1686. }
  1687. }
  1688. })
  1689. }
  1690. }
  1691. },
  1692. 'jobs.tezDag.NametoID': {
  1693. 'real': '/proxy?url=http://{historyServerHostName}:{ahsWebPort}/ws/v1/timeline/TEZ_DAG_ID?primaryFilter=dagName:{tezDagName}',
  1694. 'mock': '/data/jobs/tezDag-name-to-id.json',
  1695. 'apiPrefix': ''
  1696. },
  1697. 'jobs.tezDag.tezDagId': {
  1698. 'real': '/proxy?url=http://{historyServerHostName}:{ahsWebPort}/ws/v1/timeline/TEZ_DAG_ID/{tezDagId}?fields=relatedentities',
  1699. 'mock': '/data/jobs/tezDag.json',
  1700. 'apiPrefix': ''
  1701. },
  1702. 'jobs.tezDag.tezDagVertexId': {
  1703. 'real': '/proxy?url=http://{historyServerHostName}:{ahsWebPort}/ws/v1/timeline/TEZ_VERTEX_ID/{tezDagVertexId}?fields=otherinfo',
  1704. 'mock': '/data/jobs/tezDagVertex.json',
  1705. 'apiPrefix': ''
  1706. }
  1707. };
  1708. /**
  1709. * Replace data-placeholders to its values
  1710. *
  1711. * @param {String} url
  1712. * @param {Object} data
  1713. * @return {String}
  1714. */
  1715. var formatUrl = function (url, data) {
  1716. if (!url) return null;
  1717. var keys = url.match(/\{\w+\}/g);
  1718. keys = (keys === null) ? [] : keys;
  1719. if (keys) {
  1720. keys.forEach(function (key) {
  1721. var raw_key = key.substr(1, key.length - 2);
  1722. var replace;
  1723. if (!data || !data[raw_key]) {
  1724. replace = '';
  1725. }
  1726. else {
  1727. replace = data[raw_key];
  1728. }
  1729. url = url.replace(new RegExp(key, 'g'), replace);
  1730. });
  1731. }
  1732. return url;
  1733. };
  1734. /**
  1735. * this = object from config
  1736. * @return {Object}
  1737. */
  1738. var formatRequest = function (data) {
  1739. var opt = {
  1740. type: this.type || 'GET',
  1741. timeout: App.timeout,
  1742. dataType: 'json',
  1743. statusCode: require('data/statusCodes')
  1744. };
  1745. if (App.testMode) {
  1746. opt.url = formatUrl(this.mock ? this.mock : '', data);
  1747. opt.type = 'GET';
  1748. }
  1749. else {
  1750. var prefix = this.apiPrefix != null ? this.apiPrefix : App.apiPrefix;
  1751. opt.url = prefix + formatUrl(this.real, data);
  1752. }
  1753. if (this.format) {
  1754. jQuery.extend(opt, this.format(data, opt));
  1755. }
  1756. return opt;
  1757. };
  1758. /**
  1759. * Wrapper for all ajax requests
  1760. *
  1761. * @type {Object}
  1762. */
  1763. var ajax = Em.Object.extend({
  1764. /**
  1765. * Send ajax request
  1766. *
  1767. * @param {Object} config
  1768. * @return {$.ajax} jquery ajax object
  1769. *
  1770. * config fields:
  1771. * name - url-key in the urls-object *required*
  1772. * sender - object that send request (need for proper callback initialization) *required*
  1773. * data - object with data for url-format
  1774. * beforeSend - method-name for ajax beforeSend response callback
  1775. * success - method-name for ajax success response callback
  1776. * error - method-name for ajax error response callback
  1777. * callback - callback from <code>App.updater.run</code> library
  1778. */
  1779. send: function (config) {
  1780. console.warn('============== ajax ==============', config.name, config.data);
  1781. if (!config.sender) {
  1782. console.warn('Ajax sender should be defined!');
  1783. return null;
  1784. }
  1785. // default parameters
  1786. var params = {
  1787. clusterName: App.get('clusterName')
  1788. };
  1789. // extend default parameters with provided
  1790. if (config.data) {
  1791. jQuery.extend(params, config.data);
  1792. }
  1793. var opt = {};
  1794. if (!urls[config.name]) {
  1795. console.warn('Invalid name provided!');
  1796. return null;
  1797. }
  1798. opt = formatRequest.call(urls[config.name], params);
  1799. opt.context = this;
  1800. // object sender should be provided for processing beforeSend, success and error responses
  1801. opt.beforeSend = function (xhr) {
  1802. if (config.beforeSend) {
  1803. config.sender[config.beforeSend](opt, xhr, params);
  1804. }
  1805. };
  1806. opt.success = function (data) {
  1807. console.log("TRACE: The url is: " + opt.url);
  1808. if (config.success) {
  1809. config.sender[config.success](data, opt, params);
  1810. }
  1811. };
  1812. opt.error = function (request, ajaxOptions, error) {
  1813. if (config.error) {
  1814. config.sender[config.error](request, ajaxOptions, error, opt, params);
  1815. } else {
  1816. this.defaultErrorHandler(request, opt.url, opt.type);
  1817. }
  1818. };
  1819. opt.complete = function () {
  1820. if (config.callback) {
  1821. config.callback();
  1822. }
  1823. };
  1824. if ($.mocho) {
  1825. opt.url = 'http://' + $.hostName + opt.url;
  1826. }
  1827. return $.ajax(opt);
  1828. },
  1829. // A single instance of App.ModalPopup view
  1830. modalPopup: null,
  1831. /**
  1832. * defaultErrorHandler function is referred from App.ajax.send function and App.HttpClient.defaultErrorHandler function
  1833. * @jqXHR {jqXHR Object}
  1834. * @url {string}
  1835. * @method {String} Http method
  1836. * @showStatus {number} HTTP response code which should be shown. Default is 500.
  1837. */
  1838. defaultErrorHandler: function (jqXHR, url, method, showStatus) {
  1839. method = method || 'GET';
  1840. var self = this;
  1841. var api = " received on " + method + " method for API: " + url;
  1842. try {
  1843. var json = $.parseJSON(jqXHR.responseText);
  1844. var message = json.message;
  1845. } catch (err) {
  1846. }
  1847. if (!showStatus) {
  1848. showStatus = 500;
  1849. }
  1850. var statusCode = jqXHR.status + " status code";
  1851. if (jqXHR.status === showStatus && !this.modalPopup) {
  1852. this.modalPopup = App.ModalPopup.show({
  1853. header: jqXHR.statusText,
  1854. secondary: false,
  1855. onPrimary: function () {
  1856. this.hide();
  1857. self.modalPopup = null;
  1858. },
  1859. bodyClass: Ember.View.extend({
  1860. classNames: ['api-error'],
  1861. templateName: require('templates/utils/ajax'),
  1862. api: api,
  1863. statusCode: statusCode,
  1864. message: message,
  1865. showMessage: !!message
  1866. })
  1867. });
  1868. }
  1869. }
  1870. });
  1871. /**
  1872. * Add few access-methods for test purposes
  1873. */
  1874. if ($.mocho) {
  1875. ajax.reopen({
  1876. /**
  1877. * Don't use it anywhere except tests!
  1878. * @returns {Array}
  1879. */
  1880. fakeGetUrlNames: function() {
  1881. return Em.keys(urls);
  1882. },
  1883. /**
  1884. * Don't use it anywhere except tests!
  1885. * @param name
  1886. * @returns {*}
  1887. */
  1888. fakeGetUrl: function(name) {
  1889. return urls[name];
  1890. },
  1891. /**
  1892. * Don't use it anywhere except tests!
  1893. * @param url
  1894. * @param data
  1895. * @returns {String}
  1896. */
  1897. fakeFormatUrl: function(url, data) {
  1898. return formatUrl(url, data);
  1899. },
  1900. /**
  1901. * Don't use it anywhere except tests!
  1902. * @param urlObj
  1903. * @param data
  1904. * @returns {Object}
  1905. */
  1906. fakeFormatRequest: function(urlObj, data) {
  1907. return formatRequest.call(urlObj, data);
  1908. }
  1909. });
  1910. }
  1911. App.ajax = ajax.create({});
  1912. App.formatRequest = formatRequest;
  1913. App.urls = urls;