ajax.js 68 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. /**
  20. * Config for each ajax-request
  21. *
  22. * Fields example:
  23. * mock - testMode url
  24. * real - real url (without API prefix)
  25. * type - request type (also may be defined in the format method)
  26. * format - function for processing ajax params after default formatRequest. May be called with one or two parameters (data, opt). Return ajax-params object
  27. * testInProduction - can this request be executed on production tests (used only in tests)
  28. *
  29. * @type {Object}
  30. */
  31. var urls = {
  32. '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_name,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.source_accepted': {
  492. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/flume/flume/SOURCE/*/EventAcceptedCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  493. 'mock': '/data/services/metrics/flume/sourceEventAccepted.json',
  494. 'testInProduction': true
  495. },
  496. 'service.metrics.flume.channel_size_for_all': {
  497. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=metrics/flume/flume/CHANNEL/ChannelSize/_sum[{fromSeconds},{toSeconds},{stepSeconds}]'
  498. },
  499. 'service.metrics.flume.gc': {
  500. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  501. 'mock': '/data/services/metrics/flume/jvmGcTime.json',
  502. 'testInProduction': true
  503. },
  504. 'service.metrics.flume.jvm_heap_used': {
  505. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/jvm/memHeapUsedM[{fromSeconds},{toSeconds},{stepSeconds}]',
  506. 'mock': '/data/services/metrics/flume/jvmMemHeapUsedM.json',
  507. 'testInProduction': true
  508. },
  509. 'service.metrics.flume.jvm_threads_runnable': {
  510. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/jvm/threadsRunnable[{fromSeconds},{toSeconds},{stepSeconds}]',
  511. 'mock': '/data/services/metrics/flume/jvmThreadsRunnable.json',
  512. 'testInProduction': true
  513. },
  514. 'service.metrics.flume.cpu_user': {
  515. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/cpu/cpu_user[{fromSeconds},{toSeconds},{stepSeconds}]',
  516. 'mock': '',
  517. 'testInProduction': true
  518. },
  519. 'service.metrics.flume.incoming_event_put_successCount': {
  520. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=metrics/flume/flume/CHANNEL/EventPutSuccessCount/rate[{fromSeconds},{toSeconds},{stepSeconds}]'
  521. },
  522. 'service.metrics.flume.outgoing_event_take_success_count': {
  523. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=metrics/flume/flume/CHANNEL/EventTakeSuccessCount/rate[{fromSeconds},{toSeconds},{stepSeconds}]'
  524. },
  525. 'service.metrics.hbase.cluster_requests': {
  526. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/cluster_requests[{fromSeconds},{toSeconds},{stepSeconds}]',
  527. 'mock': '/data/services/metrics/hbase/cluster_requests.json',
  528. 'testInProduction': true
  529. },
  530. 'service.metrics.hbase.hlog_split_size': {
  531. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/splitSize_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  532. 'mock': '/data/services/metrics/hbase/hlog_split_size.json',
  533. 'testInProduction': true
  534. },
  535. 'service.metrics.hbase.hlog_split_time': {
  536. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/splitTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  537. 'mock': '/data/services/metrics/hbase/hlog_split_time.json',
  538. 'testInProduction': true
  539. },
  540. 'service.metrics.hbase.regionserver_queuesize': {
  541. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/flushQueueSize[{fromSeconds},{toSeconds},{stepSeconds}],metrics/hbase/regionserver/compactionQueueSize[{fromSeconds},{toSeconds},{stepSeconds}]',
  542. 'mock': '/data/services/metrics/hbase/regionserver_queuesize.json',
  543. 'testInProduction': true
  544. },
  545. 'service.metrics.hbase.regionserver_regions': {
  546. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/regions[{fromSeconds},{toSeconds},{stepSeconds}]',
  547. 'mock': '/data/services/metrics/hbase/regionserver_regions.json',
  548. 'testInProduction': true
  549. },
  550. 'service.metrics.hbase.regionserver_rw_requests': {
  551. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/readRequestsCount[{fromSeconds},{toSeconds},{stepSeconds}],metrics/hbase/regionserver/writeRequestsCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  552. 'mock': '/data/services/metrics/hbase/regionserver_rw_requests.json',
  553. 'testInProduction': true
  554. },
  555. 'service.metrics.mapreduce.gc': {
  556. 'real': '/clusters/{clusterName}/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  557. 'mock': '/data/services/metrics/mapreduce/gc.json',
  558. 'testInProduction': true
  559. },
  560. 'service.metrics.mapreduce.jobs_status': {
  561. '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}]',
  562. 'mock': '/data/services/metrics/mapreduce/jobs_status.json',
  563. 'testInProduction': true
  564. },
  565. 'service.metrics.mapreduce.jobs_heap': {
  566. '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}]',
  567. 'mock': '/data/services/metrics/mapreduce/jvm_heap.json',
  568. 'testInProduction': true
  569. },
  570. 'service.metrics.mapreduce.jobs_threads': {
  571. '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}]',
  572. 'mock': '/data/services/metrics/mapreduce/jvm_threads.json',
  573. 'testInProduction': true
  574. },
  575. 'service.metrics.mapreduce.map_slots': {
  576. '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}]',
  577. 'mock': '/data/services/metrics/mapreduce/map_slots.json',
  578. 'testInProduction': true
  579. },
  580. 'service.metrics.mapreduce.reduce_slots': {
  581. '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}]',
  582. 'mock': '/data/services/metrics/mapreduce/reduce_slots.json',
  583. 'testInProduction': true
  584. },
  585. 'service.metrics.mapreduce.rpc': {
  586. 'real': '/clusters/{clusterName}/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  587. 'mock': '/data/services/metrics/mapreduce/rpc.json',
  588. 'testInProduction': true
  589. },
  590. 'service.metrics.mapreduce.tasks_running_waiting': {
  591. '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}]',
  592. 'mock': '/data/services/metrics/mapreduce/tasks_running_waiting.json',
  593. 'testInProduction': true
  594. },
  595. 'service.metrics.hdfs.block_status': {
  596. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/dfs/FSNamesystem/PendingReplicationBlocks[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/FSNamesystem/UnderReplicatedBlocks[{fromSeconds},{toSeconds},{stepSeconds}]',
  597. 'mock': '/data/services/metrics/hdfs/block_status.json',
  598. 'testInProduction': true
  599. },
  600. 'service.metrics.hdfs.file_operations': {
  601. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/dfs/namenode/FileInfoOps[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/namenode/CreateFileOps[{fromSeconds},{toSeconds},{stepSeconds}]',
  602. 'mock': '/data/services/metrics/hdfs/file_operations.json',
  603. 'testInProduction': true
  604. },
  605. 'service.metrics.hdfs.gc': {
  606. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  607. 'mock': '/data/services/metrics/hdfs/gc.json',
  608. 'testInProduction': true
  609. },
  610. 'service.metrics.hdfs.io': {
  611. 'real': '/clusters/{clusterName}/services/HDFS/components/DATANODE?fields=metrics/dfs/datanode/bytes_written[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/datanode/bytes_read[{fromSeconds},{toSeconds},{stepSeconds}]',
  612. 'mock': '/data/services/metrics/hdfs/io.json',
  613. 'testInProduction': true
  614. },
  615. 'service.metrics.hdfs.jvm_heap': {
  616. '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}]',
  617. 'mock': '/data/services/metrics/hdfs/jvm_heap.json',
  618. 'testInProduction': true
  619. },
  620. 'service.metrics.hdfs.jvm_threads': {
  621. '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}]',
  622. 'mock': '/data/services/metrics/hdfs/jvm_threads.json',
  623. 'testInProduction': true
  624. },
  625. 'service.metrics.hdfs.rpc': {
  626. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  627. 'mock': '/data/services/metrics/hdfs/rpc.json',
  628. 'testInProduction': true
  629. },
  630. 'service.metrics.hdfs.space_utilization': {
  631. '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}]',
  632. 'mock': '/data/services/metrics/hdfs/space_utilization.json',
  633. 'testInProduction': true
  634. },
  635. 'service.metrics.yarn.gc': {
  636. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  637. 'mock': '/data/services/metrics/yarn/gc.json',
  638. 'testInProduction': true
  639. },
  640. 'service.metrics.yarn.jobs_threads': {
  641. '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}]',
  642. 'mock': '/data/services/metrics/yarn/jvm_threads.json',
  643. 'testInProduction': true
  644. },
  645. 'service.metrics.yarn.rpc': {
  646. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  647. 'mock': '/data/services/metrics/yarn/rpc.json',
  648. 'testInProduction': true
  649. },
  650. 'service.metrics.yarn.jobs_heap': {
  651. '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}]',
  652. 'mock': '/data/services/metrics/yarn/jvm_heap.json',
  653. 'testInProduction': true
  654. },
  655. 'service.metrics.yarn.queue.allocated': {
  656. '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}]',
  657. 'mock': '',
  658. 'testInProduction': true
  659. },
  660. 'service.metrics.yarn.queue.allocated.container': {
  661. '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}]',
  662. 'mock': '',
  663. 'testInProduction': true
  664. },
  665. 'service.metrics.yarn.node.manager.statuses': {
  666. '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}]',
  667. 'mock': '',
  668. 'testInProduction': true
  669. },
  670. 'service.metrics.yarn.queue.memory.resource': {
  671. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=',
  672. 'mock': '',
  673. 'format': function (data, opt) {
  674. var field1 = 'metrics/yarn/Queue/{queueName}/AllocatedMB[{fromSeconds},{toSeconds},{stepSeconds}]';
  675. var field2 = 'metrics/yarn/Queue/{queueName}/AvailableMB[{fromSeconds},{toSeconds},{stepSeconds}]';
  676. if (opt.url != null && data.queueNames != null && data.queueNames.length > 0) {
  677. data.queueNames.forEach(function (q) {
  678. data.queueName = q;
  679. opt.url += (formatUrl(field1, data) + ",");
  680. opt.url += (formatUrl(field2, data) + ",");
  681. });
  682. } else {
  683. opt.url += (formatUrl(field1, data) + ",");
  684. opt.url += (formatUrl(field2, data) + ",");
  685. }
  686. },
  687. 'testInProduction': true
  688. },
  689. 'service.metrics.yarn.queue.apps.states.current': {
  690. '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}]',
  691. 'mock': '',
  692. 'testInProduction': true
  693. },
  694. 'service.metrics.yarn.queue.apps.states.finished': {
  695. '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}]',
  696. 'mock': '',
  697. 'testInProduction': true
  698. },
  699. 'service.metrics.storm.nimbus': {
  700. 'real': '/clusters/{clusterName}/services/STORM/components/NIMBUS?fields={metricsTemplate}',
  701. 'mock': ''
  702. },
  703. 'dashboard.cluster_metrics.cpu': {
  704. 'real': '/clusters/{clusterName}/?fields=metrics/cpu[{fromSeconds},{toSeconds},{stepSeconds}]',
  705. 'mock': '/data/cluster_metrics/cpu_1hr.json',
  706. 'testInProduction': true
  707. },
  708. 'dashboard.cluster_metrics.load': {
  709. 'real': '/clusters/{clusterName}/?fields=metrics/load[{fromSeconds},{toSeconds},{stepSeconds}]',
  710. 'mock': '/data/cluster_metrics/load_1hr.json',
  711. 'testInProduction': true
  712. },
  713. 'dashboard.cluster_metrics.memory': {
  714. 'real': '/clusters/{clusterName}/?fields=metrics/memory[{fromSeconds},{toSeconds},{stepSeconds}]',
  715. 'mock': '/data/cluster_metrics/memory_1hr.json',
  716. 'testInProduction': true
  717. },
  718. 'dashboard.cluster_metrics.network': {
  719. 'real': '/clusters/{clusterName}/?fields=metrics/network[{fromSeconds},{toSeconds},{stepSeconds}]',
  720. 'mock': '/data/cluster_metrics/network_1hr.json',
  721. 'testInProduction': true
  722. },
  723. 'host.metrics.cpu': {
  724. '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}]',
  725. 'mock': '/data/hosts/metrics/cpu.json',
  726. 'testInProduction': true
  727. },
  728. 'host.metrics.disk': {
  729. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/disk/disk_total[{fromSeconds},{toSeconds},{stepSeconds}],metrics/disk/disk_free[{fromSeconds},{toSeconds},{stepSeconds}]',
  730. 'mock': '/data/hosts/metrics/disk.json',
  731. 'testInProduction': true
  732. },
  733. 'host.metrics.load': {
  734. '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}]',
  735. 'mock': '/data/hosts/metrics/load.json',
  736. 'testInProduction': true
  737. },
  738. 'host.metrics.memory': {
  739. '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}]',
  740. 'mock': '/data/hosts/metrics/memory.json',
  741. 'testInProduction': true
  742. },
  743. 'host.metrics.network': {
  744. '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}]',
  745. 'mock': '/data/hosts/metrics/network.json',
  746. 'testInProduction': true
  747. },
  748. 'host.metrics.processes': {
  749. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/process/proc_total[{fromSeconds},{toSeconds},{stepSeconds}],metrics/process/proc_run[{fromSeconds},{toSeconds},{stepSeconds}]',
  750. 'mock': '/data/hosts/metrics/processes.json',
  751. 'testInProduction': true
  752. },
  753. 'admin.security_status': {
  754. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs',
  755. 'mock': '',
  756. 'format': function() {
  757. return {
  758. timeout: 10000
  759. };
  760. }
  761. },
  762. 'settings.get.user_pref': {
  763. 'real': '/persist/{key}',
  764. 'mock': '/data/user_settings/{key}.json'
  765. },
  766. 'settings.post.user_pref': {
  767. 'real': '/persist',
  768. 'mock': '',
  769. 'type': 'POST',
  770. 'format': function (data) {
  771. return {
  772. data: JSON.stringify(data.keyValuePair)
  773. }
  774. }
  775. },
  776. 'cluster.load_cluster_name': {
  777. 'real': '/clusters',
  778. 'mock': '/data/clusters/info.json'
  779. },
  780. 'cluster.update_upgrade_version': {
  781. 'real': '/stacks/HDP/versions?fields=stackServices/StackServices,Versions',
  782. 'mock': '/data/wizard/stack/stacks.json'
  783. },
  784. 'cluster.load_repositories': {
  785. 'real': '/stacks/{stackName}/versions/{stackVersion}/operating_systems?fields=repositories/*',
  786. 'mock': '',
  787. 'format': function (data) {
  788. return {
  789. data: data.data
  790. };
  791. }
  792. },
  793. 'admin.high_availability.polling': {
  794. 'real': '/clusters/{clusterName}/requests/{requestId}?fields=tasks/*,Requests/*',
  795. 'mock': ''
  796. },
  797. 'admin.high_availability.getNnCheckPointStatus': {
  798. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/NAMENODE',
  799. 'mock': ''
  800. },
  801. 'admin.high_availability.getJnCheckPointStatus': {
  802. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/JOURNALNODE?fields=metrics',
  803. 'mock': ''
  804. },
  805. 'admin.high_availability.getHostComponent': {
  806. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  807. 'mock': ''
  808. },
  809. 'admin.high_availability.create_component': {
  810. 'real': '/clusters/{clusterName}/hosts?Hosts/host_name={hostName}',
  811. 'mock': '',
  812. 'type': 'POST',
  813. 'format': function (data) {
  814. return {
  815. data: JSON.stringify({
  816. "host_components": [
  817. {
  818. "HostRoles": {
  819. "component_name": data.componentName
  820. }
  821. }
  822. ]
  823. })
  824. }
  825. }
  826. },
  827. 'admin.high_availability.create_journalnode': {
  828. 'real': '/clusters/{clusterName}/services?ServiceInfo/service_name=HDFS',
  829. 'mock': '',
  830. 'type': 'POST',
  831. 'format': function() {
  832. return {
  833. data: JSON.stringify({
  834. "components": [
  835. {
  836. "ServiceComponentInfo": {
  837. "component_name": "JOURNALNODE"
  838. }
  839. }
  840. ]
  841. })
  842. }
  843. }
  844. },
  845. 'admin.high_availability.create_zkfc': {
  846. 'real': '/clusters/{clusterName}/services?ServiceInfo/service_name=HDFS',
  847. 'mock': '',
  848. 'type': 'POST',
  849. 'format': function() {
  850. return {
  851. data: JSON.stringify({
  852. "components": [
  853. {
  854. "ServiceComponentInfo": {
  855. "component_name": "ZKFC"
  856. }
  857. }
  858. ]
  859. })
  860. }
  861. }
  862. },
  863. 'admin.high_availability.load_configs': {
  864. 'real': '/clusters/{clusterName}/configurations?(type=core-site&tag={coreSiteTag})|(type=hdfs-site&tag={hdfsSiteTag})',
  865. 'mock': ''
  866. },
  867. 'admin.high_availability.save_configs': {
  868. 'real': '/clusters/{clusterName}',
  869. 'mock': '',
  870. 'type': 'PUT',
  871. 'format': function (data) {
  872. return {
  873. data: JSON.stringify({
  874. Clusters: {
  875. desired_config: {
  876. "type": data.siteName,
  877. "tag": 'version' + (new Date).getTime(),
  878. "properties": data.properties
  879. }
  880. }
  881. })
  882. }
  883. }
  884. },
  885. 'admin.high_availability.load_hbase_configs': {
  886. 'real': '/clusters/{clusterName}/configurations?type=hbase-site&tag={hbaseSiteTag}',
  887. 'mock': ''
  888. },
  889. 'admin.security.cluster_configs': {
  890. 'real': '/clusters/{clusterName}',
  891. 'mock': '',
  892. 'format': function() {
  893. return {
  894. timeout: 10000
  895. };
  896. }
  897. },
  898. 'admin.get.all_configurations': {
  899. 'real': '/clusters/{clusterName}/configurations?{urlParams}',
  900. 'mock': '',
  901. 'format': function() {
  902. return {
  903. timeout: 10000
  904. };
  905. }
  906. },
  907. 'admin.security.apply_configurations': {
  908. 'real': '/clusters/{clusterName}',
  909. 'mock': '',
  910. 'format': function (data) {
  911. return {
  912. type: 'PUT',
  913. timeout: 10000,
  914. data: data.configData
  915. };
  916. }
  917. },
  918. 'admin.security.add.cluster_configs': {
  919. 'real': '/clusters/{clusterName}' + '?fields=Clusters/desired_configs',
  920. 'mock': '',
  921. 'format': function() {
  922. return {
  923. timeout: 10000
  924. };
  925. }
  926. },
  927. 'admin.stack_upgrade.run_upgrade': {
  928. 'real': '/clusters/{clusterName}',
  929. 'mock': '',
  930. 'format': function (data) {
  931. return {
  932. type: 'PUT',
  933. data: data.data
  934. };
  935. }
  936. },
  937. 'admin.user.create': {
  938. 'real': '/users/{user}',
  939. 'mock': '/data/users/users.json',
  940. 'format': function(data) {
  941. return {
  942. type: 'POST',
  943. data: JSON.stringify(data.data)
  944. }
  945. }
  946. },
  947. 'admin.user.edit': {
  948. 'real': '/users/{user}',
  949. 'mock':'/data/users/users.json',
  950. 'format': function(data) {
  951. return {
  952. type: 'PUT',
  953. data: data.data
  954. }
  955. }
  956. },
  957. 'admin.stack_upgrade.do_poll': {
  958. 'real': '/clusters/{cluster}/requests/{requestId}?fields=tasks/*',
  959. 'mock': '/data/wizard/{mock}'
  960. },
  961. 'wizard.advanced_repositories.valid_url': {
  962. 'real': '/stacks/{stackName}/versions/{stackVersion}/operating_systems/{osType}/repositories/{repoId}',
  963. 'mock': '',
  964. 'type': 'PUT',
  965. 'format': function (data) {
  966. return {
  967. data: JSON.stringify(data.data)
  968. }
  969. }
  970. },
  971. 'wizard.service_components': {
  972. 'real': '{stackUrl}/services?fields=StackServices/*,serviceComponents/*',
  973. 'mock': '/data/stacks/HDP-2.1/service_components.json',
  974. 'format': function(data) {
  975. return {
  976. timeout: 10000
  977. };
  978. }
  979. },
  980. 'wizard.step9.installer.get_host_status': {
  981. 'real': '/clusters/{cluster}/hosts?fields=Hosts/host_state,host_components/HostRoles/state',
  982. 'mock': '/data/wizard/deploy/5_hosts/get_host_state.json'
  983. },
  984. 'wizard.step9.load_log': {
  985. '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',
  986. 'mock': '/data/wizard/deploy/5_hosts/poll_{numPolls}.json',
  987. 'format': function () {
  988. return {
  989. dataType: 'text'
  990. };
  991. }
  992. },
  993. 'wizard.step8.existing_cluster_names': {
  994. 'real': '/clusters',
  995. 'mock': ''
  996. },
  997. 'wizard.step8.create_cluster': {
  998. 'real':'/clusters/{cluster}',
  999. 'mock':'',
  1000. 'format': function(data) {
  1001. return {
  1002. type: 'POST',
  1003. dataType: 'text',
  1004. data: data.data
  1005. }
  1006. }
  1007. },
  1008. 'wizard.step8.create_selected_services': {
  1009. 'real':'/clusters/{cluster}/services',
  1010. 'mock':'',
  1011. 'format': function(data) {
  1012. return {
  1013. type: 'POST',
  1014. dataType: 'text',
  1015. data: data.data
  1016. }
  1017. }
  1018. },
  1019. 'wizard.step8.create_components': {
  1020. 'real':'/clusters/{cluster}/services?ServiceInfo/service_name={serviceName}',
  1021. 'mock':'',
  1022. 'format': function(data) {
  1023. return {
  1024. type: 'POST',
  1025. dataType: 'text',
  1026. data: data.data
  1027. }
  1028. }
  1029. },
  1030. 'wizard.step8.register_host_to_cluster': {
  1031. 'real':'/clusters/{cluster}/hosts',
  1032. 'mock':'',
  1033. 'format': function(data) {
  1034. return {
  1035. type: 'POST',
  1036. dataType: 'text',
  1037. data: data.data
  1038. }
  1039. }
  1040. },
  1041. 'wizard.step8.register_host_to_component': {
  1042. 'real':'/clusters/{cluster}/hosts',
  1043. 'mock':'',
  1044. 'format': function(data) {
  1045. return {
  1046. type: 'POST',
  1047. dataType: 'text',
  1048. data: data.data
  1049. }
  1050. }
  1051. },
  1052. 'wizard.step8.apply_configuration_to_cluster': {
  1053. 'real':'/clusters/{cluster}',
  1054. 'mock':'',
  1055. 'format': function(data) {
  1056. return {
  1057. type: 'PUT',
  1058. dataType: 'text',
  1059. data: data.data
  1060. }
  1061. }
  1062. },
  1063. 'wizard.step8.apply_configuration_groups': {
  1064. 'real':'/clusters/{cluster}/config_groups',
  1065. 'mock':'',
  1066. 'format': function(data) {
  1067. return {
  1068. type: 'POST',
  1069. dataType: 'text',
  1070. data: data.data
  1071. }
  1072. }
  1073. },
  1074. 'wizard.step8.set_local_repos': {
  1075. 'real':'{stackVersionURL}/operating_systems/{osType}/repositories/{repoId}',
  1076. 'mock':'',
  1077. 'format': function(data) {
  1078. return {
  1079. type: 'PUT',
  1080. dataType: 'text',
  1081. data: data.data
  1082. }
  1083. }
  1084. },
  1085. 'wizard.step3.jdk_check': {
  1086. 'real': '/requests',
  1087. 'mock': '',
  1088. 'format': function (data) {
  1089. return {
  1090. type: 'POST',
  1091. data: JSON.stringify({
  1092. "RequestInfo": {
  1093. "context": "Check hosts",
  1094. "action": "check_host",
  1095. "parameters" : {
  1096. "threshold" : "60",
  1097. "java_home" : data.java_home,
  1098. "jdk_location": data.jdk_location,
  1099. "check_execute_list" : "java_home_check"
  1100. }
  1101. },
  1102. "Requests/resource_filters": [{
  1103. "hosts": data.host_names
  1104. }]
  1105. })
  1106. }
  1107. }
  1108. },
  1109. 'wizard.step3.jdk_check.get_results': {
  1110. 'real': '/requests/{requestIndex}?fields=*,tasks/Tasks/host_name,tasks/Tasks/status,tasks/Tasks/structured_out',
  1111. 'mock': '/data/requests/host_check/jdk_check_results.json'
  1112. },
  1113. 'wizard.step3.host_info': {
  1114. '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',
  1115. 'mock': '/data/wizard/bootstrap/two_hosts_information.json',
  1116. 'format': function() {
  1117. return {
  1118. contentType: 'application/json'
  1119. };
  1120. }
  1121. },
  1122. 'wizard.step5.recommendations': {
  1123. 'real': '{stackVersionUrl}/recommendations',
  1124. 'mock': '/data/stacks/HDP-2.1/recommendations.json',
  1125. 'type': 'POST',
  1126. 'format': function (data) {
  1127. return {
  1128. data: JSON.stringify({
  1129. hosts: data.hosts,
  1130. services: data.services
  1131. })
  1132. }
  1133. }
  1134. },
  1135. 'preinstalled.checks': {
  1136. 'real':'/requests',
  1137. 'mock':'',
  1138. 'format': function(data) {
  1139. return {
  1140. type : 'POST',
  1141. data : JSON.stringify({
  1142. "RequestInfo": data.RequestInfo,
  1143. "Requests/resource_filters": [data.resource_filters]
  1144. })
  1145. }
  1146. }
  1147. },
  1148. 'preinstalled.checks.tasks': {
  1149. 'real':'/requests/{requestId}?fields=tasks/Tasks',
  1150. 'mock':'/data/requests/host_check/1.json'
  1151. },
  1152. 'wizard.step3.rerun_checks': {
  1153. 'real': '/hosts?fields=Hosts/last_agent_env',
  1154. 'mock': '/data/wizard/bootstrap/two_hosts_information.json',
  1155. 'format': function() {
  1156. return {
  1157. contentType: 'application/json'
  1158. };
  1159. }
  1160. },
  1161. 'wizard.step3.bootstrap': {
  1162. 'real': '/bootstrap/{bootRequestId}',
  1163. 'mock': '/data/wizard/bootstrap/poll_{numPolls}.json'
  1164. },
  1165. 'wizard.step3.is_hosts_registered': {
  1166. 'real': '/hosts',
  1167. 'mock': '/data/wizard/bootstrap/single_host_registration.json'
  1168. },
  1169. 'wizard.stacks': {
  1170. 'real': '/stacks',
  1171. 'mock': '/data/wizard/stack/stacks2.json'
  1172. },
  1173. 'wizard.stacks_versions': {
  1174. 'real': '/stacks/{stackName}/versions?fields=Versions,operatingSystems/repositories/Repositories',
  1175. 'mock': '/data/wizard/stack/{stackName}_versions.json'
  1176. },
  1177. 'wizard.launch_bootstrap': {
  1178. 'real': '/bootstrap',
  1179. 'mock': '/data/wizard/bootstrap/bootstrap.json',
  1180. 'type': 'POST',
  1181. 'format': function (data) {
  1182. return {
  1183. contentType: 'application/json',
  1184. data: data.bootStrapData,
  1185. popup: data.popup
  1186. }
  1187. }
  1188. },
  1189. 'router.login': {
  1190. 'real': '/users/{loginName}',
  1191. 'mock': '/data/users/user_{usr}.json',
  1192. 'format': function (data) {
  1193. var statusCode = jQuery.extend({}, require('data/statusCodes'));
  1194. statusCode['403'] = function () {
  1195. console.log("Error code 403: Forbidden.");
  1196. };
  1197. return {
  1198. statusCode: statusCode
  1199. };
  1200. }
  1201. },
  1202. 'router.login2': {
  1203. 'real': '/clusters',
  1204. 'mock': '/data/clusters/info.json'
  1205. },
  1206. 'router.logoff': {
  1207. 'real': '/logout',
  1208. 'mock': ''
  1209. },
  1210. 'router.authentication': {
  1211. 'real': '/clusters',
  1212. 'mock': '/data/clusters/info.json',
  1213. 'format': function() {
  1214. return {
  1215. async: false
  1216. };
  1217. }
  1218. },
  1219. 'ambari.service.load_jdk_name': {
  1220. 'real': '/services/AMBARI/components/AMBARI_SERVER?fields=RootServiceComponents/properties/jdk.name,RootServiceComponents/properties/java.home,RootServiceComponents/properties/jdk_location',
  1221. 'mock': '/data/requests/host_check/jdk_name.json'
  1222. },
  1223. 'ambari.service.load_server_version': {
  1224. 'real': '/services/AMBARI/components/AMBARI_SERVER?fields=RootServiceComponents/component_version',
  1225. 'mock': ''
  1226. },
  1227. 'ambari.service': {
  1228. 'real': '/services/AMBARI/components/AMBARI_SERVER',
  1229. 'mock': '/data/services/ambari_server.json'
  1230. },
  1231. 'ambari.service.load_server_clock': {
  1232. 'real': '/services/AMBARI/components/AMBARI_SERVER?fields=RootServiceComponents/server_clock',
  1233. 'mock': ''
  1234. },
  1235. 'config_groups.create': {
  1236. 'real': '/clusters/{clusterName}/config_groups',
  1237. 'mock': '',
  1238. 'format': function (data) {
  1239. return {
  1240. type: 'POST',
  1241. data: JSON.stringify([{
  1242. "ConfigGroup": {
  1243. "group_name": data.group_name,
  1244. "tag": data.service_id,
  1245. "description": data.description,
  1246. "desired_configs": data.desired_configs,
  1247. "hosts": data.hosts
  1248. }
  1249. }])
  1250. }
  1251. }
  1252. },
  1253. 'config_groups.update': {
  1254. 'real': '/clusters/{clusterName}/config_groups/{id}',
  1255. 'mock': '',
  1256. 'format': function (data) {
  1257. return {
  1258. type: 'PUT',
  1259. data: JSON.stringify(data.data)
  1260. }
  1261. }
  1262. },
  1263. 'rolling_restart.post': {
  1264. 'real': '/clusters/{clusterName}/request_schedules',
  1265. 'mock': '',
  1266. 'format' : function(data) {
  1267. return {
  1268. type : 'POST',
  1269. data : JSON.stringify([ {
  1270. "RequestSchedule" : {
  1271. "batch" : [ {
  1272. "requests" : data.batches
  1273. }, {
  1274. "batch_settings" : {
  1275. "batch_separation_in_seconds" : data.intervalTimeSeconds,
  1276. "task_failure_tolerance" : data.tolerateSize
  1277. }
  1278. } ]
  1279. }
  1280. } ])
  1281. }
  1282. }
  1283. },
  1284. 'request_schedule.get': {
  1285. 'real': '/clusters/{clusterName}/request_schedules/{request_schedule_id}',
  1286. 'mock': ''
  1287. },
  1288. 'restart.hostComponents': {
  1289. 'real':'/clusters/{clusterName}/requests',
  1290. 'mock':'',
  1291. 'format': function(data) {
  1292. return {
  1293. type : 'POST',
  1294. data : JSON.stringify({
  1295. "RequestInfo": {
  1296. "command": "RESTART",
  1297. "context": data.context,
  1298. "operation_level": data.operation_level
  1299. },
  1300. "Requests/resource_filters": data.resource_filters
  1301. })
  1302. }
  1303. }
  1304. },
  1305. 'mirroring.get_all_entities': {
  1306. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/list/{type}?fields=status&user.name=ambari-qa',
  1307. 'mock': '/data/mirroring/{type}s.xml',
  1308. 'apiPrefix': '',
  1309. 'format': function () {
  1310. return {
  1311. dataType: 'xml'
  1312. }
  1313. }
  1314. },
  1315. 'mirroring.get_definition': {
  1316. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/definition/{type}/{name}?user.name=ambari-qa',
  1317. 'mock': '/data/mirroring/{name}_definition.xml',
  1318. 'apiPrefix': '',
  1319. 'format': function () {
  1320. return {
  1321. cache: true,
  1322. dataType: 'xml'
  1323. }
  1324. }
  1325. },
  1326. 'mirroring.dataset.get_all_instances': {
  1327. 'real': '/proxy?url=http://{falconServer}:15000/api/instance/status/feed/{dataset}?start={start}&end={end}&user.name=ambari-qa',
  1328. 'mock': '/data/mirroring/{dataset}_instances.json',
  1329. 'apiPrefix': ''
  1330. },
  1331. 'mirroring.create_new_dataset': {
  1332. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/submitAndSchedule/feed?user.name=ambari-qa',
  1333. 'mock': '/data/mirroring/succeeded.json',
  1334. 'apiPrefix': '',
  1335. 'type': 'POST',
  1336. 'format': function (data) {
  1337. return {
  1338. contentType: 'text/xml',
  1339. dataType: 'xml',
  1340. data: data.entity,
  1341. headers: {
  1342. 'AmbariProxy-Content-Type': 'text/xml'
  1343. }
  1344. }
  1345. }
  1346. },
  1347. 'mirroring.submit_entity': {
  1348. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/submit/{type}?user.name=ambari-qa',
  1349. 'mock': '/data/mirroring/succeeded.json',
  1350. 'apiPrefix': '',
  1351. 'type': 'POST',
  1352. 'format': function (data) {
  1353. return {
  1354. contentType: 'text/xml',
  1355. dataType: 'xml',
  1356. data: data.entity,
  1357. headers: {
  1358. 'AmbariProxy-Content-Type': 'text/xml'
  1359. }
  1360. }
  1361. }
  1362. },
  1363. 'mirroring.update_entity': {
  1364. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/update/{type}/{name}?user.name=ambari-qa',
  1365. 'mock': '/data/mirroring/succeeded.json',
  1366. 'apiPrefix': '',
  1367. 'type': 'POST',
  1368. 'format': function (data) {
  1369. return {
  1370. contentType: 'text/xml',
  1371. dataType: 'xml',
  1372. data: data.entity,
  1373. headers: {
  1374. 'AmbariProxy-Content-Type': 'text/xml'
  1375. }
  1376. }
  1377. }
  1378. },
  1379. 'mirroring.delete_entity': {
  1380. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/delete/{type}/{name}?user.name=ambari-qa',
  1381. 'mock': '/data/mirroring/succeeded.json',
  1382. 'apiPrefix': '',
  1383. 'type': 'DELETE',
  1384. 'format': function () {
  1385. return {
  1386. dataType: 'xml'
  1387. }
  1388. }
  1389. },
  1390. 'mirroring.suspend_entity': {
  1391. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/suspend/{type}/{name}?user.name=ambari-qa',
  1392. 'mock': '/data/mirroring/succeeded.json',
  1393. 'apiPrefix': '',
  1394. 'type': 'POST',
  1395. 'format': function (data) {
  1396. return {
  1397. dataType: 'xml',
  1398. data: data.entity
  1399. }
  1400. }
  1401. },
  1402. 'mirroring.resume_entity': {
  1403. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/resume/{type}/{name}?user.name=ambari-qa',
  1404. 'mock': '/data/mirroring/succeeded.json',
  1405. 'apiPrefix': '',
  1406. 'type': 'POST',
  1407. 'format': function () {
  1408. return {
  1409. dataType: 'xml'
  1410. }
  1411. }
  1412. },
  1413. 'mirroring.schedule_entity': {
  1414. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/schedule/{type}/{name}?user.name=ambari-qa',
  1415. 'mock': '/data/mirroring/succeeded.json',
  1416. 'apiPrefix': '',
  1417. 'type': 'POST',
  1418. 'format': function () {
  1419. return {
  1420. dataType: 'xml'
  1421. }
  1422. }
  1423. },
  1424. 'mirroring.suspend_instance': {
  1425. 'real': '/proxy?url=http://{falconServer}:15000/api/instance/suspend/feed/{feed}?start={name}&user.name=ambari-qa',
  1426. 'mock': '/data/mirroring/succeeded.json',
  1427. 'apiPrefix': '',
  1428. 'type': 'POST'
  1429. },
  1430. 'mirroring.resume_instance': {
  1431. 'real': '/proxy?url=http://{falconServer}:15000/api/instance/resume/feed/{feed}?start={name}&user.name=ambari-qa',
  1432. 'mock': '/data/mirroring/succeeded.json',
  1433. 'apiPrefix': '',
  1434. 'type': 'POST'
  1435. },
  1436. 'mirroring.kill_instance': {
  1437. 'real': '/proxy?url=http://{falconServer}:15000/api/instance/kill/feed/{feed}?start={name}&user.name=ambari-qa',
  1438. 'mock': '/data/mirroring/succeeded.json',
  1439. 'apiPrefix': '',
  1440. 'type': 'POST'
  1441. },
  1442. 'bulk_request.decommission': {
  1443. 'real' : '/clusters/{clusterName}/requests',
  1444. 'mock' : '',
  1445. 'format': function(data) {
  1446. return {
  1447. type: 'POST',
  1448. data: JSON.stringify({
  1449. 'RequestInfo': {
  1450. 'context': data.context,
  1451. 'command': 'DECOMMISSION',
  1452. 'parameters': data.parameters,
  1453. 'operation_level': {
  1454. 'level': "CLUSTER",
  1455. 'cluster_name': data.clusterName
  1456. }
  1457. },
  1458. "Requests/resource_filters": [{"service_name" : data.serviceName, "component_name" : data.componentName}]
  1459. })
  1460. }
  1461. }
  1462. },
  1463. 'bulk_request.hosts.passive_state': {
  1464. 'real': '/clusters/{clusterName}/hosts',
  1465. 'mock': '',
  1466. 'format': function(data) {
  1467. return {
  1468. type: 'PUT',
  1469. data: JSON.stringify({
  1470. RequestInfo: {
  1471. context: data.requestInfo,
  1472. query: 'Hosts/host_name.in(' + data.hostNames + ')'
  1473. },
  1474. Body: {
  1475. Hosts: {
  1476. maintenance_state: data.passive_state
  1477. }
  1478. }
  1479. })
  1480. }
  1481. }
  1482. },
  1483. 'bulk_request.hosts.all_components.passive_state': {
  1484. 'real': '/clusters/{clusterName}/host_components',
  1485. 'mock': '',
  1486. 'format': function(data) {
  1487. return {
  1488. type: 'PUT',
  1489. data: JSON.stringify({
  1490. RequestInfo: {
  1491. context: data.requestInfo,
  1492. query: data.query
  1493. },
  1494. Body: {
  1495. HostRoles: {
  1496. maintenance_state: data.passive_state
  1497. }
  1498. }
  1499. })
  1500. }
  1501. }
  1502. },
  1503. 'jobs.lastID': {
  1504. 'real': '/proxy?url=http://{historyServerHostName}:{ahsWebPort}/ws/v1/timeline/HIVE_QUERY_ID?limit=1&secondaryFilter=tez:true',
  1505. 'mock': 'data/jobs/hive-queries.json',
  1506. 'apiPrefix': ''
  1507. },
  1508. 'jobs.tezDag.NametoID': {
  1509. 'real': '/proxy?url=http://{historyServerHostName}:{ahsWebPort}/ws/v1/timeline/TEZ_DAG_ID?primaryFilter=dagName:{tezDagName}',
  1510. 'mock': '/data/jobs/tezDag-name-to-id.json',
  1511. 'apiPrefix': ''
  1512. },
  1513. 'jobs.tezDag.tezDagId': {
  1514. 'real': '/proxy?url=http://{historyServerHostName}:{ahsWebPort}/ws/v1/timeline/TEZ_DAG_ID/{tezDagId}?fields=relatedentities,otherinfo',
  1515. 'mock': '/data/jobs/tezDag.json',
  1516. 'apiPrefix': ''
  1517. },
  1518. 'jobs.tezDag.tezDagVertexId': {
  1519. 'real': '/proxy?url=http://{historyServerHostName}:{ahsWebPort}/ws/v1/timeline/TEZ_VERTEX_ID/{tezDagVertexId}?fields=otherinfo',
  1520. 'mock': '/data/jobs/tezDagVertex.json',
  1521. 'apiPrefix': ''
  1522. },
  1523. 'views.info': {
  1524. 'real': '/views',
  1525. 'mock':''
  1526. },
  1527. /**
  1528. * Get all instances of all views across versions
  1529. */
  1530. 'views.instances': {
  1531. 'real': '/views?fields=versions/instances/ViewInstanceInfo,versions/ViewVersionInfo/label',
  1532. 'mock':''
  1533. },
  1534. 'host.host_component.flume.metrics': {
  1535. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/FLUME_HANDLER?fields=metrics/flume/flume/{flumeComponent}/*',
  1536. 'mock': ''
  1537. },
  1538. 'host.host_component.flume.metrics.timeseries': {
  1539. 'real': '',
  1540. 'mock': '',
  1541. format: function (data) {
  1542. return {
  1543. url: data.url
  1544. }
  1545. }
  1546. },
  1547. 'host.host_components.filtered': {
  1548. 'real': '/clusters/{clusterName}/hosts?{fields}',
  1549. 'mock': '',
  1550. format: function(data) {
  1551. return {
  1552. headers: {
  1553. 'X-Http-Method-Override': 'GET'
  1554. },
  1555. type: 'POST',
  1556. data: JSON.stringify({
  1557. "RequestInfo": {"query" : data.parameters}
  1558. })
  1559. };
  1560. }
  1561. },
  1562. 'host.status.counters': {
  1563. 'real': '/clusters/{clusterName}?fields=alerts,Clusters/health_report,Clusters/total_hosts&minimal_response=true',
  1564. 'mock': '/data/hosts/HDP2/host_status_counters.json'
  1565. },
  1566. 'components.filter_by_status': {
  1567. 'real': '/clusters/{clusterName}/components?fields=host_components/HostRoles/host_name,ServiceComponentInfo/component_name,ServiceComponentInfo/started_count{urlParams}&minimal_response=true',
  1568. 'mock': ''
  1569. },
  1570. 'hosts.all.install': {
  1571. 'real': '/hosts?minimal_response=true',
  1572. 'mock': ''
  1573. },
  1574. 'hosts.all': {
  1575. 'real': '/clusters/{clusterName}/hosts?minimal_response=true',
  1576. 'mock': ''
  1577. },
  1578. 'hosts.with_public_host_names': {
  1579. 'real': '/clusters/{clusterName}/hosts?fields=Hosts/public_host_name&minimal_response=true',
  1580. 'mock': ''
  1581. },
  1582. 'hosts.for_quick_links': {
  1583. 'real': '/clusters/{clusterName}/hosts?Hosts/host_name.in({masterHosts})&fields=Hosts/public_host_name,host_components/HostRoles/component_name{urlParams}&minimal_response=true',
  1584. 'mock': ''
  1585. },
  1586. 'hosts.confirmed.install': {
  1587. 'real': '/hosts?fields=Hosts/cpu_count,Hosts/disk_info,Hosts/total_mem&minimal_response=true',
  1588. 'mock': ''
  1589. },
  1590. 'hosts.confirmed': {
  1591. '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',
  1592. 'mock': ''
  1593. },
  1594. 'host_components.all': {
  1595. 'real': '/clusters/{clusterName}/host_components?fields=HostRoles/host_name&minimal_response=true',
  1596. 'mock': ''
  1597. },
  1598. 'host_components.with_services_names': {
  1599. 'real': '/clusters/{clusterName}/host_components?fields=component/ServiceComponentInfo/service_name,HostRoles/host_name&minimal_response=true',
  1600. 'mock': ''
  1601. },
  1602. 'components.get_installed': {
  1603. 'real': '/clusters/{clusterName}/components',
  1604. 'mock': ''
  1605. },
  1606. 'hosts.heatmaps': {
  1607. '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',
  1608. 'mock': ''
  1609. },
  1610. 'custom_action.create': {
  1611. 'real': '/requests',
  1612. 'mock': '',
  1613. 'format': function(data) {
  1614. var requestInfo = {
  1615. context: 'Check host',
  1616. action: 'check_host',
  1617. parameters: { }
  1618. };
  1619. $.extend(true, requestInfo, data.requestInfo)
  1620. return {
  1621. type: 'POST',
  1622. data: JSON.stringify({
  1623. 'RequestInfo': requestInfo,
  1624. 'Requests/resource_filters': [{
  1625. hosts: data.filteredHosts.join(',')
  1626. }]
  1627. })
  1628. }
  1629. }
  1630. },
  1631. 'custom_action.request': {
  1632. 'real': '/requests/{requestId}/tasks/{taskId}',
  1633. 'mock': '',
  1634. 'format': function(data) {
  1635. return {
  1636. requestId: data.requestId,
  1637. taskId: data.taskId || ''
  1638. }
  1639. }
  1640. },
  1641. 'hosts.high_availability.wizard': {
  1642. 'real': '/clusters/{clusterName}/hosts?fields=Hosts/cpu_count,Hosts/disk_info,Hosts/total_mem&minimal_response=true',
  1643. 'mock': ''
  1644. },
  1645. 'hosts.security.wizard': {
  1646. 'real': '/clusters/{clusterName}/hosts?fields=host_components/HostRoles/service_name&minimal_response=true',
  1647. 'mock': ''
  1648. },
  1649. 'host_component.installed.on_hosts': {
  1650. 'real': '/clusters/{clusterName}/host_components?HostRoles/component_name={componentName}&HostRoles/host_name.in({hostNames})&fields=HostRoles/host_name&minimal_response=true',
  1651. 'mock': ''
  1652. },
  1653. 'hosts.by_component.one': {
  1654. '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',
  1655. 'mock': ''
  1656. },
  1657. 'hosts.by_component.all': {
  1658. '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',
  1659. 'mock': ''
  1660. },
  1661. 'hosts.config_groups': {
  1662. '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',
  1663. 'mock': ''
  1664. },
  1665. 'cluster.fields': {
  1666. real: '/clusters/{clusterName}?fields={fields}',
  1667. mock: '',
  1668. format: function(data) {
  1669. return {
  1670. async: true,
  1671. fields: data.fields.join(',')
  1672. }
  1673. }
  1674. },
  1675. 'hosts.host_components.pre_load': {
  1676. real: '',
  1677. mock: '',
  1678. format: function(data) {
  1679. return {
  1680. url: data.url
  1681. }
  1682. }
  1683. },
  1684. 'hosts.bulk.operations': {
  1685. real: '/clusters/{clusterName}/hosts?fields=Hosts/host_name,Hosts/maintenance_state,' +
  1686. 'host_components/HostRoles/state,host_components/HostRoles/maintenance_state,' +
  1687. 'host_components/HostRoles/stale_configs&minimal_response=true',
  1688. mock: '',
  1689. format: function(data) {
  1690. return {
  1691. headers: {
  1692. 'X-Http-Method-Override': 'GET'
  1693. },
  1694. type: 'POST',
  1695. data: JSON.stringify({
  1696. "RequestInfo": {"query" : data.parameters }
  1697. })
  1698. }
  1699. }
  1700. },
  1701. 'service.config.version.get': {
  1702. //TODO set actual url when API is ready
  1703. 'real': '',
  1704. 'mock': '',
  1705. format: function(data) {
  1706. return {
  1707. url: data.url
  1708. }
  1709. }
  1710. }
  1711. };
  1712. /**
  1713. * Replace data-placeholders to its values
  1714. *
  1715. * @param {String} url
  1716. * @param {Object} data
  1717. * @return {String}
  1718. */
  1719. var formatUrl = function (url, data) {
  1720. if (!url) return null;
  1721. var keys = url.match(/\{\w+\}/g);
  1722. keys = (keys === null) ? [] : keys;
  1723. if (keys) {
  1724. keys.forEach(function (key) {
  1725. var raw_key = key.substr(1, key.length - 2);
  1726. var replace;
  1727. if (!data || !data[raw_key]) {
  1728. replace = '';
  1729. }
  1730. else {
  1731. replace = data[raw_key];
  1732. }
  1733. url = url.replace(new RegExp(key, 'g'), replace);
  1734. });
  1735. }
  1736. return url;
  1737. };
  1738. /**
  1739. * this = object from config
  1740. * @return {Object}
  1741. */
  1742. var formatRequest = function (data) {
  1743. var opt = {
  1744. type: this.type || 'GET',
  1745. timeout: App.timeout,
  1746. dataType: 'json',
  1747. statusCode: require('data/statusCodes')
  1748. };
  1749. if (App.get('testMode')) {
  1750. opt.url = formatUrl(this.mock ? this.mock : '', data);
  1751. opt.type = 'GET';
  1752. }
  1753. else {
  1754. var prefix = this.apiPrefix != null ? this.apiPrefix : App.apiPrefix;
  1755. opt.url = prefix + formatUrl(this.real, data);
  1756. }
  1757. if (this.format) {
  1758. jQuery.extend(opt, this.format(data, opt));
  1759. }
  1760. return opt;
  1761. };
  1762. /**
  1763. * Wrapper for all ajax requests
  1764. *
  1765. * @type {Object}
  1766. */
  1767. var ajax = Em.Object.extend({
  1768. /**
  1769. * Send ajax request
  1770. *
  1771. * @param {Object} config
  1772. * @return {$.ajax} jquery ajax object
  1773. *
  1774. * config fields:
  1775. * name - url-key in the urls-object *required*
  1776. * sender - object that send request (need for proper callback initialization) *required*
  1777. * data - object with data for url-format
  1778. * beforeSend - method-name for ajax beforeSend response callback
  1779. * success - method-name for ajax success response callback
  1780. * error - method-name for ajax error response callback
  1781. * callback - callback from <code>App.updater.run</code> library
  1782. */
  1783. send: function (config) {
  1784. if (!config.sender) {
  1785. console.warn('Ajax sender should be defined!');
  1786. return null;
  1787. }
  1788. // default parameters
  1789. var params = {
  1790. clusterName: App.get('clusterName')
  1791. };
  1792. // extend default parameters with provided
  1793. if (config.data) {
  1794. jQuery.extend(params, config.data);
  1795. }
  1796. var opt = {};
  1797. if (!urls[config.name]) {
  1798. console.warn('Invalid name provided!');
  1799. return null;
  1800. }
  1801. opt = formatRequest.call(urls[config.name], params);
  1802. opt.context = this;
  1803. // object sender should be provided for processing beforeSend, success and error responses
  1804. opt.beforeSend = function (xhr) {
  1805. if (config.beforeSend) {
  1806. config.sender[config.beforeSend](opt, xhr, params);
  1807. }
  1808. };
  1809. opt.success = function (data) {
  1810. console.log("TRACE: The url is: " + opt.url);
  1811. if (config.success) {
  1812. config.sender[config.success](data, opt, params);
  1813. }
  1814. };
  1815. opt.error = function (request, ajaxOptions, error) {
  1816. if (config.error) {
  1817. config.sender[config.error](request, ajaxOptions, error, opt, params);
  1818. } else {
  1819. this.defaultErrorHandler(request, opt.url, opt.type);
  1820. }
  1821. };
  1822. opt.complete = function () {
  1823. if (config.callback) {
  1824. config.callback();
  1825. }
  1826. };
  1827. if ($.mocho) {
  1828. opt.url = 'http://' + $.hostName + opt.url;
  1829. }
  1830. return $.ajax(opt);
  1831. },
  1832. // A single instance of App.ModalPopup view
  1833. modalPopup: null,
  1834. /**
  1835. * defaultErrorHandler function is referred from App.ajax.send function and App.HttpClient.defaultErrorHandler function
  1836. * @jqXHR {jqXHR Object}
  1837. * @url {string}
  1838. * @method {String} Http method
  1839. * @showStatus {number} HTTP response code which should be shown. Default is 500.
  1840. */
  1841. defaultErrorHandler: function (jqXHR, url, method, showStatus) {
  1842. method = method || 'GET';
  1843. var self = this;
  1844. var api = " received on " + method + " method for API: " + url;
  1845. try {
  1846. var json = $.parseJSON(jqXHR.responseText);
  1847. var message = json.message;
  1848. } catch (err) {
  1849. }
  1850. if (!showStatus) {
  1851. showStatus = 500;
  1852. }
  1853. var statusCode = jqXHR.status + " status code";
  1854. if (jqXHR.status === showStatus && !this.modalPopup) {
  1855. this.modalPopup = App.ModalPopup.show({
  1856. header: Em.I18n.t('common.error'),
  1857. secondary: false,
  1858. onPrimary: function () {
  1859. this.hide();
  1860. self.modalPopup = null;
  1861. },
  1862. bodyClass: Ember.View.extend({
  1863. classNames: ['api-error'],
  1864. templateName: require('templates/utils/ajax'),
  1865. api: api,
  1866. statusCode: statusCode,
  1867. message: message,
  1868. showMessage: !!message
  1869. })
  1870. });
  1871. }
  1872. }
  1873. });
  1874. /**
  1875. * Add few access-methods for test purposes
  1876. */
  1877. if ($.mocho) {
  1878. ajax.reopen({
  1879. /**
  1880. * Don't use it anywhere except tests!
  1881. * @returns {Array}
  1882. */
  1883. fakeGetUrlNames: function() {
  1884. return Em.keys(urls);
  1885. },
  1886. /**
  1887. * Don't use it anywhere except tests!
  1888. * @param name
  1889. * @returns {*}
  1890. */
  1891. fakeGetUrl: function(name) {
  1892. return urls[name];
  1893. },
  1894. /**
  1895. * Don't use it anywhere except tests!
  1896. * @param url
  1897. * @param data
  1898. * @returns {String}
  1899. */
  1900. fakeFormatUrl: function(url, data) {
  1901. return formatUrl(url, data);
  1902. },
  1903. /**
  1904. * Don't use it anywhere except tests!
  1905. * @param urlObj
  1906. * @param data
  1907. * @returns {Object}
  1908. */
  1909. fakeFormatRequest: function(urlObj, data) {
  1910. return formatRequest.call(urlObj, data);
  1911. }
  1912. });
  1913. }
  1914. App.ajax = ajax.create({});