use of org.infinispan.server.core.ServerManagement in project infinispan by infinispan.
the class ServerResource method doIgnoreOp.
private CompletionStage<RestResponse> doIgnoreOp(RestRequest restRequest) {
NettyRestResponse.Builder builder = new NettyRestResponse.Builder().status(NO_CONTENT);
boolean add = restRequest.method().equals(POST);
String cacheManagerName = restRequest.variables().get("cache-manager");
DefaultCacheManager cacheManager = invocationHelper.getServer().getCacheManager(cacheManagerName);
if (cacheManager == null)
return completedFuture(builder.status(NOT_FOUND).build());
String cacheName = restRequest.variables().get("cache");
if (!cacheManager.getCacheNames().contains(cacheName)) {
return completedFuture(builder.status(NOT_FOUND).build());
}
ServerManagement server = invocationHelper.getServer();
ServerStateManager ignoreManager = server.getServerStateManager();
return Security.doAs(restRequest.getSubject(), (PrivilegedAction<CompletionStage<Void>>) () -> add ? ignoreManager.ignoreCache(cacheName) : ignoreManager.unignoreCache(cacheName)).thenApply(r -> builder.build());
}
use of org.infinispan.server.core.ServerManagement in project infinispan by infinispan.
the class ServerResource method report.
private CompletionStage<RestResponse> report(RestRequest restRequest) {
ServerManagement server = invocationHelper.getServer();
NettyRestResponse.Builder responseBuilder = new NettyRestResponse.Builder();
return Security.doAs(restRequest.getSubject(), (PrivilegedAction<CompletionStage<RestResponse>>) () -> server.getServerReport().handle((path, t) -> {
if (t != null) {
return responseBuilder.status(HttpResponseStatus.INTERNAL_SERVER_ERROR).build();
} else {
return responseBuilder.contentType(MediaType.fromString("application/gzip")).header("Content-Disposition", String.format("attachment; filename=\"%s-%s-%3$tY%3$tm%3$td%3$tH%3$tM%3$tS-report.tar.gz\"", Version.getBrandName().toLowerCase().replaceAll("\\s", "-"), invocationHelper.getRestCacheManager().getNodeName(), Calendar.getInstance())).entity(path.toFile()).build();
}
}));
}
Aggregations