| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395 |
1
1
1
1
1
1
1
1
1
1
17
9
10
11
2264
2264
2264
2
2262
3525
2262
2264
8
3
3
1
2
12
11
11
5
1
1
1
1
1
2
2
2
2
2
2
1
1
1
2
1
1
1
1
2
2
1
1
2
2
1
2
2
1
2
| 'use strict';
;require.register("app", function (exports, require, module) {
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Eif (Ember.$.uuid === undefined) {
Ember.$.uuid = 0;
}
// Application bootstrapper
require('utils/bootstrap_reopen');
require('utils/ember_reopen');
require('utils/ember_computed');
var stringUtils = require('utils/string_utils');
var stompClientClass = require('utils/stomp_client');
module.exports = Em.Application.create({
name: 'Ambari Web',
rootElement: '#wrapper',
store: DS.Store.create({
revision: 4,
adapter: DS.FixtureAdapter.create({
simulateRemoteResponse: false
}),
typeMaps: {},
recordCache: []
}),
StompClient: stompClientClass.create(),
isAdmin: false,
isOperator: false,
isClusterUser: false,
isPermissionDataLoaded: false,
auth: undefined,
isOnlyViewUser: function () {
return App.auth && (App.auth.length == 0 || App.isAuthorized('VIEW.USE') && App.auth.length == 1);
}.property('auth'),
/**
* @type {boolean}
* @default false
*/
isKerberosEnabled: false,
/**
* state of stack upgrade process
* states:
* - NOT_REQUIRED
* - PENDING
* - IN_PROGRESS
* - HOLDING
* - COMPLETED
* - ABORTED
* - HOLDING_FAILED
* - HOLDING_TIMEDOUT
* @type {String}
*/
upgradeState: 'NOT_REQUIRED',
/**
* Check if upgrade is in INIT state
* 'INIT' is set on upgrade start and when it's finished
* @type {boolean}
*/
upgradeInit: Em.computed.equal('upgradeState', 'NOT_REQUIRED'),
/**
* flag is true when upgrade process is running
* @returns {boolean}
*/
upgradeInProgress: Em.computed.equal('upgradeState', 'IN_PROGRESS'),
/**
* Checks if update process is completed
* @type {boolean}
*/
upgradeCompleted: Em.computed.equal('upgradeState', 'COMPLETED'),
/**
* flag is true when upgrade process is waiting for user action
* to proceed, retry, perform manual steps etc.
* @returns {boolean}
*/
upgradeHolding: function () {
return this.get('upgradeState').contains("HOLDING") || this.get('upgradeAborted');
}.property('upgradeState', 'upgradeAborted'),
/**
* flag is true when upgrade process is aborted
* SHOULD behave similar to HOLDING_FAILED state
* @returns {boolean}
*/
upgradeAborted: function () {
return this.get('upgradeState') === "ABORTED" && !App.router.get('mainAdminStackAndUpgradeController.isSuspended');
}.property('upgradeState', 'router.mainAdminStackAndUpgradeController.isSuspended'),
/**
* flag is true when upgrade process is suspended
* @returns {boolean}
*/
upgradeSuspended: function () {
return this.get('upgradeState') === "ABORTED" && App.router.get('mainAdminStackAndUpgradeController.isSuspended');
}.property('upgradeState', 'router.mainAdminStackAndUpgradeController.isSuspended'),
/**
* RU is running
* @type {boolean}
*/
upgradeIsRunning: Em.computed.or('upgradeInProgress', 'upgradeHolding'),
/**
* flag is true when upgrade process is running or suspended
* or wizard used by another user
* @returns {boolean}
*/
wizardIsNotFinished: function () {
return this.get('upgradeIsRunning') || this.get('upgradeSuspended') || App.router.get('wizardWatcherController.isNonWizardUser');
}.property('upgradeIsRunning', 'upgradeAborted', 'router.wizardWatcherController.isNonWizardUser', 'upgradeSuspended'),
/**
* @param {string} authRoles
* @returns {boolean}
*/
havePermissions: function havePermissions(authRoles) {
var result = false;
authRoles = $.map(authRoles.split(","), $.trim);
// When Upgrade running(not suspended) only operations related to upgrade should be allowed
if (!this.get('upgradeSuspended') && !authRoles.contains('CLUSTER.UPGRADE_DOWNGRADE_STACK') && !authRoles.contains('CLUSTER.MANAGE_USER_PERSISTED_DATA') && !App.get('supports.opsDuringRollingUpgrade') && !['NOT_REQUIRED', 'COMPLETED'].contains(this.get('upgradeState')) || !App.auth) {
return false;
}
authRoles.forEach(function (auth) {
result = result || App.auth.contains(auth);
});
return result;
},
/**
* @param {string} authRoles
* @returns {boolean}
*/
isAuthorized: function isAuthorized(authRoles) {
return this.havePermissions(authRoles) && !App.router.get('wizardWatcherController.isNonWizardUser');
},
isStackServicesLoaded: false,
/**
* return url prefix with number value of version of HDP stack
*/
stackVersionURL: function () {
return '/stacks/{0}/versions/{1}'.format(this.get('currentStackName') || 'HDP', this.get('currentStackVersionNumber'));
}.property('currentStackName', 'currentStackVersionNumber'),
falconServerURL: function () {
var falconService = this.Service.find().findProperty('serviceName', 'FALCON');
if (falconService) {
return falconService.get('hostComponents').findProperty('componentName', 'FALCON_SERVER').get('hostName');
}
return '';
}.property().volatile(),
/* Determine if Application Timeline Service supports Kerberization.
* Because this value is retrieved from the cardinality of the component, it is safe to keep in app.js
* since its value will not change during the lifetime of the application.
*/
doesATSSupportKerberos: function () {
var YARNService = App.StackServiceComponent.find().filterProperty('serviceName', 'YARN');
if (YARNService.length) {
var ATS = App.StackServiceComponent.find().findProperty('componentName', 'APP_TIMELINE_SERVER');
return !!ATS && !!ATS.get('minToInstall');
}
return false;
}.property('router.clusterController.isLoaded'),
clusterId: null,
clusterName: null,
clockDistance: null, // server clock - client clock
currentStackVersion: '',
currentStackName: function () {
return Em.get((this.get('currentStackVersion') || this.get('defaultStackVersion')).match(/(.+)-\d.+/), '1');
}.property('currentStackVersion', 'defaultStackVersion'),
/**
* true if cluster has only 1 host
* for now is used to disable move/HA actions
* @type {boolean}
*/
isSingleNode: Em.computed.equal('allHostNames.length', 1),
allHostNames: [],
/**
* This object is populated to keep track of uninstalled components to be included in the layout for recommendation/validation call
* @type {object}
* keys = componentName, hostName
*/
componentToBeAdded: {},
/**
* This object is populated to keep track of installed components to be excluded in the layout for recommendation/validation call
* @type {object}
* keys = componentName, hostName
*/
componentToBeDeleted: {},
uiOnlyConfigDerivedFromTheme: [],
currentStackVersionNumber: function () {
var regExp = new RegExp(this.get('currentStackName') + '-');
return (this.get('currentStackVersion') || this.get('defaultStackVersion')).replace(regExp, '');
}.property('currentStackVersion', 'defaultStackVersion', 'currentStackName'),
isHadoopWindowsStack: Em.computed.equal('currentStackName', 'HDPWIN'),
/**
* If NameNode High Availability is enabled
* Based on <code>clusterStatus.isInstalled</code>, stack version, <code>SNameNode</code> availability
*
* @type {bool}
*/
isHaEnabled: function () {
return App.Service.find('HDFS').get('isLoaded') && !App.HostComponent.find().someProperty('componentName', 'SECONDARY_NAMENODE');
}.property('router.clusterController.dataLoadList.services', 'router.clusterController.isServiceContentFullyLoaded'),
hasNameNodeFederation: function () {
return App.HDFSService.find('HDFS').get('masterComponentGroups.length') > 1;
}.property('router.clusterController.isHostComponentMetricsLoaded', 'router.clusterController.isHDFSNameSpacesLoaded'),
/**
* If ResourceManager High Availability is enabled
* Based on number of ResourceManager host components installed
*
* @type {bool}
*/
isRMHaEnabled: function () {
var result = false;
var rmStackComponent = App.StackServiceComponent.find().findProperty('componentName', 'RESOURCEMANAGER');
Iif (rmStackComponent && rmStackComponent.get('isMultipleAllowed')) {
result = this.HostComponent.find().filterProperty('componentName', 'RESOURCEMANAGER').length > 1;
}
return result;
}.property('router.clusterController.isLoaded', 'isStackServicesLoaded'),
/**
* If Ranger Admin High Availability is enabled
* Based on number of Ranger Admin host components installed
*
* @type {bool}
*/
isRAHaEnabled: function () {
var result = false;
var raStackComponent = App.StackServiceComponent.find().findProperty('componentName', 'RANGER_ADMIN');
Iif (raStackComponent && raStackComponent.get('isMultipleAllowed')) {
result = App.HostComponent.find().filterProperty('componentName', 'RANGER_ADMIN').length > 1;
}
return result;
}.property('router.clusterController.isLoaded', 'isStackServicesLoaded'),
/**
* Object with utility functions for list of service names with similar behavior
*/
services: Em.Object.create({
all: function () {
return App.StackService.find().mapProperty('serviceName');
}.property('App.router.clusterController.isLoaded'),
clientOnly: function () {
return App.StackService.find().filterProperty('isClientOnlyService').mapProperty('serviceName');
}.property('App.router.clusterController.isLoaded'),
hasClient: function () {
return App.StackService.find().filterProperty('hasClient').mapProperty('serviceName');
}.property('App.router.clusterController.isLoaded'),
hasMaster: function () {
return App.StackService.find().filterProperty('hasMaster').mapProperty('serviceName');
}.property('App.router.clusterController.isLoaded'),
hasSlave: function () {
return App.StackService.find().filterProperty('hasSlave').mapProperty('serviceName');
}.property('App.router.clusterController.isLoaded'),
noConfigTypes: function () {
return App.StackService.find().filterProperty('isNoConfigTypes').mapProperty('serviceName');
}.property('App.router.clusterController.isLoaded'),
servicesWithHeatmapTab: function () {
return App.StackService.find().filterProperty('hasHeatmapSection').mapProperty('serviceName');
}.property('App.router.clusterController.isLoaded'),
monitoring: function () {
return App.StackService.find().filterProperty('isMonitoringService').mapProperty('serviceName');
}.property('App.router.clusterController.isLoaded'),
hostMetrics: function () {
return App.StackService.find().filterProperty('isHostMetricsService').mapProperty('serviceName');
}.property('App.router.clusterController.isLoaded'),
serviceMetrics: function () {
return App.StackService.find().filterProperty('isServiceMetricsService').mapProperty('serviceName');
}.property('App.router.clusterController.isLoaded'),
supportsServiceCheck: function () {
return App.StackService.find().filterProperty('serviceCheckSupported').mapProperty('serviceName');
}.property('App.router.clusterController.isLoaded'),
supportsDeleteViaUI: function () {
return App.StackService.find().filterProperty('supportDeleteViaUi').mapProperty('serviceName');
}.property('App.router.clusterController.isLoaded')
}),
/**
* List of components with allowed action for them
* @type {Em.Object}
*/
components: Em.Object.create({
isMasterAddableOnlyOnHA: function () {
return App.StackServiceComponent.find().filterProperty('isMasterAddableOnlyOnHA').mapProperty('componentName');
}.property('App.router.clusterController.isLoaded'),
allComponents: function () {
return App.StackServiceComponent.find().mapProperty('componentName');
}.property('App.router.clusterController.isLoaded'),
reassignable: function () {
return App.StackServiceComponent.find().filterProperty('isReassignable').mapProperty('componentName');
}.property('App.router.clusterController.isLoaded'),
restartable: function () {
return App.StackServiceComponent.find().filterProperty('isRestartable').mapProperty('componentName');
}.property('App.router.clusterController.isLoaded'),
deletable: function () {
return App.StackServiceComponent.find().filterProperty('isDeletable').mapProperty('componentName');
}.property('App.router.clusterController.isLoaded'),
rollinRestartAllowed: function () {
return App.StackServiceComponent.find().filterProperty('isRollinRestartAllowed').mapProperty('componentName');
}.property('App.router.clusterController.isLoaded'),
decommissionAllowed: function () {
return App.StackServiceComponent.find().filterProperty('isDecommissionAllowed').mapProperty('componentName');
}.property('App.router.clusterController.isLoaded'),
refreshConfigsAllowed: function () {
return App.StackServiceComponent.find().filterProperty('isRefreshConfigsAllowed').mapProperty('componentName');
}.property('App.router.clusterController.isLoaded'),
addableToHost: function () {
return App.StackServiceComponent.find().filterProperty('isAddableToHost').mapProperty('componentName');
}.property('App.router.clusterController.isLoaded'),
addableMasterInstallerWizard: function () {
return App.StackServiceComponent.find().filterProperty('isMasterAddableInstallerWizard').mapProperty('componentName');
}.property('App.router.clusterController.isLoaded'),
multipleMasters: function () {
return App.StackServiceComponent.find().filterProperty('isMasterWithMultipleInstances').mapProperty('componentName');
}.property('App.router.clusterController.isLoaded'),
slaves: function () {
return App.StackServiceComponent.find().filterProperty('isSlave').mapProperty('componentName');
}.property('App.router.clusterController.isLoaded'),
masters: function () {
return App.StackServiceComponent.find().filterProperty('isMaster').mapProperty('componentName');
}.property('App.router.clusterController.isLoaded'),
clients: function () {
return App.StackServiceComponent.find().filterProperty('isClient').mapProperty('componentName');
}.property('App.router.clusterController.isLoaded'),
nonHDP: function () {
return App.StackServiceComponent.find().filterProperty('isNonHDPComponent').mapProperty('componentName');
}.property('App.router.clusterController.isLoaded')
})
});
}); |