Search in sources :

Example 6 with BackupException

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);
            }
        });
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) BackupException(com.alibaba.maxgraph.compiler.api.exception.BackupException) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HashMap(java.util.HashMap) Map(java.util.Map) BackupException(com.alibaba.maxgraph.compiler.api.exception.BackupException) IOException(java.io.IOException)

Example 7 with BackupException

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);
            }
        });
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) BackupException(com.alibaba.maxgraph.compiler.api.exception.BackupException) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HashMap(java.util.HashMap) Map(java.util.Map) BackupException(com.alibaba.maxgraph.compiler.api.exception.BackupException) IOException(java.io.IOException)

Aggregations

BackupException (com.alibaba.maxgraph.compiler.api.exception.BackupException)7 IOException (java.io.IOException)7 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)7 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)7 HashMap (java.util.HashMap)4 Map (java.util.Map)4 StoreBackupId (com.alibaba.graphscope.groot.store.StoreBackupId)3 MaxGraphException (com.alibaba.maxgraph.compiler.api.exception.MaxGraphException)3 FileNotFoundException (java.io.FileNotFoundException)3 SnapshotWithSchema (com.alibaba.graphscope.groot.SnapshotWithSchema)1 BackupInfo (com.alibaba.maxgraph.sdkcommon.common.BackupInfo)1 Path (java.nio.file.Path)1