ajax.js 67 KB

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