| 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 |
1
1
1
1
1
1
9
9
9
9
9
9
9
9
9
9
9
9
9
2
2
3
3
3
2
2
2
1
2
2
2
2
1
1
1
2
2
4
1
1
1
1
1
1
1
1
1
1
2
2
2
2
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
3
3
3
2
2
2
| 'use strict';
;require.register("controllers/main/admin/highAvailability/journalNode/wizard_controller", 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.
*/
var App = require('app');
App.ManageJournalNodeWizardController = App.WizardController.extend({
name: 'manageJournalNodeWizardController',
totalSteps: 7,
displayName: Em.I18n.t('admin.manageJournalNode.wizard.header'),
/**
* Used for hiding back button in wizard
*/
hideBackButton: true,
content: Em.Object.create({
controllerName: 'manageJournalNodeWizardController',
cluster: null,
hosts: null,
services: null,
slaveComponentHosts: null,
masterComponentHosts: null,
serviceConfigProperties: [],
serviceName: 'MISC',
hdfsUser: "hdfs",
nameServiceIds: [],
failedTask: null,
requestIds: null
}),
setCurrentStep: function setCurrentStep(currentStep, completed) {
this._super(currentStep, completed);
App.clusterStatus.setClusterStatus({
clusterName: this.get('content.cluster.name'),
clusterState: 'JOURNALNODE_MANAGEMENT',
wizardControllerName: 'manageJournalNodeWizardController',
localdb: App.db.data
});
},
/**
* return new object extended from clusterStatusTemplate
* @return Object
*/
getCluster: function getCluster() {
return jQuery.extend({}, this.get('clusterStatusTemplate'), { name: App.router.getClusterName() });
},
loadMap: {
'1': [{
type: 'async',
callback: function callback() {
var dfd = $.Deferred(),
self = this,
usersLoadingCallback = function usersLoadingCallback() {
self.save('hdfsUser');
self.load('cluster');
self.loadHosts().done(function () {
self.loadServicesFromServer();
self.loadMasterComponentHosts().done(function () {
self.load('hdfsUser');
Iif (!self.getDBProperty('activeNN')) {
self.saveNNs();
} else {
self.loadNNs();
}
dfd.resolve();
});
});
};
Eif (self.getDBProperty('hdfsUser')) {
usersLoadingCallback();
} else {
this.loadHdfsUserFromServer().done(function (data) {
self.set('content.hdfsUser', Em.get(data, '0.properties.hdfs_user'));
usersLoadingCallback();
});
}
return dfd.promise();
}
}],
2: [{
type: 'sync',
callback: function callback() {
this.loadNameServiceIds();
this.loadServiceConfigProperties();
}
}],
'4': [{
type: 'sync',
callback: function callback() {
this.loadTasksStatuses();
this.loadTasksRequestIds();
this.loadRequestIds();
}
}]
},
getJournalNodesToAdd: function getJournalNodesToAdd() {
var result = [];
var masterComponentHosts = this.get('content.masterComponentHosts');
if (masterComponentHosts) {
result = masterComponentHosts.filterProperty('component', 'JOURNALNODE').filterProperty('isInstalled', false).mapProperty('hostName');
}
return result;
},
getJournalNodesToDelete: function getJournalNodesToDelete() {
var result = [];
var masterComponentHosts = this.get('content.masterComponentHosts');
if (masterComponentHosts) {
var currentJNs = masterComponentHosts.filterProperty('component', 'JOURNALNODE');
var existingHosts = App.HostComponent.find().filterProperty('componentName', 'JOURNALNODE').mapProperty('hostName');
result = existingHosts.filter(function (host) {
return currentJNs.filterProperty('hostName', host).length === 0;
});
}
return result;
},
isDeleteOnly: function () {
return this.get('currentStep') > 1 && this.getJournalNodesToAdd().length === 0 && this.getJournalNodesToDelete().length > 0;
}.property('content.masterComponentHosts', 'App.router.clusterController.isHostsLoaded', 'currentStep'),
/**
* Save config properties
* @param stepController ManageJournalNodeWizardStep3Controller
*/
saveServiceConfigProperties: function saveServiceConfigProperties(stepController) {
var serviceConfigProperties = [];
var data = stepController.get('serverConfigData');
var _content = stepController.get('stepConfigs')[0];
_content.get('configs').forEach(function (_configProperties) {
var siteObj = data.items.findProperty('type', _configProperties.get('filename'));
Eif (siteObj) {
siteObj.properties[_configProperties.get('name')] = _configProperties.get('value');
}
}, this);
this.setDBProperty('serviceConfigProperties', data);
this.set('content.serviceConfigProperties', data);
},
/**
* Load serviceConfigProperties to model
*/
loadServiceConfigProperties: function loadServiceConfigProperties() {
this.set('content.serviceConfigProperties', this.getDBProperty('serviceConfigProperties'));
},
saveNNs: function saveNNs() {
var activeNN = App.HostComponent.find().findProperty('displayNameAdvanced', 'Active NameNode');
var standByNN = App.HostComponent.find().findProperty('displayNameAdvanced', 'Standby NameNode');
this.set('content.activeNN', activeNN);
this.set('content.standByNN', standByNN);
this.setDBProperty('activeNN', activeNN);
this.setDBProperty('standByNN', standByNN);
},
loadNNs: function loadNNs() {
var activeNN = this.getDBProperty('activeNN');
var standByNN = this.getDBProperty('standByNN');
this.set('content.activeNN', activeNN);
this.set('content.standByNN', standByNN);
},
saveConfigTag: function saveConfigTag(tag) {
App.db.setManageJournalNodeWizardConfigTag(tag);
this.set('content.' + tag.name, tag.value);
},
loadConfigTag: function loadConfigTag(tag) {
var tagVal = App.db.getManageJournalNodeWizardConfigTag(tag);
this.set('content.' + tag, tagVal);
},
saveNameServiceIds: function saveNameServiceIds(nameServiceIds) {
this.setDBProperty('nameServiceIds', nameServiceIds);
this.set('content.nameServiceIds', nameServiceIds);
},
loadNameServiceIds: function loadNameServiceIds() {
var nameServiceIds = this.getDBProperty('nameServiceIds');
this.set('content.nameServiceIds', nameServiceIds);
},
/**
* Remove all loaded data.
* Created as copy for App.router.clearAllSteps
*/
clearAllSteps: function clearAllSteps() {
this.clearInstallOptions();
// clear temporary information stored during the install
this.set('content.cluster', this.getCluster());
},
clearTasksData: function clearTasksData() {
this.saveTasksStatuses(undefined);
this.saveRequestIds(undefined);
this.saveTasksRequestIds(undefined);
},
/**
* Clear all temporary data
*/
finish: function finish() {
App.db.data.Installer = {};
this.resetDbNamespace();
App.router.get('updateController').updateAll();
}
});
}); |