Search in sources :

Example 1 with TestPrimaryElection

use of io.atomix.primitive.partition.TestPrimaryElection in project atomix by atomix.

the class PrimaryBackupTest 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);
    nodes = new ArrayList<>();
    memberId = 0;
    sessionId = 0;
    clients = new ArrayList<>();
    servers = new ArrayList<>();
    protocolFactory = new TestPrimaryBackupProtocolFactory();
    election = new TestPrimaryElection(PartitionId.from("test", 1));
}
Also used : BackupInput(io.atomix.primitive.service.BackupInput) ServiceExecutor(io.atomix.primitive.service.ServiceExecutor) DefaultSerializers(io.atomix.utils.serializer.serializers.DefaultSerializers) TimeoutException(java.util.concurrent.TimeoutException) CompletableFuture(java.util.concurrent.CompletableFuture) Role(io.atomix.protocols.backup.PrimaryBackupServer.Role) EventType(io.atomix.primitive.event.EventType) TestPrimaryBackupProtocolFactory(io.atomix.protocols.backup.protocol.TestPrimaryBackupProtocolFactory) MemberGroupStrategy(io.atomix.primitive.partition.MemberGroupStrategy) PartitionId(io.atomix.primitive.partition.PartitionId) ArrayList(java.util.ArrayList) SessionId(io.atomix.primitive.session.SessionId) OperationId(io.atomix.primitive.operation.OperationId) PrimitiveOperation.operation(io.atomix.primitive.operation.PrimitiveOperation.operation) PrimitiveManagementService(io.atomix.primitive.PrimitiveManagementService) PrimitiveConfig(io.atomix.primitive.config.PrimitiveConfig) After(org.junit.After) Duration(java.time.Duration) TestClusterMembershipService(io.atomix.cluster.TestClusterMembershipService) MemberId(io.atomix.cluster.MemberId) Session(io.atomix.primitive.session.Session) Futures(io.atomix.utils.concurrent.Futures) ConcurrentTestCase(net.jodah.concurrentunit.ConcurrentTestCase) Before(org.junit.Before) PrimitiveBuilder(io.atomix.primitive.PrimitiveBuilder) Commit(io.atomix.primitive.service.Commit) TestPrimaryElection(io.atomix.primitive.partition.TestPrimaryElection) Test(org.junit.Test) Collectors(java.util.stream.Collectors) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) AtomicLong(java.util.concurrent.atomic.AtomicLong) List(java.util.List) PrimitiveService(io.atomix.primitive.service.PrimitiveService) AbstractPrimitiveService(io.atomix.primitive.service.AbstractPrimitiveService) Ignore(org.junit.Ignore) ServiceConfig(io.atomix.primitive.service.ServiceConfig) PrimitiveType(io.atomix.primitive.PrimitiveType) PrimaryElection(io.atomix.primitive.partition.PrimaryElection) Replication(io.atomix.primitive.Replication) BackupOutput(io.atomix.primitive.service.BackupOutput) SessionClient(io.atomix.primitive.session.SessionClient) Serializer(io.atomix.utils.serializer.Serializer) Assert.assertEquals(org.junit.Assert.assertEquals) TestPrimaryElection(io.atomix.primitive.partition.TestPrimaryElection) TestPrimaryBackupProtocolFactory(io.atomix.protocols.backup.protocol.TestPrimaryBackupProtocolFactory) Before(org.junit.Before) After(org.junit.After)

Example 2 with TestPrimaryElection

use of io.atomix.primitive.partition.TestPrimaryElection 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)2 TestClusterMembershipService (io.atomix.cluster.TestClusterMembershipService)2 PrimitiveBuilder (io.atomix.primitive.PrimitiveBuilder)2 PrimitiveManagementService (io.atomix.primitive.PrimitiveManagementService)2 PrimitiveType (io.atomix.primitive.PrimitiveType)2 PrimitiveConfig (io.atomix.primitive.config.PrimitiveConfig)2 EventType (io.atomix.primitive.event.EventType)2 OperationId (io.atomix.primitive.operation.OperationId)2 MemberGroupStrategy (io.atomix.primitive.partition.MemberGroupStrategy)2 PartitionId (io.atomix.primitive.partition.PartitionId)2 PrimaryElection (io.atomix.primitive.partition.PrimaryElection)2 TestPrimaryElection (io.atomix.primitive.partition.TestPrimaryElection)2 AbstractPrimitiveService (io.atomix.primitive.service.AbstractPrimitiveService)2 BackupInput (io.atomix.primitive.service.BackupInput)2 BackupOutput (io.atomix.primitive.service.BackupOutput)2 Commit (io.atomix.primitive.service.Commit)2 PrimitiveService (io.atomix.primitive.service.PrimitiveService)2 ServiceConfig (io.atomix.primitive.service.ServiceConfig)2 ServiceExecutor (io.atomix.primitive.service.ServiceExecutor)2 Session (io.atomix.primitive.session.Session)2