use of com.alibaba.maxgraph.compiler.api.exception.BackupException in project GraphScope by alibaba.
the class BackupAgent method createNewStoreBackup.
public void createNewStoreBackup(int globalBackupId, CompletionCallback<StoreBackupId> callback) {
try {
checkEnable();
} catch (BackupException e) {
callback.onError(e);
return;
}
StoreBackupId storeBackupId = new StoreBackupId(globalBackupId);
AtomicInteger counter = new AtomicInteger(this.idToPartitionBackup.size());
AtomicBoolean finished = new AtomicBoolean(false);
for (Map.Entry<Integer, GraphPartitionBackup> entry : this.idToPartitionBackup.entrySet()) {
this.backupExecutor.execute(() -> {
if (finished.get()) {
return;
}
try {
int partitionId = entry.getKey();
int partitionBackupId = entry.getValue().createNewPartitionBackup();
storeBackupId.addPartitionBackupId(partitionId, partitionBackupId);
if (counter.decrementAndGet() == 0) {
callback.onCompleted(storeBackupId);
}
} catch (Exception e) {
if (finished.getAndSet(true)) {
return;
}
callback.onError(e);
}
});
}
}
use of com.alibaba.maxgraph.compiler.api.exception.BackupException in project GraphScope by alibaba.
the class BackupAgent method clearUnavailableStoreBackups.
public void clearUnavailableStoreBackups(Map<Integer, List<Integer>> readyPartitionBackupIds, CompletionCallback<Void> callback) {
try {
checkEnable();
} catch (BackupException e) {
callback.onError(e);
return;
}
if (readyPartitionBackupIds.size() != this.idToPartitionBackup.size()) {
callback.onError(new BackupException("doing store backup up gc with incorrect ready partitionBackupId" + " lists"));
return;
}
AtomicInteger counter = new AtomicInteger(this.idToPartitionBackup.size());
AtomicBoolean finished = new AtomicBoolean(false);
for (Map.Entry<Integer, GraphPartitionBackup> entry : this.idToPartitionBackup.entrySet()) {
this.backupExecutor.execute(() -> {
if (finished.get()) {
return;
}
try {
int partitionId = entry.getKey();
entry.getValue().partitionBackupGc(readyPartitionBackupIds.get(partitionId));
if (counter.decrementAndGet() == 0) {
callback.onCompleted(null);
}
} catch (Exception e) {
if (finished.getAndSet(true)) {
return;
}
callback.onError(e);
}
});
}
}
Aggregations