Search in sources :

Example 1 with NativeBackupable

use of voldemort.store.backup.NativeBackupable in project voldemort by voldemort.

the class AdminServiceRequestHandler method handleNativeBackup.

public VAdminProto.AsyncOperationStatusResponse handleNativeBackup(VAdminProto.NativeBackupRequest request) {
    final File backupDir = new File(request.getBackupDir());
    final boolean isIncremental = request.getIncremental();
    final boolean verifyFiles = request.getVerifyFiles();
    final String storeName = request.getStoreName();
    int requestId = asyncService.getUniqueRequestId();
    VAdminProto.AsyncOperationStatusResponse.Builder response = VAdminProto.AsyncOperationStatusResponse.newBuilder().setRequestId(requestId).setComplete(false).setDescription("Native backup").setStatus("started");
    try {
        final StorageEngine storageEngine = getStorageEngine(storeRepository, storeName);
        final long start = System.currentTimeMillis();
        if (storageEngine instanceof NativeBackupable) {
            asyncService.submitOperation(requestId, new AsyncOperation(requestId, "Native backup") {

                @Override
                public void markComplete() {
                    long end = System.currentTimeMillis();
                    status.setStatus("Native backup completed in " + (end - start) + "ms");
                    status.setComplete(true);
                }

                @Override
                public void operate() {
                    ((NativeBackupable) storageEngine).nativeBackup(backupDir, verifyFiles, isIncremental, status);
                }

                @Override
                public void stop() {
                    status.setException(new VoldemortException("Fetcher interrupted"));
                }
            });
        } else {
            response.setError(ProtoUtils.encodeError(errorCodeMapper, new VoldemortException("Selected store is not native backupable")));
        }
    } catch (VoldemortException e) {
        response.setError(ProtoUtils.encodeError(errorCodeMapper, e));
        logger.error("handleFetchStore failed for request(" + request.toString() + ")", e);
    }
    return response.build();
}
Also used : NativeBackupable(voldemort.store.backup.NativeBackupable) MysqlStorageEngine(voldemort.store.mysql.MysqlStorageEngine) StorageEngine(voldemort.store.StorageEngine) SlopStorageEngine(voldemort.store.slop.SlopStorageEngine) ReadOnlyStorageEngine(voldemort.store.readonly.ReadOnlyStorageEngine) File(java.io.File) VoldemortException(voldemort.VoldemortException)

Aggregations

File (java.io.File)1 VoldemortException (voldemort.VoldemortException)1 StorageEngine (voldemort.store.StorageEngine)1 NativeBackupable (voldemort.store.backup.NativeBackupable)1 MysqlStorageEngine (voldemort.store.mysql.MysqlStorageEngine)1 ReadOnlyStorageEngine (voldemort.store.readonly.ReadOnlyStorageEngine)1 SlopStorageEngine (voldemort.store.slop.SlopStorageEngine)1