ajax.js 59 KB

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