ajax.js 65 KB

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