ajax.js 67 KB

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