use of io.atomix.protocols.raft.protocol.TestRaftProtocolFactory in project atomix by atomix.
the class RaftTest method clearTests.
@Before
@After
public void clearTests() throws Exception {
clients.forEach(c -> {
try {
c.close().get(10, TimeUnit.SECONDS);
} catch (Exception e) {
}
});
servers.forEach(s -> {
try {
if (s.isRunning()) {
s.shutdown().get(10, TimeUnit.SECONDS);
}
} catch (Exception e) {
}
});
Path directory = Paths.get("target/test-logs/");
if (Files.exists(directory)) {
Files.walkFileTree(directory, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
Files.delete(file);
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
Files.delete(dir);
return FileVisitResult.CONTINUE;
}
});
}
if (context != null) {
context.close();
}
members = new ArrayList<>();
nextId = 0;
clients = new ArrayList<>();
servers = new ArrayList<>();
context = new SingleThreadContext("raft-test-messaging-%d");
protocolFactory = new TestRaftProtocolFactory(context);
}
Aggregations