Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scavenge log changes #195

Merged
merged 3 commits into from
Dec 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/js/modules/admin/controllers/AdminCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ define(['./_module'], function (app) {
adminService.scavenge().then(null, function () {
msg.failure('Scavenge failed');
});
};

$scope.stopScavenge = function ($event, $history) {
stop($event);

adminService.stopScavenge($history.scavengeId).then(null, function () {
msg.failure('Stopping scavenge ' + $history.scavengeId + ' failed');
});
};

$scope.scavengeHistory = function() {
Expand Down
63 changes: 52 additions & 11 deletions src/js/modules/admin/controllers/ScavengeCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,26 +80,67 @@ define(['./_module'], function (app) {
type: entry.EventType
});
break;
} case '$scavengeChunksCompleted': {
var chunkData = JSON.parse(entry.data);
}
case '$scavengeChunksCompleted': {
var indexData = JSON.parse(entry.data);
result = 'No chunks scavenged';
if(chunkData.wasScavenged) {
var chunksScavenged = chunkData.chunkEndNumber - chunkData.chunkStartNumber + 1;
if(indexData.wasScavenged) {
var chunksScavenged = indexData.chunkEndNumber - indexData.chunkStartNumber + 1;
result = chunksScavenged + ' chunk(s) scavenged';
}
if (chunkData.errorMessage) {
result = 'Error: ' + chunkData.errorMessage;
if (indexData.errorMessage) {
result = 'Error: ' + indexData.errorMessage;
}
info.push({
status: 'Scavenging chunks ' + chunkData.chunkStartNumber + ' - ' +
chunkData.chunkEndNumber + ' complete',
timeTaken: chunkData.timeTaken,
spaceSaved: chunkData.spaceSaved,
status: 'Scavenging chunks ' + indexData.chunkStartNumber + ' - ' +
indexData.chunkEndNumber + ' complete',
timeTaken: indexData.timeTaken,
spaceSaved: indexData.spaceSaved,
type: entry.eventType,
result: result
});
break;
} case '$scavengeCompleted': {
}
case '$scavengeMergeCompleted': {
var indexData = JSON.parse(entry.data);
result = 'No chunks merged';
if(indexData.wasMerged) {
var chunksScavenged = indexData.chunkEndNumber - indexData.chunkStartNumber + 1;
result = chunksScavenged + ' chunk(s) merged';
}
if (indexData.errorMessage) {
result = 'Error: ' + indexData.errorMessage;
}
info.push({
status: 'Merging chunks ' + indexData.chunkStartNumber + ' - ' +
indexData.chunkEndNumber + ' complete',
timeTaken: indexData.timeTaken,
spaceSaved: indexData.spaceSaved,
type: entry.eventType,
result: result
});
break;
}
case '$scavengeIndexCompleted': {
var indexData = JSON.parse(entry.data);
result = 'Index table not scavenged';
if(indexData.wasScavenged) {
result = indexData.entriesDeleted + ' index entries scavenged';
}
if (indexData.errorMessage) {
result = 'Error: ' + indexData.errorMessage;
}
var tableIndexId = '(' + indexData.level + ',' + indexData.index + ')';
info.push({
status: 'Scavenging index table ' + tableIndexId + ' complete',
timeTaken: indexData.timeTaken,
spaceSaved: indexData.spaceSaved,
type: entry.eventType,
result: result
});
break;
}
case '$scavengeCompleted': {
var data = JSON.parse(entry.data);
result = data.result;
if(data.result === 'Failed') {
Expand Down
4 changes: 4 additions & 0 deletions src/js/modules/admin/services/AdminService.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ define(['./_module'], function (app) {
var url = urlBuilder.build(urls.admin.scavenge);
return $http.post(url);
},
stopScavenge: function($scavengeId){
var url = urlBuilder.build(urls.admin.scavenge + '/' + $scavengeId);
return $http.delete(url);
},
getSubsystems: function() {
var url = urlBuilder.build(urls.system.subsystems);
return $http.get(url);
Expand Down
2 changes: 1 addition & 1 deletion src/js/modules/admin/templates/templates.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions src/js/modules/admin/views/admin.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,16 @@ <h2 class="page-title">Admin</h2>
<td><a ui-sref="scavenge({scavengeId: history.scavengeId, page: 0, from: 0})">{{history.nodeEndpoint}}
<br />{{history.scavengeId}}</a></td>
<td>{{history.startTime | date:'yyyy-MM-dd HH:mm'}}</td>
<td><span ng-show="history.endTime">{{history.endTime | date:'yyyy-MM-dd HH:mm'}}</span><em ng-hide="history.endTime">Not Finished</em></td>
<td><span ng-show="history.result">{{history.result}}</span><span ng-hide="history.result">...</span></td>
<td>
<span ng-show="history.endTime">{{history.endTime | date:'yyyy-MM-dd HH:mm'}}</span><span ng-hide="history.endTime"><em>Not Finished</em>
</span>
</td>
<td>
<span ng-show="history.result">{{history.result}}</span>
<span ng-hide="history.result" class="page-nav__item">
<a ui-sref="#" ng-click="stopScavenge($event, history)">Cancel</a>
</span>
</td>
</tr>
</tbody>
</table>
Expand Down
3 changes: 3 additions & 0 deletions src/js/services/ScavengeNotificationService.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ define(['./_module'], function (app) {
if(eventData.error) {
scavengeNotifyMsg += ' failed';
msg.failure(scavengeNotifyMsg);
} else if(eventData.result === 'Stopped') {
scavengeNotifyMsg += ' stopped';
msg.success(scavengeNotifyMsg);
} else {
scavengeNotifyMsg += ' completed';
msg.success(scavengeNotifyMsg);
Expand Down