ajax.js 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479
  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. 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. 'background_operations.get_most_recent': {
  33. 'real': '/clusters/{clusterName}/requests?to=end&page_size=10&fields=Requests',
  34. 'mock': '/data/background_operations/list_on_start.json',
  35. 'testInProduction': true
  36. },
  37. 'background_operations.get_by_request': {
  38. 'real': '/clusters/{clusterName}/requests/{requestId}?fields=*,tasks/Tasks/command,tasks/Tasks/exit_code,tasks/Tasks/host_name,tasks/Tasks/id,tasks/Tasks/role,tasks/Tasks/status',
  39. 'mock': '/data/background_operations/task_by_request{requestId}.json',
  40. 'testInProduction': true,
  41. 'format': function (data) {
  42. return {
  43. async: !data.sync
  44. };
  45. }
  46. },
  47. 'background_operations.get_by_task': {
  48. 'real': '/clusters/{clusterName}/requests/{requestId}/tasks/{taskId}',
  49. 'mock': '/data/background_operations/list_on_start.json',
  50. 'testInProduction': true,
  51. 'format': function (data) {
  52. return {
  53. async: !data.sync
  54. };
  55. }
  56. },
  57. 'service.item.start_stop': {
  58. 'real': '/clusters/{clusterName}/services/{serviceName}',
  59. 'mock': '/data/wizard/deploy/poll_1.json',
  60. 'format': function (data, opt) {
  61. return {
  62. type: 'PUT',
  63. data: JSON.stringify({
  64. RequestInfo: {
  65. "context": data.requestInfo
  66. },
  67. Body: {
  68. ServiceInfo: {
  69. state: data.state
  70. }
  71. }
  72. })
  73. };
  74. }
  75. },
  76. 'service.item.smoke': {
  77. 'real': '/clusters/{clusterName}/requests',
  78. 'mock': '/data/wizard/deploy/poll_1.json',
  79. 'format': function (data) {
  80. return {
  81. 'type': 'POST',
  82. data: JSON.stringify({
  83. RequestInfo: {
  84. "context": data.displayName + " Smoke Test",
  85. "command" : data.actionName,
  86. "service_name" : data.serviceName
  87. }
  88. })
  89. };
  90. }
  91. },
  92. 'service.load_config_groups': {
  93. 'real': '/clusters/{clusterName}/config_groups?fields=*',
  94. 'mock': ''
  95. },
  96. 'reassign.stop_services': {
  97. 'real': '/clusters/{clusterName}/services',
  98. 'mock': '',
  99. 'format': function (data, opt) {
  100. return {
  101. type: 'PUT',
  102. data: JSON.stringify({
  103. "RequestInfo": {
  104. "context": "Stop all services"
  105. },
  106. "Body": {
  107. "ServiceInfo": {
  108. "state": "INSTALLED"
  109. }
  110. }
  111. })
  112. }
  113. }
  114. },
  115. 'reassign.start_services': {
  116. 'real': '/clusters/{clusterName}/services?params/run_smoke_test=true',
  117. 'mock': '',
  118. 'format': function (data, opt) {
  119. return {
  120. type: 'PUT',
  121. data: JSON.stringify({
  122. "RequestInfo": {
  123. "context": "Start all services"
  124. },
  125. "Body": {
  126. "ServiceInfo": {
  127. "state": "STARTED"
  128. }
  129. }
  130. })
  131. }
  132. }
  133. },
  134. 'reassign.maintenance_mode': {
  135. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  136. 'mock': '',
  137. 'type': 'PUT',
  138. 'format': function () {
  139. return {
  140. data: JSON.stringify(
  141. {
  142. "HostRoles": {
  143. "state": "MAINTENANCE"
  144. }
  145. }
  146. )
  147. }
  148. }
  149. },
  150. 'reassign.remove_component': {
  151. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  152. 'mock': '',
  153. 'type': 'DELETE'
  154. },
  155. 'reassign.load_configs': {
  156. 'real': '/clusters/{clusterName}/configurations?{urlParams}',
  157. 'mock': ''
  158. },
  159. 'reassign.save_configs': {
  160. 'real': '/clusters/{clusterName}',
  161. 'mock': '',
  162. 'type': 'PUT',
  163. 'format': function (data) {
  164. return {
  165. async: false,
  166. data: JSON.stringify({
  167. Clusters: {
  168. desired_config: {
  169. "type": data.siteName,
  170. "tag": 'version' + (new Date).getTime(),
  171. "properties": data.properties
  172. }
  173. }
  174. })
  175. }
  176. }
  177. },
  178. 'config.advanced': {
  179. 'real': '{stack2VersionUrl}/stackServices/{serviceName}/configurations?fields=*',
  180. 'mock': '/data/wizard/stack/hdp/version{stackVersion}/{serviceName}.json',
  181. 'format': function (data) {
  182. return {
  183. async: false
  184. };
  185. }
  186. },
  187. 'config.advanced.global': {
  188. 'real': '{stack2VersionUrl}/stackServices?fields=configurations/StackConfigurations/type',
  189. 'mock': '/data/wizard/stack/hdp/version1.3.0/global.json',
  190. 'format': function (data) {
  191. return {
  192. async: false
  193. };
  194. }
  195. },
  196. 'config.tags': {
  197. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs',
  198. 'mock': '/data/clusters/cluster.json'
  199. },
  200. 'config.tags_and_groups': {
  201. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs,config_groups/*',
  202. 'mock': '/data/clusters/tags_and_groups.json'
  203. },
  204. 'config.tags.sync': {
  205. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs',
  206. 'mock': '/data/clusters/cluster.json',
  207. 'format': function (data) {
  208. return {
  209. async: false
  210. };
  211. }
  212. },
  213. 'config_groups.all_fields': {
  214. 'real': '/clusters/{clusterName}/config_groups?fields=*',
  215. 'mock': ''
  216. },
  217. 'config_groups.get_config_group_by_id': {
  218. 'real': '/clusters/{clusterName}/config_groups/{id}',
  219. 'mock': ''
  220. },
  221. 'config_groups.update_config_group': {
  222. 'real': '/clusters/{clusterName}/config_groups/{id}',
  223. 'mock': '',
  224. 'type': 'PUT',
  225. 'format': function (data) {
  226. return {
  227. async: false,
  228. data: JSON.stringify(
  229. [
  230. data.configGroup
  231. ]
  232. )
  233. }
  234. }
  235. },
  236. 'config_groups.delete_config_group': {
  237. 'real': '/clusters/{clusterName}/config_groups/{id}',
  238. 'mock': '',
  239. 'type': 'DELETE'
  240. },
  241. 'config.on_site': {
  242. 'real': '/clusters/{clusterName}/configurations?{params}',
  243. 'mock': '/data/configurations/cluster_level_configs.json?{params}',
  244. 'format': function (data) {
  245. return {
  246. async: false
  247. };
  248. }
  249. },
  250. 'config.host_overrides': {
  251. 'real': '/clusters/{clusterName}/configurations?{params}',
  252. 'mock': '/data/configurations/host_level_overrides_configs.json?{params}',
  253. 'format': function (data) {
  254. return {
  255. async: false
  256. };
  257. }
  258. },
  259. 'host.host_component.action': {
  260. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  261. 'mock': '',
  262. 'type': 'PUT',
  263. 'format': function (data) {
  264. return {
  265. data: JSON.stringify({
  266. RequestInfo: {
  267. "context": data.context
  268. },
  269. Body: {
  270. "HostRoles": {
  271. "state": data.state
  272. }
  273. }
  274. })
  275. }
  276. }
  277. },
  278. 'host.delete': {
  279. 'real': '/clusters/{clusterName}/hosts/{hostName}',
  280. 'mock': '',
  281. 'type': 'DELETE',
  282. 'format': function (data) {
  283. return {
  284. async: false
  285. }
  286. }
  287. },
  288. 'config.stale.stop_component': {
  289. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  290. 'mock': '',
  291. 'type': 'PUT',
  292. 'format': function (data) {
  293. return {
  294. data: JSON.stringify({
  295. RequestInfo: {
  296. "context": "Stop " + data.displayName
  297. },
  298. Body: {
  299. "HostRoles": {
  300. "state": "INSTALLED"
  301. }
  302. }
  303. })
  304. }
  305. }
  306. },
  307. 'config.stale.start_component': {
  308. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  309. 'mock': '',
  310. 'type': 'PUT',
  311. 'format': function (data) {
  312. return {
  313. data: JSON.stringify({
  314. RequestInfo: {
  315. "context": "Start " + data.displayName
  316. },
  317. Body: {
  318. "HostRoles": {
  319. "state": "STARTED"
  320. }
  321. }
  322. })
  323. }
  324. }
  325. },
  326. 'service.metrics.flume.channel_fill_percent': {
  327. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/CHANNEL/*/ChannelFillPercentage[{fromSeconds},{toSeconds},{stepSeconds}]',
  328. 'mock': '/data/services/metrics/flume/channelFillPct.json',
  329. 'testInProduction': true
  330. },
  331. 'service.metrics.flume.channel_size': {
  332. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/CHANNEL/*/ChannelSize[{fromSeconds},{toSeconds},{stepSeconds}]',
  333. 'mock': '/data/services/metrics/flume/channelSize.json',
  334. 'testInProduction': true
  335. },
  336. 'service.metrics.flume.sink_drain_success': {
  337. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/SINK/*/EventDrainSuccessCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  338. 'mock': '/data/services/metrics/flume/sinkDrainSuccessCount.json',
  339. 'testInProduction': true
  340. },
  341. 'service.metrics.flume.sink_connection_failed': {
  342. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/SINK/*/ConnectionFailedCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  343. 'mock': '/data/services/metrics/flume/sinkConnectionFailedCount.json',
  344. 'testInProduction': true
  345. },
  346. 'service.metrics.flume.gc': {
  347. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  348. 'mock': '/data/services/metrics/flume/jvmGcTime.json',
  349. 'testInProduction': true
  350. },
  351. 'service.metrics.flume.jvm_heap_used': {
  352. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/jvm/memHeapUsedM[{fromSeconds},{toSeconds},{stepSeconds}]',
  353. 'mock': '/data/services/metrics/flume/jvmMemHeapUsedM.json',
  354. 'testInProduction': true
  355. },
  356. 'service.metrics.flume.jvm_threads_runnable': {
  357. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/jvm/threadsRunnable[{fromSeconds},{toSeconds},{stepSeconds}]',
  358. 'mock': '/data/services/metrics/flume/jvmThreadsRunnable.json',
  359. 'testInProduction': true
  360. },
  361. 'service.metrics.flume.cpu_user': {
  362. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/cpu/cpu_user[{fromSeconds},{toSeconds},{stepSeconds}]',
  363. 'mock': '',
  364. 'testInProduction': true
  365. },
  366. 'service.metrics.flume.source_accepted': {
  367. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/SOURCE/*/EventAcceptedCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  368. 'mock': '/data/services/metrics/flume/sourceEventAccepted.json',
  369. 'testInProduction': true
  370. },
  371. 'service.metrics.hbase.cluster_requests': {
  372. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/cluster_requests[{fromSeconds},{toSeconds},{stepSeconds}]',
  373. 'mock': '/data/services/metrics/hbase/cluster_requests.json',
  374. 'testInProduction': true
  375. },
  376. 'service.metrics.hbase.hlog_split_size': {
  377. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/splitSize_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  378. 'mock': '/data/services/metrics/hbase/hlog_split_size.json',
  379. 'testInProduction': true
  380. },
  381. 'service.metrics.hbase.hlog_split_time': {
  382. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/splitTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  383. 'mock': '/data/services/metrics/hbase/hlog_split_time.json',
  384. 'testInProduction': true
  385. },
  386. 'service.metrics.hbase.regionserver_queuesize': {
  387. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/flushQueueSize[{fromSeconds},{toSeconds},{stepSeconds}],metrics/hbase/regionserver/compactionQueueSize[{fromSeconds},{toSeconds},{stepSeconds}]',
  388. 'mock': '/data/services/metrics/hbase/regionserver_queuesize.json',
  389. 'testInProduction': true
  390. },
  391. 'service.metrics.hbase.regionserver_regions': {
  392. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/regions[{fromSeconds},{toSeconds},{stepSeconds}]',
  393. 'mock': '/data/services/metrics/hbase/regionserver_regions.json',
  394. 'testInProduction': true
  395. },
  396. 'service.metrics.hbase.regionserver_rw_requests': {
  397. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/readRequestsCount[{fromSeconds},{toSeconds},{stepSeconds}],metrics/hbase/regionserver/writeRequestsCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  398. 'mock': '/data/services/metrics/hbase/regionserver_rw_requests.json',
  399. 'testInProduction': true
  400. },
  401. 'service.metrics.mapreduce.gc': {
  402. 'real': '/clusters/{clusterName}/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  403. 'mock': '/data/services/metrics/mapreduce/gc.json',
  404. 'testInProduction': true
  405. },
  406. 'service.metrics.mapreduce.jobs_status': {
  407. '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}]',
  408. 'mock': '/data/services/metrics/mapreduce/jobs_status.json',
  409. 'testInProduction': true
  410. },
  411. 'service.metrics.mapreduce.jobs_heap': {
  412. '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}]',
  413. 'mock': '/data/services/metrics/mapreduce/jvm_heap.json',
  414. 'testInProduction': true
  415. },
  416. 'service.metrics.mapreduce.jobs_threads': {
  417. '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}]',
  418. 'mock': '/data/services/metrics/mapreduce/jvm_threads.json',
  419. 'testInProduction': true
  420. },
  421. 'service.metrics.mapreduce.map_slots': {
  422. '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}]',
  423. 'mock': '/data/services/metrics/mapreduce/map_slots.json',
  424. 'testInProduction': true
  425. },
  426. 'service.metrics.mapreduce.reduce_slots': {
  427. '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}]',
  428. 'mock': '/data/services/metrics/mapreduce/reduce_slots.json',
  429. 'testInProduction': true
  430. },
  431. 'service.metrics.mapreduce.rpc': {
  432. 'real': '/clusters/{clusterName}/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  433. 'mock': '/data/services/metrics/mapreduce/rpc.json',
  434. 'testInProduction': true
  435. },
  436. 'service.metrics.mapreduce.tasks_running_waiting': {
  437. '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}]',
  438. 'mock': '/data/services/metrics/mapreduce/tasks_running_waiting.json',
  439. 'testInProduction': true
  440. },
  441. 'service.metrics.hdfs.block_status': {
  442. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/dfs/FSNamesystem/PendingReplicationBlocks[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/FSNamesystem/UnderReplicatedBlocks[{fromSeconds},{toSeconds},{stepSeconds}]',
  443. 'mock': '/data/services/metrics/hdfs/block_status.json',
  444. 'testInProduction': true
  445. },
  446. 'service.metrics.hdfs.file_operations': {
  447. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/dfs/namenode/FileInfoOps[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/namenode/CreateFileOps[{fromSeconds},{toSeconds},{stepSeconds}]',
  448. 'mock': '/data/services/metrics/hdfs/file_operations.json',
  449. 'testInProduction': true
  450. },
  451. 'service.metrics.hdfs.gc': {
  452. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  453. 'mock': '/data/services/metrics/hdfs/gc.json',
  454. 'testInProduction': true
  455. },
  456. 'service.metrics.hdfs.io': {
  457. 'real': '/clusters/{clusterName}/services/HDFS/components/DATANODE?fields=metrics/dfs/datanode/bytes_written[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/datanode/bytes_read[{fromSeconds},{toSeconds},{stepSeconds}]',
  458. 'mock': '/data/services/metrics/hdfs/io.json',
  459. 'testInProduction': true
  460. },
  461. 'service.metrics.hdfs.jvm_heap': {
  462. '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}]',
  463. 'mock': '/data/services/metrics/hdfs/jvm_heap.json',
  464. 'testInProduction': true
  465. },
  466. 'service.metrics.hdfs.jvm_threads': {
  467. '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}]',
  468. 'mock': '/data/services/metrics/hdfs/jvm_threads.json',
  469. 'testInProduction': true
  470. },
  471. 'service.metrics.hdfs.rpc': {
  472. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  473. 'mock': '/data/services/metrics/hdfs/rpc.json',
  474. 'testInProduction': true
  475. },
  476. 'service.metrics.hdfs.space_utilization': {
  477. '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}]',
  478. 'mock': '/data/services/metrics/hdfs/space_utilization.json',
  479. 'testInProduction': true
  480. },
  481. 'service.start_stop': {
  482. 'real': '/clusters/{clusterName}/services?params/run_smoke_test=true',
  483. 'mock': '/data/mirroring/poll/poll_6.json',
  484. 'format': function (data, opt) {
  485. return {
  486. type: 'PUT',
  487. async: false,
  488. data: data.data
  489. };
  490. }
  491. },
  492. 'service.metrics.yarn.gc': {
  493. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  494. 'mock': '/data/services/metrics/yarn/gc.json',
  495. 'testInProduction': true
  496. },
  497. 'service.metrics.yarn.jobs_threads': {
  498. '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}]',
  499. 'mock': '/data/services/metrics/yarn/jvm_threads.json',
  500. 'testInProduction': true
  501. },
  502. 'service.metrics.yarn.rpc': {
  503. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  504. 'mock': '/data/services/metrics/yarn/rpc.json',
  505. 'testInProduction': true
  506. },
  507. 'service.metrics.yarn.jobs_heap': {
  508. '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}]',
  509. 'mock': '/data/services/metrics/yarn/jvm_heap.json',
  510. 'testInProduction': true
  511. },
  512. 'service.metrics.yarn.queue.allocated': {
  513. '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}]',
  514. 'mock': '',
  515. 'testInProduction': true
  516. },
  517. 'service.metrics.yarn.queue.allocated.container': {
  518. '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}]',
  519. 'mock': '',
  520. 'testInProduction': true
  521. },
  522. 'service.metrics.yarn.node.manager.statuses': {
  523. '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}]',
  524. 'mock': '',
  525. 'testInProduction': true
  526. },
  527. 'service.metrics.yarn.queue.memory.resource': {
  528. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=',
  529. 'mock': '',
  530. 'format': function (data, opt) {
  531. var field1 = 'metrics/yarn/Queue/{queueName}/AllocatedMB[{fromSeconds},{toSeconds},{stepSeconds}]';
  532. var field2 = 'metrics/yarn/Queue/{queueName}/AvailableMB[{fromSeconds},{toSeconds},{stepSeconds}]';
  533. if (opt.url != null && data.queueNames != null) {
  534. data.queueNames.forEach(function (q) {
  535. data.queueName = q;
  536. opt.url += (formatUrl(field1, data) + ",");
  537. opt.url += (formatUrl(field2, data) + ",");
  538. });
  539. }
  540. },
  541. 'testInProduction': true
  542. },
  543. 'service.metrics.yarn.queue.apps.states.current': {
  544. '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}]',
  545. 'mock': '',
  546. 'testInProduction': true
  547. },
  548. 'service.metrics.yarn.queue.apps.states.finished': {
  549. '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}]',
  550. 'mock': '',
  551. 'testInProduction': true
  552. },
  553. 'dashboard.cluster_metrics.cpu': {
  554. 'real': '/clusters/{clusterName}/?fields=metrics/cpu[{fromSeconds},{toSeconds},{stepSeconds}]',
  555. 'mock': '/data/cluster_metrics/cpu_1hr.json',
  556. 'testInProduction': true
  557. },
  558. 'dashboard.cluster_metrics.load': {
  559. 'real': '/clusters/{clusterName}/?fields=metrics/load[{fromSeconds},{toSeconds},{stepSeconds}]',
  560. 'mock': '/data/cluster_metrics/load_1hr.json',
  561. 'testInProduction': true
  562. },
  563. 'dashboard.cluster_metrics.memory': {
  564. 'real': '/clusters/{clusterName}/?fields=metrics/memory[{fromSeconds},{toSeconds},{stepSeconds}]',
  565. 'mock': '/data/cluster_metrics/memory_1hr.json',
  566. 'testInProduction': true
  567. },
  568. 'dashboard.cluster_metrics.network': {
  569. 'real': '/clusters/{clusterName}/?fields=metrics/network[{fromSeconds},{toSeconds},{stepSeconds}]',
  570. 'mock': '/data/cluster_metrics/network_1hr.json',
  571. 'testInProduction': true
  572. },
  573. 'host.metrics.cpu': {
  574. '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}]',
  575. 'mock': '/data/hosts/metrics/cpu.json',
  576. 'testInProduction': true
  577. },
  578. 'host.metrics.disk': {
  579. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/disk/disk_total[{fromSeconds},{toSeconds},{stepSeconds}],metrics/disk/disk_free[{fromSeconds},{toSeconds},{stepSeconds}]',
  580. 'mock': '/data/hosts/metrics/disk.json',
  581. 'testInProduction': true
  582. },
  583. 'host.metrics.load': {
  584. '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}]',
  585. 'mock': '/data/hosts/metrics/load.json',
  586. 'testInProduction': true
  587. },
  588. 'host.metrics.memory': {
  589. '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}]',
  590. 'mock': '/data/hosts/metrics/memory.json',
  591. 'testInProduction': true
  592. },
  593. 'host.metrics.network': {
  594. '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}]',
  595. 'mock': '/data/hosts/metrics/network.json',
  596. 'testInProduction': true
  597. },
  598. 'host.metrics.processes': {
  599. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/process/proc_total[{fromSeconds},{toSeconds},{stepSeconds}],metrics/process/proc_run[{fromSeconds},{toSeconds},{stepSeconds}]',
  600. 'mock': '/data/hosts/metrics/processes.json',
  601. 'testInProduction': true
  602. },
  603. 'host.service_config_hosts_overrides': {
  604. 'real': '/clusters/{clusterName}/configurations?{urlParams}',
  605. 'mock': '',
  606. 'format': function (data, opt) {
  607. return {
  608. async: false,
  609. timeout: 10000
  610. };
  611. }
  612. },
  613. 'admin.security_status': {
  614. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs',
  615. 'mock': '',
  616. 'format': function (data, opt) {
  617. return {
  618. timeout: 10000
  619. };
  620. }
  621. },
  622. 'settings.get.user_pref': {
  623. 'real': '/persist/{key}',
  624. 'mock': '',
  625. 'type': 'GET',
  626. 'format': function (data, opt) {
  627. return {
  628. };
  629. }
  630. },
  631. 'settings.post.user_pref': {
  632. 'real': '/persist',
  633. 'mock': '',
  634. 'type': 'POST',
  635. 'format': function (data) {
  636. return {
  637. data: JSON.stringify(data.keyValuePair)
  638. }
  639. }
  640. },
  641. 'cluster.load_cluster_name': {
  642. 'real': '/clusters',
  643. 'mock': '/data/clusters/info.json',
  644. 'format': function (data, opt) {
  645. return {
  646. async: false
  647. };
  648. }
  649. },
  650. 'cluster.state': {
  651. 'type': 'POST',
  652. 'real': '/persist/',
  653. 'mock': '',
  654. 'format': function (data, opt) {
  655. return {
  656. async: false,
  657. data: JSON.stringify(data.keyValuePair)
  658. };
  659. }
  660. },
  661. 'cluster.update_upgrade_version': {
  662. 'real': '/stacks2/HDP/versions?fields=stackServices/StackServices,Versions',
  663. 'mock': '/data/wizard/stack/stacks.json',
  664. 'format': function (data, opt) {
  665. return {
  666. async: false
  667. };
  668. }
  669. },
  670. 'cluster.load_repositories': {
  671. 'real': '/stacks2/{stackName}/versions/{stackVersion}/operatingSystems?fields=repositories/*',
  672. 'mock': '',
  673. 'type': 'GET',
  674. 'format': function (data, opt) {
  675. return {
  676. data: data.data
  677. };
  678. }
  679. },
  680. 'admin.high_availability.stop_all_services': {
  681. 'real': '/clusters/{clusterName}/services',
  682. 'mock': '',
  683. 'format': function (data, opt) {
  684. return {
  685. type: 'PUT',
  686. data: JSON.stringify({
  687. "RequestInfo": {
  688. "context": "Stop all services"
  689. },
  690. "Body": {
  691. "ServiceInfo": {
  692. "state": "INSTALLED"
  693. }
  694. }
  695. })
  696. }
  697. }
  698. },
  699. 'admin.high_availability.start_all_services': {
  700. 'real': '/clusters/{clusterName}/services',
  701. 'mock': '',
  702. 'format': function (data, opt) {
  703. return {
  704. type: 'PUT',
  705. data: JSON.stringify({
  706. "RequestInfo": {
  707. "context": "Start all services"
  708. },
  709. "Body": {
  710. "ServiceInfo": {
  711. "state": "STARTED"
  712. }
  713. }
  714. })
  715. }
  716. }
  717. },
  718. 'admin.high_availability.polling': {
  719. 'real': '/clusters/{clusterName}/requests/{requestId}?fields=tasks/*',
  720. 'mock': '',
  721. 'type': 'GET'
  722. },
  723. 'admin.high_availability.getNnCheckPointStatus': {
  724. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/NAMENODE',
  725. 'mock': '',
  726. 'type': 'GET'
  727. },
  728. 'admin.high_availability.getJnCheckPointStatus': {
  729. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/JOURNALNODE?fields=metrics',
  730. 'mock': ''
  731. },
  732. 'admin.high_availability.getHostComponent': {
  733. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  734. 'mock': ''
  735. },
  736. 'admin.high_availability.create_component': {
  737. 'real': '/clusters/{clusterName}/hosts?Hosts/host_name={hostName}',
  738. 'mock': '',
  739. 'type': 'POST',
  740. 'format': function (data) {
  741. return {
  742. data: JSON.stringify({
  743. "host_components": [
  744. {
  745. "HostRoles": {
  746. "component_name": data.componentName
  747. }
  748. }
  749. ]
  750. })
  751. }
  752. }
  753. },
  754. 'admin.high_availability.create_journalnode': {
  755. 'real': '/clusters/{clusterName}/services?ServiceInfo/service_name=HDFS',
  756. 'mock': '',
  757. 'type': 'POST',
  758. 'format': function (data) {
  759. return {
  760. data: JSON.stringify({
  761. "components": [
  762. {
  763. "ServiceComponentInfo": {
  764. "component_name": "JOURNALNODE"
  765. }
  766. }
  767. ]
  768. })
  769. }
  770. }
  771. },
  772. 'admin.high_availability.create_zkfc': {
  773. 'real': '/clusters/{clusterName}/services?ServiceInfo/service_name=HDFS',
  774. 'mock': '',
  775. 'type': 'POST',
  776. 'format': function (data) {
  777. return {
  778. data: JSON.stringify({
  779. "components": [
  780. {
  781. "ServiceComponentInfo": {
  782. "component_name": "ZKFC"
  783. }
  784. }
  785. ]
  786. })
  787. }
  788. }
  789. },
  790. 'admin.high_availability.install_component': {
  791. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  792. 'mock': '',
  793. 'type': 'PUT',
  794. 'format': function (data) {
  795. return {
  796. data: JSON.stringify({
  797. RequestInfo: {
  798. "context": "Install " + data.displayName
  799. },
  800. Body: {
  801. "HostRoles": {
  802. "state": "INSTALLED"
  803. }
  804. }
  805. })
  806. }
  807. }
  808. },
  809. 'admin.high_availability.start_component': {
  810. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  811. 'mock': '',
  812. 'type': 'PUT',
  813. 'format': function (data) {
  814. return {
  815. data: JSON.stringify({
  816. RequestInfo: {
  817. "context": "Start " + data.displayName
  818. },
  819. Body: {
  820. "HostRoles": {
  821. "state": "STARTED"
  822. }
  823. }
  824. })
  825. }
  826. }
  827. },
  828. 'admin.high_availability.maintenance_mode': {
  829. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  830. 'mock': '',
  831. 'type': 'PUT',
  832. 'format': function () {
  833. return {
  834. data: JSON.stringify({
  835. "HostRoles": {
  836. "state": "MAINTENANCE"
  837. }
  838. })
  839. }
  840. }
  841. },
  842. 'admin.high_availability.stop_component': {
  843. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  844. 'mock': '',
  845. 'type': 'PUT',
  846. 'format': function (data) {
  847. return {
  848. data: JSON.stringify({
  849. RequestInfo: {
  850. "context": "Stop " + data.displayName
  851. },
  852. Body: {
  853. "HostRoles": {
  854. "state": "INSTALLED"
  855. }
  856. }
  857. })
  858. }
  859. }
  860. },
  861. 'admin.high_availability.load_configs': {
  862. 'real': '/clusters/{clusterName}/configurations?(type=core-site&tag={coreSiteTag})|(type=hdfs-site&tag={hdfsSiteTag})',
  863. 'mock': '',
  864. 'type': 'GET'
  865. },
  866. 'admin.high_availability.save_configs': {
  867. 'real': '/clusters/{clusterName}',
  868. 'mock': '',
  869. 'type': 'PUT',
  870. 'format': function (data) {
  871. return {
  872. async: false,
  873. data: JSON.stringify({
  874. Clusters: {
  875. desired_config: {
  876. "type": data.siteName,
  877. "tag": 'version' + (new Date).getTime(),
  878. "properties": data.properties
  879. }
  880. }
  881. })
  882. }
  883. }
  884. },
  885. 'admin.high_availability.load_hbase_configs': {
  886. 'real': '/clusters/{clusterName}/configurations?type=hbase-site&tag={hbaseSiteTag}',
  887. 'mock': '',
  888. 'type': 'GET'
  889. },
  890. 'admin.high_availability.delete_component': {
  891. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  892. 'mock': '',
  893. 'type': 'DELETE'
  894. },
  895. 'admin.security.cluster_configs': {
  896. 'real': '/clusters/{clusterName}',
  897. 'mock': '',
  898. 'format': function (data, opt) {
  899. return {
  900. timeout: 10000
  901. };
  902. }
  903. },
  904. 'admin.delete_host': {
  905. 'real': '/clusters/{clusterName}/hosts/{hostName}',
  906. 'mock': '',
  907. 'type': 'DELETE'
  908. },
  909. 'admin.security.all_configurations': {
  910. 'real': '/clusters/{clusterName}/configurations?{urlParams}',
  911. 'mock': '',
  912. 'format': function (data, opt) {
  913. return {
  914. timeout: 10000
  915. };
  916. }
  917. },
  918. 'admin.security.apply_configurations': {
  919. 'real': '/clusters/{clusterName}',
  920. 'mock': '',
  921. 'format': function (data, opt) {
  922. return {
  923. type: 'PUT',
  924. timeout: 10000,
  925. data: data.configData
  926. };
  927. }
  928. },
  929. 'admin.security.apply_configuration': {
  930. 'real': '/clusters/{clusterName}',
  931. 'mock': '',
  932. 'format': function (data, opt) {
  933. return {
  934. type: 'PUT',
  935. async: false,
  936. timeout: 5000,
  937. data: JSON.stringify(data.clusterData)
  938. };
  939. }
  940. },
  941. 'admin.security.add.cluster_configs': {
  942. 'real': '/clusters/{clusterName}' + '?fields=Clusters/desired_configs',
  943. 'mock': '',
  944. 'format': function (data, opt) {
  945. return {
  946. timeout: 10000
  947. };
  948. }
  949. },
  950. 'admin.stack_upgrade.run_upgrade': {
  951. 'real': '/clusters/{clusterName}',
  952. 'mock': '',
  953. 'format': function (data, opt) {
  954. return {
  955. type: 'PUT',
  956. async: false,
  957. data: data.data
  958. };
  959. }
  960. },
  961. 'admin.stack_upgrade.stop_services': {
  962. 'real': '/clusters/{clusterName}/services?ServiceInfo/state=STARTED',
  963. 'mock': '',
  964. 'format': function (data, opt) {
  965. return {
  966. type: 'PUT',
  967. async: false,
  968. data: data.data
  969. };
  970. }
  971. },
  972. 'admin.stack_upgrade.do_poll': {
  973. 'real': '/clusters/{cluster}/requests/{requestId}?fields=tasks/*',
  974. 'mock': '/data/wizard/{mock}'
  975. },
  976. 'wizard.advanced_repositories.valid_url': {
  977. 'real': '/stacks2/{stackName}/versions/{stackVersion}/operatingSystems/{osType}/repositories/{nameVersionCombo}',
  978. 'mock': '',
  979. 'type': 'PUT',
  980. 'format': function (data) {
  981. return {
  982. async: true,
  983. data: JSON.stringify(data.data)
  984. }
  985. }
  986. },
  987. 'wizard.install_services.add_host_controller.is_retry': {
  988. 'real': '/clusters/{cluster}/host_components',
  989. 'mock': '',
  990. 'format': function (data, opt) {
  991. return {
  992. type: 'PUT',
  993. async: false,
  994. data: data.data
  995. };
  996. }
  997. },
  998. 'wizard.install_services.add_host_controller.not_is_retry': {
  999. 'real': '/clusters/{cluster}/host_components',
  1000. 'mock': '',
  1001. 'format': function (data, opt) {
  1002. return {
  1003. type: 'PUT',
  1004. async: false,
  1005. data: data.data
  1006. };
  1007. }
  1008. },
  1009. 'wizard.install_services.installer_controller.is_retry': {
  1010. 'real': '/clusters/{cluster}/host_components?HostRoles/state=INSTALLED',
  1011. 'mock': '/data/wizard/deploy/2_hosts/poll_1.json',
  1012. 'type': 'PUT',
  1013. 'format': function (data, opt) {
  1014. return {
  1015. async: false,
  1016. data: data.data
  1017. };
  1018. }
  1019. },
  1020. 'wizard.install_services.installer_controller.not_is_retry': {
  1021. 'real': '/clusters/{cluster}/services?ServiceInfo/state=INIT',
  1022. 'mock': '/data/wizard/deploy/2_hosts/poll_1.json',
  1023. 'type': 'PUT',
  1024. 'format': function (data, opt) {
  1025. return {
  1026. async: false,
  1027. data: data.data
  1028. };
  1029. }
  1030. },
  1031. 'wizard.install_services.add_service_controller.get_failed_host_components': {
  1032. 'real': '/clusters/{clusterName}/host_components?fields=HostRoles/state,component/ServiceComponentInfo/service_name',
  1033. 'mock': '',
  1034. 'format': function (data, opt) {
  1035. return {
  1036. async: false
  1037. };
  1038. }
  1039. },
  1040. 'wizard.service_components': {
  1041. 'real': '{stackUrl}/stackServices?fields=StackServices',
  1042. 'mock': '/data/wizard/stack/hdp/version/{stackVersion}.json',
  1043. 'format': function (data, opt) {
  1044. return {
  1045. timeout: 10000,
  1046. async: false
  1047. };
  1048. }
  1049. },
  1050. 'wizard.step9.installer.launch_start_services': {
  1051. 'real': '/clusters/{cluster}/services?ServiceInfo/state=INSTALLED&params/run_smoke_test=true&params/reconfigure_client=false',
  1052. 'mock': '/data/wizard/deploy/5_hosts/poll_6.json',
  1053. 'format': function (data, opt) {
  1054. var data = {
  1055. type: 'PUT',
  1056. async: false,
  1057. data: data.data
  1058. };
  1059. if (App.testMode) {
  1060. data.type = 'GET';
  1061. }
  1062. return data;
  1063. }
  1064. },
  1065. 'wizard.step9.add_host.launch_start_services': {
  1066. 'real': '/clusters/{cluster}/host_components',
  1067. 'mock': '/data/wizard/deploy/5_hosts/poll_6.json',
  1068. 'format': function (data, opt) {
  1069. return {
  1070. type: 'PUT',
  1071. async: false,
  1072. data: data.data
  1073. };
  1074. }
  1075. },
  1076. 'wizard.step8.delete_cluster': {
  1077. 'real': '/clusters/{name}',
  1078. 'mock': '',
  1079. 'format': function (data, opt) {
  1080. return {
  1081. type: 'DELETE',
  1082. async: false
  1083. };
  1084. }
  1085. },
  1086. 'wizard.step8.existing_cluster_names': {
  1087. 'real': '/clusters',
  1088. 'mock': '',
  1089. 'format': function (data, opt) {
  1090. return {
  1091. async: false
  1092. };
  1093. }
  1094. },
  1095. 'wizard.step3.host_info': {
  1096. 'real': '/hosts?fields=Hosts/total_mem,Hosts/cpu_count,Hosts/disk_info,Hosts/last_agent_env,Hosts/host_name,Hosts/os_type',
  1097. 'mock': '/data/wizard/bootstrap/two_hosts_information.json',
  1098. 'format': function (data, opt) {
  1099. return {
  1100. contentType: 'application/json'
  1101. };
  1102. }
  1103. },
  1104. 'wizard.step3.rerun_checks': {
  1105. 'real': '/hosts?fields=Hosts/last_agent_env',
  1106. 'mock': '/data/wizard/bootstrap/two_hosts_information.json',
  1107. 'format': function (data, opt) {
  1108. return {
  1109. contentType: 'application/json'
  1110. };
  1111. }
  1112. },
  1113. 'wizard.step3.bootstrap': {
  1114. 'real': '/bootstrap/{bootRequestId}',
  1115. 'mock': '/data/wizard/bootstrap/poll_{numPolls}.json'
  1116. },
  1117. 'wizard.step3.is_hosts_registered': {
  1118. 'real': '/hosts',
  1119. 'mock': '/data/wizard/bootstrap/single_host_registration.json'
  1120. },
  1121. 'wizard.stacks': {
  1122. 'real': '/stacks2',
  1123. 'mock': '/data/wizard/stack/stacks2.json',
  1124. 'format': function (data) {
  1125. return {
  1126. async: false
  1127. };
  1128. }
  1129. },
  1130. 'wizard.stacks_versions': {
  1131. 'real': '/stacks2/{stackName}/versions?fields=Versions,operatingSystems/repositories/Repositories',
  1132. 'mock': '/data/wizard/stack/{stackName}_versions.json',
  1133. 'format': function (data) {
  1134. return {
  1135. async: false
  1136. };
  1137. }
  1138. },
  1139. 'wizard.launch_bootstrap': {
  1140. 'real': '/bootstrap',
  1141. 'mock': '/data/wizard/bootstrap/bootstrap.json',
  1142. 'type': 'POST',
  1143. 'format': function (data) {
  1144. return {
  1145. async: false,
  1146. contentType: 'application/json',
  1147. data: data.bootStrapData
  1148. }
  1149. }
  1150. },
  1151. 'router.login': {
  1152. 'real': '/users/{loginName}',
  1153. 'mock': '/data/users/user_{usr}.json',
  1154. 'format': function (data, opt) {
  1155. var statusCode = jQuery.extend({}, require('data/statusCodes'));
  1156. statusCode['403'] = function () {
  1157. console.log("Error code 403: Forbidden.");
  1158. }
  1159. return {
  1160. statusCode: statusCode
  1161. };
  1162. }
  1163. },
  1164. 'router.login2': {
  1165. 'real': '/clusters',
  1166. 'mock': '/data/clusters/info.json'
  1167. },
  1168. 'router.logoff': {
  1169. 'real': '/logout',
  1170. 'mock': ''
  1171. },
  1172. 'router.set_ambari_stacks': {
  1173. 'real': '/stacks',
  1174. 'mock': '/data/wizard/stack/stacks.json',
  1175. 'format': function (data, opt) {
  1176. return {
  1177. async: false
  1178. };
  1179. }
  1180. },
  1181. 'router.authentication': {
  1182. 'real': '/clusters',
  1183. 'mock': '/data/clusters/info.json',
  1184. 'format': function (data, opt) {
  1185. return {
  1186. async: false
  1187. };
  1188. }
  1189. },
  1190. 'ambari.service': {
  1191. 'real': '/services/AMBARI/components/AMBARI_SERVER',
  1192. 'mock': ''
  1193. },
  1194. 'dashboard.get.user_pref': {
  1195. 'real': '/persist/{key}',
  1196. 'mock': '',
  1197. 'format': function (data, opt) {
  1198. return {
  1199. async: false
  1200. };
  1201. }
  1202. },
  1203. 'dashboard.post.user_pref': {
  1204. 'real': '/persist',
  1205. 'mock': '',
  1206. 'type': 'POST',
  1207. 'format': function (data) {
  1208. return {
  1209. async: false,
  1210. data: JSON.stringify(data.keyValuePair)
  1211. }
  1212. }
  1213. },
  1214. 'config_groups.create': {
  1215. 'real': '/clusters/{clusterName}/config_groups',
  1216. 'mock': '',
  1217. 'format': function (data) {
  1218. return {
  1219. async: false,
  1220. type: 'POST',
  1221. data: JSON.stringify([{
  1222. "ConfigGroup": {
  1223. "group_name": data.group_name,
  1224. "tag": data.service_id,
  1225. "description": data.description,
  1226. "desired_configs": data.desired_configs
  1227. }
  1228. }])
  1229. }
  1230. }
  1231. },
  1232. 'config_groups.update': {
  1233. 'real': '/clusters/{clusterName}/config_groups/{id}',
  1234. 'mock': '',
  1235. 'format': function (data) {
  1236. return {
  1237. async: true,
  1238. type: 'PUT',
  1239. data: JSON.stringify(data.data)
  1240. }
  1241. }
  1242. }
  1243. };
  1244. /**
  1245. * Replace data-placeholders to its values
  1246. *
  1247. * @param {String} url
  1248. * @param {Object} data
  1249. * @return {String}
  1250. */
  1251. var formatUrl = function (url, data) {
  1252. if (!url) return null;
  1253. var keys = url.match(/\{\w+\}/g);
  1254. keys = (keys === null) ? [] : keys;
  1255. if (keys) {
  1256. keys.forEach(function (key) {
  1257. var raw_key = key.substr(1, key.length - 2);
  1258. var replace;
  1259. if (!data || !data[raw_key]) {
  1260. replace = '';
  1261. }
  1262. else {
  1263. replace = data[raw_key];
  1264. }
  1265. url = url.replace(new RegExp(key, 'g'), replace);
  1266. });
  1267. }
  1268. return url;
  1269. };
  1270. /**
  1271. * this = object from config
  1272. * @return {Object}
  1273. */
  1274. var formatRequest = function (data) {
  1275. var opt = {
  1276. type: this.type || 'GET',
  1277. timeout: App.timeout,
  1278. dataType: 'json',
  1279. statusCode: require('data/statusCodes')
  1280. };
  1281. if (App.testMode) {
  1282. opt.url = formatUrl(this.mock ? this.mock : '', data);
  1283. opt.type = 'GET';
  1284. }
  1285. else {
  1286. opt.url = App.apiPrefix + formatUrl(this.real, data);
  1287. }
  1288. if (this.format) {
  1289. jQuery.extend(opt, this.format(data, opt));
  1290. }
  1291. return opt;
  1292. };
  1293. /**
  1294. * Wrapper for all ajax requests
  1295. *
  1296. * @type {Object}
  1297. */
  1298. var ajax = Em.Object.extend({
  1299. /**
  1300. * Send ajax request
  1301. *
  1302. * @param {Object} config
  1303. * @return Object jquery ajax object
  1304. *
  1305. * config fields:
  1306. * name - url-key in the urls-object *required*
  1307. * sender - object that send request (need for proper callback initialization) *required*
  1308. * data - object with data for url-format
  1309. * beforeSend - method-name for ajax beforeSend response callback
  1310. * success - method-name for ajax success response callback
  1311. * error - method-name for ajax error response callback
  1312. * callback - callback from <code>App.updater.run</code> library
  1313. */
  1314. send: function (config) {
  1315. console.warn('============== ajax ==============', config.name, config.data);
  1316. if (!config.sender) {
  1317. console.warn('Ajax sender should be defined!');
  1318. return null;
  1319. }
  1320. // default parameters
  1321. var params = {
  1322. clusterName: App.get('clusterName')
  1323. };
  1324. // extend default parameters with provided
  1325. if (config.data) {
  1326. jQuery.extend(params, config.data);
  1327. }
  1328. var opt = {};
  1329. if (!urls[config.name]) {
  1330. console.warn('Invalid name provided!');
  1331. return null;
  1332. }
  1333. opt = formatRequest.call(urls[config.name], params);
  1334. opt.context = this;
  1335. // object sender should be provided for processing beforeSend, success and error responses
  1336. opt.beforeSend = function (xhr) {
  1337. if (config.beforeSend) {
  1338. config.sender[config.beforeSend](opt, xhr, params);
  1339. }
  1340. };
  1341. opt.success = function (data, textStatus, xhr) {
  1342. console.log("TRACE: The url is: " + opt.url);
  1343. if (config.success) {
  1344. config.sender[config.success](data, opt, params);
  1345. }
  1346. };
  1347. opt.error = function (request, ajaxOptions, error) {
  1348. if (config.error) {
  1349. config.sender[config.error](request, ajaxOptions, error, opt);
  1350. } else {
  1351. this.defaultErrorHandler(request, opt.url, opt.type);
  1352. }
  1353. };
  1354. opt.complete = function () {
  1355. if (config.callback) {
  1356. config.callback();
  1357. }
  1358. };
  1359. if ($.mocho) {
  1360. opt.url = 'http://' + $.hostName + opt.url;
  1361. }
  1362. return $.ajax(opt);
  1363. },
  1364. // A single instance of App.ModalPopup view
  1365. modalPopup: null,
  1366. /**
  1367. * defaultErrorHandler function is referred from App.ajax.send function and App.HttpClient.defaultErrorHandler function
  1368. * @jqXHR {jqXHR Object}
  1369. * @url {string}
  1370. * @method {String} Http method
  1371. * @showStatus {number} HTTP response code which should be shown. Default is 500.
  1372. */
  1373. defaultErrorHandler: function (jqXHR, url, method, showStatus) {
  1374. method = method || 'GET';
  1375. var self = this;
  1376. var api = " received on " + method + " method for API: " + url;
  1377. var showMessage = true;
  1378. try {
  1379. var json = $.parseJSON(jqXHR.responseText);
  1380. var message = json.message;
  1381. } catch (err) {
  1382. }
  1383. if (showStatus === null) {
  1384. showStatus = 500;
  1385. }
  1386. if (message === undefined) {
  1387. showMessage = false;
  1388. }
  1389. var statusCode = jqXHR.status + " status code";
  1390. if (jqXHR.status === showStatus && !this.modalPopup) {
  1391. this.modalPopup = App.ModalPopup.show({
  1392. header: jqXHR.statusText,
  1393. secondary: false,
  1394. onPrimary: function () {
  1395. this.hide();
  1396. self.modalPopup = null;
  1397. },
  1398. bodyClass: Ember.View.extend({
  1399. classNames: ['api-error'],
  1400. templateName: require('templates/utils/ajax'),
  1401. api: api,
  1402. statusCode: statusCode,
  1403. message: message,
  1404. showMessage: showMessage
  1405. })
  1406. });
  1407. }
  1408. }
  1409. });
  1410. /**
  1411. * Add few access-methods for test purposes
  1412. */
  1413. if ($.mocho) {
  1414. ajax.reopen({
  1415. /**
  1416. * Don't use it anywhere except tests!
  1417. * @deprecated
  1418. * @returns {Array}
  1419. */
  1420. fakeGetUrlNames: function() {
  1421. var names = [];
  1422. for (var name in urls) {
  1423. names.push(name);
  1424. }
  1425. return names;
  1426. },
  1427. /**
  1428. * Don't use it anywhere except tests!
  1429. * @deprecated
  1430. * @param name
  1431. * @returns {*}
  1432. */
  1433. fakeGetUrl: function(name) {
  1434. return urls[name];
  1435. },
  1436. /**
  1437. * Don't use it anywhere except tests!
  1438. * @deprecated
  1439. * @param url
  1440. * @param data
  1441. * @returns {String}
  1442. */
  1443. fakeFormatUrl: function(url, data) {
  1444. return formatUrl(url, data);
  1445. },
  1446. /**
  1447. * Don't use it anywhere except tests!
  1448. * @deprecated
  1449. * @param urlObj
  1450. * @param data
  1451. * @returns {Object}
  1452. */
  1453. fakeFormatRequest: function(urlObj, data) {
  1454. return formatRequest.call(urlObj, data);
  1455. }
  1456. });
  1457. }
  1458. App.ajax = ajax.create({});