Revision 46241
Added by Michele Artini over 7 years ago
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/administration/uis/modules/services/ServicesInspectorModule.java | ||
---|---|---|
16 | 16 |
import org.springframework.web.bind.annotation.RequestMapping; |
17 | 17 |
import org.springframework.web.bind.annotation.RequestParam; |
18 | 18 |
import org.springframework.web.bind.annotation.RestController; |
19 |
import org.springframework.web.client.RestTemplate; |
|
19 | 20 |
|
20 | 21 |
import com.google.common.collect.Maps; |
21 | 22 |
|
... | ... | |
106 | 107 |
|
107 | 108 |
} |
108 | 109 |
|
110 |
@RequestMapping("workers/pause") |
|
111 |
public MsroWorkerRunningInstance pause(@RequestParam final String baseUrl) { |
|
112 |
return (new RestTemplate()).getForObject(baseUrl + "/pause", MsroWorkerRunningInstance.class); |
|
113 |
} |
|
114 |
|
|
115 |
@RequestMapping("workers/resume") |
|
116 |
public MsroWorkerRunningInstance resume(@RequestParam final String baseUrl) throws Exception { |
|
117 |
return (new RestTemplate()).getForObject(baseUrl + "/resume", MsroWorkerRunningInstance.class); |
|
118 |
} |
|
119 |
|
|
109 | 120 |
} |
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/java/eu/dnetlib/administration/uis/modules/base/MsroWorkersShutdownModule.java | ||
---|---|---|
1 |
package eu.dnetlib.administration.uis.modules.base; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import org.springframework.beans.factory.annotation.Autowired; |
|
6 |
import org.springframework.ui.ModelMap; |
|
7 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
8 |
import org.springframework.web.bind.annotation.RestController; |
|
9 |
|
|
10 |
import eu.dnetlib.administration.uis.annotations.Authorization; |
|
11 |
import eu.dnetlib.administration.uis.annotations.MenuEntry; |
|
12 |
import eu.dnetlib.administration.uis.annotations.MenuGroup; |
|
13 |
import eu.dnetlib.administration.uis.annotations.PermissionLevel; |
|
14 |
import eu.dnetlib.administration.uis.modules.UIModule; |
|
15 |
import eu.dnetlib.administration.uis.utils.ShutdownUtils; |
|
16 |
import eu.dnetlib.enabling.common.StoppableDetails; |
|
17 |
|
|
18 |
@RestController |
|
19 |
@RequestMapping("/ajax/shutdown") |
|
20 |
@MenuEntry(value = "Prepare Workers Shutdown", urlSection = "shutdown", group = MenuGroup.CONFIGURATION) |
|
21 |
@Authorization(PermissionLevel.WF_ADMIN) |
|
22 |
public class MsroWorkersShutdownModule extends UIModule { |
|
23 |
|
|
24 |
@Autowired |
|
25 |
private ShutdownUtils shutdownUtils; |
|
26 |
|
|
27 |
@RequestMapping("listStoppableDetails.json") |
|
28 |
public List<StoppableDetails> listStoppableDetails() { |
|
29 |
return shutdownUtils.listStoppableDetails(); |
|
30 |
} |
|
31 |
|
|
32 |
@RequestMapping("stopAll.do") |
|
33 |
public boolean stopAll() { |
|
34 |
return shutdownUtils.stopAll(); |
|
35 |
} |
|
36 |
|
|
37 |
@RequestMapping("resumeAll.do") |
|
38 |
public boolean resumeAll() { |
|
39 |
return shutdownUtils.resumeAll(); |
|
40 |
} |
|
41 |
|
|
42 |
@Override |
|
43 |
public void populateModelMap(final ModelMap map) { |
|
44 |
// TODO Auto-generated method stub |
|
45 |
|
|
46 |
} |
|
47 |
|
|
48 |
} |
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/resources/static/html/services/workers.html | ||
---|---|---|
1 |
<p class="text-right"> |
|
2 |
<button class="btn btn-sm btn-default" ng-click="refresh()"> |
|
3 |
<span class="glyphicon glyphicon-refresh"></span> refresh |
|
4 |
</button> |
|
5 |
</p> |
|
6 |
|
|
1 | 7 |
<table class="table table-striped"> |
2 | 8 |
<thead> |
3 | 9 |
<tr> |
4 |
<th class="col-xs-1">#</th> |
|
5 |
<th class="col-xs-7">Worker</th> |
|
6 |
<th class="col-xs-2 text-center">Last executions</th> |
|
7 |
<th class="col-xs-1 text-right"># procs</th> |
|
8 |
<th class="col-xs-1 text-right">Status</th> |
|
10 |
<th class="text-right" style="width: 50px;">#</th> |
|
11 |
<th>Worker</th> |
|
12 |
<th class="text-center" style="width: 160px;">Last executions</th> |
|
13 |
<th class="text-right" style="width: 100px;"># procs</th> |
|
14 |
<th class="text-center" style="width: 80px;">Status</th> |
|
15 |
<th style="width: 30px;"></th> |
|
9 | 16 |
</tr> |
10 | 17 |
</thead> |
11 | 18 |
<tbody> |
12 | 19 |
<tr ng-show="workers.length == 0"> |
13 |
<td colspan="5" class="text-muted"><i>- empty -</i></td>
|
|
20 |
<td colspan="6" class="text-muted"><i>- empty -</i></td>
|
|
14 | 21 |
</tr> |
15 | 22 |
<tr ng-repeat="worker in workers"> |
16 |
<td>{{$index + 1}}</td> |
|
23 |
<td class="text-right">{{$index + 1}}</td>
|
|
17 | 24 |
|
18 | 25 |
<td> |
19 | 26 |
<a href="{{worker.baseUrl}}" title="{{worker.id}}">{{worker.baseUrl}}</a> |
... | ... | |
26 | 33 |
ng-repeat="wf in worker.lastExecutions"> |
27 | 34 |
</span> |
28 | 35 |
</td> |
29 |
<td class="text-right">{{worker.runningWfs}}</td> |
|
30 |
<td class="text-right">{{worker.status}}</td> |
|
36 |
<td class="text-right">{{worker.runningWfs}} <span class="text-muted">(+ {{worker.queuedWfs}})</span></td> |
|
37 |
<td class="text-center"> |
|
38 |
<span class="label" ng-class="{ |
|
39 |
'label-success': worker.status == 'ACTIVE', |
|
40 |
'label-default': worker.status == 'PAUSED', |
|
41 |
'label-warning': (worker.status != 'ACTIVE') && (worker.status != 'PAUSED') |
|
42 |
}">{{worker.status}}</span> |
|
43 |
</td> |
|
44 |
<td class="text-right"> |
|
45 |
<button class="btn btn-xs btn-primary" ng-if="worker.status != 'PAUSED'" ng-click="pause(true, worker.baseUrl)"> |
|
46 |
<span class="glyphicon glyphicon-pause"></span> |
|
47 |
</button> |
|
48 |
<button class="btn btn-xs btn-primary" ng-if="worker.status == 'PAUSED'" ng-click="pause(false, worker.baseUrl)"> |
|
49 |
<span class="glyphicon glyphicon-play"></span> |
|
50 |
</button> |
|
51 |
</td> |
|
31 | 52 |
</tr> |
32 | 53 |
</tbody> |
33 | 54 |
</table> |
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/resources/static/js/shutdown/shutdown.js | ||
---|---|---|
1 |
var module = angular.module('shutdownUI', []); |
|
2 |
|
|
3 |
module.controller('shutdownCtrl', function ($scope, $http) { |
|
4 |
$scope.stoppables = []; |
|
5 |
|
|
6 |
$scope.stopLaunched = false; |
|
7 |
$scope.stopEnded = false; |
|
8 |
|
|
9 |
initSpinner(); |
|
10 |
|
|
11 |
$scope.loadStoppables = function() { |
|
12 |
showSpinner(); |
|
13 |
$scope.stoppables = []; |
|
14 |
$http.get('shutdown/listStoppableDetails.json').success(function(data) { |
|
15 |
hideSpinner(); |
|
16 |
$scope.stoppables = data; |
|
17 |
$scope.calculateStatus(); |
|
18 |
}).error(function() { |
|
19 |
show_notification("error","An error occurred while fetching stoppable modules"); |
|
20 |
hideSpinner(); |
|
21 |
}); |
|
22 |
} |
|
23 |
|
|
24 |
$scope.calculateStatus = function() { |
|
25 |
var lauched = true; |
|
26 |
var ended = true; |
|
27 |
angular.forEach($scope.stoppables, function(value, key) { |
|
28 |
if (value.status == 'RUNNING') { |
|
29 |
lauched = false; |
|
30 |
} |
|
31 |
if (value.status != 'STOPPED') { |
|
32 |
ended = false; |
|
33 |
} |
|
34 |
}); |
|
35 |
$scope.stopLaunched = lauched; |
|
36 |
$scope.stopEnded = ended; |
|
37 |
} |
|
38 |
|
|
39 |
$scope.prepareShutdown = function() { |
|
40 |
if (confirm("Are you sure ?")) { |
|
41 |
showSpinner(); |
|
42 |
$scope.stoppables = []; |
|
43 |
$http.get('shutdown/stopAll.do').success(function(data) { |
|
44 |
hideSpinner(); |
|
45 |
$scope.stopLaunched = true; |
|
46 |
show_notification("info", "You will be able to stop the web application soon"); |
|
47 |
$scope.loadStoppables(); |
|
48 |
}).error(function() { |
|
49 |
show_notification("error","An error occurred while fetching stoppable modules"); |
|
50 |
hideSpinner(); |
|
51 |
}); |
|
52 |
} |
|
53 |
} |
|
54 |
|
|
55 |
$scope.resumeShutdown = function() { |
|
56 |
if (confirm("Are you sure ?")) { |
|
57 |
showSpinner(); |
|
58 |
$scope.stoppables = []; |
|
59 |
$http.get('shutdown/resumeAll.do').success(function(data) { |
|
60 |
hideSpinner(); |
|
61 |
$scope.stopLaunched = false; |
|
62 |
show_notification("info", "Resuming stopped modules"); |
|
63 |
$scope.loadStoppables(); |
|
64 |
}).error(function() { |
|
65 |
show_notification("error","An error occurred while fetching stoppable modules"); |
|
66 |
hideSpinner(); |
|
67 |
}); |
|
68 |
} |
|
69 |
} |
|
70 |
|
|
71 |
$scope.loadStoppables(); |
|
72 |
|
|
73 |
}); |
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/resources/static/js/services/services.js | ||
---|---|---|
77 | 77 |
|
78 | 78 |
$scope.refresh = function() { |
79 | 79 |
showSpinner(); |
80 |
$scope.workers = []; |
|
81 | 80 |
$http.get('/ajax/services/workers').success(function(data) { |
82 | 81 |
hideSpinner(); |
83 | 82 |
$scope.workers = data; |
... | ... | |
87 | 86 |
}); |
88 | 87 |
}; |
89 | 88 |
|
89 |
$scope.pause = function(b, baseUrl) { |
|
90 |
showSpinner(); |
|
91 |
var url; |
|
92 |
if (b) { url = '/ajax/services/workers/pause'; } |
|
93 |
else { url = '/ajax/services/workers/resume'; } |
|
94 |
|
|
95 |
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8"; |
|
96 |
$http.post(url, $.param({ |
|
97 |
'baseUrl' : baseUrl |
|
98 |
})).success(function(data) { |
|
99 |
hideSpinner(); |
|
100 |
$scope.refresh() |
|
101 |
}).error(function() { |
|
102 |
hideSpinner(); |
|
103 |
show_notification('error', 'An error has occurred !'); |
|
104 |
}); |
|
105 |
} |
|
106 |
|
|
90 | 107 |
$scope.refresh(); |
91 | 108 |
}); |
92 | 109 |
|
modules/dnet-springboot-apps/trunk/dnet-administration-uis/src/main/resources/templates/shutdown/body.ftl | ||
---|---|---|
1 |
ssss |
Also available in: Unified diff
worker pause/resume