ajax.js 64 KB

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