Search in sources :

Example 6 with BackupManager

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));
}
Also used : Set(java.util.Set) BackupManager(org.infinispan.server.core.BackupManager)

Example 7 with BackupManager

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);
    });
}
Also used : BackupManager(org.infinispan.server.core.BackupManager)

Example 8 with BackupManager

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));
}
Also used : BackupManager(org.infinispan.server.core.BackupManager)

Example 9 with BackupManager

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);
    });
}
Also used : BackupManager(org.infinispan.server.core.BackupManager)

Example 10 with BackupManager

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());
    }
}
Also used : BackupManager(org.infinispan.server.core.BackupManager) File(java.io.File) NettyRestResponse(org.infinispan.rest.NettyRestResponse)

Aggregations

BackupManager (org.infinispan.server.core.BackupManager)11 IOException (java.io.IOException)3 Path (java.nio.file.Path)3 Set (java.util.Set)3 File (java.io.File)2 DefaultCacheManager (org.infinispan.manager.DefaultCacheManager)2 BlockingManager (org.infinispan.util.concurrent.BlockingManager)2 FullHttpRequest (io.netty.handler.codec.http.FullHttpRequest)1 DefaultHttpDataFactory (io.netty.handler.codec.http.multipart.DefaultHttpDataFactory)1 DiskAttribute (io.netty.handler.codec.http.multipart.DiskAttribute)1 DiskFileUpload (io.netty.handler.codec.http.multipart.DiskFileUpload)1 HttpPostMultipartRequestDecoder (io.netty.handler.codec.http.multipart.HttpPostMultipartRequestDecoder)1 InterfaceHttpPostRequestDecoder (io.netty.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder)1 BufferedReader (java.io.BufferedReader)1 InputStreamReader (java.io.InputStreamReader)1 ObjectInput (java.io.ObjectInput)1 ObjectOutput (java.io.ObjectOutput)1 URL (java.net.URL)1 Paths (java.nio.file.Paths)1 PrivilegedActionException (java.security.PrivilegedActionException)1