示例#1
0
        public void TimeOfflineNoOld()
        {
            var te = Executors.NewTest();
            var rp = new ReplayProcessor <int>(16, TimeSpan.FromSeconds(2), te);

            rp.OnNext(1);
            rp.OnNext(2);

            te.AdvanceTimeBy(TimeSpan.FromSeconds(1));

            rp.OnNext(3);
            rp.OnNext(4);

            te.AdvanceTimeBy(TimeSpan.FromSeconds(1));

            var ts = rp.Test();

            ts.AssertValues(3, 4);

            te.AdvanceTimeBy(TimeSpan.FromSeconds(1));

            rp.OnComplete();

            ts.AssertResult(3, 4);

            rp.Test().AssertResult();
        }
示例#2
0
        public void BoundedTimeOffline()
        {
            var rp = new ReplayProcessor <int>(16, TimeSpan.FromMinutes(1), Executors.Task);

            for (int i = 0; i < 9; i++)
            {
                rp.OnNext(i);
            }
            rp.OnComplete();

            rp.Test()
            .AssertResult(0, 1, 2, 3, 4, 5, 6, 7, 8);
        }
示例#3
0
        public void BoundedOffline()
        {
            var rp = new ReplayProcessor <int>(16);

            for (int i = 0; i < 9; i++)
            {
                rp.OnNext(i);
            }
            rp.OnComplete();

            rp.Test()
            .AssertResult(0, 1, 2, 3, 4, 5, 6, 7, 8);
        }
示例#4
0
        public void Offline()
        {
            var rp = ReplayProcessor <int> .CreateUnbounded(2);

            for (int i = 0; i < 9; i++)
            {
                rp.OnNext(i);
            }
            rp.OnComplete();

            rp.Test()
            .AssertResult(0, 1, 2, 3, 4, 5, 6, 7, 8);
        }
        public override IPublisher <int> CreatePublisher(long elements)
        {
            var pp = new ReplayProcessor <int>();

            Task.Factory.StartNew(() => {
                while (!pp.HasSubscribers)
                {
                    Thread.Sleep(10);
                }
                for (int i = 0; i < elements; i++)
                {
                    pp.OnNext(i);
                }
                pp.OnComplete();
            }, TaskCreationOptions.LongRunning);

            return(pp);
        }
示例#6
0
        static void ParseReplayLog(string replayName, Stream file)
        {
            var key = new ReplayKey(
                replayName.Substring(0, 2),
                DateTime.ParseExact(replayName.Substring(3, 19), "yyyy-MM-dd-HH-mm-ss", CultureInfo.InvariantCulture)
                );

            if (ExistingRecords.Contains(key))
            {
                return;
            }

            var stream = PboFile.FromStream(file).OpenFile("log.txt");

            if (stream != null)
            {
                using (var input = new StreamReader(stream))
                {
                    var    p = new ReplayProcessor(input);
                    Replay replay;
                    try
                    {
                        replay = p.ProcessReplay();
                        if (replay != null)
                        {
                            Interlocked.Increment(ref counterParsed);
                        }
                    }
                    catch (ParseException e)
                    {
                        exceptions.Writer.TryWrite(Tuple.Create(replayName, (Exception)e));
                        replay = p.GetResult();
                    }
                    Interlocked.Increment(ref counterProcessed);
                    if (replay != null)
                    {
                        replay.Server = replayName.Substring(0, 2);
                        queue.Writer.TryWrite(replay);
                    }
                }
            }
        }