Search in sources :

Example 1 with LocalRaftProtocolFactory

use of io.atomix.protocols.raft.test.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<>();
    addressMap = new ConcurrentHashMap<>();
    protocolFactory = new LocalRaftProtocolFactory(PROTOCOL_SERIALIZER);
}
Also used : LocalRaftProtocolFactory(io.atomix.protocols.raft.test.protocol.LocalRaftProtocolFactory)

Example 2 with LocalRaftProtocolFactory

use of io.atomix.protocols.raft.test.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(PROTOCOL_SERIALIZER);
}
Also used : Scheduled(io.atomix.utils.concurrent.Scheduled) Path(java.nio.file.Path) LocalRaftProtocolFactory(io.atomix.protocols.raft.test.protocol.LocalRaftProtocolFactory) FileVisitResult(java.nio.file.FileVisitResult) IOException(java.io.IOException) IOException(java.io.IOException) BasicFileAttributes(java.nio.file.attribute.BasicFileAttributes)

Aggregations

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