ajax.js 68 KB

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