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();
}
Aggregations