Add supervisors to overlord console. (#4248)

This commit is contained in:
Gian Merlino 2017-05-05 03:13:12 +09:00 committed by Fangjin Yang
parent d0f89e969a
commit f0fd8ba191
2 changed files with 53 additions and 0 deletions

View File

@ -37,6 +37,11 @@
<body> <body>
<div class="container"> <div class="container">
<div class="heading">Coordinator Console</div> <div class="heading">Coordinator Console</div>
<div class="supervisors_section" style="display: none;">
<h2>Supervisors</h2>
<table id="supervisorsTable"></table>
</div>
<h2>Running Tasks</h2> <h2>Running Tasks</h2>
<div class="running_loading">Loading Running Tasks... this may take a few minutes</div> <div class="running_loading">Loading Running Tasks... this may take a few minutes</div>
<table id="runningTable"></table> <table id="runningTable"></table>

View File

@ -16,6 +16,34 @@ var killTask = function(taskId) {
} }
} }
var resetSupervisor = function(supervisorId) {
if(confirm('Do you really want to reset: '+ supervisorId)) {
$.ajax({
type:'POST',
url: '/druid/indexer/v1/supervisor/' + supervisorId + '/reset',
data: ''
}).done(function(data) {
setTimeout(function() { location.reload(true) }, 750);
}).fail(function(data) {
alert('Reset request failed, please check overlord logs for details.');
})
}
}
var shutdownSupervisor = function(supervisorId) {
if(confirm('Do you really want to shutdown: '+ supervisorId)) {
$.ajax({
type:'POST',
url: '/druid/indexer/v1/supervisor/' + supervisorId + '/shutdown',
data: ''
}).done(function(data) {
setTimeout(function() { location.reload(true) }, 750);
}).fail(function(data) {
alert('Shutdown request failed, please check overlord logs for details.');
})
}
}
$(document).ready(function() { $(document).ready(function() {
var augment = function(data, showKill) { var augment = function(data, showKill) {
for (i = 0 ; i < data.length ; i++) { for (i = 0 ; i < data.length ; i++) {
@ -31,6 +59,26 @@ $(document).ready(function() {
} }
} }
$.get('/druid/indexer/v1/supervisor', function(dataList) {
var data = []
for (i = 0 ; i < dataList.length ; i++) {
var supervisorId = encodeURIComponent(dataList[i])
data[i] = {
"dataSource" : supervisorId,
"more" :
'<a href="/druid/indexer/v1/supervisor/' + supervisorId + '">payload</a>' +
'<a href="/druid/indexer/v1/supervisor/' + supervisorId + '/status">status</a>' +
'<a href="/druid/indexer/v1/supervisor/' + supervisorId + '/history">history</a>' +
'<a onclick="resetSupervisor(\'' + supervisorId + '\');">reset</a>' +
'<a onclick="shutdownSupervisor(\'' + supervisorId + '\');">shutdown</a>'
}
}
buildTable((data), $('#supervisorsTable'));
if (dataList.length > 0) {
$('.supervisors_section').show();
}
});
$.get('/druid/indexer/v1/runningTasks', function(data) { $.get('/druid/indexer/v1/runningTasks', function(data) {
$('.running_loading').hide(); $('.running_loading').hide();
augment(data, true); augment(data, true);