Search in sources :

Example 6 with StoreBackupId

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());
    }
}
Also used : BackupException(com.alibaba.maxgraph.compiler.api.exception.BackupException) BackupException(com.alibaba.maxgraph.compiler.api.exception.BackupException) MaxGraphException(com.alibaba.maxgraph.compiler.api.exception.MaxGraphException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) StoreBackupId(com.alibaba.graphscope.groot.store.StoreBackupId) AtomicInteger(java.util.concurrent.atomic.AtomicInteger)

Example 7 with StoreBackupId

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());
    }
}
Also used : BackupException(com.alibaba.maxgraph.compiler.api.exception.BackupException) BackupException(com.alibaba.maxgraph.compiler.api.exception.BackupException) MaxGraphException(com.alibaba.maxgraph.compiler.api.exception.MaxGraphException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) StoreBackupId(com.alibaba.graphscope.groot.store.StoreBackupId) AtomicInteger(java.util.concurrent.atomic.AtomicInteger)

Aggregations

StoreBackupId (com.alibaba.graphscope.groot.store.StoreBackupId)7 IOException (java.io.IOException)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 BackupException (com.alibaba.maxgraph.compiler.api.exception.BackupException)3 MaxGraphException (com.alibaba.maxgraph.compiler.api.exception.MaxGraphException)3 FileNotFoundException (java.io.FileNotFoundException)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 Test (org.junit.jupiter.api.Test)3 SnapshotWithSchema (com.alibaba.graphscope.groot.SnapshotWithSchema)2 Configs (com.alibaba.maxgraph.common.config.Configs)2 BackupInfo (com.alibaba.maxgraph.sdkcommon.common.BackupInfo)2 CompletionCallback (com.alibaba.graphscope.groot.CompletionCallback)1 SnapshotCache (com.alibaba.graphscope.groot.SnapshotCache)1 BackupManager (com.alibaba.graphscope.groot.coordinator.BackupManager)1 MetaService (com.alibaba.graphscope.groot.meta.MetaService)1 MetaStore (com.alibaba.graphscope.groot.meta.MetaStore)1 BackupAgent (com.alibaba.graphscope.groot.store.BackupAgent)1 GraphPartition (com.alibaba.graphscope.groot.store.GraphPartition)1 StoreService (com.alibaba.graphscope.groot.store.StoreService)1 JnaGraphBackupEngine (com.alibaba.graphscope.groot.store.jna.JnaGraphBackupEngine)1