You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ratis.apache.org by ru...@apache.org on 2021/01/20 10:52:36 UTC
[incubator-ratis] branch master updated: RATIS-1289. Support skip
the storagedir with multiple volumes which cause by bad disk (#396)
This is an automated email from the ASF dual-hosted git repository.
runzhiwang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ratis.git
The following commit(s) were added to refs/heads/master by this push:
new 17bc494 RATIS-1289. Support skip the storagedir with multiple volumes which cause by bad disk (#396)
17bc494 is described below
commit 17bc4949b6293760661369eb959a162986661957
Author: cchenax <38...@users.noreply.github.com>
AuthorDate: Wed Jan 20 18:52:25 2021 +0800
RATIS-1289. Support skip the storagedir with multiple volumes which cause by bad disk (#396)
---
.../java/org/apache/ratis/server/impl/ServerState.java | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/ratis-server/src/main/java/org/apache/ratis/server/impl/ServerState.java b/ratis-server/src/main/java/org/apache/ratis/server/impl/ServerState.java
index 29d8320..728f7e9 100644
--- a/ratis-server/src/main/java/org/apache/ratis/server/impl/ServerState.java
+++ b/ratis-server/src/main/java/org/apache/ratis/server/impl/ServerState.java
@@ -40,6 +40,7 @@ import org.apache.ratis.util.Timestamp;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
+import java.nio.file.AccessDeniedException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -67,7 +68,7 @@ class ServerState implements Closeable {
/** The thread that applies committed log entries to the state machine */
private final StateMachineUpdater stateMachineUpdater;
/** local storage for log and snapshot */
- private final RaftStorageImpl storage;
+ private RaftStorageImpl storage;
private final SnapshotManager snapshotManager;
private volatile Timestamp lastNoLeaderTime;
private final TimeDuration noLeaderTimeout;
@@ -103,10 +104,17 @@ class ServerState implements Closeable {
configurationManager = new ConfigurationManager(initialConf);
LOG.info("{}: {}", getMemberId(), configurationManager);
- // use full uuid string to create a subdirectory
- final File dir = chooseStorageDir(RaftServerConfigKeys.storageDir(prop),
- group.getGroupId().getUuid().toString());
- storage = new RaftStorageImpl(dir, RaftServerConfigKeys.Log.corruptionPolicy(prop));
+ List<File> directories = RaftServerConfigKeys.storageDir(prop);
+ while (!directories.isEmpty()) {
+ // use full uuid string to create a subdirectory
+ File dir = chooseStorageDir(directories, group.getGroupId().getUuid().toString());
+ try {
+ storage = new RaftStorageImpl(dir, RaftServerConfigKeys.Log.corruptionPolicy(prop));
+ break;
+ } catch (AccessDeniedException e) {
+ directories.remove(dir);
+ }
+ }
snapshotManager = new SnapshotManager(storage, id);
stateMachine.initialize(server.getRaftServer(), group.getGroupId(), storage);