ajax.js 60 KB

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