ajax.js 63 KB

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