Skip to content

Commit

Permalink
Refactor some code in RocksDBStdSessions
Browse files Browse the repository at this point in the history
Change-Id: I0561be1a71322644465e745ded9ca1636bff078a
  • Loading branch information
Linary committed Mar 26, 2021
1 parent 060f190 commit fcb5860
Show file tree
Hide file tree
Showing 7 changed files with 209 additions and 205 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ private String writeManifest(SnapshotWriter writer,
// Write all backend compressed snapshot file path to manifest
String jraftSnapshotPath = Paths.get(writerPath, SNAPSHOT_DIR)
.toString();
File snapshotManifest = new File(jraftSnapshotPath, MANIFEST);
File snapshotManifestFile = new File(jraftSnapshotPath, MANIFEST);
try {
FileUtils.writeLines(snapshotManifest, snapshotFiles);
FileUtils.writeLines(snapshotManifestFile, snapshotFiles);
} catch (IOException e) {
done.run(new Status(RaftError.EIO,
"Failed to write backend snapshot file path " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ public class HugeSecurityManager extends SecurityManager {
ImmutableSet.of("execute")
);

private static final Map<String, Set<String>> ROCKSDB_SNAPSHOT = ImmutableMap.of(
"com.baidu.hugegraph.backend.store.rocksdb.RocksDBStore",
ImmutableSet.of("createSnapshot", "resumeSnapshot")
);

private static final Set<String> HBASE_CLASSES = ImmutableSet.of(
// Fixed #758
"com.baidu.hugegraph.backend.store.hbase.HbaseStore",
Expand All @@ -103,10 +108,6 @@ public class HugeSecurityManager extends SecurityManager {
"com.baidu.hugegraph.backend.store.hbase.HbaseSessions$RowIterator"
);

private static final Set<String> ROCKSDB_CLASSES = ImmutableSet.of(
"com.baidu.hugegraph.backend.store.rocksdb.RocksDBStore"
);

private static final Set<String> RAFT_CLASSES = ImmutableSet.of(
"com.baidu.hugegraph.backend.store.raft.RaftNode",
"com.baidu.hugegraph.backend.store.raft.StoreStateMachine",
Expand Down Expand Up @@ -451,7 +452,7 @@ private static boolean callFromBackendHbase() {
}

private static boolean callFromBackendRocksDB() {
return callFromWorkerWithClass(ROCKSDB_CLASSES);
return callFromMethods(ROCKSDB_SNAPSHOT);
}

private static boolean callFromRaft() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@

package com.baidu.hugegraph.backend.store.rocksdb;

import java.nio.file.Path;
import java.util.List;
import java.util.Set;

import org.apache.commons.lang3.tuple.Pair;
import org.rocksdb.RocksDBException;

import com.alipay.sofa.jraft.storage.snapshot.remote.Session;
import com.baidu.hugegraph.backend.store.BackendEntry.BackendColumnIterator;
import com.baidu.hugegraph.backend.store.BackendSession.AbstractBackendSession;
import com.baidu.hugegraph.backend.store.BackendSessionPool;
Expand All @@ -52,10 +52,10 @@ public abstract RocksDBSessions copy(HugeConfig config,

public abstract void resumeSnapshot(String snapshotPath);

public abstract Path buildSnapshotPath(Path originDataPath,
String snapshotPrefix,
boolean deleteSnapshot)
throws RocksDBException;
public abstract String buildSnapshotPath(String snapshotPrefix);

public abstract String hardLinkSnapshot(String snapshotPath)
throws RocksDBException;

public abstract void reloadRocksDB() throws RocksDBException;

Expand Down
Loading

0 comments on commit fcb5860

Please sign in to comment.