ajax.js 53 KB

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