ajax.js 62 KB

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