YARN-9089. Add Terminal Link to Service component instance page for UI2. Contributed by Eric Yang

This commit is contained in:
Billie Rinaldi 2018-12-14 18:38:03 -08:00
parent 1ea29b7385
commit aab310978f
5 changed files with 46 additions and 0 deletions

View File

@ -21,6 +21,7 @@ export function initialize( application ) {
application.inject('controller', 'env', 'service:env'); application.inject('controller', 'env', 'service:env');
application.inject('route', 'env', 'service:env'); application.inject('route', 'env', 'service:env');
application.inject('adapter', 'env', 'service:env'); application.inject('adapter', 'env', 'service:env');
application.inject('model', 'env', 'service:env');
} }
export default { export default {

View File

@ -110,6 +110,29 @@ function getClusterIdFromYARN(rmhost, application) {
return clusterId; return clusterId;
} }
function getNodeManagerPort(rmhost, application) {
var httpUrl = window.location.protocol + "//" +
(ENV.hosts.localBaseAddress ? ENV.hosts.localBaseAddress + '/' : '') + rmhost
+ ":" + window.location.port + "/conf?name=yarn.nodemanager.webapp.address";
var port = "8042";
$.ajax({
type: 'GET',
dataType: 'json',
async: false,
context: this,
url: httpUrl,
success: function(data) {
port = data.property.value.split(":")[1];
application.advanceReadiness();
},
error: function() {
port = "8042";
application.advanceReadiness();
}
});
return port;
}
function updateConfigs(application) { function updateConfigs(application) {
var hostname = window.location.hostname; var hostname = window.location.hostname;
var rmhost = hostname + (window.location.port ? ':' + window.location.port: '') + var rmhost = hostname + (window.location.port ? ':' + window.location.port: '') +
@ -134,6 +157,9 @@ function updateConfigs(application) {
var clusterIdFromYARN = getClusterIdFromYARN(rmhost, application); var clusterIdFromYARN = getClusterIdFromYARN(rmhost, application);
ENV.clusterId = clusterIdFromYARN; ENV.clusterId = clusterIdFromYARN;
var nodeManagerPort = getNodeManagerPort(rmhost, application);
ENV.nodeManagerPort = nodeManagerPort;
if(!ENV.hosts.timelineWebAddress) { if(!ENV.hosts.timelineWebAddress) {
var timelinehost = ""; var timelinehost = "";
$.ajax({ $.ajax({

View File

@ -47,5 +47,15 @@ export default DS.Model.extend({
return Converter.timeStampToDate(timestamp); return Converter.timeStampToDate(timestamp);
} }
return 'N/A'; return 'N/A';
}),
termLink: Ember.computed('node', 'containerId', function() {
var protocol = window.location.protocol;
var node = this.get('node');
var port = this.get('env.app.nodeManagerPort');
var containerId = this.get('containerId');
var url = protocol + "//" + node + ":" + port +
"/terminal/terminal.template?container=" + containerId;
return url;
}) })
}); });

View File

@ -39,6 +39,11 @@ export default AbstractRoute.extend({
}); });
}, },
afterModel(model) {
const appContrl = this.controllerFor('application');
model.userInfo = appContrl.get('userInfo');
},
unloadAll() { unloadAll() {
this.store.unloadAll('yarn-component-instance'); this.store.unloadAll('yarn-component-instance');
} }

View File

@ -61,6 +61,10 @@
<td>Exit Status Code</td> <td>Exit Status Code</td>
<td>{{check-availability model.container.exitStatusCode}}</td> <td>{{check-availability model.container.exitStatusCode}}</td>
</tr> </tr>
<tr>
<td>Terminal</td>
<td><a href="{{model.container.termLink}}&user.name={{model.userInfo.requestedUser}}" target="_blank">Link</a></td>
</tr>
</tbody> </tbody>
</table> </table>
</div> </div>