use of org.infinispan.server.core.BackupManager in project infinispan by infinispan.
the class ClusterResource method getAllRestoreNames.
private CompletionStage<RestResponse> getAllRestoreNames(RestRequest request) {
BackupManager backupManager = invocationHelper.getServer().getBackupManager();
Set<String> names = Security.doAs(request.getSubject(), (PrivilegedAction<Set<String>>) backupManager::getRestoreNames);
return asJsonResponseFuture(Json.make(names));
}
use of org.infinispan.server.core.BackupManager in project infinispan by infinispan.
the class ContainerResource method backup.
private CompletionStage<RestResponse> backup(RestRequest request) {
BackupManager backupManager = invocationHelper.getServer().getBackupManager();
return BackupManagerResource.handleBackupRequest(request, backupManager, (name, workingDir, json) -> {
BackupManager.Resources resources = BackupManagerResource.getResources(json);
Map<String, BackupManager.Resources> backupParams = Collections.singletonMap(cacheManagerName, resources);
backupManager.create(name, workingDir, backupParams);
});
}
use of org.infinispan.server.core.BackupManager in project infinispan by infinispan.
the class ContainerResource method getAllRestoreNames.
private CompletionStage<RestResponse> getAllRestoreNames(RestRequest request) {
BackupManager backupManager = invocationHelper.getServer().getBackupManager();
Set<String> names = backupManager.getRestoreNames();
return asJsonResponseFuture(Json.make(names));
}
use of org.infinispan.server.core.BackupManager in project infinispan by infinispan.
the class ContainerResource method restore.
private CompletionStage<RestResponse> restore(RestRequest request) {
BackupManager backupManager = invocationHelper.getServer().getBackupManager();
return BackupManagerResource.handleRestoreRequest(request, backupManager, (name, path, json) -> {
BackupManager.Resources resources = BackupManagerResource.getResources(json);
Map<String, BackupManager.Resources> restoreParams = Collections.singletonMap(cacheManagerName, resources);
return backupManager.restore(name, path, restoreParams);
});
}
use of org.infinispan.server.core.BackupManager in project infinispan by infinispan.
the class BackupManagerResource method handleGetBackup.
private static CompletionStage<RestResponse> handleGetBackup(String name, RestRequest request, BackupManager backupManager, Method method) {
BackupManager.Status status = backupManager.getBackupStatus(name);
switch(status) {
case FAILED:
return responseFuture(INTERNAL_SERVER_ERROR);
case NOT_FOUND:
return responseFuture(NOT_FOUND);
case IN_PROGRESS:
return responseFuture(ACCEPTED);
default:
File zip = backupManager.getBackupLocation(name).toFile();
NettyRestResponse.Builder responseBuilder = new NettyRestResponse.Builder();
responseBuilder.contentType(MediaType.APPLICATION_ZIP).header("Content-Disposition", String.format("attachment; filename=%s", zip.getName())).contentLength(zip.length());
if (method == Method.GET)
responseBuilder.entity(zip);
return CompletableFuture.completedFuture(responseBuilder.build());
}
}
Aggregations