Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,17 @@ private RaftServerImpl getImpl(RaftGroupId groupId) throws IOException {
List<RaftServerImpl> getImpls() throws IOException {
final List<RaftServerImpl> list = new ArrayList<>();
for(CompletableFuture<RaftServerImpl> f : impls.getAll()) {
list.add(IOUtils.getFromFuture(f, this::getId));
try {
RaftServerImpl result = f.exceptionally(e->{
LOG.warn("raft groupid " + this.getId() +" initlog is error");
return null;
}).get();
if (result != null) {
list.add(IOUtils.getFromFuture(f, this::getId));
}
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
}
return list;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down