Exemplo n.º 1
0
        public override async Task TestFixtureTearDown()
        {
            _logFormat?.Dispose();
            await base.TestFixtureTearDown();

            Service.Handle(new SystemMessage.BecomeShuttingDown(Guid.NewGuid(), true, true));
        }
Exemplo n.º 2
0
        public override async Task TestFixtureSetUp()
        {
            await base.TestFixtureSetUp();

            Publisher.Subscribe(new AdHocHandler <ReplicationTrackingMessage.ReplicaWriteAck>(msg => ReplicaWriteAcks.Enqueue(msg)));
            Publisher.Subscribe(new AdHocHandler <SystemMessage.VNodeConnectionLost>(msg => ReplicaLostMessages.Enqueue(msg)));
            TcpSendPublisher.Subscribe(new AdHocHandler <TcpMessage.TcpSend>(msg => TcpSends.Enqueue(msg)));

            DbConfig = CreateDbConfig();
            var db = new TFChunkDb(DbConfig);

            db.Open();
            Service = new LeaderReplicationService(
                publisher: Publisher,
                instanceId: LeaderId,
                db: db,
                tcpSendPublisher: TcpSendPublisher,
                epochManager: new FakeEpochManager(),
                clusterSize: ClusterSize,
                unsafeAllowSurplusNodes: false,
                queueStatsManager: new QueueStatsManager());

            Service.Handle(new SystemMessage.SystemStart());
            Service.Handle(new SystemMessage.BecomeLeader(Guid.NewGuid()));

            ReplicaSubscriptionId         = AddSubscription(ReplicaId, true, out ReplicaManager1);
            ReplicaSubscriptionId2        = AddSubscription(ReplicaId2, true, out ReplicaManager2);
            ReadOnlyReplicaSubscriptionId = AddSubscription(ReadOnlyReplicaId, false, out ReadOnlyReplicaManager);


            When();
        }
Exemplo n.º 3
0
        public override async Task TestFixtureSetUp()
        {
            await base.TestFixtureSetUp();

            var indexDirectory = GetFilePathFor("index");

            _logFormat = LogFormatHelper <TLogFormat, TStreamId> .LogFormatFactory.Create(new() {
                IndexDirectory = indexDirectory,
            });

            TcpSendPublisher.Subscribe(new AdHocHandler <TcpMessage.TcpSend>(msg => TcpSends.Enqueue(msg)));

            DbConfig = CreateDbConfig();
            Db       = new TFChunkDb(DbConfig);
            Db.Open();

            Writer       = new TFChunkWriter(Db);
            EpochManager = new EpochManager <TStreamId>(
                Publisher,
                5,
                DbConfig.EpochCheckpoint,
                Writer,
                1, 1,
                () => new TFChunkReader(Db, Db.Config.WriterCheckpoint,
                                        optimizeReadSideCache: Db.Config.OptimizeReadSideCache),
                _logFormat.RecordFactory,
                _logFormat.StreamNameIndex,
                _logFormat.EventTypeIndex,
                _logFormat.CreatePartitionManager(
                    reader: new TFChunkReader(Db, Db.Config.WriterCheckpoint),
                    writer: Writer),
                Guid.NewGuid());
            Service = new LeaderReplicationService(
                Publisher,
                LeaderId,
                Db,
                TcpSendPublisher,
                EpochManager,
                ClusterSize,
                false,
                new QueueStatsManager());

            Service.Handle(new SystemMessage.SystemStart());
            Service.Handle(new SystemMessage.BecomeLeader(Guid.NewGuid()));

            When();
        }