Search in sources :

Example 1 with LocalRaftProtocolFactory

use of io.atomix.protocols.raft.protocol.LocalRaftProtocolFactory in project atomix by atomix.

the class RaftFuzzTest method reset.

/**
 * Shuts down clients and servers.
 */
private void reset() throws Exception {
    for (Scheduled shutdownTimer : shutdownTimers.values()) {
        shutdownTimer.cancel();
    }
    shutdownTimers.clear();
    for (Scheduled restartTimer : restartTimers.values()) {
        restartTimer.cancel();
    }
    restartTimers.clear();
    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/fuzz-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;
            }
        });
    }
    members = new ArrayList<>();
    port = 5000;
    clients = new ArrayList<>();
    servers = new ArrayList<>();
    protocolFactory = new LocalRaftProtocolFactory(protocolSerializer);
}
Also used : Scheduled(io.atomix.utils.concurrent.Scheduled) Path(java.nio.file.Path) LocalRaftProtocolFactory(io.atomix.protocols.raft.protocol.LocalRaftProtocolFactory) FileVisitResult(java.nio.file.FileVisitResult) IOException(java.io.IOException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) BasicFileAttributes(java.nio.file.attribute.BasicFileAttributes)

Example 2 with LocalRaftProtocolFactory

use of io.atomix.protocols.raft.protocol.LocalRaftProtocolFactory in project atomix by atomix.

the class RaftPerformanceTest method reset.

/**
 * Resets the test state.
 */
private void reset() throws Exception {
    totalOperations.set(0);
    readCount.set(0);
    writeCount.set(0);
    shutdown();
    members = new ArrayList<>();
    clients = new ArrayList<>();
    servers = new ArrayList<>();
    messagingServices = new ArrayList<>();
    endpointMap = new ConcurrentHashMap<>();
    protocolFactory = new LocalRaftProtocolFactory(protocolSerializer);
}
Also used : LocalRaftProtocolFactory(io.atomix.protocols.raft.protocol.LocalRaftProtocolFactory)

Aggregations

LocalRaftProtocolFactory (io.atomix.protocols.raft.protocol.LocalRaftProtocolFactory)2 Scheduled (io.atomix.utils.concurrent.Scheduled)1 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 FileVisitResult (java.nio.file.FileVisitResult)1 Path (java.nio.file.Path)1 BasicFileAttributes (java.nio.file.attribute.BasicFileAttributes)1