Search in sources :

Example 1 with TestLogProtocolFactory

use of io.atomix.protocols.log.protocol.TestLogProtocolFactory in project atomix by atomix.

the class DistributedLogTest method clearTests.

@Before
@After
public void clearTests() throws Exception {
    Futures.allOf(servers.stream().map(s -> s.stop().exceptionally(v -> null)).collect(Collectors.toList())).get(30, TimeUnit.SECONDS);
    Futures.allOf(clients.stream().map(c -> c.close().exceptionally(v -> null)).collect(Collectors.toList())).get(30, TimeUnit.SECONDS);
    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;
            }
        });
    }
    nodes = new ArrayList<>();
    memberId = 0;
    sessionId = 0;
    clients = new ArrayList<>();
    servers = new ArrayList<>();
    protocolFactory = new TestLogProtocolFactory();
    election = new TestPrimaryElection(PartitionId.from("test", 1));
}
Also used : ServiceExecutor(io.atomix.primitive.service.ServiceExecutor) Arrays(java.util.Arrays) TimeoutException(java.util.concurrent.TimeoutException) MemberGroupStrategy(io.atomix.primitive.partition.MemberGroupStrategy) SessionId(io.atomix.primitive.session.SessionId) PrimitiveManagementService(io.atomix.primitive.PrimitiveManagementService) Duration(java.time.Duration) PrimitiveConfig(io.atomix.primitive.config.PrimitiveConfig) After(org.junit.After) Session(io.atomix.primitive.session.Session) Path(java.nio.file.Path) SimpleFileVisitor(java.nio.file.SimpleFileVisitor) ConcurrentTestCase(net.jodah.concurrentunit.ConcurrentTestCase) PrimitiveBuilder(io.atomix.primitive.PrimitiveBuilder) Predicate(java.util.function.Predicate) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) FileVisitResult(java.nio.file.FileVisitResult) List(java.util.List) PrimitiveService(io.atomix.primitive.service.PrimitiveService) ServiceConfig(io.atomix.primitive.service.ServiceConfig) PrimaryElection(io.atomix.primitive.partition.PrimaryElection) BackupOutput(io.atomix.primitive.service.BackupOutput) Serializer(io.atomix.utils.serializer.Serializer) BackupInput(io.atomix.primitive.service.BackupInput) DefaultSerializers(io.atomix.utils.serializer.serializers.DefaultSerializers) CompletableFuture(java.util.concurrent.CompletableFuture) EventType(io.atomix.primitive.event.EventType) ArrayList(java.util.ArrayList) PartitionId(io.atomix.primitive.partition.PartitionId) OperationId(io.atomix.primitive.operation.OperationId) LogSession(io.atomix.primitive.log.LogSession) TestClusterMembershipService(io.atomix.cluster.TestClusterMembershipService) MemberId(io.atomix.cluster.MemberId) Futures(io.atomix.utils.concurrent.Futures) Before(org.junit.Before) TestLogProtocolFactory(io.atomix.protocols.log.protocol.TestLogProtocolFactory) Files(java.nio.file.Files) Commit(io.atomix.primitive.service.Commit) TestPrimaryElection(io.atomix.primitive.partition.TestPrimaryElection) IOException(java.io.IOException) Test(org.junit.Test) BasicFileAttributes(java.nio.file.attribute.BasicFileAttributes) File(java.io.File) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) AbstractPrimitiveService(io.atomix.primitive.service.AbstractPrimitiveService) Paths(java.nio.file.Paths) PrimitiveType(io.atomix.primitive.PrimitiveType) Assert.assertEquals(org.junit.Assert.assertEquals) Path(java.nio.file.Path) TestPrimaryElection(io.atomix.primitive.partition.TestPrimaryElection) FileVisitResult(java.nio.file.FileVisitResult) IOException(java.io.IOException) TestLogProtocolFactory(io.atomix.protocols.log.protocol.TestLogProtocolFactory) BasicFileAttributes(java.nio.file.attribute.BasicFileAttributes) Before(org.junit.Before) After(org.junit.After)

Aggregations

MemberId (io.atomix.cluster.MemberId)1 TestClusterMembershipService (io.atomix.cluster.TestClusterMembershipService)1 PrimitiveBuilder (io.atomix.primitive.PrimitiveBuilder)1 PrimitiveManagementService (io.atomix.primitive.PrimitiveManagementService)1 PrimitiveType (io.atomix.primitive.PrimitiveType)1 PrimitiveConfig (io.atomix.primitive.config.PrimitiveConfig)1 EventType (io.atomix.primitive.event.EventType)1 LogSession (io.atomix.primitive.log.LogSession)1 OperationId (io.atomix.primitive.operation.OperationId)1 MemberGroupStrategy (io.atomix.primitive.partition.MemberGroupStrategy)1 PartitionId (io.atomix.primitive.partition.PartitionId)1 PrimaryElection (io.atomix.primitive.partition.PrimaryElection)1 TestPrimaryElection (io.atomix.primitive.partition.TestPrimaryElection)1 AbstractPrimitiveService (io.atomix.primitive.service.AbstractPrimitiveService)1 BackupInput (io.atomix.primitive.service.BackupInput)1 BackupOutput (io.atomix.primitive.service.BackupOutput)1 Commit (io.atomix.primitive.service.Commit)1 PrimitiveService (io.atomix.primitive.service.PrimitiveService)1 ServiceConfig (io.atomix.primitive.service.ServiceConfig)1 ServiceExecutor (io.atomix.primitive.service.ServiceExecutor)1