コード例 #1
0
        public void SetUp()
        {
            Configuration configuration = new Configuration();

            configuration.AddEventType("MarketDataEvent", typeof(MarketDataEvent).FullName);
            configuration.EngineDefaults.EventMetaConfig.ClassPropertyResolutionStyle = PropertyResolutionStyle.CASE_INSENSITIVE;

            epService = EPServiceProviderManager.GetProvider("TestTicksPerSecondStatement", configuration);
            epService.Initialize();

            listener = new SupportUpdateListener();
            var stmt = TicksPerSecondStatement.Create(epService.EPAdministrator);

            stmt.Events += listener.Update;

            // Use external clocking for the test
            epService.EPRuntime.SendEvent(new TimerControlEvent(TimerControlEvent.ClockTypeEnum.CLOCK_EXTERNAL));
        }
コード例 #2
0
ファイル: FeedSimMain.cs プロジェクト: ikvm/nesper
        public void Run()
        {
            if (_isWaitKeypress)
            {
                Console.WriteLine("...press enter to start simulation...");
                Console.ReadKey();
            }

            // Configure engine with event names to make the statements more readable.
            // This could also be done in a configuration file.
            Configuration configuration = new Configuration();
            configuration.AddEventType("MarketDataEvent", typeof(MarketDataEvent).FullName);

            // Get engine instance
            EPServiceProvider epService = EPServiceProviderManager.GetProvider(_engineURI, configuration);

            // Set up statements
            var tickPerSecStmt = TicksPerSecondStatement.Create(epService.EPAdministrator);
            tickPerSecStmt.Events += LogRate;

            var falloffStmt = TicksFalloffStatement.Create(epService.EPAdministrator);
            falloffStmt.Events += MonitorRate;

            // Send events
            var threadPool = new DedicatedExecutorService(string.Empty, _numberOfThreads);
            MarketDataSendRunnable[] runnables = new MarketDataSendRunnable[_numberOfThreads];
            for (int i = 0; i < _numberOfThreads; i++)
            {
                runnables[i] = new MarketDataSendRunnable(epService);
                threadPool.Submit(runnables[i].Run);
            }

            int seconds = 0;
            Random random = new Random();
            while (seconds < _numSeconds)
            {
                seconds++;
                Thread.Sleep(1000);

                FeedEnum? feedToDropOff;
                if (random.NextDouble() * 100 < _dropProbability)
                {
                    feedToDropOff = FeedEnum.FEED_A;
                    if (random.Next(0, 2) == 1)
                    {
                        feedToDropOff = FeedEnum.FEED_B;
                    }
                    Log.Info("Setting drop-off for feed {0}", feedToDropOff);
                }
                else
                {
                    feedToDropOff = null;
                }
                
                foreach (MarketDataSendRunnable t in runnables) 
                {
                    t.SetRateDropOffFeed(feedToDropOff);
                }
            }

            Log.Info("Shutting down threadpool");
            for (int i = 0; i < runnables.Length; i++)
            {
                runnables[i].SetShutdown();
            }
            threadPool.Shutdown();
            threadPool.AwaitTermination(new TimeSpan(0, 0, 0, 10));
        }