use of com.alibaba.graphscope.groot.store.StoreBackupId in project GraphScope by alibaba.
the class BackupManager method verifyBackup.
public void verifyBackup(int globalBackupId) throws BackupException {
checkEnable();
if (!this.globalBackupIdToInfo.containsKey(globalBackupId)) {
throw new BackupException("backup #[" + globalBackupId + "] not ready/existed");
}
List<StoreBackupId> storeBackupIds = getStoreBackupIds(globalBackupId);
AtomicInteger counter = new AtomicInteger(storeNodeCount);
AtomicBoolean finished = new AtomicBoolean(false);
CompletableFuture<Void> future = new CompletableFuture<>();
for (int sId = 0; sId < storeNodeCount; sId++) {
storeBackupTaskSender.verifyStoreBackup(sId, storeBackupIds.get(sId), new CompletionCallback<Void>() {
@Override
public void onCompleted(Void res) {
if (!finished.get() && counter.decrementAndGet() == 0) {
future.complete(null);
}
}
@Override
public void onError(Throwable t) {
if (finished.getAndSet(true)) {
return;
}
future.completeExceptionally(t);
}
});
}
try {
future.get();
} catch (Exception e) {
throw new BackupException(e.getMessage());
}
}
use of com.alibaba.graphscope.groot.store.StoreBackupId in project GraphScope by alibaba.
the class BackupManager method restoreGraphStore.
private void restoreGraphStore(int globalBackupId, String storeRestorePath) throws BackupException {
List<StoreBackupId> storeBackupIds = getStoreBackupIds(globalBackupId);
AtomicInteger counter = new AtomicInteger(storeNodeCount);
AtomicBoolean finished = new AtomicBoolean(false);
CompletableFuture<Void> future = new CompletableFuture<>();
for (int sId = 0; sId < storeNodeCount; sId++) {
storeBackupTaskSender.restoreFromStoreBackup(sId, storeBackupIds.get(sId), storeRestorePath, new CompletionCallback<Void>() {
@Override
public void onCompleted(Void res) {
if (!finished.get() && counter.decrementAndGet() == 0) {
future.complete(null);
}
}
@Override
public void onError(Throwable t) {
if (finished.getAndSet(true)) {
return;
}
future.completeExceptionally(t);
}
});
}
try {
future.get();
} catch (Exception e) {
throw new BackupException(e.getMessage());
}
}
Aggregations